method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
97bbad75-4890-46c9-8ea9-bf448e9f13bf
5
private int runDvi(String fileName, int resolution) throws IOException, InterruptedException, ServletException { int depth = 0; String[] command = String.format(DVI_COMMAND, Integer.toString(RESOLUTIONS[resolution]), fileName + IMAGE_SUFFIX, fileName + ...
2280a9ef-c231-431f-b715-430adb49abfb
8
public void atualizar() { jComboBoxEdicao.removeAllItems(); jComboBoxAnoPublicacao.removeAllItems(); jComboBoxAutor.removeAllItems(); jComboBoxEditora.removeAllItems(); jComboBoxCategoria.removeAllItems(); jComboBoxPublico.removeAllItems(); jComboBoxFormato.remove...
d68101e6-b41f-4f75-998e-0b28df82454c
5
private void setupDisplay() throws LWJGLException { try { DisplayMode displayMode = null; DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { if (modes[i].getWidth() == WorldSettings.SCREEN_WIDTH && modes[i].getHeight() == WorldSettings.SCREEN_HEIGHT...
93f6282a-70de-4d72-80e8-5ef557d133f8
2
public void run() { while(true) { try { repaint(); Thread.sleep(5); } catch(InterruptedException ie) { stop(); } } }
a7ca0227-5d44-4a5c-b742-06e5dad67c74
2
public void modificarCliente(Cliente c){ try { int especial = 0; if(c.isEspecial()){ especial = 1; } Statement comando=connection.createStatement(); comando.executeUpdate("UPDATE Cliente SET " + "Nombre='"+c.getNombr...
429ff34e-c8d1-4f78-bb42-27c38d6e2d00
6
private void initialiseSequencer() { try { // Attempt to locate the MIDE sequencer as one of the MIDI devices MidiDevice.Info[] midiDeviceInfo = MidiSystem.getMidiDeviceInfo(); int sequencerPos = -1; for (int idx = 0; idx < midiDeviceInfo.length; idx++) { ...
46f1094d-fd0b-4cb0-9821-fc0da25bf9a7
3
static Direction counterclockwise(Direction direction) { if (direction == NORTH) return WEST; if (direction == WEST) return SOUTH; if (direction == SOUTH) return EAST; return NORTH; }
5b73590e-167a-4602-9c60-96e2f51c854d
4
public boolean isOptOut() { synchronized (optOutLock) { try { // Reload the metrics file configuration.load(getConfigFile()); } catch (IOException ex) { if (debug) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.g...
95f80267-9497-4a1f-860e-5f3c4879781d
8
public MClientCmdListener(String analyticsServerRef, String billingServerRef, ExecutorService mClientExecutionService) { this.analyticsServerRef = analyticsServerRef; this.billingServerRef = billingServerRef; this.mClientExecutionService = mClientExecutionService; // create EventListener Remote Object try ...
7ff8c080-0f7e-475b-b507-f1659b509130
9
public StatistikZusammenfassung<Team> getStatistikZusammenfassung(String teamId) { Team team = eloPersistence.findById(Team.class, teamId); int anzahlSiege = 0; int toreGeschossen = 0; int toreGefangen = 0; int eloMinimum = Integer.MAX_VALUE; int eloMaximum = Integer.MIN_VALUE; for (EloPunktzahl punktza...
d9e3eb09-60be-4060-bee2-ba133ef1939a
1
public int putRef(int tag, Reference ref) { String className = ref.getClazz(); String typeSig = ref.getType(); if (tag == FIELDREF) TypeSignature.checkTypeSig(typeSig); else TypeSignature.checkMethodTypeSig(typeSig); int classIndex = putClassType(className); int nameIndex = putUTF8(ref.getName()); ...
d78ca89d-25e7-47ea-b6a1-5468cc6b9a39
6
@Override public void setToNative(long i, Object o) { if (o == null) { stringLengths.setShort(i, (short) -1); } else { if (!(o instanceof String)) { throw new IllegalArgumentException(o + " is not a string."); } String s = (String) ...
2ed6928c-6fef-46d9-83b5-6f6d6b8c14cf
3
public void txtToJson(String txtPath) { Json json = new Json(); json.prettyPrint(json); FileReader fileReader = null; BufferedReader br = null; try { fileReader = new FileReader(txtPath); br = new BufferedReader(fileReader); String strLine; // Read File Line By Line while ((strLine = br.readLin...
f4abdf28-c916-462e-b8d6-3e09d646a5b7
4
static final public void unary() throws ParseException { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MINUS: jj_consume_token(MINUS); element(); break; case CONSTANT: case 12: element(); break; default: jj_la1[5] = jj_gen; jj_consume_token(-1); throw n...
03b5ce23-ca39-4112-9f34-403fd8d12db9
5
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Field other = (Field) obj; if (x != other.x) return false; if (y != other.y) return false; return true; }
f0e6509c-ab9e-4316-a094-272048c9e9de
7
@Test public void adenAskStudentPriceTest(){ LocalDate date = LocalDate.now(); int dayOfWeek = date.getDayOfWeek(); boolean weekend = false; Canteen c3 = new Canteen(new CanteenData(CanteenNames.ADENAUERRING, 0)); int dayShift = (dayOfWeek + 2) % 7; if(dayOfWeek == 0 || (dayOfWeek == 6)) { // weekends ...
614fd4d9-d985-4a9b-abe6-5c71ce9483c1
5
public Packing createPacking(String type){ Packing pack = null; if(type.equalsIgnoreCase("cloth")){ pack = new Cloth(); } else{ if(type.equalsIgnoreCase("cellophane")){ pack = new Cellophane(); } else{ if(typ...
3b741f2e-8f34-4940-b3f8-f393c09257e9
6
@Test public void testUS36_consultationFicheVideo() { //intLgTitreVideo = Integer.parseInt(lgTitreVideo); String titreVideoC = null; String lgTitreVideo; int intLgTitreVideo; int intCptVideo; String cptVideo; String varVideoTitle; String varVideoTitleComplete; String pointSuspension; String ...
0f9255dd-2185-4152-b9d8-504fc7aac8b3
7
public static boolean closedPropositionP(Proposition self) { { MemoizationTable memoTable000 = null; Cons memoizedEntry000 = null; Stella_Object memoizedValue000 = null; if (Stella.$MEMOIZATION_ENABLEDp$) { memoTable000 = ((MemoizationTable)(Logic.SGT_LOGIC_F_CLOSED_PROPOSITIONp_MEMO_TABL...
a6bbbc8a-8cad-41bb-9b7f-0c66ad7f0521
1
public boolean useCard(int id) throws JSONException { // Würfel eine 2 (id = 6) // POST /bundesklatsche/get_data/0/3/2 HTTP/1.1\r\n // Freiwurf (id = 4) // POST /bundesklatsche/get_data/0/1 // refresh info(0); int field = getCard(id); if (field == 0) { return false; } Utils.getString("bunde...
243179de-1e99-4888-bac5-9533bb7547a7
5
@Override public void mouseReleased(MouseEvent e) { if (!potentialDrag) return; source.removeMouseMotionListener( this ); potentialDrag = false; if (changeCursor) source.setCursor( originalCursor ); if (destination instanceof JComponent) { ((JComponent)destination).setAutoscrolls( autoscrolls ); ...
62c4bc1e-6636-4c2b-9fea-13be0ca0c281
0
public NondeterminismAction(Automaton automaton, Environment environment) { super("Highlight Nondeterminism", null); this.automaton = automaton; this.environment = environment; }
075b7524-f739-449a-bfaa-c2173e933eae
3
@SuppressWarnings("nls") @Override public String toString() { StringBuilder buffer = new StringBuilder(); if (getParent() == null) { buffer.append("FLOATING "); } buffer.append("Dock Container [x:"); buffer.append(getX()); buffer.append(" y:"); buffer.append(getY()); buffer.append(" w:"); buffer....
4f3014ae-8dc2-48c2-841c-452825a14162
3
public long writeToOutputStream(OutputStream out) throws IOException { long documentLength = documentSeekableInput.getLength(); SeekableInputConstrainedWrapper wrapper = new SeekableInputConstrainedWrapper( documentSeekableInput, 0L, documentLength, false); try { wrap...
e2831a09-fe55-4a70-a9c5-07cc98f18e95
5
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Schedule schedule = (Schedule) o; if (id != schedule.id) return false; if (seqNumber != schedule.seqNumber) return false; return true;...
bfdff963-91d4-4325-ad70-e2babf570a61
7
@Override public void keyPressed(int key, char character, GUIComponent component) { String entryString = entryText.getText(); if (GraphicalFont.isStandardChar(character)) { setEntryText(entryString + character); } switch (key) { case (Keyboard.KEY_RETURN) : ...
96cfb9a7-315b-4d85-a7c4-464d0d6f1031
5
private byte[] encrypt(byte[] plain, byte[][] _iv){ if(passphrase==null) return plain; if(cipher==null) cipher=genCipher(); byte[] iv=_iv[0]=new byte[cipher.getIVSize()]; if(random==null) random=genRandom(); random.fill(iv, 0, iv.length); byte[] key=genKey(passphrase, iv); byte[] encoded=...
67f19519-109d-4431-b495-55f2a61ccb3d
7
private void startConnectLoop() { connectLoop = new Thread() { @Override public void run() { final int numSlots = 20; int numAttempts = firstConnection ? 0 : 1; try { while(connectLoop != null) { Random random = new Random(); int upperBound = Math.min((int)Math.pow(2, numAttempts...
10f4969e-2d27-4edc-831d-0c53fa1db110
1
private boolean indexWithinCapacity(int index) { return index < array.length && index >= 0; }
0c75a020-0f31-4645-8a13-943a0135b935
5
public void prune() { ConstPool cp = compact0(); LinkedList newAttributes = new LinkedList(); AttributeInfo invisibleAnnotations = getAttribute(AnnotationsAttribute.invisibleTag); if (invisibleAnnotations != null) { invisibleAnnotations = invisibleAnnotations.copy...
114313d2-0512-4431-a57a-827d80a85d1b
3
@Override public Categoria ListById(int id_categoria) { Connection conn = null; PreparedStatement pstm = null; ResultSet rs = null; Categoria c = new Categoria(); try{ conn = ConnectionFactory.getConnection(); pstm = conn.prepareStatement(LISTBYID); ...
75014cd5-1510-49d4-9b8e-d3663585c954
7
public static void menuprincipal() { Scanner input = new Scanner(System.in); System.out.println("--------------------------------------------------------------------"); System.out.println("------------------------ MENU PRINCIPAL ----------------------------"); System.out.println...
a1f6173f-fcd9-4b9d-a5c9-54a4725a79b1
2
public void findRoomType(String roomType) { Query q = em.createQuery("SELECT t from TypeEntity t"); for (Object o : q.getResultList()) { TypeEntity p = (TypeEntity) o; if (p.getName().equals(roomType)) { typeEntity = p; } } }
bba4d434-d5f7-4dab-99e4-214a844bba3c
7
public void run() { while(Project1.applicationRunning){ /** * Highest Priority is to send Clock Replies. * So sending them first. */ while(!sendClockReplyQueue.isEmpty()){ Message toSend=sendClockReplyQueue.poll(); //System.out.println(toSend.getRecieverAddress()+String.valueOf...
e15929fd-6319-4c01-96ef-eb09f8a97f60
6
public static List<COIN> getCoinsForAmount(float amount) { List<COIN> coins = new ArrayList<COIN>(); /* Well, the canadian govt has decided to abandon 1 cent penny. So, we can't dispense exact change, but will do closest to 5 cent change. I am just implementing ...
d96c2b78-c12b-47c0-a6eb-d12324d84c87
7
@SuppressWarnings({ "deprecation", "unchecked" }) public List<ComponentOut> search(Map<String, String> criterias) { List<ComponentOut> results; Set<String> keys = criterias.keySet(); Session session = HibernateUtil.sessionFactory.getCurrentSession(); session.beginTransaction(); ...
215ea15b-23fd-4420-ba84-fd79e12a80d2
3
public static void helium(String sourceFile, String targetFile) { Sound sourceObj = new Sound(sourceFile); //Construct a new Sound object called sourceObj. A sourceObject now represents the sourceFile object. Sound target = new Sound(sourceObj); ...
657cbdaa-330f-4cdb-86ce-154974c389c1
5
private static int[] getBestUsers(List<Map<Integer, Integer>> userMaps, int userID, int size) { int[] retVals = new int[size]; Map<Integer, Integer> nSimMap = new LinkedHashMap<Integer, Integer>(); if (userID < userMaps.size()) { Map<Integer, Integer> tags = userMaps.get(userID); for (int i = 0; i < userMap...
8c1dc5f6-312c-44d5-9f8c-4eaa9509363d
8
private void findNextPotentialReference(int startPosition) { nextPotentialReferencePosition = Math.max(startPosition, nextSemicolonPosition - MAX_REFERENCE_SIZE); do { nextPotentialReferencePosition = originalMessage.indexOf('&', nextPotentialReferencePosition); if (nextSe...
840c0e21-4b1d-4df5-abcc-22140d7d6d02
3
protected static int getInt(String key, JSONObject json) throws JSONException { String str = json.getString(key); if(null == str || "".equals(str)||"null".equals(str)){ return -1; } return Integer.parseInt(str); }
5606c10e-18e2-46ff-9129-54ea411a191b
0
@Override public String toString() { return String.format( "annotatedWith(%s)", this.annotation ); }
9c1a4235-b64c-4705-89a9-5d183d191684
0
public TimerTest() { super(); }
40934901-29ed-44d5-92f6-0055ad806c85
6
private String scanFlowScalarBreaks () { StringBuilder chunks = new StringBuilder(); String pre = null; for (;;) { pre = prefix(3); if ((pre.equals("---") || pre.equals("...")) && NULL_BL_T_LINEBR.indexOf(peek(3)) != -1) throw new TokenizerException("While scanning a quoted scalar, found unexpected docu...
45ab6a7b-ae90-4af9-a7fb-a07128c3b808
4
public boolean isOptOut() { synchronized (optOutLock) { try { // Reload the metrics file configuration.load(getConfigFile()); } catch (IOException ex) { if (debug) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.g...
b970bd56-1b9b-4833-a9b9-ac03d6422a11
4
@Override public Component getTreeCellRendererComponent(final JTree tree, final Object value, final boolean selected, final boolean expanded, final boolean leaf, final int row, final boolean hasFocus) { final NBTRecord rec = (NBTRecord) value; final String chg = rec.hasChanged() ? "*" : " "; f...
f2f634df-5e18-453f-9704-7b7a1e20f6ef
8
public MemberBean getMemberInfo(String id) { Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; MemberBean member = null; try { conn = getConnection(); pstmt = conn.prepareStatement("select * from member where id=?"); pstmt.setString(1, id); rs = pstmt.executeQuery(); ...
c1547b02-4260-4764-a9de-d9e7106dc688
1
public void addToWealth(int val){ iMoneyInBank += val; if(iMoneyInBank < 0) iMoneyInBank = 0; }
59b28a8c-a2dd-45d1-9c26-711f47a437c7
0
public static boolean getImagesHaveBeenLoaded() { return imagesHaveBeenLoaded; }
b3622003-ecc7-4fb2-9c3a-1f74603962a5
7
public Date floor(Date date, int field) { Calendar cal = Calendar.getInstance(); cal.setTime(date); for (int currentField : fields) { if (currentField > field) { if (currentField == Calendar.DAY_OF_MONTH && (field == Calendar.WEEK_OF_MONTH || field == Calendar.WEEK_OF_YEAR)) { continue; } ...
2e1e173a-f5c9-4426-b917-a11bb88bbe86
1
private static void debug(String str) { if(debug) System.out.println(str); }
b84278a6-d6fe-4743-ae0b-87af86e1e63f
8
public void actionPerformed(ActionEvent arg0) { Object[] inputDetails = new Object[16]; int counter = 0; for(int i = 0; i < comps.length; i++){ if(comps[i].getClass() == JTextField.class){ JTextField compTemp = (JTextField) comps[i]; inputDetails[counter] = compTemp.getText(); counter++; } i...
773958d6-dd13-4216-8942-935d0e79b302
1
@Override public IRemoteCallObject call(String command, Object params) throws Exception { checkInitiate(); final IRemoteCallObject rco = new RemoteCallObject(); synchronized (rco) { long callId = getNextCallId(); rco.setCallObjectId(callId); rco.setMetaDataObject(new RemoteCallObjectMet...
fad3951c-819f-43f1-b436-c9efe2e633a6
1
public int compareTo(Object obj) { if (obj instanceof Mark) { int pos = ((Mark)obj).position; return position - pos; } return -1; }
228050e1-3692-4389-bcac-699e5f1638f3
1
public Ligne jouer(LigneMarqueur marqVerif){ if(derniereCombiJouee != null){ // Si derniereCombinaison n'a pas été initilaisé, càd si l'IA joue pour la première fois listePossibles.supprimeCombiImp(derniereCombiJouee, marqVerif); } derniereCombiJouee = listePossibles.choixCombi(); ...
a496e27f-14b3-47d2-8275-7d88c80868fa
2
public String preProcess(String s){ int n = s.length(); if(n == 0) return ""; StringBuilder sb = new StringBuilder(); for(int i = 0; i < n; i++){ sb.append('#'); sb.append(s.charAt(i)); } sb.append('#'); return sb.toString(); ...
fec6fa8d-9468-48a5-9585-e3186f0e1e90
1
private boolean jj_3R_72() { if (jj_scan_token(IDENTIFIER)) return true; return false; }
288634e0-63b9-4a83-a80b-78a34b5589ea
2
public void testRead() { try { ConfigurationManager.init("src/test/resources/test.json"); try { Object[] test_array = ConfigurationManager.read.getArrayItem("test", "array"); assertEquals(123L, test_array[0]); Long test_long = ConfigurationManager.read.getLongItem("test", "long"); asser...
5121f2ed-c1ba-4a24-9bf4-0d0f336f2cf0
5
private void checkSpikes(){ int fromTileX = TileMap.pixelsToTiles(player.getPos().getX()); int fromTileY = TileMap.pixelsToTiles(player.getPos().getY()); int toTileX = TileMap.pixelsToTiles(player.getPos().getX() + player.getWidth()); int toTileY = TileMap.pixelsToTiles(player.getPos().getY() + player.getHeight...
f23c67f2-3c84-4bc3-ac81-1fe7407571e2
6
static private Object interpretToken(String s) throws Exception{ if(s.equals("nil")) { return null; } else if(s.equals("true")) { return RT.T; } else if(s.equals("false")) { return RT.F; } else if(s.equals("/")) { return SLASH; } else if(s.equals("clojure.core//")) { return CLOJURE_SLAS...
bf144d90-9b4f-4328-a80b-6426504fdae3
3
private void ekskey(byte data[], byte key[]) { int i; int koffp[] = { 0 }, doffp[] = { 0 }; int lr[] = { 0, 0 }; int plen = P.length, slen = S.length; for (i = 0; i < plen; i++) P[i] = P[i] ^ streamtoword(key, koffp); for (i = 0; i < plen; i += 2) { lr[0] ^= streamtoword(data, doffp); lr[1] ^= st...
88446c9f-e7a8-4177-958f-5af79181d242
1
public boolean deleteTask(int id) throws SQLException { if (daoList.idExists(id)) { daoList.deleteById(id); return true; } return false; }
ab605b43-69f8-4b69-a016-55025bdf708f
1
protected void addIndividualPath(String path, U target, boolean named, int defaultHttpMethods) { PathPattern<U> pattern = new PathPattern<U>(target, path, named, defaultHttpMethods); String key = pattern.getKey(); List<PathPattern<U>> list = map.get(key); if (list == null) { ...
4b2caa26-3899-4a48-be3b-e7433844f144
6
@Override public void onUpdate(World apples) { if (!apples.inBounds((int)X, (int)Y)||apples.checkCollision((int)X, (int)Y)) { alive = false; //apples.explode(X, Y, 32, 8, 16); } for (Player p:apples.playerList) { if (apples.pointDis(X, ...
3649e3e4-20b8-4c96-9c7c-eb976837c6c1
7
*/ public void testLargeReadWrite() throws Exception { ByteBuffer b = ByteBuffer.allocate(4000); log.info("getting all proper connections"); int size = 40; String[] methodNames = new String[size]; for(int i = 0; i < size; i++) { methodNames[i] = "connected"; } TCPChannel[] clients = new TCPChannel[...
139ac2f1-a6aa-4ce4-8746-d79de1837ffe
7
public static Tile[][] read(File file){ BufferedImage paintImage = null; try{ paintImage = loadImage(file); }catch(Exception e){ Logger.logErr("Was not able to read image located at " + file.getAbsolutePath() + "\n Cause: " + e.getCause(),MapReader.class); } Tile[][] tileMap = new Tile[paintImage.get...
c2c60075-f6c7-40ce-a629-a01fbeb466a1
4
public void setValue(int x, int y, Pixel value) { if (x >= getWidth() || y >= getHeight() || x < 0 || y < 0) { return; } rawData[x][y] = value; }
c20fe1f8-e7f4-402d-b914-d04c332a6f19
4
public int executeWriteQuery(String sqlStatement) { int rc = 0; try { Class.forName(this.sqlDriver); con = DriverManager.getConnection(sqlURL, this.sqlUser, this.sqlPassword); Statement stmt = con.createStatement(); System.out.println("insertSQL: " + sqlStatement); rc = stmt.executeUpdate(sqlSt...
f8bd70f2-fd4d-444b-b397-d36225053398
7
protected String[][] create_matrix(String plain) { ArrayList<String> s=new ArrayList<String>(); boolean dig; if(di_begin) { dig=true; } else { dig=false; } int string_index=0; int plain_size=plain.length(); while(string_index<plain_size) { if(dig) { if(string_index==plain_size-1...
960f3545-1293-4efc-930e-6a494f622a36
1
public Event getNextEvent(){ Event a=this.ListCust.peek(); return (a!=null) ? this.ListCust.remove() : null; }
bb53eb33-4b2a-405f-aee2-ac41bb512832
5
public void checkLogin(String msg){ try{ if(containsMoreThanNeeded(msg)){ CC.getDataTransfer().sendMessage("Sorry but that was an invalid username/password"); CC.Terminate(); return; } msg = msg.replaceFirst("Login ", ""); String[] usernpass = msg.split(":"); if(!ClientHandler.getClientMap(...
64ae2bed-426e-46f7-b9b1-125070501612
2
@Override public Object execute(HttpServletRequest request, HttpServletResponse response) throws Exception { Contexto oContexto = (Contexto) request.getAttribute("contexto"); oContexto.setVista("jsp/alumno/form.jsp"); AlumnoBean oAlumnoBean; AlumnoDao oAlumnoDao; oAlumnoBean ...
e7a5d3df-b3c1-468c-aabd-971a6dec3d4c
5
public static TFTPPacket fromOPCode(short opcode){ switch(opcode){ case 1 : return new RRQPacket(); case 2 : return new WRQPacket(); case 3 : return new DataPacket(); case 4 : return new AckPacket(); case 5 : return new ErrorPacket(); } ...
3315fcf9-44cf-4c34-96f5-844b04bd5d94
9
public String simplifyPath(String path) { if (path == null || path.length() == 0) return path; String[] paths = path.split("/+"); LinkedList<String> list = new LinkedList<>(); for (String tmp : paths) { if ("..".equals(tmp)) { if (!list.isEmpty()) { ...
17734aef-1ace-4275-aa76-a0b6ee86cabf
3
public static void tpAll( String sender, String target ) { BSPlayer p = PlayerManager.getPlayer( sender ); BSPlayer t = PlayerManager.getPlayer( target ); if ( t == null ) { p.sendMessage( Messages.PLAYER_NOT_ONLINE ); return; } for ( BSPlayer player : Pla...
8cf4ea86-9d31-4720-be7e-ed43ebbfbb1a
6
static private boolean glob0(byte[] pattern, int pattern_index, byte[] name, int name_index){ if(name.length>0 && name[0]=='.'){ if(pattern.length>0 && pattern[0]=='.'){ if(pattern.length==2 && pattern[1]=='*') return true; return glob(pattern, pattern_index+1, name, name_index+1); ...
40ddd7fd-3ff2-4c79-b8e2-7e969721ba6b
5
private boolean parseFlags(String parameter) { boolean success = false; if (parameter.matches("-[^-]*v[^-]*")) { verboseMode = true; success = true; } if (parameter.matches("-[^-]*d[^-]*")) { devMode = true; success = true; } if (parameter.matches("-[^-]*n[^-]*")) { System.out.println("Disabl...
563984b3-a53b-42b1-99c5-d2d82fe3cb5d
8
public boolean restartLevel() { GameState state = StateUtil.getGameState(proxy); if(state == GameState.WON || state == GameState.LOST) { proxy.send( new ProxyClickMessage(420,380));//Click the left most button at the end page System.out.println(" restart the level "); try { Thread.sleep(2000); } cat...
3f9ca928-35d4-40a6-a1e5-cd76a2a1f806
6
public static boolean is_integer(String str) { if (str == null) return false; if (str.equals("")) return false; Character c = str.charAt(0); if (!c.equals('-') && !c.equals("+") && !Character.isDigit(c)) return false; try { @SuppressWarnings("unused") Integer test = parseInt(str); } catch (NumberForma...
4cd281b5-c41e-4081-a386-fd02239efe9c
8
@Override public void happens() { // TODO: add movement to the patio for this case ArrayList<Character> characters = Game.getInstance().getCharacters(); for(Character character: characters){ if (character.getCurrentRoom().getNameEnum() == RoomName.GARDENS || character.getCurrentRoom().getNameEnum() == R...
e8de82ab-dafd-4001-8a13-ab7dfade8f9b
3
@Test public void testCarbohydratePercentage() { MealRepartition mr = new MealRepartition(); try { mr.setCarbohydratePercentage(0.49); fail("A BadCarbohydratePercentageException should have been thrown."); } catch (BadCarbohydratePercentageException e) {} try { mr.setCarbohydratePercentage(0.56); f...
e818e2f3-fa12-4878-85a4-bd22d53f1da6
8
public boolean isPalindrome(int x) { //if nagetive if (x < 0) { return false; } //0~9 is palindrome if (x < 10) { return true; } //10, 100, etc. are not palindrome if (x % 10 == 0) { return false; } int ...
ab53a722-8763-4a0d-85c9-784bcea88c55
7
public void run() { try { //init IO-Stream from/to client and send Ready-Message inFromClient = new BufferedReader(new InputStreamReader( connectionSocket.getInputStream())); outToClient = new DataOutputStream( connectionSocket.getOutp...
7556c1cc-5bc9-4c3c-8b29-4d41942dd9ec
9
@Override protected void buildModel() throws Exception { for (int iter = 1; iter <= numIters; iter++) { errs = 0; loss = 0; // for each rated user-item (u,i) pair for (int u : trainMatrix.rows()) { SparseVector Ru = trainMatrix.row(u); for (VectorEntry ve : Ru) { // each rated item i ...
110c64bb-844b-4673-b332-ee011ac11194
2
@Override public void onMouseButtonPress(int buttonID) { for(GuiButton button : buttons) { if(button.isMouseOver()) { Sound.button_hit.play(); button.onClick(); } } }
33e77617-e485-4a44-8cee-e2c790358338
0
public String getSerialNo() { return serialNo; }
4686da11-2188-437b-93de-434a0efff7cf
5
public void sanitise() { if (this.modName == null || this.modName.length() < 1) this.modName = "all"; if (this.modVersion == null || this.modVersion < 0.0F) this.modVersion = 0.0F; if (this.remoteCacheTimeSeconds < 0) this.remoteCacheTimeSeconds = 600L; }
2f805667-4b54-4339-8d8f-22d4b8f9f315
9
public void partActivated(IWorkbenchPart partArg) { if ((partArg == this.part) && (this.timestamp > -1L) && ((this.resource == null) || (this.resource.exists()) || (this.part .isDirty()))) { if (!readable()) { String[] buttons = { "Save", "Close" }; MessageDialog dialog = new MessageDialog( ...
396e3ac4-cfa7-4923-a515-9a33b0083ea2
3
public boolean contains(Vector2 point) { Vector2 min = this.getMinimumPoint(); Vector2 max = this.getMaximumPoint(); return (point.x >= min.x && point.x <= max.x && point.y >= min.y && point.y <= max.y); }
9404371f-893a-46f6-ada4-8c2156fb7f8a
7
public List<Sailplane> getRecentSailplane() { try{ List<Sailplane> sailplanes = DatabaseDataObjectUtilities.getSailplanes(); List<Sailplane> recentSailplaneList = new ArrayList<Sailplane>(); if(instance == null) { return null; } ...
c751e064-8590-46c7-a7c2-c8b706b01490
3
NodeListGraph(int vecticeCount) { if(vecticeCount <= 0) { throw new IllegalArgumentException(); } @SuppressWarnings("unchecked") LinkedList<EdgePair>[] nodeListArray = (LinkedList<EdgePair>[]) new LinkedList<?>[vecticeCount]; edges = new TreeSet<Integer>(); for(int i = 0; i < vecticeCount; i++) { ...
ecfb9a74-753c-4c73-87f8-75ed4594ac6b
4
@Override public Optimus1Ddata FindMaxMin(ArrayID aid, PID pid, OptimusShape pshape, OptimusShape start, OptimusShape off) throws Exception { // TODO Auto-generated method stub OptimusData data = this.readDouble(aid, pid, pshape, start, off); if (data == null) return null; double[] fdata = data.getData(...
f558daf3-86f3-4013-b89f-d3cff27c89f5
8
private void ValidateTag(Iterator<ITag> iter, Class<? extends ITag>... classes) { if (isValid) { while ((iter.hasNext()) && this.isValid) { boolean pass = false; ITag child = iter.next(); Class<? extends ITag> childClass = child.getClass(); for (Class<? extends ITag> type : classes) { if ...
63895b12-97d3-45ce-a17c-dcfa575a5003
0
@Override public void mouseEntered(MouseEvent e) { }
f8c33566-ff5c-4fca-b84c-a63026841781
6
public static String findCollisions(ArrayList<Planet> planets) { String collisions = ""; for (int i = 0; i < planets.size(); i++) { for (int j = 0; j < planets.size(); j++) { if (i != j) { if (Planet.areColliding(planets.get(i), planets.get(j))) { ...
f5440c47-46fe-401a-abec-880a10b0fc73
7
public RackRequestHandler(FilterConfig config) { log.info("Creating new RubyRequestHandler instance"); // Configure ignore paths String pathCfg = config.getInitParameter("ignorePaths"); if (pathCfg != null) { this.ignorePaths = pathCfg.split("\\s+"); } ...
af6b206f-01e1-4af2-b5c4-fd7269adf1f5
9
@Override public int eval(int player, int alpha, int beta, int depth, int nt, int stackIndex, State4 s) { StackFrame frame = stack[stackIndex]; if(nt != SearchContext.NODE_TYPE_PV && depth <= 3 * Search34.ONE_PLY && !frame.pawnPrePromotion && !frame.alliedKingAttacked && frame.hasNonPawnMaterial ...
4b48a09d-c034-4131-8bd9-10ce9d48065e
3
public String name() { if (this.tooltip != null) return (this.tooltip); Resource res = this.res.get(); if ((res != null) && (res.layer(Resource.tooltip) != null)) { return res.layer(Resource.tooltip).t; } return null; }
cf81a434-48d8-4796-a8c1-025ca4a57a90
4
private static void buildBasicSet(Release set, List<SeperatorDefinition> seps) throws MalformedURLException { for(MagicColor c: MagicColor.values()) { if (!c.includeInDefaultSets()) continue; SeperatorDefinition def = new SeperatorDefinition(); ...
9b581978-53e3-4e1a-95af-0ac793d0ad0d
5
public Chord pickRandomWeighted(Chord chord){ String next =""; double total = 0; String chordString = chord.toString(); if(histogram.get(chordString).isEmpty()){ return null; } for(Integer i: histogram.get(chordString).values()){ total+=i; } int random = (int) (Math.random()*(total+1)); for ...
a43c381a-ddef-44a4-b3df-6d949fcad563
6
public List<List<Integer>> subsetsWithDup(int[] num){ Arrays.sort(num); int size = num.length ; int total = (int)Math.pow(2,size); List<List<Integer>> result= new ArrayList<List<Integer>>(); for(int i=0;i < total;i++) result.add(new ArrayList<Integer>()); for...