method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
bcbd31c9-f015-4321-bd04-b13b28e81533
3
@Override public boolean equals(Object obj) { if (!(obj instanceof Ball)) return false; return (super.equals(obj)) && (this.xSpeed == ((Ball) obj).xSpeed) && (this.ySpeed == ((Ball)obj).ySpeed); }
f614b70e-54db-48fe-b1c5-9e9f16873006
8
public void updateRanks(DB_Timers timer, Boolean all) { if (all) { List<DB_Timers> timers = this.plugin.database.getDatabase().find(DB_Timers.class).findList(); if (timers != null && timers.size() > 0) { for (DB_Timers timerdata : timers) { Integer TimerID = timerdata.getId(); HashMap<String, Stri...
648a4911-5a70-46c3-addc-edef88edb156
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BoundingBox other = (BoundingBox) obj; if (Double.doubleToLongBits(bottom) != Double .doubleToLongBits(other.bottom)) return false; if (...
2520c65a-db0f-4dee-8215-ccfca8618f6d
2
private void testRead(){ String f_name = this.path + Params.nTests + ".txt"; long startTime = 0; long endTime = 0; File f = new File(f_name); FileInputStream fin = null; try{ fin = new FileInputStream(f); byte[] buf = new byte[Params.packSize * Params.nPacks]; for(int i = 0 ; i...
9c047353-4b99-427e-a0f7-ca5aaf357261
7
private void computeUidlCommand(String message) { String[] cmd = message.split(" "); // Auf Argument ueberpruefen if (cmd.length > 1) { // Es wurde ein Argument gefunden int n = Integer.parseInt(cmd[1]); // -ERR Antwort, wenn Mail geloescht wurde if (mailIsDeleted(n)) { try { writeToClient("-...
1272898a-bbfc-4880-9994-3e23cbf163b5
0
public OSCPacket() { }
b645253d-b744-4fe6-b86a-d2447f3c551d
9
public boolean inBorders(Crossing c) { //Don't know if commenting out this makes it work. huh double tolerance = 0.00001; if (c.atInf()) { if (c.atNegInf() && leftborder) { return false; } if (!c.atNegInf() && rightborder) { return false; } } if (leftborder && c.crAt() < leftb-tolerance) { r...
cc40dc15-0b24-4745-9543-de7d743ec3f3
6
public Personaje(InterfazPersonaje tipo, Juego g, Ventana window, int x, int y) throws IOException{ this.posX = x; this.posY = y; this.game = g; this.tipoPersonaje = tipo; this.tipoPersonaje.cambiarPoder(this); this.tipoPersonaje.cambiarImagenes(this); this.escudo = this.espada = this.gema = false; if...
f40db1f4-e4ce-4a9d-938f-213e1cb8fe13
3
public void openConnection() { System.out.println("-------- Oracle JDBC Connection Testing ------"); try { Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { System.out.println("Where is your Oracle JDBC Driver?"); ...
e957fa5f-f21e-438f-a72e-f5e7d6bbaef5
6
public void run() { /* if (Frame.clickButton.isVisible()) { } else { } if (buttonHaveBeenClicked) { buttonHaveBeenClicked = false; if (timer.get_ticks() == 1000 - (score * 100)) { buttonHaveBeenClicked = false; } if((score >= 10) && (buttonSize >= 20)) { buttonSi...
db15b005-bdd0-4574-b34e-7a94657245e6
9
protected void calcIntegValue() { double a = 0.0, b = 0.0; double eps = 1e-4; double result = 0.0; try { a = Double.parseDouble(lowTextField.getText()); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "积分下限输入错误,请检查重输。"); lowTextField.requestFocus(); lowTextField.selectAll(...
84bf2949-e0a6-4b3f-bbee-7315e8bf03a5
0
public void hideAll() { defaultVisible = false; visibleNodes.clear(); }
5b0dafb6-64c2-427b-84f5-6521d0e724fe
0
public SimpleStringProperty cityCodeProperty() { return cityCode; }
5f3d70f2-1022-4292-9159-5e4afaf11c7e
3
private void shutdownOpenGL() throws Exception { log("Shutting down OpenGL"); if (Keyboard.isCreated()) { log("Destroying keyboard"); Keyboard.destroy(); } if (Mouse.isCreated()) { log("Destroying mouse"); Mouse.destroy(); } if (Display.isCreated()) { log("Destroying d...
459fc3b5-cedb-4d6a-9bdc-0b26214acaaa
0
public UnboundGrammar() { setStartVariable("S"); }
5ff8b875-1fdc-45e1-a761-68d83141e8f3
2
public void run() { while (!generator.isCanceled()) { int val = generator.next(); if (val % 2 != 0) { System.out.println(val + " not even!"); generator.cancel(); // Cancels all EvenCheckers } } }
b81e4e9f-bb07-4bdf-b057-b185aa9eca26
1
public void makeMove(int position, int player){ if (validMove(position,player)){ updateGameField(position,player); this.changeTurn(); } }
54641307-5882-4b4c-a948-a1735ff48e05
5
public static Color biomeToColor(byte b) { switch (b) { case DESERT: return DESERT_COLOR; case SAVANNAH: return SAVANNAH_COLOR; case SWAMP_RAIN_FOREST: return SWAMP_RAIN_FOREST_COLOR; case MODERATE: return MODERATE_COLOR; case TUNDRA: return TUNDRA_COLOR; default: return MODE...
67146b03-8089-439d-ac71-6ac94a9c27c3
5
public static int[] contains(String position) { int[] v = new int[2]; for (int i = 2; i < 10; i++) { for (int j = 2; j < 10; j++) { for (int k = 2; k < 10; k++) { for (int l = 2; l < 10; l++) { if (position.equals(boardOfMoves[i][j...
4b512410-2419-4abf-872f-1081d2913727
6
public void insertTag(Tag tag, int index) { if (type != Type.TAG_List && type != Type.TAG_Compound) throw new RuntimeException(); Tag[] subtags = (Tag[]) value; if (subtags.length > 0) if (type == Type.TAG_List && tag.getType() != getListType()) throw new ...
294043a4-1b96-4f82-9da6-8c04f41d9114
9
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target.fetchEffect(this.ID())!=null) { mob.tell(target,null,null,L("<S-NAME> <S-IS-...
5c65098c-366f-4b51-a170-ca0e768411e8
2
private void updatePhysicalEntityList() { allPhysicalEntities = new ArrayList<Mob>(); for (Mob m : dots) allPhysicalEntities.add(m); for (Mob m : polygons) allPhysicalEntities.add(m); }
2fb222ba-5cb5-48c9-a46f-60aeef2da143
9
public String runMacro(HTTPRequest httpReq, String parm) { final String last=httpReq.getUrlParameter("COMPONENT"); if(last==null) return " @break@"; if(last.length()>0) { final String fixedCompID=last.replace(' ','_').toUpperCase(); final List<AbilityComponent> set=new Vector<AbilityComponent>(); i...
ca18b701-6b57-423d-9654-b05f45281028
2
@Override public Key select(int rank) { if (rank < 0 || rank >= N) return null; return keys[rank]; }
462d0c52-8902-4476-bd37-ca6ab20ae790
0
@Override public void keyPressed(KeyEvent arg0) { inputEvents.addLast(arg0); }
46cbdff6-e0a1-474c-aad7-44811df4052d
3
public static String getTime() { Calendar cal = Calendar.getInstance(); String hour = String.valueOf(cal.get(Calendar.HOUR_OF_DAY)); if (hour.length() == 1) { hour = "0" + hour; //pad with zero for 0..9 } String min = String.valueOf(cal.get(Calendar.MINUTE)); if (min.length() == 1) { min = "0" ...
584cb6dc-ddcd-4393-8850-9b6155282474
5
public static boolean isPrime(long num) { if (num<2) return false; if (num==2) return true; if (num%2==0) return false; for (long i = 3; (i*i)<=(num); i+=2) { if (num%i == 0) return false; } return true; }
2b5a20b0-f28e-403d-bd76-ebe43df34ac9
6
public void drawSprite(int i, int k) { i += anInt1442; k += anInt1443; int l = i + k * DrawingArea.width; int i1 = 0; int j1 = myHeight; int k1 = myWidth; int l1 = DrawingArea.width - k1; int i2 = 0; if(k < DrawingArea.topY) { int j2 = DrawingArea.topY - k; j1 -= j2; k = DrawingArea.topY; ...
111cf8c1-5a17-4a17-9eea-5dd856025385
9
public static void main(String[] args) throws Exception { if (args != null && args.length > 0) { ResourceBundleUtil.init(args[0].substring(0, args[0].lastIndexOf("."))); } TestRunner.rowCounter = new AtomicCounter(Integer.parseInt(get("base.row"))); rowCounter.getPrevousValu...
9afd9f35-584b-4148-a027-01eb0ef093d2
8
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final DateDTO other = (DateDTO) obj; if (!Objects.equals(this.year, other.year)) { return false; ...
52034449-d2b2-4784-b8fc-ddb385fa31eb
6
private void fillTileArrays() { for (int i = 0; i < pixels.length; i++) { for (int j = 0; j < pixels[0].length; j++) { int value = mapImage.getRGB(i, j); value = value & 255; pixels[i][j] = value > 0 ? 3 : 0; if (value == 0) { ...
244bfbfc-2216-4ed7-81fa-67deced0c72c
5
private void encode(Object value) { this.value = value; if (value==null) { type = 1; return; } if (value instanceof Dubble) encodeDouble(); if (value instanceof Bool) encodeBool(); if (value instanceof VLQ) encodeVLQ(); if (value instanceof VLQString) encodeVLQString(); ...
e01633b9-5532-4a8e-be4a-ddf5a6396761
9
@Override public void actionPerformed(ActionEvent arg0) { if (colorGain) colorN += 3; else colorN -= 5; if (colorN >= 200) colorGain = false; else if (colorN <= 30) colorGain = true; if (!seen) { if(frame.getTutorial() <= 4) { tutorial = true; hero.setPaused(true); if (tutori...
73266fe5-8859-4bd4-8a49-9e9b719c223b
6
@Override public void mouseClicked(MouseEvent event) { if (frame.getCurrentPlayer().getPlaysLeft() != 0 && !frame.isGameOver()) { int row = (int) Math.round(4.0 / 3.0 * (event.getY() - 40.0) / HEX_HEIGHT); int col = (int) Math.round((event.getX() - 40 - 0.5 * HEX_WIDTH * (5 - row)) / HEX_WIDTH);...
4233d6ca-fce0-41d1-ad55-775a60fb64b9
5
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for(int x = 0; x < maxFields; x++){ for(int y = 0; y < maxFields; y++) { this.field = map.get(x).get(y); ...
4ce2ad29-225e-4efe-8e7a-8bf2d257ec4c
0
public ColorResource(int a, int r, int g, int b) { this.a = a; this.r = r; this.g = g; this.b = b; }
8bb2fdb6-2197-4f83-acff-a264d56bd077
5
public boolean sLeft(){ boolean change = false; //i -> y | j -> x for (int i = 0 ; i < 4 ; i ++){ for (int j = 0; j < 4 ; j++) { if(mLeft(j, i)) change = true; } if (aLeft(i)) change = true; } if (change){ //System.out.println(change); //debug genTile(); } return change; ...
409488ed-0423-4376-886d-37374aadf448
8
@EventHandler public void onPlayerMove(PlayerMoveEvent event) { if (event.getFrom().getWorld() == event.getTo().getWorld() && event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockY() == event.getTo().getBlockY() && event.getFrom().getBlockZ() == event.getTo().getBlockZ()) ...
caa7b7ea-5445-46c3-989e-3400a565bef5
8
@Override public SimOrgNode update( SimNode rootNode, long timestamp, Message m, List<Message> messageDest ) { if( timestamp < nextAutoUpdateTime && !BitAddressUtil.rangesIntersect(m, minId, maxId) ) return this; for( int i=0; i<childs.length; ++i ) { SimNode newChild = childs[i].update( rootNode, timestamp, ...
56f409f8-e219-4aff-8ac9-d318b07e139d
6
public void actionPerformed(ActionEvent arg0) { if (arg0.getSource() == internalView.getNextMonthButton()) { internalModel.getModel().addMonth(1); } else if (arg0.getSource() == internalView.getPreviousMonthButton()) { internalModel.getModel().addMonth(-1); } else if (arg0.getSource() == intern...
c2382191-5632-4ce1-b8a6-d848aa513559
1
public void setEscapes(String escapes, String replacements){ int length = escapes.length(); if (replacements.length() < length){ length = replacements.length(); } this.escapes = escapes.substring(0, length); this.replacements = replacements.substring(0, length); }
31e44d60-9f54-4b4f-a9f5-ed6af87c131b
4
private void JBEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBEditarActionPerformed this.zerarModelo(); int crm; try{ int linha = JTListaMedico.getSelectedRow(); if( linha >= 0){ crm = (int) JTListaMedico.getValueAt(linha,0); ...
8864e74c-5444-4c0b-b3b0-9785f5a98787
8
public ArrayList<Employee> AllEmployeesInFranchise(int FranID) throws UnauthorizedUserException, BadConnectionException { PreparedStatement pStmnt = null; ArrayList<Employee> BPList = new ArrayList<Employee>(); // Get the employee type through JClIO instance lio = JC...
372b1a80-d702-46ca-8396-1375b80c0f2b
2
public static void main(String[] args) { System.out.println("Which kind of connection should be established?"); System.out.println("typ 1 for a anonymous session"); System.out.println("typ 2 for a user+password session"); Scanner scanner = new Scanner(System.in); int input; input = scanner.nextInt(); ...
9b7466eb-f5d9-4bfa-bca0-e568077258ed
0
public void setContactName(String contactName) { this.contactName = contactName; }
2ab2ea75-233f-48ac-a4ef-78e6b767b1bd
1
public int getRowDividerHeight() { return mShowRowDivider ? 1 : 0; }
b9b904b7-8759-438c-96fb-7bc3626e9e1a
6
public void mouseReleased(MouseEvent evt) { if (mousein == 1 && evt.getSource()==buy){ settle(); calcStats(); refresh(); } if (mousein == 2 && evt.getSource()==ok){ settle(); setVisible(false); //you can't see me! dispose(); //Destroy the JFrame object } if (mousein == 3 && evt.ge...
520323ae-fd60-4d63-9e3d-1aef1ec05dcf
8
public float getHeight(float x, float y, float z) { if(x < 0 || y < 0 || z < 0 || x >= xyz[0] || y >= xyz[1] || z >= xyz[2]) { return 1; } int tile = tiles[(int)x][(int)y][(int)z].type; switch (tile) { case 0: //empty return -1;...
b884b06c-d2d7-41cd-83be-1dd92cc38ec4
6
private boolean formatFilePaths(){ //If the inputFilePath is empty turn result false boolean result = true; if(inputFilePath.equals("")){ result = false; } else { String findExtension = "(.*)\\.txt$"; //String findSRC ="src\\/"; //String findFile = "(src\\/)?(.*)\\.txt$"; Pattern ...
f92074c5-fe5c-4027-81b6-e7409bf344d1
0
@Override public void startSetup(Attributes atts) { super.startSetup(atts); setEnabled(false); addActionListener(this); Outliner.documents.addDocumentRepositoryListener(this); }
1ba82731-b12d-49ea-96f5-8171633fac38
5
public boolean add(String key, int ttlSec, Object value, long timeoutMiliSec) throws TimeoutException { try { StringBuilder sb = new StringBuilder(); byte valueBytes[] = null; int flag = -1; if (value instanceof String) { String arg = (String) value; valueBytes = arg.getBytes(charset); fla...
0942a26c-db40-4ad1-bcb2-031729dd57e0
0
public JFrame getFrame() { return frame; }
d702a0c3-927f-479e-a345-3c456a05e9ed
6
private static void loadLibraries() throws Exception { /* load all software libraries */ int lwjgl = 0; for(File file : new File("libs").listFiles()) { String name = file.getName(); if(!name.endsWith(".jar")) { continue; } if(name.contains("lwjgl")) { ++lwjgl; } addSoftwareLibrary(file);...
66259a7d-ff16-4d89-a926-21e79d3be9ef
6
public static double estimateGoalCost(Proposition goal) { { Keyword testValue000 = goal.kind; if ((testValue000 == Logic.KWD_ISA) || ((testValue000 == Logic.KWD_FUNCTION) || (testValue000 == Logic.KWD_PREDICATE))) { { NamedDescription description = Logic.getDescription(((Surrogat...
b44a280b-b29c-4446-8bc3-8d5912d5a111
1
public ChatPanel(User user){ Dimension channelListSize = new Dimension(190, 450); this.dbCon = DatabaseConnection.getInstance(); this.user = user; this.updater = new ChannelListUpdater(); this.imgLdr = new GUIImageLoader(); setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); setBorder(BorderFactory.creat...
02f258d3-b34c-45a4-93b5-488997aee52c
4
public static void SenderOTs(Circuit c, Formatter f, OT ot, ObjectOutputStream oos, ObjectInputStream ois) { Vector<OTTASK> OTs = new Vector<OTTASK>(10, 10); IO io = null; // Construct vector of all OTs to be executed for (int i = 0; i < f.FMT.size(); i++) { io =...
45ec43e8-5a58-4932-951a-d98b3ee2ed05
9
public void onEnable() { PluginDescriptionFile pdf = getDescription(); // Load configuration FileConfiguration config = this.getConfig(); boolean configChanged = false; if (config.get("build.message") == null) { config.set("build.message", config.getString("message", "You don't have permission to build!")...
5b7d66f6-1ba3-4041-b526-f0721b6c08f3
7
@Override protected boolean isDirty() { boolean dirty = super.isDirty(); if (dirty) { return true; } else if (isCheckingDirtyChildPainters()) { for (Painter<T> p : painters) { if (p instanceof AbstractPainter) { AbstractPainter<?> ap = (AbstractPainter<?>) p; if (ap.isDirty()) ...
4681a93f-c828-4a81-8049-4ba39db71460
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Book other = (Book) obj; if (available != other.available) return false; if (readingCounter != other.readingCounter) return false; if (...
04660c47-7c07-4b6d-9e33-c13e349973cb
5
private List<PTM> remapParentPtms(PTM currentPTM) { List<PTM> resultPTMs = new ArrayList<PTM>(); for(Comparable parent: ((PSIModPTM)currentPTM).getParentPTMList()){ PSIModPTM psiModPTM = (PSIModPTM) psiModController.getPTMbyAccession((String) parent); if(psiModPTM.getUnimodId() !...
42df9474-384d-4d6c-be6c-dbc3884c64e0
3
@Override public void run() { while (!isExit) { lock.lock(); for(Map.Entry<Integer, PlayerConnection> entry : clients.entrySet()) { PlayerConnection connection = entry.getValue(); connection.listenSocket(); } try { await.awaitNanos(20); } catch (InterruptedException e) { e...
9e317096-1ab1-4c49-b927-659562505c5f
3
private void findOpeningBracket(String str, boolean sign) throws ParseException { Matcher matcher = Pattern.compile(sign ? "\\s*([+-]?)\\(" : "\\s*\\(").matcher(str); if (!matcher.lookingAt()) { throw new ParseException("(", offset); } if (sign) { ...
718351f1-925c-4b89-a68a-6f1790885db5
8
public Collision checkCollision(Game g) { int snakeX = g.getSnake().getX(); int snakeY = g.getSnake().getY(); GameBoard gb = g.getGameBoard(); String coordKey = g.getObjectRegister().createCoordinateKey(new Coordination(snakeX, snakeY)); // Koli...
87eb1394-2d51-41f3-be35-4d287ef9289e
3
public Configuration loadEmbeddedConfig(final String resource) { final YamlConfiguration config = new YamlConfiguration(); final InputStream defaults = this.getResource(resource); if (defaults == null) return config; final InputStreamReader reader = new InputStreamReader(defaults, Custo...
c944d5e2-61b4-49f4-a531-60d8c2d9b86a
4
@Override public String toString() { String result = "["; Queue<MapNode> q = new Queue<>(); if (!isEmpty()) q.enqueue((MapNode)root); while (!q.isEmpty()) { MapNode n = q.dequeue(); if (n.left != null) q.enqueue((MapNode)n.left); if (...
e54742b9-a18e-48e2-9453-dacd7c45bd24
7
private void onStartFlush(Address flushStarter, Message msg, FlushHeader fh) { if (stats) { startFlushTime = System.currentTimeMillis(); numberOfFlushes += 1; } boolean proceed = false; boolean amIFlushInitiator = false; Tuple<Collection<? extends Address>...
dcd43309-02e8-4a59-88f3-17549796bf88
5
@Override public boolean processBuffer() { // Stream buffers can only be queued for streaming sources: if( errorCheck( channelType != SoundSystemConfig.TYPE_STREAMING, "Buffers are only processed for streaming sources." ) ) return false; // Ma...
2124bbbe-2a57-4419-9fa1-3847fbe3a144
9
@Override public void run() { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch (Exception ex) { System.out.println("Cant load JDBC driver."); } DataInputStream in; DataOutputStream out; String message; Con...
d7892856-d055-440b-9ab4-de32bb3c63ff
2
public boolean isChanged() { if (name != nameSave || sizeInformation() != sizeSave) { nameSave = name; sizeSave = sizeInformation(); return true; } return false; }
a673ef4a-261d-423e-9dea-9d4345691bef
3
public static byte[] gzip(String input) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzos = null; try { gzos = new GZIPOutputStream(baos); gzos.write(input.getBytes("UTF-8")); } catch (IOException e) { e.printStackTrace...
31528d76-064a-40fd-a051-344921f41bd5
3
public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = ""; out = new StringBuilder(); ring = new int[16]; int times = 1; while ((line = in.readLine()) != null && line.length() != 0) { if (times != 1) out.appe...
5a321c4c-23db-4104-b811-a994cf04f1f3
1
public void closeSession(){ try{ bf.close(); pf.close(); s.close(); }catch(IOException io){ System.out.println("echec de fermeture"); io.printStackTrace(); } }
1e0af998-73d5-4102-853e-9d3471b48ab5
7
public void doInsert_jdbc6(ParamHolder myParamHolder) { try { PreparedStatement pstmt = myParamHolder.conn.prepareStatement("insert into "+myParamHolder.table.toUpperCase()+"( file_name, "+myParamHolder.clobFieldName.toUpperCase()+", file_tag) values ( ? ,? , ?)"); pstmt.setString(1, my...
eae25065-fe9d-4a6d-9489-36d3efc61d90
0
public VueVisiteur(CtrlAbstrait ctrl) { super(ctrl); initComponents(); modeleJComboBoxVisiteur = new DefaultComboBoxModel(); modeleJComboBoxLabo = new DefaultComboBoxModel(); modeleJComboBoxSecteur = new DefaultComboBoxModel(); jComboBoxVisiteur.setModel(modeleJComboB...
ccbcdc8a-72ee-4aad-8e7d-87aef06ef874
2
public java.io.Serializable fromDOM(Document document) { Map e2t = elementsToText(document.getDocumentElement()); String expression = (String) e2t.get(EXPRESSION_NAME); if (expression == null) if (e2t.containsKey(EXPRESSION_NAME)) throw new ParseException("Regular expression structure has no " + EXPR...
c0fa935d-5793-4fd3-b3f3-6fc595390fae
4
public static void changeMemberSurname(String surname, int memberID){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try{ PreparedStatemen...
dfed69f3-f74b-4be3-a3b0-d90a7f2cac3b
8
public List<PersonasDTO> getDataPersonas() throws Exception { try { List<Personas> personas = XMLHibernateDaoFactory.getInstance() .getPersonasDAO() .findAll(); List<P...
974e7d55-4dfd-45a9-ad39-b5f5f614c0a5
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...
40045fda-05de-4821-894e-3e9501ad389f
2
private void alustaTaso(int i) { /** * Tason lukeminen ja parsiminen tiedostosta, ja sen asettaminen * pelaajalle */ try { Tiedostonlukija lukija = new Tiedostonlukija("src/tasot/" + i + ".txt"); TasonLuonti luonti = new TasonLuonti(lukija.getRivit()); ...
4bc81539-45e7-45fb-a059-852c71015ded
2
public void makeMove(Location loc) { if (loc.equals(getLocation())) { double r = Math.random(); int angle; if (r < 0.5) angle = Location.LEFT; else angle = Location.RIGHT; setDirection(getDirection() + angle)...
d5d19027-ac68-4eaa-8460-85e26d021db3
5
public static void main(String[] args) throws InterruptedException { final BlockingQueue<Integer> blockingQueue = new BlockingQueue<>(10); final Random random = new Random(); Thread t1 = new Thread(new Runnable() { public void run() { try { while (...
66495c02-cfa3-4309-82c1-d1895ae4e906
2
public static void unsetFlag(BoardModel boardModel, Point point) { Cell currentCell = boardModel.getBoard()[point.getPosX()][point.getPosY()]; if (boardModel.getNumberOfFlags() < boardModel.getNumberOfMines() && currentCell.isFlagged()) { currentCell.setFlagged(false); boardMode...
4ee8c0c9-3503-451b-9286-65d4e2dc9e2a
8
public List<Word> sentenceProcess(String sentence) { List<Word> tokens = new ArrayList<Word>(); int N = sentence.length(); Map<Integer, List<Integer>> dag = createDAG(sentence); Map<Integer, Pair<Integer>> route = calc(sentence, dag); int x = 0; int y = 0; ...
0c557c00-67ec-4ee9-81f2-a23de96e6d8a
8
protected void insertRecords(PreparedStatement stmt, Importer importer) throws IOException, SQLException { int recordCount = 0; int insertedCount = 0; int errorCount = 0; while (true) { Object[] row = importer.nextRow(); if (row == null || row.length == 0) { ...
dc37cc1e-368a-4f21-9181-090ef42bf902
3
@Override public void keyReleased(int key, char c) { if(key == 57) { //space checkDialogs(); } if(!inputEnabled) return; ArrayList<GameKeyListener> keyListenersCopy = new ArrayList<GameKeyListener>(keyListeners); //Create a copy because scripts can register keyrelease components. System.out.println(...
0db922ef-2846-4560-a634-c39e35c4be9e
4
public static void main(String[] args) { String[] sortedData; SortOperations so = new SortOperations(); MyFileReader rf = new MyFileReader(); String fileContent; if (args.length == 2 && 0 == args[0].compareTo("-r")) { fileContent = rf.readFile(args[1]); St...
b8d961ef-2d84-4aa6-92f7-dc72b08cbb18
0
@Override public void init(GameContainer container) throws SlickException { board = new GameBoard(); selected = new int[2]; select = false; wturn = true; black = new chess_game.NPC(false); //Create the players players = new ChessPlayer[2]; pl...
46b3a618-4e42-4292-80db-67d4761a4118
0
@Override public void extract() { Thread extract = new ExtractThread(); extract.start(); }
5286539b-a48e-4e50-a92a-d72a39668bce
7
public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { resetPath(); repaint(); return; } for (int i = e.getX() - pRadius; i<e.getX()+pRadius; i++) { for (int j = e.getY() -pRadius; j<e.getY()+pRadius; j++) { Node temp = myGraph.nodeAt(i, j); ...
936666d1-d928-425b-9077-f9f96f7fed7c
1
public void updateGemsInBag(String newTheme) { for(int loop = 0; loop<Bag.size(); loop++) { Gem temp = (Gem) Bag.get(loop); temp.setNewImage(newTheme+"Gem.png"); } }
cfa77026-befe-4871-8dd4-7c10c432772a
4
public static void main(String[] args) { Scanner in = new Scanner(System.in); int score = Integer.parseInt(in.next()); if (score > 85) { System.out.println("A"); } else if (score > 75) { System.out.println("B"); } else if (score > 65) { System....
a53fa5a4-8fe3-4d9c-abcc-8ea62f9cdec7
8
public void writeTableToFile(GetLectureTweets lt, GetTagTweet tt, GetToTweet totw, String tag, String tagStartDate, String tagStartTime, String tagEndDate, String tagEndTime, String svTwUni, String lectureStartDate, String lectureStartTime, String lectureEndDate, String lectureEndTime, String lectureName){ ...
a6df4e11-a799-4c9f-ac50-0afe28dce24f
7
public int calculoElevacao(JButton button, String grausDigitado) { int graus = Integer.parseInt(grausDigitado); try { if ("Elevação".equals(button.getActionCommand())) { System.out.println("**************ELEVAÇÃO*********************"); if (graus >= 0 && graus...
19657e0a-77a0-416c-89e1-793a5644533d
1
@Override public String toString() { return String.format("%1$-15s %2$-5d %3$-7s %4$13d", getAddress().getHostAddress(), getPort(), isOnline() ? "online" : "offline", getUsage()); }
76925c84-10e3-46ef-85cf-4f4c064a25ee
7
public static void parser(File fIn, Socket sckIn, EzimContact ecIn) { Hashtable<String, String> htHdr = null; InputStream isData = null; String strCType = null; String strCLen = null; long lCLen = 0; try { isData = sckIn.getInputStream(); htHdr = EzimDtxSemantics.getHeader(fIn); strCType = htHd...
23f4a99a-3369-4d28-be08-f4bdeef20a2a
9
private void verifyBranches() throws AssemblyException { int maxLabelLength = 0; for (int i = 0; i < lines.size(); ++i) { String label = lines.get(i).label; if (label != null) { if (label.length() > maxLabelLength) maxLabelLength = label.length(); if (branches.containsKey(label)) throw new A...
de7339a8-b4f4-46f4-87d8-53bce62ed89a
6
private void kingBottomLeftPossibleMove(Piece piece, Position position) { int x1 = position.getPositionX(); int y1 = position.getPositionY(); if((x1 >= 1 && y1 >= 1) && (x1 < maxWidth && y1 < maxHeight)) { if(board.getChessBoardSquare(x1-1, y1-1).getPiece().getPieceType() != board.getBlankPiece().getPiec...
442456ed-a21e-4ebb-b990-b4475c80b527
3
@Override public String execute(SessionRequestContent request) throws ServletLogicException { String page = ConfigurationManager.getProperty("path.page.hotels"); try { Criteria criteria = new Criteria(); Hotel currHotel = (Hotel) request.getSessionAttribute(JSP_CURRENT_HOTEL)...
5555e4ea-4acc-4d2d-b819-de9a60728ae0
7
private void setType(int type) { if (type == 0){ units1 = new JComboBox<Object>(LengthUnits.values()); units2 = new JComboBox<Object>(LengthUnits.values()); } else if (type == 1){ units1 = new JComboBox<Object>(AreaUnits.values()); units2 = new JComboBox<Object>(AreaUnits.values()); } else if (type ==...
ba5b56c6-371f-4c62-97c2-d92357aed689
6
private Object getIndexOf(Object o, int index) { if (index == -1) { return o; } if (o instanceof List<?>) { List<?> list = (List<?>) o; if (index < list.size()) { return list.get(index); } else { return 0; ...