method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
4937fd1f-211a-49c6-9fbb-84e62f8e899c
9
private void undoHelper(boolean fromNetwork) { //get the top of the action stack, handle it, and push it to the future actions stack for redo if(pastActions.empty()) { System.out.println("no actions to undo!"); return; } if(!fromNetwork) networking.sendAction(new BoardEltExchange(null, BoardActionType...
93ede41b-12fe-45ba-a433-cbee6960be47
7
private synchronized void updatePathImage_Old() { if (gPanel.getWidth() == 0 || gPanel.getHeight() == 0) { return; } mPathImage = new BufferedImage(gPanel.getWidth(), gPanel.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = mPathImage.createGraphics(); g2d.setColor(Color.black); g2d.fillR...
697199ed-9188-460b-a4c0-6490101867d9
9
public void UpdateProbabilities(){ // Compute probabilities of each player being each role. // Do this by calling AllPlayers method from GameState // Compile a tally of each player being each thing against total states int[][] RoleCount = new int[NumPlayers][4 + (2 * NumWolves)]; // First index is the play...
f1c1e254-f84a-4782-ab3b-908cda762ef1
3
public static void main(String args[]) { OggPlayer ogg = new OggPlayer(); try { if (args.length < 1) { args = new String[1]; args[0] = "/audio/Madrugada - Ice.ogg"; } InputStream input = ogg.getClass().getResourceAsStream(args[0]); ogg.open(new OggInputStream(input)); ogg.play(); while (ogg...
f3a2a027-3c0e-47e6-be7a-cbfa6e60c198
9
static final void method2028(int i, ObjectDefinition class51, int i_0_, AbstractToolkit var_ha, int i_1_, int i_2_) { try { anInt3395++; Class218 class218 = Class2.aClass141_117 .method1173((byte) 31, ((ObjectDefinition) class51).anInt875); if ((((Class218) class218).anInt2853 ^ 0xfffffff...
5f6e17a0-f94b-4ad3-bd51-e5d830ae8742
1
@Test public void testEncryptBlock2() { byte[] key = ByteHelper.convertBinaryStringToByteArray("1010011010111000011110011110100111011001100111111001100101110010".replace(" ", "")); byte[][][] subKeys = new byte[][][] { KeyCalculator.generateSubKeys(key) }; byte[] block = ByteHelper.convert...
8285acfc-0017-43d6-b713-9dcd2e42c6f9
2
private Command getCommand(String alias) { if(commands.getAllValidAliases().contains(alias)) { return commands.get(alias); } else if(ungroupedCommands.getAllValidAliases().contains(alias)) { return ungroupedCommands.get(alias); } else { return getInheritedCommand(alias); } }
a3b91307-5375-4428-b27c-1ddfaf7cbe0c
0
@XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "KeyValue") public JAXBElement<KeyValueType> createKeyValue(KeyValueType value) { return new JAXBElement<KeyValueType>(_KeyValue_QNAME, KeyValueType.class, null, value); }
777e47e8-7e06-44db-a871-8d060a5dc31f
5
private boolean handleGetMessageBody() { final int expectedBytes; final int bytesRead; try { expectedBytes = buffer.remaining(); bytesRead = channel.read(buffer); if (bytesRead == -1) { // EOF currentState = RxThread...
b2ae55ff-72b0-4e71-9c0a-bc6c466144e1
9
private static boolean isBigger(Context cx, Scriptable scope, Object x, Object y, Object cmp, Object[] cmpBuf) { if (cmp == null) { if (cmpBuf != null) Kit.codeBug(); } else { if (cmpBuf == null || cmpBuf...
fd487b2f-8eeb-4683-abd9-7099eaa97ad2
1
@Override public Object findById(Integer theId) throws Exception { try { session = HibernateUtil.getSessionFactory().openSession(); //Query q = session.getNamedQuery("id.igual"); Query q = session.getNamedQuery(getNamedQueryToFindById()); q.setString("id", the...
3714acc2-56f5-48a0-9c0b-6f731dba69eb
4
public static boolean isConsistent(int[] result, int N) { for (int i=0; i<N; i++) { if(result[N] == result[i]) return false; if(result[N] - result[i] == N - i) return false; if(result[N] - result[i] == i - N) return false; } return true; }
aff965b1-1fa6-451e-b43f-b2cc706837df
9
public MultiImportDialog(Frame parent, final File file) { super(parent, true); setTitle("导入多张表格"); setBounds(100, 100, 450, 442); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, Borde...
1412117d-5251-487e-a8ff-c15bc1e74ba7
4
Power(String name, int properties, String imgFile, String helpInfo) { this.name = name ; this.helpInfo = helpInfo ; this.buttonTex = Texture.loadTexture(IMG_DIR+imgFile) ; this.properties = properties ; }
7cf774cc-c3b6-4240-8998-97470b2d257c
2
public void actionPerformed(ActionEvent e) { String action = e.getActionCommand(); if (action.equals(Constantes.OK)) { ok(); } else if (action.equals(Constantes.CANCEL)) { close(); } }
d9e402fd-d62f-4c1d-8bb5-4d592596eaf2
1
public String getLabel() { if (label == null) label = "switch_" + (serialno++) + "_"; return label; }
f16fd837-6866-43af-901a-3d2efa455773
2
public void visitFrame(final int type, final int nLocal, final Object[] local, final int nStack, final Object[] stack) { instructions.add(new FrameNode(type, nLocal, local == null ? null : getLabelNodes(local), nStack, stack == null ? null : getLabelNodes(stack))); }
13fe14c4-65e2-4d4c-949c-ec09d18fb9a9
4
public String crypt(String str) { if (str == null || str.length() == 0) { throw new IllegalArgumentException("Error"); } String stringKey = str + HASHKEY; digester.update(stringKey.getBytes()); byte[] hash = digester.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < hash.lengt...
5bf10378-2b20-45bf-bb54-80ba85cefcfc
0
public Osoba getOsoba() { return new Osoba(nazwiskoTextField.getText(), imieTextField.getText(), kodPocztowyTextField.getText(), miastoTextField.getText(), ulicaTextField.getText(), telefonTextField.getText(), telefonTextField.getText()); }
40d5c8b7-53bc-47fd-9a10-455be9cd782b
5
private Integer[] getVersionInts(String versionString) { String bits; if (versionString.split("\\-v").length == 2) { bits = versionString.split("\\-v")[1]; } else if (versionString.split(" v").length == 2) { bits = versionString.split(" v")[1]; } else if (versionS...
30053256-7b37-47f9-be44-9fa428f41ba5
3
public static PlayableSound parse(String string) throws IllegalArgumentException, NumberFormatException { Matcher matcher = pattern.matcher(string); if (!matcher.matches()) { return null; } if (matcher.group(3) != null) { return new PlayableSound(Sound...
8c9aaa71-ef89-4457-990d-2c8a9666ae1b
9
public static void main (String [] args) throws IOException { in = new BufferedReader (new FileReader (new File ("find_the_mintxt.txt"))); out = new PrintWriter (new FileWriter ("findthemin.out")); int T = Integer.parseInt (in.readLine()); int t = 0; StringTokenizer st; w...
8413f580-f021-4b02-8105-7528cceb3b3b
3
private JButton createButton(String buttonCaption) { final JButton button = new JButton(buttonCaption); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setSelectedFile(file); int selection; switch ...
66841d11-50e5-40b5-90b3-093fc4f7dc78
6
private Gob gobatpos(Coord c) { for (Sprite.Part d : obscured) { Gob gob = (Gob) d.owner; if (gob == null) continue; if (d.checkhit(c.add(gob.sc.inv()))) return (gob); } for (Sprite.Part d : clickable) { Gob gob = (G...
170f6d3d-120c-438b-996e-e07ace53cab8
7
public boolean equivalentWasStartedBys (WasStartedBy description1, WasStartedBy description2) { return bothNull (description1, description2) || (neitherNull (description1, description2) && equivalentIdentifiers (description1, description2) && equivalentAttrib...
e1dfa4f9-e5dd-4c29-a327-1f05133fb5c5
2
public void setSelectedFontSize(int size) { String sizeString = String.valueOf(size); for (int i = 0; i < this.fontSizeStrings.length; i++) { if (this.fontSizeStrings[i].equals(sizeString)) { getFontSizeList().setSelectedIndex(i); break...
999f5721-42ac-43a8-a7d9-dbca055f5d88
7
public static void ALS_branch(String num, String filepath, String downloadpath, String []paras, Scanner scanner){ String line="", result = ""; int item=0; System.out.println("Please choose the light status you want to test: 1=dark, 2=bright, 0=return:"); System.out.println("If you choose to test the dark status...
3dd0d59f-0318-44cb-bcb1-604a5a563a32
5
private void muoviNera(boolean turn){ // cerca possibili mosse bianche (movimenti e mangiate) // try catch usati per evitare i controlli sulle celle (superamento estremi damiera) boolean occupata = false; // cella vicina è occupata da una pedina try{ if(damiera.getCella...
825612ab-518c-4846-8547-3ca7463500ca
2
@Test @Ignore public void test_SurveyCompletionGet() { SurveyCompletionList laSurveyCompletions = laClient.getSurveyCompletions("20160226060916990275000000", "00456799"); System.out.println(laSurveyCompletions.getSurveyCompletionList().size()); if (laSurveyCompletions.getSurveyCompletionList().size() > 0) { ...
4af7a82f-d858-48a7-8218-96fdc3472592
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Node other = (Node) obj; if (fullPath == null) { if (other.fullPath != null) return false; } else if (!fullPath.equals(other.fullPath)) ...
355e7ad9-4c63-48fc-a05e-966c9e4ff157
9
public int maximumGap_notMine(int[] num) { // not my solution if (num == null || num.length < 2) return 0; // get the max and min value of the array int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; for (int i:num) { min = Math.min(min, i); ...
71141de0-119c-4c31-9626-6dda3b49be18
4
private String guessMimeType(String path) { int lastDot = path.lastIndexOf('.'); if (lastDot == -1) { return null; } String extension = path.substring(lastDot + 1).toLowerCase(); String mimeType = mimeTypes.get(extension); if (mimeT...
7b748614-7b34-487d-afe1-d6a674be5003
9
private String decodeDrink(String command) { StringBuilder b = new StringBuilder(); Pattern p = Pattern.compile("(.*):(.*):(.*)"); Matcher matcher = p.matcher(command); if(!matcher.matches()) throw new IllegalArgumentException("Invalid command"); String drinkType = ...
8b2a5eb9-00e2-470e-a4a3-d1bed8d700d4
3
private void redirect(String recordType) throws IOException { if (recordType.equals("user")) { if (request.getParameter("type").equals("doctor")) response.sendRedirect("register_doctor.jsp"); else if (request.getParameter("type").equals("patient")) response.sendRedirect("register_patient...
13252761-89ad-4334-bcfc-0c80fef2bda9
1
public String toString() { if (nome != null) return nome.toString(); return id + ""; }
75be2566-0c97-4432-85c9-9b63ee983764
2
void runSimulation() { CyclicBarrier cb = new CyclicBarrier(4, new ClientSynchronizer()); ClientThread[] clients = new ClientThread[dimensionRatio]; for (int i=0; i<dimensionRatio; i++) { clients[i] = new ClientThread(i,cb); } for (int i=0; i<dimensionRatio; ...
9f041d1b-f40a-4b1d-99c8-c59f359805ab
4
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Attributes)) return false; Attributes that = (Attributes) o; if (attributes != null ? !attributes.equals(that.attributes) : that.attributes != null) return false; ...
7f2d6150-64c4-4e6c-86d1-915b59af29dd
7
public static boolean vote(Proposal proposal, int optionId) { Vote vote = new Vote(FOTE.getUser().getId(), optionId, proposal.getId()); VoteModel voteModel = new VoteModel(); // Try to find a vote already made by this user for this proposal Iterable<Entry> voteQuery = voteModel.query("{...
726bc58b-e2f0-4ee3-ba77-6fe87f70855d
7
private void setImage(ImageIcon image, boolean inputDescription) { annotater.setImage(image); if (!gallery.hasNoProperty()) { Object o = gallery.getProperty("grid:" + image.getDescription()); if (o instanceof GridSetting) { annotater.setShowGrid(true); annotater.setGridCellSize(((GridSetting) o).getCe...
8a9ba58d-14be-46ad-ba16-d68d2ce9ebcc
6
@EventHandler public void SilverfishStrength(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getSilverfishConfig().getDouble("Silve...
0d2934bb-ee0b-404c-990f-7ab5edc372b7
2
public int CreationIndex() { for (int i = 0; i < CreateButtonSize; ++i) { if (CreateButtons[i].IsClicked()) return i; } return -1; }
7cc19fe0-21c7-4dbe-a497-846522f8b6b0
3
public boolean containSameStates(State[] states1, State[] states2) { int len1 = states1.length; int len2 = states2.length; if (len1 != len2) return false; Arrays.sort(states1, new Comparator<State>(){ public int compare(State s, State t){ return s.hashCode() - t.hashCode(); ...
a0b1eb4d-0cba-4ab2-9db7-c21198cc1733
9
public void update(float deltaT) { boolean tempButton = false; boolean tempSelected = true; if (owner instanceof SelectableUnit) { tempSelected = ((SelectableUnit) owner).isSelected(); } if (abilityButton != null) { tempButton = abilityButton.isPressed(); ...
12e4447f-4b57-4446-935d-ba6d1fae8405
1
private void prepare() { if (executor == null) { executor = new AsyncExecutor(); } }
1b574a2d-510f-403b-9c66-109c9d1a3380
5
protected File getFile(JPackage pkg, String fileName ) throws IOException { File dir; if(pkg.isUnnamed()) dir = target; else dir = new File(target, toDirName(pkg)); if(!dir.exists()) dir.mkdirs(); File fn = new File(dir,fileName); ...
ae46eb20-476e-4e49-b96a-26659cb933dd
4
public Set pseudoAlreadyUse(int nbjoueur){ Set<Joueur> hjoueur = new HashSet<Joueur>(); Scanner sc = new Scanner(System.in); boolean isAlreadyUsed = false; String pseudo = new String(); for(int i=1; i<nbjoueur+1; i++){ // On demande le pseudo du joueur i jusq...
541a5d4d-95ca-4d7f-859a-00aeff453050
8
private static void loadMenus() throws IOException { JsonArray json = (JsonArray) GameFiles.readJson("StructureMenu.json"); for (JsonValue item : json) { JsonObject menu = (JsonObject) item; String title; switch (menu.getString("title", "")) { case "bmCat_houses": title = "Housing"; break; case "bmCa...
ee19eb40-cceb-4ac1-98c3-ce47a9dae654
2
public void addDestino(String cod, double area) { if (destinos == null) destinos = new HashMap<String, Double>(); if (destinos.get(cod) == null) destinos.put(cod, area); else { double a = destinos.get(cod); a += area; destinos.put(cod, a); } }
f76d6234-ea5f-4bcd-a5dc-b4084a8b4d45
7
private static byte[] scanPublicKey(CryptobyConsole console) { byte[] retKey = null; do { scanner = new Scanner(System.in); String keyText = ""; // Input Key for decryption System.out.println("\nEnter the public Key (Type '" + quit + "' to Escape):"); ...
7124df57-6218-41b4-b509-bac93115f290
3
public static String getFileNameByUrl(String url) { if (isNull(url)) { return null; } // 移除http:// if (url.startsWith("http://")) { url = url.substring(7); } // 移除https:// else if (url.startsWith("https://")) ...
9c7f4e2c-b15a-4589-847c-e4b903c2d383
6
public String extractString() { if (offset_pointer <= 0) throw new NetworkBufferException("Buffer is empty, cannot extract a string."); StringBuilder sb = new StringBuilder(max_capacity); // Just to be safe in case the string is the length of our array Byte b = null; for (int i = 0; i < offset_pointer; i++) ...
45a5e20b-087f-49a1-b2a9-eb4e1faa792d
1
public static void main(String[] args) { String className = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"; try { UIManager.setLookAndFeel(className); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { e.printStackTrace(); } E...
7e1bf54c-53e9-4a73-a1d9-d3b4b07853cf
8
public void movePlayerWeapons(){ /* blaster shots */ ArrayList blasterShots = player.getBlasterShots(); /* if the blaster is visible - move */ for (int i = 0; i < blasterShots.size(); ++i){ Blaster temp = (Blaster)blasterShots.get(i); if (temp.isVisible() == true)...
3d365867-f11d-47c2-81d1-f9fe7e37952d
7
public void Solve() { ArrayList<HashMap<String, List<String>>> polygonals = new ArrayList<HashMap<String, List<String>>>(); for (int i = 0; i < 6; i++) { polygonals.add(new HashMap<String, List<String>>()); } int n = 1; int minValue = 0; while (minValue < _ma...
a327fe8c-5867-496f-bd6d-019c81a82f4d
3
public long add(long millis, long value) { int weekyear = get(millis); int newWeekyear = weekyear + FieldUtils.safeToInt(value); if (weekyear < 0) { if (newWeekyear >= 0) { newWeekyear++; } } else { if (newWeekyear <= 0) { ...
c5bd7006-62e2-4f2d-8135-39f6ca2a29cf
7
public static String getAlias(Class<? extends ConfigurationSerializable> clazz) { DelegateDeserialization delegate = clazz.getAnnotation(DelegateDeserialization.class); if (delegate != null) { if ((delegate.value() == null) || (delegate.value() == clazz)) { delegate = null; ...
4cffc35e-6e01-46bb-9bf7-c36f7749ddee
0
public synchronized static boolean setInventory(String identifier, int newInventory) { StockStorage store = StockStorage.getInstance(); return store.setInventory(identifier, newInventory); }
32d71adf-579b-420f-840f-d5e598f491dc
3
public org.omg.CORBA.portable.OutputStream _invoke (String $method, org.omg.CORBA.portable.InputStream in, org.omg.CORBA.portable.ResponseHandler $rh) { org.omg.CORBA.portable.OutputStream out = null; java.lang.Integer __method = (java.lang.Integ...
9000ae47-87eb-4a63-952f-5c24f5fd8d3f
3
@Override public void ejecutar(Stack<Valor> st, MemoriaDatos md, Cp cp) throws Exception { if (st.size() < 2) throw new Exception("DESAPILA_IND: faltan operandos"); Valor v = st.pop(); Valor d = st.pop(); if (d instanceof Entero) { if(v==null){ v=new Entero(0); } md.put((int) d.getValo...
c9e398ae-61fc-4594-a798-60ce8801a2e2
9
@Override public GameState use(Game game) { List <Npc> npcs; npcs = game.getCurrentRoom().getNpcs(); Killable killablenpc = null; for(Npc creature : npcs){ if(creature instanceof Killable){ killablenpc = (Killable) creature; ...
458a4273-23ab-481d-a8ff-adf2fa96d064
4
private int getPixelVal(int x, int y) { int i = x + y * width; int bpp = getBpp(); if (bpp == 8) return data[i]; if (bpp == 16) return data[i * 2] | data[i * 2 + 1] << 8; if (bpp == 4) { int res = data[i / 2]; res = res ...
24c381a3-3873-4e20-8afe-36f22abff279
7
public static int oppgave1() { int antallFeil = 0; Liste<Integer> liste = new DobbeltLenketListe<>(); if (liste.antall() != 0) { antallFeil++; System.out.println("Oppgave 1a: Feil i metoden antall()!"); } if (liste.tom() != true) { antallFeil++; System.out.println...
74e58b20-bac2-4f19-a3f6-4976bc44f999
7
public static void getLLcontactGraphStats(){ int maxNumOutEdges = 0; int maxNumInEdges = 0; try { Connection con = dbConnect(); PreparedStatement getNumOutboundEdges = con.prepareStatement( "SELECT COUNT(*) FROM "+llTbl+" WHERE location1ID = ?"); PreparedStatement getNumInboundEdges = con.prepareSt...
c3f7e058-fba0-4004-b149-c610d88c88ee
7
public Vector<Account> loadDB() throws SQLException, IOException { Vector<Account> result = new Vector<Account>(); PreparedStatement statement; statement = bd.prepareStatement("SELECT * FROM accounts;"); statement.execute(); rs = statement.getResultSet(); while (rs.next()) { Account curAccount = new A...
67f7806c-227f-4276-8e9a-71304b565085
3
public String toString(int itemsPerLine) { StringBuilder handString = new StringBuilder(); int itemsPrinted = 1; for (Card c : playerHand) { handString.append(c.toString()); if ((playerHand.indexOf(c) < playerHand.size() - 1)) { handString.append(", "); ...
c0247c4f-6486-4084-acfe-d35c55796608
4
public void remove( int offs, int len ) throws BadLocationException { boolean proceed = true; if ( dontCheck == false ) { try { String tmp = super.getText(0, offs) + (super.getLength()>(offs+len) ? super.getText(offs+len, super.getLength()-(offs+len)) : ""); Matcher m = p.matcher(tmp); proceed = m.m...
388aa481-a17f-47bf-b8e1-8be1f52131fd
9
public String largestNumber(int[] nums) { if (nums == null) { return null; } Comparator<String> comparator = (s1, s2) -> { if (s1.equals(s2)) return 0; String option1 = s1+s2; String option2 = s2+s1; char chars1[] = option1.toCharA...
5eac5eda-fad0-4c84-9fa4-fe9a4e39b000
2
@Override public void mouseClicked(MouseEvent e) { if (!pelota.getMov() && pelota.contiene(e.getX(), e.getY())) { pelota.lanzar(); } }
a30d72c5-06d8-4d08-ac81-17d5aa62d094
1
public void undo() { revising = true; if (!TEXT_HISTORY.isEmpty()) { String lastText = TEXT_HISTORY.pop(); TEXT_FUTURE.push(lastText); textLower.setText(lastText); // gui.TEXT_HISTORY.tailMap(fromKey) } }
8711419f-292f-45c6-a921-2f6a00a40bdf
5
@Override public void serialEvent(SerialPortEvent ev) { if (ev.getEventType() == SerialPortEvent.DATA_AVAILABLE) { try { int available = inputStream.available(); byte[] receiveBuffer = new byte[available]; inputStream.read(r...
f23be564-dc88-4177-b84d-54447c47291d
3
public static void checkSubstitute(int index) { System.out.println("Substitute detected"); if(Mechanics.hasSubstitute[index]) { if(Mechanics.substituteHealth[index]<=0) { Mechanics.substituteHealth[index]=0; Mechanics.hasSubstitute[index]=false; if(index==0) b1.addText("Your substitute b...
c2020649-0e91-4ae7-afc0-851c6335ff6e
7
@Override public boolean getDados() { preenchido = true; String msg = bundle.getString("Os Campos: "); nome = txtNome.getText(); localizacao = txtLocalizacao.getText(); desc = txtaDesc.getText(); preco = (double) spPreco.getValue(); descIng = txtaDescIng.get...
9c05ed80-b368-44f3-8247-c699326fd966
3
public double laskeRivihinta(Juoma j, String koko, int maara) { double rivihinta = 0; // lasketaan tilausrivin hinta sen perusteella kuinka suuri juoma // ja kuinka monta kappaletta niitä halutaan lisätä ostoskoriin if (koko.equals("pieni")) { rivihinta = j.getPieniHinta() * maara; } else if (koko.e...
4e8fe744-6526-4d65-a97c-444edc119f29
2
public Vector<String> getAllAdmin() { Vector<String> ans = new Vector<String>(); String select = "SELECT * FROM ADMIN"; try { ResultSet rs = stat.executeQuery(select); while (rs.next()) ans.add(rs.getString("NAME").trim()); } catch (SQLException e) { e.printStackTrace(); } return ans; }
839ba27a-492a-4c96-9792-a01db5ce2a1c
4
public static boolean containsInstance(Collection<?> collection, Object element) { if (collection != null) { for (Object candidate : collection) { if (candidate == element) { return true; } } } return false; }
28dea455-8afe-419a-9566-0e574549f0cc
3
public static void createBoat(String type){ switch(type){ case RACE_MODE: instance = new RaceBoat(); break; case STATION_KEEPING_MODE: instance = new StationKeepingBoat(); break; default: System.out.println("Cannot set boat mode : unknown mode " + type); if(instance == null){ System.out...
238fd52a-139d-4b6b-a83f-f02a30f10e0d
1
public static void asm_decf(Integer akt_Befehl, Prozessor cpu) { Integer f = getOpcodeFromToBit(akt_Befehl, 0, 6); Integer result = cpu.getSpeicherzellenWert(f) - 1; // Speicherort abfragen if(getOpcodeFromToBit(akt_Befehl, 7, 7) == 1) { // in f Register speichern cpu.setSpeicherzellenWert(f, result, tr...
c36bff41-e7f2-4e31-8784-78556c5a0872
6
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((collator == null) ? 0 : collator.hashCode()); result = prime * result + ((field == null) ? 0 : field.hashCode()); result = prime * result + (includeLower ? 1231 : 1237); result = ...
2211bd3f-64de-413b-a2d5-8b7d7008e303
6
public synchronized String cds() { if (cds != null) return cds; // Concatenate all exons List<Exon> exons = sortedStrand(); StringBuilder sequence = new StringBuilder(); int utr5len = 0, utr3len = 0; // 5 prime UTR length for (Utr utr : get5primeUtrs()) utr5len += utr.size(); // Append all exon se...
419dcc8b-9504-48d0-b279-633f5a90ebc9
2
public MyTableModel(Collection<SupplierProduct> initialData) { ArrayList<SupplierProduct> sortedData = new ArrayList<SupplierProduct>(initialData); Collections.sort(sortedData, new Comparator<SupplierProduct>() { @Override public int compare(SupplierProduct o1, SupplierProduct o2) { return o1.supplier...
7dcf27d9-6eda-4827-a905-cefe4c7b7404
5
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton9ActionPerformed {//GEN-HEADEREND:event_jButton9ActionPerformed if (!gameover) { if (rule.turn()) { if (rule.check(2, 2)) { rule.pressed(2, 2); if ...
233ca4ae-175c-4e56-97c8-b006ac5ddeaa
1
public boolean establishConnection() { try { client.connectToServer(); } catch (HttpClientException e) { return false; } return true; }
bbc39dad-b2d2-464d-94ac-785350fd7f99
4
public Snowball makeSnowball(Location l, Direction d, SnowballType s) { if (s == SnowballType.SUPER) { return new Snowball(l, d, 50, 2, s); } else if (s == SnowballType.FAST) { return new Snowball(l, d, 35, 1, s); } else if (s == SnowballType.ONE_HIT) { return new Snowball(l, d, 100, 2, s); } else if (...
82c06d60-86f5-4198-a295-c93c9750b458
3
public List<Strategy> getSecondaryStrategies () { List<Strategy> rv = new ArrayList<Strategy>(); Strategy primaryStrategy = getPrimaryStrategy(); for (Strategy s : Strategy.values()) if (s != primaryStrategy && getScoreForStrategy (s) > 5) rv.add (s); return rv; }
92a9e5e8-07ee-4033-b6a1-98f88074477a
7
public void reopenFiles() { ArrayList<File> filesToDisplay = new ArrayList<File>(); for(int i=0; i<50; i++) { String key = "display." + Integer.valueOf(i).toString(); if (props.containsKey(key)) { String filepath = props.getProperty(key); File file = new File(filepath); if (fi...
18d8a440-0b9e-4f24-855f-ebc64bdaf559
0
public void setIsInSources(boolean isInSources) { _isInSources = isInSources; }
4a2c99a6-233f-4e57-964d-01761fe784ca
9
final boolean method3905(int i) { anInt4183++; if (aBoolean4177) { return true; } if (aClass241_4178 == null) { try { int i_1_ = Class240.aClass329_2943 != Node_Sub38_Sub1.aClass329_10086 ? Class320_Sub24.aClass197_8443.id + 7000 : 80; aClass241_4178 = Class240.aSignLink2946.method3642((byte) -80,...
51995ecf-6e85-4ca0-8778-5ef8c40b5425
2
@EventHandler public void onNameTag(PlayerReceiveNameTagEvent e) { Player player = e.getNamedPlayer(); if (plugin.onDuty.contains(player.getName())) { if (player.getName().length() <15) { e.setTag(ChatColor.RED + player.getName()); } } }
1cc62506-c8cf-4bcb-9188-02d693ff26b0
5
@Override public boolean equals(Object o) { if(this == o) { return true; } if(o == null || getClass() != o.getClass()) { return false; } FieldData fieldData = (FieldData) o; if(fieldNumber != fieldData.fieldNumber) { return false; } if(!name.equals(fieldData.name)) { return false; } r...
0fa96184-52eb-4bcd-8aaf-d388a52f509f
6
private static ExceptionData findMatchingException(Stacktrace currentStacktrace) { ExceptionData matchedException = null; for (ExceptionData exceptionData : exceptions) { boolean match = false; Stacktrace stacktrace = exceptionData.getStacktrace(); int lineDiff = Math.abs(currentStacktrace.getLines().size...
4daa7e91-8f7d-4712-ac01-df8c10b279bc
7
private void editorChangeValue(Font font) { for (int i = 0; i < fonts.length; i++) { if (fonts[i].equals(font.getName())) { familyNameCombo.setSelectedIndex(i); break; } } for (int i = 0; i < pointSizes.length; i++) { if (font.getSize() <= pointSizes[i]...
8ae29c80-b754-4fab-8bac-533d3b6f2cd9
5
public synchronized String[] validatePlayer(QuizServer quizAccess){ int playerId=0; String playerName=""; String[] playerData={"",""}; List<Player> playerList=null; Iterator<Player> playerIterator=null; List<Integer> playerIdList =null; try{ BufferedReader bufferedReader= new BufferedReader(new Inpu...
410bff4a-4712-408c-85ee-a46b3c27f0cf
1
public void addRows(List<Project> array) { ProjectTableModel tableModel = new ProjectTableModel(array, manager); int row = array.size(); int col = 0; for (Project data : array) { setValueAt(data, row - 1, col++); } }
dc1a84ae-5738-4c88-a945-1d9c1283355d
4
public Tile getTileAt(Position p) { if ( p.getRow() == 0 && p.getColumn() == 0 ) { return new StubTile(GameConstants.FOREST, 0, 0); } if ( p.getRow() == 1 && p.getColumn() == 0 ) { return new StubTile(GameConstants.HILLS, 1, 0); } return new StubTile(GameConstants.PLAINS, 0, 1); }
59039a64-db7f-450b-b573-827234748cfa
4
public void layoutContainer(Container parent) { synchronized (parent.getTreeLock()) { Insets insets = parent.getInsets(); int totalWidth = maxWidth - insets.left - insets.right; int height = 0; int width = 0; int maxHeightOfThisLine = 0; int componentCount = parent.getComponentCount(); for(...
3ccf14e5-c512-445a-9c8b-f789aae2947b
1
@Override public List<Integer> update(Criteria beans, Criteria criteria, GenericUpdateQuery updateGeneric, Connection conn) throws DaoQueryException { List paramList1 = new ArrayList<>(); List paramList2 = new ArrayList<>(); StringBuilder sb = new StringBuilder(UPDATE_QUERY); String ...
81295b15-de42-4f04-87c1-6386baf5abee
5
public void populatePeers(ArrayList<Peer> trackerPeers){ System.out.println("PeerList returned from tracker: (new valid peers accentuated with **)"); //Iterate through the list of peers, and add them to new list if they match the specified requirements. for (int currPeerIndex = 0; currPeerIndex < trackerPeers.siz...
16d94399-b7cb-4007-a658-8409a47e4ed5
9
public static SortedMap<Double, List<Double>> classify(double[] breakPoints, double[] data) { SortedMap<Double, List<Double>> sortedMap = new TreeMap<Double, List<Double>>(); double nextbreakPoint = Double.MAX_VALUE; DecimalFormat twoDForm = new DecimalFormat("#.##"); //format to two decimal pla...
302de690-38e1-4ddc-b45a-99e24f294bcd
1
@Override public void writeAll(Collection<Element> elements) throws CacheException { // TODO Auto-generated method stub for (Element e : elements) { write(e); } }
65338984-2b86-4adc-b84c-6fa974fe58d8
7
public State path(Node f, Node t, Queue<State> q, int len) { HashSet<Node> v = new HashSet<Node>(); q.offer(new State(f)); while (!q.isEmpty()) { State cur = q.poll(); if (!v.contains(cur.node)) { v.add(cur.node); if (cur.node.compareTo(t) == 0) return cur; for (Node n: edges.get(cur.node).keySe...