text
stringlengths
14
410k
label
int32
0
9
private void save(String kodikosV,String daidromiV){ /* * apothikeuei ta stoixia sthn vash kai emfanizei to katalilo minima ston xristi */ String query="insert into oximata(id,diadromi,lat,lon) values(?,?,'37.973263','23.740768') on duplicate key update diadromi=?"; try { con.pS=con.conn.prepareStatemen...
3
@EventHandler public void EnderDragonStrength(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.getEnderDragonConfig().getDouble("End...
6
public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(br.readLine().trim()); for (int t = 0; t < T; t++) { int N = Integer.parseInt(br.readLine().trim()); String[] name ...
8
private void writeBookList() { BookXMLHandler addBook = new BookXMLHandler(); try { addBook.writeToFile(bookList); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-g...
2
@Override public void onEnable() { configData.load(); PluginManager pm = this.getServer().getPluginManager(); pm.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Priority.Highest, this); pdfFile = t...
2
@Override public void setVisible(boolean state) { if (state) { eventStart.setTime(MainWindow.setupData.getEventStartDate()); startDatePicker.getModel().setDate( eventStart.get(Calendar.YEAR), eventStart.get(Calendar.MONTH), eventStart.get(Calendar.DATE)); startDatePicker.getMode...
1
public static void main(String[] args) throws Exception { switch (args.length) { case 2: expr = args[1]; /*FALLTHROUGH*/ case 1: fileName = args[0]; break; case 0: default: System.err.println("Usage: XPathRunner file [xpath-expr]\n"); return; } DocumentBuilder parser = DocumentBuilde...
5
private String parseMethodName(String signature) { String methodBeforeArguments = signature.substring(0, signature.indexOf("(")); int positionOfMethodNameStart = methodBeforeArguments.lastIndexOf("."); return methodBeforeArguments.substring(positionOfMethodNameStart + 1); }
0
public Objective getObjectiveFromTypes(String type, String name){ for(Objective obj : this.objectives){ if(obj.type.equalsIgnoreCase(type) && obj.getObjectiveName().equalsIgnoreCase(name)) return obj; } //no matching objective return null; }
3
public Integer getFrequency() { return frequency; }
0
public void applicationLoop() { int sign = -1; float height = 0; Transform3D transform = new Transform3D(); Transform3D transform2 = new Transform3D(); screen = canvas.getGraphics2D(); canvas.setFrameRate(String.format("Frame [%d]", frameCounter)); canvas.setCameraPosition(String.format("Camera Position...
5
public String sendMessage(String messageWithName) { Set<String> clientList = this.updater.getClientList(); for (String s : clientList) { try { // Angepasst this.udpVerbindung.send(s, this.userName + ": " + messageWithName); } catch (UnknownHostExce...
3
private void jbInit() throws Exception { this.contentPane = (JPanel) this.getContentPane(); this.contentPane.setLayout(this.gridBagLayout2); this.setDefaultCloseOperation(0); this.setJMenuBar(this.menuBar); this.setSize(new Dimension(759, 548)); this.setTitle("State Table Editor"); JComboBox<String> in...
7
public CipherReferenceType createCipherReferenceType() { return new CipherReferenceType(); }
0
public ProtocolElem(JFrame frame, String key, String type) { this.id = StringUtils.Md5("" + System.nanoTime()); this.setText(key, type); this.setSize(type); this.addMouseListener(new MouseAdapter() { private void button1Clicked() { MessageBox.showPEInfoBox(f...
4
@Override public Class<?> getColumnClass(int columnIndex){ Class type = String.class; switch (columnIndex){ case 0: type = Integer.class; break; case 1: type = String.class; break; case 2: type = Double.class; break; case 3: type = Double.class; break; case 4: type = Double.cla...
6
public void dividirEquipos(Collection<Inscripcion> equipo1, Collection<Inscripcion> equipo2, PriorityQueue<Inscripcion> primeros10Ordenados){ for (int i=1;i<=5;i++){ equipo1.add(primeros10Ordenados.poll()); equipo2.add(primeros10Ordenados.poll()); } }
1
public Date getEventDate() { return eventDate; }
0
public static void testValidity(Object o) throws JSONException { if (o != null) { if (o instanceof Double) { if (((Double) o).isInfinite() || ((Double) o).isNaN()) { throw new JSONException( "JSON does not allow non-finite numbers."); ...
7
public int getDepth() { Row parent = mParent; int depth = 0; while (parent != null) { depth++; parent = parent.mParent; } return depth; }
1
public void moveRobot(int ID) { robotar.get(ID).moveForward(); for(int i = 0;i < block.length;i++) { if(robotar.get(ID).touches(block[i])) { feedback.get(ID).setRobotkrock(true); robotar.get(ID).moveBackward(); } } ...
5
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { btn_addeditC = new javax.swing.JButton(); btn_addeditE = new javax.swing.JButton(); btn_refresh = new javax.swing.JButton(); b...
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; HairDryer other = (HairDryer) obj; if (windSpeed != other.windSpeed) { re...
8
private static void buttonPointSettings(final JButton button) { button.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { String text = textField.getText(); if (text.contains(".")) { if (text.contains("+")) { String subText = text.substring(text.indexOf(...
9
private boolean camposCompletos (){ if((!field_codigo.getText().equals(""))&& (!field_descripcion.getText().equals(""))&& (!field_cantidad.getText().equals(""))&& (!field_costo_u.getText().equals(""))&& (!field_precio_venta.getText().equals(""))&& (!field_t...
8
public boolean checkGuess(String question, String guess) { for(int i = 0; i < wordpairs.size(); i++) { if(question.equalsIgnoreCase(wordpairs.get(i).getDanishWord())) { if(wordpairs.get(i).getEnglishWord().equalsIgnoreCase(guess)) { ...
5
public float getLow() { float lowVal = Float.MIN_VALUE; try { lowVal = Float.parseFloat(low.getText()); if (lowVal == lowVal) return lowVal; } catch (Exception e) { } return lowVal; }
2
public static Font getDisplayFont() { return displayFont; }
0
private String getSelectClause() { if (!groupByColumns.isEmpty()) { if (selectedColumns.isEmpty()) { throw new RuntimeException("The SELECT list cannot be empty when the GROUP BY clause is specified."); } for (Column column : selectedColumns) { if (!groupByColumns.contains(column)...
7
@Override public void setGroup(ResourceGroup group) { if (group != null && !group.equals(this.group)) { if (this.group != null) { this.group.removeResourceDefinition(this); } if (!group.containsDefinition(this)) { group.addResourceDefinition(this); } } this.group = group; }
4
private final void method212(Frame frame, byte i) { boolean bool = false; if (i <= 47) method212(null, (byte) -25); try { Field field = Class.forName("sun.awt.Win32GraphicsDevice") .getDeclaredField("valid"); field.setAccessible(true); boolean bool_7_ = ((Boolean) field.get(aGraphicsDevice157))....
8
@Override public void run() { ServerSocket server; try { server = new ServerSocket(8080); while (true) { Socket socket = server.accept(); ReceivingThread thread = new ReceivingThread(socket, window); thread.start(); } } catch (IOException e) { // TODO Auto-generated catch block e.prin...
2
public static boolean arrayIncludes(Object a[], Object e) { if (a == null || e == null) return false ; for (Object o : a) if (o == e) return true ; return false ; }
4
public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); while (true) { String name = reader.readLine(); if (name.isEmpty()) break; int age = Integer.parseInt(reader.readLin...
5
public void init(String game){ Connection conn = new Connection("130.243.137.236", 8080); NetManager network = new NetManager(conn); Encoder enc = new Encoder(); try { network.connectToServer(); } catch (IOException e2) { e2.printStackTrace(); } String JSONtext = ""; try { JSONtext = enc....
5
public Position getHuffPosition() { return huffPosition; }
0
public static String multiply(String num1, String num2) { int len1 = num1.length(); int len2 = num2.length(); List<Integer> res = new ArrayList<Integer>(); for (int i = len2 - 1; i >= 0; i--) { //if ('0' == num2.charAt(i)) continue; for (int j = len1 - 1; j >= 0; j--) { int start...
9
public String toString() { if (this == Male) { return "♂"; } if (this == Female) { return "♀"; } return ""; }
2
public static void main(String[] args) { description = "Description: " + "Testing some crazy hardcore!!!!!" + "Testing overprocessing by Bank. " + "Works until requests == 0."; System.out.println("Main thread started"); String hours = new SimpleDateFormat("HH")...
8
public final JSONObject putOpt(String key, Object value) throws JSONException { if (key != null && value != null) { put(key, value); } return this; }
2
public ActionPanel(final Joculus app) { this.app_instance = app; setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); // Setting an empty border on a button removes its decoration. final EmptyBorder btn_border = new EmptyBorder(4, 4, 4, 4); JButton b; b = new JButton(getToolbar...
1
private Station(){ this.lineQueue = new Queue(); switch(Define.batcherType){ case Define.RoundRobinBatcher : this.batcher = new RoundRobinBatcher(); break; case Define.PriorityQueueBatcher : this.batcher = new PriorityQueueBatcher(); break; case Define.RandomBatc...
5
public static void main(String[] args) throws IOException, ParseException { numArgs = args.length; if(numArgs == 0) { GUI freezeUI = new GUI(); freezeUI.setVisible(true); } else { //Expect multiple switches but one command command = ""; f...
9
protected synchronized void acquire(boolean throwInterrupt) throws InterruptedException { if(acquired) return; if(throwInterrupt && Thread.interrupted()) throw new InterruptedException(); owner=getOwner(); sendGrantLockRequest(name, lock_id...
8
public static Object best(List quantity_list) { if(quantity_list == null) throw new NullPointerException(); Collections.sort(quantity_list); return quantity_list.get(0); }
1
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Vehicle other = (Vehicle) obj; if (!Objects.equals(this.szVehicleId, other.szVehicleId)) { re...
3
private void addPars() { int beginParCount=0, endParCount=0; for (int i=0;i<input.length();i++) { switch (input.charAt(i)) { case '(': beginParCount+=1; break; case ')': endParCount+=1; break; } } ...
5
public Collection realsAtBlock(final Block block) { LinkedList l = reals[cfg.preOrderIndex(block)]; if (l == null) { l = new LinkedList(); reals[cfg.preOrderIndex(block)] = l; } return l; }
1
private Animation createPlayerStanding(Image player1, Image player2) { Animation anim = new Animation(); anim.addFrame(player1, 250); anim.addFrame(player2, 250); return anim; }
0
private void loadAdjacentMaps() { String[] ways = new String[] { "north", "east", "south", "west" }; for (int i = 0; i < ways.length; i++) { String way = ways[i]; String newMap = map.getMapProperty(way, null); if (newMap != null) { if (way.equals("north")) { transitions.put(Globals.DIRECTION_UP, ...
6
AbstractDialog() { super(); setAlwaysOnTop(true); setUndecorated(true); }
0
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); txt_codigo = new j...
5
*/ public String toString() { int f = front; int r = rear; String outString = ""; if (f < r) { while (f < r) { outString += array.get(f).toString(); f++; } } else if (f > r) { while (f < array.size()) { outString += array.get(f).toString(); } for (int i = 0; i <= r; i++) { outS...
5
public static CorePhrase[] getPhrases(Connection con, Dictionary dict, User user) { LinkedList<CorePhrase> data = new LinkedList<CorePhrase>(); try { PreparedStatement ps = con.prepareStatement( "SELECT Phrases.ID, Success, RevSuccess, Performances.ID " + "FROM Phrases " + "LEFT OUTER JOIN Perf...
5
public void getSavedFiles(String file) { try{ int duplicate = 1; String textLine = ""; Scanner fileScanner = new Scanner(new File(file)); while (fileScanner.hasNextLine()) { textLine = fileScanner.nextLine() + ","; //add a comma to the end to make parsing easier int count = 0; //count the numb...
9
public UserRole role(String username) { // Open the connection connect(); // Make the statement PreparedStatement statement; try { statement = getConnection().prepareStatement( "select * from users where username = ?"); statement.setString(1, username); set = statement.executeQuery(); // ...
6
private KeyValuePair transferColumn(ColumnMapping column,ResultSet records,int i,KeyValuePair pair){ ResultSetMetaData metaData = null; try { metaData = records.getMetaData(); if(R.entity.type.transfer.equalsIgnoreCase(column.getType())){ if(column.getSrc_name().e...
4
public void setState2(State state2) throws IllegalArgumentException{ if(state2 != null) this.state2 = state2; else throw new IllegalArgumentException(); }
1
protected StdImage getIcon(TreeRow row) { return mIconAccessor != null ? mIconAccessor.getIcon(row) : null; }
1
public static List<String> getFolderNameInList(String path) { List<String> list = null; File file = new File(path); if (file.isDirectory()) { list = new LinkedList<String>(); File[] ary = file.listFiles(); for (int i = 0; i < StringUtil.size(ary); i++) { if (ary[i].isDirectory()) { list.add(ary[...
3
public void execute(final State state) { //do something special if this is the first scan if (isPreInitialScan) { isPreInitialScan = false; doInitialScan(state); } else if (state.targetPosition != null) { // don't bother if we don't know where the enemy is yet doExecute(state); } }
2
public static void main(String[] args) { Scanner s = new Scanner(System.in); String str; Integer a, b, c, d; System.out.println("This program will divide two numbers that you enter."); System.out.print("Please enter your first number: "); str = ...
2
public void KeyListener(){ for(int i=0;i<keys.length;i++){ keys[i]=false; typed[i]=true; } for(int i=0;i<mouse.length;i++){ mouse[i]=false; } }
2
public void setGraph(LaenderGraph graph) { laenderGraph = graph; }
0
protected int unicodeEscapeLexer(int c) throws IOException { int ret = 0; // ignore 'u' (assume c==\ now) and read 4 hex digits c = in.read(); code.clear(); try { for (int i = 0; i < 4; i++) { c = in.read(); if (isEndOfFile(c) || isEndO...
4
public void bucketSort(int[] data){ int max = data[0] , min = data[0]; for (int i = 0; i < data.length; i++) { if(max < data[i]){ max = data[i]; } if(min > data[i]){ min = data[i]; } } int bucketSize = (max - min + 1)/10 + 1; Node[] bucket = new Node[bucketSize]; for (int i = 0; i < b...
7
public void show(){ Scanner scan = new Scanner(System.in); int choice=0; while(choice!=4){ System.out.println("=============="); System.out.println(" Movie Menu "); System.out.println("=============="); System.out.println("1) Create Movie"); System.out.println("2) Update Movie"); System.out...
7
public void deposit(BigInteger amount) throws IllegalArgumentException { if ( (amount == null) || (amount.compareTo(BigInteger.ZERO) < 0) ) throw new IllegalArgumentException(); setBalance(this.getBalance().add(amount)); }
2
public String getStateParametersValueKeyPair() { String parameters = ""; for (int i = 0; i < parameterKeys.length; i++) { // Add the parameter key parameters += parameterKeys[i] + "="; // add the parameter values if you can null otherwise if (parameterValues.length > i) { parameters += parameterValu...
3
String transformValue(int val) { switch (val) { case 0: return "Arithmetic"; case 1: return "Geometric"; case -1: default: return "-1"; } }
3
private void run() { init(); log("Initializing game"); game.init(); System.out.println(); boolean running = true; long time = 0, lastTime = 0, currentFPSSample = 0; float delta = 0, fps = 0; float[] fpsSamples = new float[targetFPS/2]; while(running) { if(Display.wasResized()) { ...
6
public NexTClient(){ // The default port int port_number=2222; String host="localhost"; // Initialization section: // Try to open a socket on a given host and port // Try to open input and output streams try { clientSocket = new Socket(host, port_number); inputLine = new Buffere...
7
public Task[] generateWISCandidates(PQModel2 model, PQInput2 input, PQOutput2 correctOutput, double lossWeight) { // Implementation of a method for comparison between two tasks. // It is used to find out in which position we have to insert the // new task in the list of tasks. Ordered by task end. Comparator...
8
static double grad(int hash, double x, double y, double z) { int h = hash & 15; // CONVERT LO 4 BITS OF HASH CODE double u = h < 8 || h == 12 || h == 13 ? x : y, // INTO 12 GRADIENT DIRECTIONS. v = h < 4 || h == 12 || h == 13 ? y : z; return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v); ...
8
public void addVertex(double d, double d1, double d2) { if (!this.renderingChunk) { GL11.glVertex3f((float) (d + this.xOffset), (float) (d1 + this.yOffset), (float) (d2 + this.zOffset)); } else { ++this.addedVertices; if (this.drawMode == 7 && Tessellator.convertQuads...
8
public void paintEndFallingBlocks(Graphics g){ Graphics2D g2d = (Graphics2D) g; if(tetrominoes.size()>1) for(int index =0 ; index<tetrominoes.size()-1;index++) for(int x=0; x < coordonneJeu.getNombreColonne(); x++) for(int y=0; y < coordonneJeu.getNombr...
5
public void file_save_as(){ JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); int r = fc.showSaveDialog(this); if(r==fc.CANCEL_OPTION) return; File myfile = fc.getSelectedFile(); if(myfile==null || myfile.getName().equals(...
6
public static void main(String[] args) throws Throwable{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); for (int h = 0; h < n; h++) { in.readLine(); String entrada = in.readLine(); String salida = ""; int ultimoOval = -1; int ultim...
9
public void testParsePeriod_simple() { Period expect = new Period(1, 2, 3, 4, 5, 6, 7, 8); assertEquals(expect, f.parsePeriod("P1Y2M3W4DT5H6M7.008S")); try { f.parsePeriod("ABC"); fail(); } catch (IllegalArgumentException ex) {} }
1
public CustomConfig(File configFile) { this.config = new YamlConfiguration(); this.configFile = configFile; }
0
public static void endTurn() { game.totalTurns++; if(isTwoPlayers) { swap(); } else { game.myTurn = true; readyToSwap = false; int[] bombPoint = BattleShipAI.takeShot(game.mySea.getObfuscatedSea()); Ship shipSunk = game.mySea.bombTile(bombPoint[0], bombPoint[1]); int bombedTile = game...
5
public boolean sameOrder(Matrix a) { //Doesn't work with jagged arrays, call isJagged() first if (a == null) { return false; } if (this.isJagged || a.isJagged) { return false; } if (this.rowCount != a.rowCount) { return false; //different row ...
5
static Function<Class<?>, Object> getDefaultInstanceSupplier() { return (c) -> { try { return c.newInstance(); } catch (InstantiationException | IllegalAccessException ex) { throw new IllegalStateException("Cannot instantiate view: " + c, ex); ...
2
private void doClearAppenders() { for (Iterator<String> it = appenders.iterator(); it.hasNext();) { removeAppender(it.next()); } }
1
public static List<Estado> listaDeEstados() { Estado estado; List<Estado> listaEstado; Statement statement = null; ResultSet tr = null; String select = "SELECT * FROM estados"; listaEstado = new ArrayList<Estado>(); Connection conexion = null; try { ...
9
public synchronized String getShortName(String realName) { realName = realName.trim(); //prüfen, ob bereits ein shortname existiert String shortName = realToShortNames.get(realName.toLowerCase()); if (shortName != null) { return shortName; } //ansonsten prüfen...
9
public ArrayList<Point> getPossibleMoves(Point start) { ArrayList<Point> result = new ArrayList<Point>(); int colStart = start.getX(); int rowStart = start.getY(); int numOfPieces = 0; // col. up numOfPieces = getNumPiecesInCol(colStart); if (checkMove(rowStart, colStart, rowStart - numOfPieces, colStart...
8
@Override public String toString(){ return "id= "+this.getId()+", "+this.getName()+"\n"+getTime()+"\n"+"Высота: "+this.getHig()+"\n"+"Радиус: "+this.getRad()+"\n"+"Диагональ: "+this.getDiag()+"\n"+ "Площадь тела вращения: "+this.getArea_Body()+"\n"+"S=: "+this.getArea()+" V=: "+this.getVolume()+"\n"; }
0
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...
6
public List<String> getMinor() { Connection conn = null; ResultSet rs = null; PreparedStatement ps = null; List<String> minor = Constants.Minor; String asString = (String)Constants.Minor.get(0) + "," + (String)Constants.Minor.get(1); try { conn = iConomy.getiCoDatabase().getConnection(...
8
public static boolean MatchRankSuit(Card playercard, Card openedcard) { if (playercard.getRank().equals(Rank.ACE)) { if (openedcard.getRank().equals(Rank.ACE)) {//ace on ace return false; } else {//ace match return true; } } else if ((o...
7
public void exit() { setVisible(false); }
0
public void setDepartureStation(String value) { this._departureStation = value; }
0
public List findByInputFormat(Object inputFormat) { return findByProperty(INPUT_FORMAT, inputFormat); }
0
final void method3685(Class98 class98, int i) { Class167 class167 = method3724(Thread.currentThread()); Class318_Sub9 class318_sub9 = (((Class88) ((Class98) class98).aClass88_1569) .aClass318_Sub9_1503); for (Class318_Sub9 class318_sub9_65_ = ((Class318_Sub9) class318_sub9).aClass318_Sub9_6469; ...
8
public void drawCities() { cities=new BufferedImage(w.WIDTH,w.HEIGHT,BufferedImage.TYPE_INT_ARGB); Graphics2D page=cities.createGraphics(); for (int y1=0;y1<w.HEIGHT;y1++) for (int x1=0;x1<w.WIDTH;x1++) { if (w.map[x1][y1].owner!=null) { page.setColor(Color.getHSBColor(w.map[x1][y1].owner.owner.hue...
3
public Object nextValue() throws JSONException { char c = this.nextClean(); String string; switch (c) { case '"': case '\'': return this.nextString(c); case '{': this.back(); return new JSONObject(this); ...
7
public List<String> topTags(){ PreparedStatement stmt = null; Connection conn = null; ResultSet rs = null; List<String> tags = new ArrayList(); try { conn = DbConnection.getConnection(); stmt = conn.prepareStatement(TOP_TAG_STMT); rs = stmt.executeQuery(); for(int i = 0 ;i<10;i++){ if(!...
9
protected Stmt createStore(VarExpr target, final Expr source) { target = (VarExpr) target.clone(); // Source is an undefined variable, initialize it if ((source instanceof VarExpr) && (source.def() == null)) { return createUndefinedStore(target); } return new ExprStmt(new StoreExpr(target, (Expr) source....
2
private boolean indexOK(int index) { return index < array.length && index >= 0; }
1