method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
7d840be8-0ef1-4a7f-8ce9-5669aa3d0d07
2
private List<T> calcPath(T start, T goal) { // TODO if invalid nodes are given (eg cannot find from // goal to start, this method will result in an infinite loop!) LinkedList<T> path = new LinkedList<T>(); T curr = goal; boolean done = false; while (!done) { path.a...
6f4cd418-24a6-4ae0-b5eb-2ff9356311cc
2
public void addWorldModelListener(final WorldModelListener listener) { if (listener != null && !listenersWorld.contains(listener)) { this.listenersWorld.add(listener); } }
a3c0890d-be48-46a3-a00c-6ef2320fec82
6
public int evalRPN(String[] tokens) { Stack<Integer> stack = new Stack<Integer>(); for (String str : tokens) { if (str.length() == 1) { switch (str.charAt(0)) { case '+': stack.push(stack.pop() + stack.pop()); break; case '-': { int first = stack.pop(); stack.push(stack.pop() - fi...
5e920b0e-c303-4107-a2f6-bb867ccc9d93
8
private Sentence parseSentence(String itemSource) { Sentence sentence = new Sentence(); String[] split = itemSource.split(SENTENCE_PART_MARGIN); for (String itemSource1 : split) { if (itemSource1.equals(String.valueOf(' '))) { Whitespace whitespace = new Whitespace('...
ffd6968b-4b88-42fe-93a0-c737f24998b0
7
private void modifyPanelInit(){ modifyPanel = new JPanel(); generator.createRigidSpace(modifyPanel, 15); //Add a table of all the equipment to the panel final JTable allEquipment = new JTable(allEquipmentModel.getTableModel(5)); allEquipment.removeColumn(allEquipment.getColumn("ID Number")); allEquipm...
82c60b75-2a5f-47f5-949a-189cc95b7db6
8
private static ArrayList<ResidualEdge> minCostFlowWithBellmanFordSub( ArrayList<ResidualEdge>[] edges, int s, int t) { int n = edges.length; ResidualEdge[] prevE = new ResidualEdge[n]; int[] prevV = new int[n]; int[] dist = new int[n]; Arrays.fill(prevV, -1); ...
0d29b51d-fab8-4a32-a7e1-ce3707f66181
6
void run() { long countUnknown = 0; long lineNum = 1; Timer.showStdErr("Converting lines from QSEQ to FASTQ (Sanger)"); // Process file try { String linePe1, linePe2, lineIdx; // Open inputs BufferedReader inPe1Buff = new BufferedReader(new InputStreamReader(new FileInputStream(inPe1))); Buffer...
dd0444d4-916b-40d7-8129-d9f7333004d8
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * F...
612a148c-650c-422c-9849-1409208f1862
7
private void registerCommands() { getCommand("chteam").setExecutor(new CommandExecutor() { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { return getGame(sender).cmdChangeTeam(sender, args); } }); getCommand("teamhome").setExecutor(new Command...
8561132e-6ab0-4156-81f6-35d48b266ade
8
private static List<Part> layout(Part fp, int w) { List<Part> ret = new LinkedList<Part>(); List<Part> line = new LinkedList<Part>(); int x = 0, y = 0; int mw = 0, lh = 0; for(Part p = fp; p != null; p = p.next) { boolean lb = p instanceof Newline; int pw, ph; while(true) { p.x = x;...
52a5bf54-13fe-4f96-8d06-4e0d0905580d
9
public GenesSearchResult getGenes(List<String> geneNames) { List<GeneInput> loadedGenes = new LinkedList<GeneInput>(); List<String> notFoundGeneNames = new LinkedList<String>(); for (String geneName : geneNames) { GeneInput gene = new GeneInput(geneName); GeneInput select...
6995c47a-19a0-4209-8e91-6e0e4e4857ca
1
public void accapt(Visitor visitor) { for (Element element : elements) element.accapt(visitor); }
93bf49be-a1ee-485b-b670-da142007d1c7
3
private static void calcNoOfNodes(Node node) { if (node instanceof Parent) { if (((Parent) node).getChildrenUnmodifiable().size() != 0) { ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable(); noOfNodes += tempChildren.size(); f...
070bc9a1-3fc4-4ec0-a432-821dfb28771b
1
public static void loadAllXML() { if (isLoaded) { System.out.println("XML already loaded"); return; } isLoaded = true; DBConnection.resetDatabase(); // Load users new XMLReader("./xml/users.xml"); // Load quizzes new XMLReader("./xml/bunny.xml"); new XMLReader("./xml/cities.xml"); new XMLRe...
aeab4443-71a1-4ee0-9415-0a09e20fa478
3
public JSONObject putOnce(String key, Object value) throws JSONException { if (key != null && value != null) { if (this.opt(key) != null) { throw new JSONException("Duplicate key \"" + key + "\""); } this.put(key, value); } return this; }
16ad084d-9f0f-40a4-bf80-10b8478a27bd
4
public boolean IsAlive(int playerID) { for (Planet p : planets) { if (p.Owner() == playerID) { return true; } } for (Fleet f : fleets) { if (f.Owner() == playerID) { return true; } } return false; }
cf3eec28-a0b7-4653-8ebb-6cf89b2991cc
5
public void pathRecurse(String folderPath, List<String> targetList) { File musicFolder = new File(folderPath); if(!musicFolder.exists()) { musicFolder.mkdirs(); } File[] abstractPaths = musicFolder.listFiles(); for(File path: abstractPaths) { //only add ...
85d6d4d4-44de-414e-a81f-61c2036ead37
1
public ByteVector putInt(final int i) { int length = this.length; if (length + 4 > data.length) { enlarge(4); } byte[] data = this.data; data[length++] = (byte) (i >>> 24); data[length++] = (byte) (i >>> 16); data[length++] = (byte) (i >>> 8); data[length++] = (byte) i; this.length = length; retu...
aca1fb58-353f-4daa-a92c-1d71f68dec99
7
private static void createGUI() throws MidiUnavailableException, InvalidMidiDataException, IOException { //Set up the GUI. dropdownFont = new Font("Dialog", Font.PLAIN, 12); // the main frame frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // add icon for OS tray // This icon is also used in var...
4f1e9cd1-21ff-49e4-9c32-3ba9c27f89ca
8
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Playlist that = (Playlist) o; if (idPlaylist != that.idPlaylist) return false; if (description != null ? !description.equals(that.description) ...
2be85b46-d92d-41a0-8a43-9cdc0653263a
9
public int[] searchForRange(int[] num, int target){ int[] res = new int[2]; if (num.length == 0){ res[0] = -1; res[1] = -1; return res; } /* search for the start index. */ int start = -1; if (num[0] == target){ start = 0; } else { for (int i = 1; i < num.le...
ab70ec56-8ac9-456c-b986-a1e44736a830
3
public void suspend() { suspending = true; //prepare the file transferring inFile.setMigrateState(true); outFile.setMigrateState(true); //close the transactional IO try { inFile.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { outFi...
947f8f4b-553e-429c-ba5b-5e19808f54df
9
public void generate(Entity entity, UUID uuid) { if(PluginVars.hasDeck(uuid)) { return; } else { List<Card> newdeck = new ArrayList<Card>(); List<Integer> newint = new ArrayList<Integer>(); if(entity.getType() == EntityType.ENDERMAN) { if(PluginVars.random.nextBoolean()) { newdeck = new DeckGen...
c18c7104-9ed0-4256-8ef0-fb6b7437e94c
2
public void SetAPIKey(String apiKey) { _apiKey = apiKey; if (null == _apiKey || _apiKey.length() < 5) throw new IllegalArgumentException("Too short API key."); }
3ec66cfc-b039-401e-b34d-6742f42a8d51
0
public String getNumber() { StringBuilder contactNumber = new StringBuilder(); contactNumber.append(getCountryCode() + " (" + getCityCode() + ") " + getLocalNumber() + " - " + getExtension()); return contactNumber.toString(); }
8c339b5a-e1ee-4993-9060-937d4bb94fba
2
public void exit() { try { UnicastRemoteObject.unexportObject(mInstance, true); logout(); } catch(Exception ex) { if(connect()) { exit(); return; } System.out.println("Error on exit"); System.out.println(ex.getMessage()); } }
c8d8f4a7-9372-4aa5-8666-346a05894f26
6
private void addFire() { squareSelector.reset(); squareSelector.setCriteria(new SquareCriteria() { private final String desc = "Add: Fire"; public String getDescription() { return desc; } public boolean isSquareValid( SquareSelector squareSelector, int roomId, int squareId ) { if ( roomId < 0 || squa...
68de060d-6011-42f8-b086-14f15dc45e1b
4
public void move() { if (y + ya > 0 && y + ya < game.getHeight() - HEIGHT) y += ya; if (x+xa > (game.getWidth()/2) && x + xa < game.getWidth() -WIDTH) x -= xa; }
3a3ba861-01f1-4cf9-985e-165b342a1fd8
8
public Ability getCombatSpell(boolean malicious) { final List<Ability> spellSet=getCombatSpellSet(); int tries=0; while(((++tries)<1000)) { final Ability A=spellSet.get(CMLib.dice().roll(1,spellSet.size(),-1)); if(((malicious)&&(A.canTarget(Ability.CAN_MOBS))&&(A.enchantQuality()==Ability.QUALITY_MALICIO...
eef510e1-4488-4121-b08c-f42fa49138a9
8
public static byte[] encodePapPassword( final MessageDigest md5, final byte[] userPass, final byte[] requestAuthenticator, final String sharedSecret) { // encrypt the password. byte[] userPassBytes = null; //the password must be a multiple of...
61158ff5-5375-420d-98fa-de8d7bdb68af
3
public Message fetchMessage(int id) { initConnection(); String preparedString = null; PreparedStatement preparedQuery = null; Message message = new Message(); try { //Prepare Statement preparedString = "SELECT * FROM messages " + "INNER JOIN users ON users.email = messages.user " + ...
b11f6c96-dc4f-4a60-9195-0bddad604665
1
public static void write(String record, BufferedWriter out) { try { out.write("db." + COLLECTION_NAME + ".insert(" + record + ");\n"); } catch (IOException e) { e.printStackTrace(); } }
be1f206e-5fc1-4360-a1c1-46e44c638ca3
8
public static void setupres() { if (ResCache.global != null) Resource.addcache(ResCache.global); if (Config.resurl != null) Resource.addurl(Config.resurl); if (ResCache.global != null) { try { Resource.loadlist(ResCache.global.fetch("tmp/alluse...
2ef63eaf-efdc-492a-80d7-4d1fc48fb329
0
private Stock(){}
f5da1194-cd69-440c-9fab-a3e80ca957d2
9
@Override public boolean shutdown() { //int numTicks=tickGroup.size(); while(allTicks.size()>0) { //Log.sysOut("ServiceEngine","Shutting down all tick "+which+"/"+numTicks+"..."); final TickableGroup tock=allTicks.iterator().next(); if(tock!=null) { CMProps.setUpAllLowVar(CMProps.Str.MUDSTATUS,"...
bb18506b-bf78-4dee-b92a-38091bfd4cc8
5
private void processEvent(Event event) { switch (event.getType()) { case NEW_PROCESS: newProcess(); break; case SWITCH_PROCESS: switchProcess(); break; case END_PROCESS: endProcess(); break; case IO_REQUEST: processIoRequest(); break; case END_IO: endIoOperation(); break; } ...
90cab0c0-31b1-4c6a-b0ef-13b3f24e00bc
2
public long getLong(String key) throws JSONException { Object object = this.get(key); try { return object instanceof Number ? ((Number)object).longValue() : Long.parseLong((String)object); } catch (Exception e) { throw new JSONException("JS...
0bddbfb6-5591-4acf-a4cc-522f2ddd8492
4
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(args.length==1){ BansManager.unipBanPlayer(sender.getName(),args[0], ""); return true; } if(args.length>1){ String msg = ""; for(String data: args){ if(!data.equals(args[0])){ msg+...
a89e692c-8b74-4341-ac9c-77408acfd687
9
public static void main(String[] args) { try { File dirname = new File(args[0]); File writename = new File(args[1]); String reportdate = args[2]; writename.createNewFile(); BufferedWriter out = new BufferedWriter(new FileWriter(writename)); for (File filename : dirname.listFiles()) { if (...
fdb4cb3c-d524-43e9-acbd-5e1a3aee5197
5
public Writer write(Writer writer) throws JSONException { try { boolean b = false; int len = length(); writer.write('['); for (int i = 0; i < len; i += 1) { if (b) { writer.write(','); } Object ...
2d546833-55ab-4560-bfe6-5113a859d0f6
2
@Override public void processingInstruction(String target, String data) { if (PI_VERBOSE.equalsIgnoreCase(target)) { HashMap map = parseAttributes(data); String enabled = (String) map.get(PI_NAME_ENABLED); setVerbose(TruthTest.getBooleanTruthValue(enabled)); try { String level = (String) map....
b22b0688-c3ee-4887-9a5a-e14cdb7a024c
7
@Override public void executeMsg(final Environmental myHost, final CMMsg msg) { super.executeMsg(myHost,msg); if((affected!=null) &&(affected instanceof MOB) &&(msg.amISource((MOB)affected)||msg.amISource(((MOB)affected).amFollowing())||(msg.source()==invoker())) &&(msg.sourceMinor()==CMMsg.TYP_QUIT)) { ...
73b77b65-eae0-46e3-bda0-65bef9e755b8
6
public void tick() { for (int i = 0; i < entities.size(); i++) { Entity e = entities.get(i); if (!e.removed) e.tick(); if (e.removed) { blockmap.remove(e); e.onRemoved(); entities.remove(i--); } else { blockmap.update(e); } } for (int i = 0; i < particles.size(); i++) { Particl...
2b634c4b-5a5a-4733-bd1a-c32110c2fd91
8
public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; StringBuilder out = new StringBuilder(); HashSet<String> dictionary = new HashSet<String>(); ArrayList<String> list = new ArrayList<String>(120000); d: do {...
cc31f9f3-cdea-4423-9a58-bc163e5eea82
0
@Basic @Column(name = "FUN_APORTA_FONDO") public String getFunAportaFondo() { return funAportaFondo; }
59c2c1d8-74ab-4ee9-8f04-3c14a2301867
8
public static String ragoz(Szo szo, FonevRag... ragok) { List<FonevRag> ragokLista = new ArrayList<>(); Collections.addAll(ragokLista, ragok); String ret = szo.getSzo(); if (ragokLista.contains(FonevRag.TOBBES_SZAM)) { ret = addTobbesSzamRag(szo); } else if ( ...
02a7c642-b08d-4a2d-b9be-d390383889d9
7
int getNorthTweak(int cellId) { int row = getRow(cellId); int positionInRow = getPositionInRow(cellId); if ((row <= 0) || (row >= 5*n)) { return 0; } else if (row == n - 1) { return getSegmentNumber(cellId) / 2; } else if ((row == 2*n - 1) && (n != 1)) { ...
c13f407a-8c8b-45b0-9a2b-e10d504bed54
7
@Override public void actionPerformed(ActionEvent ae) { if(this.on==1){ int deltaX = 258-x2; int deltaY = 352-y2; //System.out.println("DeltaX: "+deltaX); //System.out.println("DeltaY: "+deltaY); int originX = x2+deltaX; int originY = y...
93dc01f5-986c-4ad9-b524-9237775bde5b
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
46129766-b916-49c8-88fd-23cd87b16e6b
4
public void useActiveTool(int x, int y, int prevX, int prevY) { imageGfx = image.getGraphics(); if (!isMarking) { return; } if (activeTool == Tool.PENCIL || activeTool == Tool.ERASER) { drawLine(x, y, prevX, prevY); } if (activeTool == Tool.PAINTBUCKET) { fillArea(x, y, color.getRGB()); } ...
7d3df114-04a0-4dac-9101-aa12735a47d5
1
protected void closeImpl() { if (source != null) { source.close(); } }
d03c32dd-3713-4d4b-9340-6bce91705ba9
7
public static void main(String[] args) { final SieveOfAtkin sieve = new SieveOfAtkin(10000); final int max = 10000; final ArrayList<Integer> list = sieve.run(); final HashMap<Integer, Integer> primes = new HashMap<Integer, Integer>(); for (int prime : list) { primes.p...
000b2113-b3d4-4edf-b529-280bd85e00b9
4
public static void removeRentTransaction(int rentTransactionId){// deze functie zou ik niet gebruiken try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }...
db02f115-a1ab-4b93-98ff-42354e684c87
9
public static double binomialCoefficientLog(final int n, final int k) { ArithmeticUtils.checkBinomial(n, k); if ((n == k) || (k == 0)) { return 0; } if ((k == 1) || (k == n - 1)) { return FastMath.log(n); } /* * For values small enough to do exact integer computation, return the * log of the ex...
b68db112-10ff-4a7e-a5a1-7d20b0509f3a
1
@Override public boolean showMenu() { // TODO Auto-generated method stub if(rb.getString("validate").equals("1")) return true; else return false; }
987a8d3c-695c-47ad-b29d-4aa3c912ff45
7
public void cargarTabla(){ try{ if(jComboBoxTipoCuenta.getSelectedIndex()==0 && jComboBoxTipoCliente.getSelectedIndex()==0){ tipoCuenta=1; tipoCliente=1; tablaCuentaAhorroClienteFisico(); }else{ if(jComboBoxTipoCuenta.getSel...
7302ca50-5b99-41a8-b607-cdeca367382d
2
public int compare(bean1 o1, bean1 o2) { if(o1.sal > o2.sal) return -1; else if (o1.sal < o2.sal) return 1; else return 0; }
56af488c-4978-45d9-b53d-e917e1a26c87
3
private void listarEmpleados() { ControladorEmpleado unControlador = new ControladorEmpleado(); try { LinkedList listaDeEmpleados = unControlador.buscarTodosLosEmpleadosConVentas(); Object columnasDeDatos[] = new Object[4]; //obtenemos el modelo def...
1d037bbd-06a5-463b-a57c-3a3b7aa1180a
1
public static boolean testEmptyString(String s) { return s == null || s.equals(""); }
5c7870cb-8d87-4ecf-b3ee-457a4e3c3d68
5
private void init(){ allDes = new LinkedList<>(); allDeplacements = new LinkedList<>(); if(tours != null){ for (Tour tour : tours) { int length = tour.getDeSixFaces().size(); List<DeSixFaces> des = tour.getDeSixFaces(); List<Deplacement> deplacements = tour.getListDeplacement(); for( in...
46222acc-499c-46bf-afa7-a0f6821428b8
2
public void testPropertyCompareToMinute() { LocalDateTime test1 = new LocalDateTime(TEST_TIME1); LocalDateTime test2 = new LocalDateTime(TEST_TIME2); assertEquals(true, test1.minuteOfHour().compareTo(test2) < 0); assertEquals(true, test2.minuteOfHour().compareTo(test1) > 0); asse...
17c925f0-536b-49c4-912c-75056cbadb0e
0
public void setDefaultTime(Date defaultTime) { this.defaultTime = defaultTime; }
2df6aafb-b1d2-4bb1-a3c8-df357a8c623a
2
public static void clear() { Keyboard.destroy(); try { Keyboard.create(); } catch (LWJGLException e1) { e1.printStackTrace(); } for(Keybinds e : Keybinds.values()) { e.key.setPressed(false); } }
98f28ab2-3d31-4a96-8625-26c909cf8e7f
4
@Override public void mouseDragged(MouseEvent e) { if (inside) if (draggedComponente != null) { draggedComponente.move(lastPoint, e.getPoint()); lastPoint = e.getPoint(); } else if (draggedNodo != null) { if (startPoint == null) { ...
ed209f27-3eef-48cb-b211-f183b7f527a3
0
protected final void setName(String name) { _name = name; }
99942906-baa6-4512-ae24-58effa509f08
3
@Override public void run() { //try { if(!messages.isEmpty() && connection != null) { try { PreparedStatement messageInsertStatement = connection.prepareStatement( "INSERT INTO BlackBoxMessages(timestamp, mes...
96c85c6c-1e0e-4ec9-b665-b2a6b5532609
6
@Override public void mouseEntered(MouseEvent e) { if(!czyRozmieszczonoLosowo) { if(widokRozmiesc.cb_RodzajStatku.getItemCount() > 0) for(int i = 0;i < 10; i++) for(int j = 0;j < 10; j++) if(e.getSource() == lb_polaGry[j][i]) { if(widokRozmiesc.uzytkownik.plansza.sprawdzWspolrzedneUs...
d3f0533b-8a59-4b7b-b39f-9cf3f1ff2db5
9
public static int getYerX(int lvl){ if(lvl == 1) return 210; if(lvl == 2) return 200; if(lvl == 3) return 310; if(lvl == 4) return 290; if(lvl == 5) return 120; if(lvl == 6) return 200; ...
48404a3b-103c-46cb-a23d-bf4ed3d65a28
4
private void initSecOptMenu(Color bg) { this.secOptMenu = new JPanel(); this.secOptMenu.setBackground(bg); this.secOptMenu.setLayout(new VerticalLayout(5, VerticalLayout.LEFT)); // position Position pos = this.skin.getSecurityMenu_Position(); boolean[] active = { true, t...
4119ba08-ca49-4340-a4cc-e14ee543cda6
6
public void draw(Graphics g, int width, int height) { //TODO optimize - build vector of objs in FOV, need only draw these cameraMan.setMatrix(); obj3dManager.sortObjects(); for (ObjectLayer layer : obj3dManager.layers) { for (Object3d object : layer) { object...
ab34c587-ba47-4264-a0fe-e3dc510407c6
3
private static double getBlackPercent(BufferedImage capture) { int blackcount = 0; for(int i = 0; i < capture.getWidth(); i++){ for(int j = 0; j < capture.getHeight(); j++){ int rgb = capture.getRGB(i, j); float[] hsb = Color.RGBtoHSB((rgb >> 16 & 0xFF), (rgb >> 8 & 0xFF), (rgb & 0xFF), null); if(hs...
7cd95f25-3aa5-4eca-b2b8-17494fa8b204
0
public final void startIdentServer() { new IdentServer(this, getLogin()); }
adcba4dc-cc36-4ced-ac8b-133f110ed899
3
public static String getSearchRecordsString(String searchKey, Storage storage) { String result = "Name" + "\t" + "PhoneNumber" + "\t" + "Address" + "\n"; List<Contact> searchedContacts = new ArrayList<Contact>(); int recordCount = 0; searchedContacts = getSearchObject(searchKey, storage...
31ac6370-4803-42d4-8ed5-caa61575ecfe
5
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final AuthenticationInfo other = (AuthenticationInfo) obj; if ((this.login == null) ? (other.login != null) : !this.login.equals(other.login)) { ...
8ce3863d-1537-4fa0-a095-6aca904c73b2
0
public int getKillstreak() { return killstreak; }
5c68a48a-571f-4078-8857-b74c4acbf4ad
0
public static void main(String[] args) { serviceConsumer(new Implementation1Factory()); // Implementations are completely interchangeable: serviceConsumer(new Implementation2Factory()); }
3c84a446-ece3-4731-a958-f1a5472427a9
3
public int execute() { // The UNLISTEN listen command is described as follows: // UNLISTEN <socketID> if( this.getParamCount() != 1 ) { this.getFactory().getServer().getLogger().log( Level.SEVERE, "Illegal argument count." ); return 1; // implies error } // OK. Take the last argumen...
c4e5c17b-27d7-4004-b860-693a68d0efc4
4
@Override public void run() { while (running) { for (WorkerThread w : this.getWorker()) { Socket s = w.getSocket(); if (!s.isConnected()) { try { System.out.println("ConnectionInsepctor: " + s.getInetAddress() + " keine ...
b04487b2-0031-4a6a-bbf5-1b309de415ac
8
public Card getCard(String name, String desc, int power, int ActionID){ switch(ActionID){ case 1 : { return new BoostCard(name, desc, power);} case 2 : { return new AttackCard(name, desc, power);} case 3 : { return new StopCard(name, desc, power);} case 4 : { return new TrapSetCard(name, desc);} c...
3f7a70ca-a692-4deb-a0a8-f757c96ef9a3
3
private int insert(Funcionario f) { Connection con = null; PreparedStatement pstm = null; int retorno = -1; try { //con = guarda a conexão aberta no connectionFactory con = ConnectionFactory.getConnection(); //pstm = manda um sql para o banco ...
362aec0e-ca0f-435d-bb33-ade2ec7ce5f8
4
public BufferedImage getSprite(String key) throws NullPointerException { if (VectorWorld.DEBUG_GFX) { System.out.println("Trying to get the sprite with key " + key + "..."); } BufferedImage bi = (BufferedImage) imagesMap.get(key); if (bi == null) { ...
b72d75e5-7665-4c3d-8c4e-f1298fb26d42
7
public boolean subs(String user, String tag, boolean unsubscribe) { clearResultMetaInformation(); boolean subscribeResult = false; StringBuffer result = new StringBuffer(); GetMethod get; if (!unsubscribe) { get = new GetMethod(apiEndpoint + DeliciousConstants.INBOX_...
9072ac43-bd08-4192-8cab-3c1905f3eb14
9
public static int computerChoice() { int emptyrow= 0; // first check if a move can win for (int i=0; i<COLUMNS; i++) { if (!isColumnFull(board,i)) { emptyrow = firstEmptyRow(board,i); board[emptyrow][i] = XPLAYER; if (winningDisk(board, emptyrow, i)) { board[emptyrow][i] = EMPTY; // reset ...
84c0be40-b7e8-48af-abe8-140a6603a974
3
public SubjectID getSubjectID() { SubjectID result = null; try { Node elem = Utilities.selectSingleNode(this.node, "./dc:SubjectID", XMLLabels.STANDARD_NAMESPACES); if(elem != null && elem.getNodeType() == Node.ELEMENT_NODE) { String type = Utilities.getAttributeValue(elem, "type"); result = new Su...
71d2a232-0121-4532-a1f8-bc8125e56c10
3
@Override public String toJson(int tabs) { StringBuilder b = new StringBuilder(); b.append("["); for (int c = 0; c < this.array.size(); c++) { if (c > 0) { b.append(", "); } Object obj = this.array.get(c); if (obj instanceof IJsonSerializer) { b.append(((IJsonSeria...
dd988ec3-92f0-4316-9a5e-271b65aef97a
3
public String lire(String path) { BufferedReader lect; String tmp = ""; try { lect = new BufferedReader(new FileReader(path)); while (lect.ready() == true) { tmp += lect.readLine() + "\n"; } lect.close(); }//try catch (NullPointerException a) { System.out.println("Erreur : pointeur null"...
9eb995fa-f9fd-4b48-902f-f7a27223043c
4
public static String getRichtung(List<Raum> raums) { if(raums == null || raums.size() < 2) return null; Raum raum1 = raums.get(0); Raum raum2 = raums.get(1); for(String richtung : raum1.getMoeglicheAusgaenge()) { if(raum1.getAusgang(richtung) == raum2) return richtung; } return null; }
900f3644-dd7e-4d09-af65-414084a15db3
8
public synchronized void clearBoard(boolean clearBackup) { if (clearBackup) { backup.clear(); try { // remove unused images Iterator<Integer> i = ImageTable.getInstance().keySet().iterator(); while(i.hasNext()) { Integer id = i.next(); if (backgroundImgID == null || !backgroundImgID.equals...
bfb875cd-d951-4b6c-a5ea-9724d42d1ee1
7
public static void prepareExtensionElement(Document doc, Element command, epp_Extension[] extensions) throws epp_XMLException { if (extensions != null) { Element extension_element = doc.createElement("extension"); for (int count = 0; count < extensions.length; count++) { epp_Extension extension = extensi...
58dd0455-d3a6-4135-8e04-0d1345bc099d
6
public synchronized static String leaveGame(String ip) { String msg = "LEAVE_GAME FAILURE"; boolean flag = false; NodeList nList = doc.getElementsByTagName("player"); for (int i = 0; i < nList.getLength(); i++) { Element myEl = (Element) nList.item(i); if (nList.item(i).getParentNode().getParentNode().to...
2c35d3ed-db2f-4ac0-b45f-136582e4ed40
6
public HashMap<Integer, ArrayList<Integer>> zigzagLevelHelper(TreeNode root){ HashMap<Integer, ArrayList<Integer>> res = new HashMap<Integer, ArrayList<Integer>>(); if(root == null){ return res; } Queue<TreeNode> q = new LinkedList<TreeNode>(); Queue<Integer>...
29b2007c-ec48-4f71-8a7c-389dfe4585e0
7
public final JPoclASTParser.parameters_return parameters() throws RecognitionException { JPoclASTParser.parameters_return retval = new JPoclASTParser.parameters_return(); retval.start = input.LT(1); TypeTree root_0 = null; Token char_literal113=null; JPoclASTParser.bexpr0_retu...
f0590005-2328-41e9-96f7-cd6c5726d4d2
9
public void updateImagePath() { if (team.num == 1) { if (theta == 0) { this.imagePath = IMAGE_TANK_UP_BLUE; } else if (theta == 90) { this.imagePath = IMAGE_TANK_RIGHT_BLUE; } else if (theta == 180) { this.imagePath = IMAGE_TANK_DOWN_BLUE; } else if (theta == 270) { this.imagePath = IMAGE...
6d1a8184-5d12-4ad3-b15f-904bbfef0f9e
8
public boolean Connect() { /* Get all available ports */ Enumeration<?> portIdentifiers = CommPortIdentifier.getPortIdentifiers(); /* Find requested port */ CommPortIdentifier portId = null; while (portIdentifiers.hasMoreElements()) { CommPortIdentifier p = (CommPortIdentifier)portIdentifiers.nextElement(...
858f7edc-2138-4a6f-bcee-982178bef9f0
9
static void generate_hypotheses(final int order, final Hypothesis h, // final multimap<String, String> tag_dictionary, final ArrayList<ME_Model> vme, List<Hypothesis> vh) { int n = h.sentence.size(); int pred_position = -1; double min_ent = 999999; // String pred = ""; //jenia //...
4ac90cb2-f238-4565-bd2f-042c24719b54
1
public static void saveProducts() { if (!productsModified) return; SerialFileHandler.writeObject(products, supplier.getName() + ".dat"); productsModified = false; }
563c9894-47d8-4b92-86a3-7ca8420b65ab
5
private void pop(char c) throws JSONException { if (this.top <= 0) { throw new JSONException("Nesting error."); } char m = this.stack[this.top - 1] == null ? 'a' : 'k'; if (m != c) { throw new JSONException("Nesting error."); } this.top -= 1; ...
2a08662b-ecbf-4873-acbd-3c59dd1fbb91
4
private boolean isValidName(String s) { if (!isValidNMTOKEN(s)) return false; int c = s.charAt(0); return ! ((c>=0x30 && c<=0x39) || c=='.' || c=='-' ); }
76d7b022-eed2-4058-b84b-232572d662b3
3
public Object load(String path, Class c) throws SlickException { if(c.equals(Image.class)) { return new Image(path); } else if (c.equals(Sound.class)) { return new Sound(path); } else if (c.equals(Music.class)) { return new Music(path); } else { throw new UnsupportedOperationException("Object to loa...
a2a2b544-fdc2-44b5-acd8-f5b26d562c57
8
private void writeInstance(Instance inst) throws Exception{ StringBuffer insert = new StringBuffer(); insert.append("INSERT INTO "); insert.append(m_tableName); insert.append(" VALUES ( "); if(m_id){ insert.append(m_count); insert.append(", "); m_count++; }...