text
stringlengths
14
410k
label
int32
0
9
private void teamMatches() { clear(); try { ArrayList<Team> teams = teammgr.listAll(); printShowHeader(); for (Team t : teams) { System.out.println(t); } System.out.println("Select team id: "); ...
4
@Autowired public void createTemplate(DataSource dataSource) { this.jdbcTemplate = new SimpleJdbcTemplate(dataSource); }
0
public int getWidth() { return width; }
0
@Override public boolean containsLongArray(String name) { JOSObject<? , ?> raw = this.getObject(name); if(raw == null) return false; if(raw.getName().equalsIgnoreCase(LONG_ARRAY_NAME)) return true; return false; }
4
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!par1World.isRemote) { if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && Block.lightOpacity[par1World.getBlockId(par2, par3 + 1, par4)] > 2) { par1World....
8
protected void addOnLoaded(Handler<T> doneHandler) { //once loaded is true, it will never go back to false. //even if double checked locking fails and we incorrectly go into the synchronized block, //no harm will be done because by the end, we'll see that loaded is in fact true. //thus, double checked locking e...
4
private int findMonth (String input) { Scanner s = new Scanner (input); int[] date = new int[3]; s.useDelimiter("/"); while(s.hasNext()) { for (int i = 0; i < date.length; i++) { date[i] = s.nextInt(); } } s.close(); return date[0]; }
2
public CarBuilder setBuiltOn(Date builtOn) { delegate.setBuiltOn(builtOn); return this; }
0
@SuppressWarnings("unused") public void buildPanel() { this.setBounds(150, 250, widthPanelWin, heightPanelWin); this.setVisible(false); this.setBackground(Color.BLACK); JLabel label = new JLabel(); label.setText("Hourra ! Vous vous en êtes bien tiré ! Vous avez éliminé tous vos adversaires ! Bravo !"); ...
5
public static boolean checkFileFormat(File file) { if (!file.exists() && !file.isFile()) return false; try { AudioFormat format = AudioSystem.getAudioFileFormat(file) .getFormat(); if ((format.getEncoding() == AudioFormat.Encoding.PCM_SIGNED || format .getEncoding() == AudioFormat.Encoding.PCM_UN...
8
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof User)) return false; User other = (User) obj; if (ID != other.ID) return false; if (nick == null) { if (other.nick != null) return false; } else if (!nick.equ...
7
public void startSQL() { try { InputStream in = this.getClass().getResourceAsStream("/sols/Util/jdbc.properties"); Properties pp = new Properties(); pp.load(in); url = pp.getProperty("jdbc.url"); user = pp.getProperty("jdbc.username"); pas...
1
@Override public Type getType() { // left and right must be the same type if (oper == Symbol.EQ || oper == Symbol.NEQ || oper == Symbol.LE || oper == Symbol.LT || oper == Symbol.GE || oper == Symbol.GT) { return Type.booleanType; } else if (oper == Symbol.AND || oper == Symbol.OR) { ...
8
public void mutate() { cachedTotalOverlap = null; GeometryFactory factory = Helper.getGeometryFactory(); for (LabelGene gene : this) { double overlapArea = getGeneOverlap(gene, factory); if (overlapArea > 0) { gene.mutate(); } } }
2
public static long sortedExperiment(){ startTime = (new Date()).getTime(); int choice; Long number; for(int i = 0; i < NUMBER_OF_CHOICES; i++) { choice = choices[i]; number = numbers[choice]; if(!binarySearch(number)) { System.out.println("Not found"); break; } ...
3
public static void main(String[] args) { File file = new File("config.properties"); if (!file.exists()) { try { file.createNewFile(); prop.setProperty("maxram", "1024"); prop.store(new FileOutputStream("config.properties"), null); } catch (IOException e) { e.printStackTrace(); } } try {...
7
@Override public void start() throws Exception { String[] args= this.par.getArgs(); int inputNumberValues= args.length - 1; //-1 for command word if(inputNumberValues < 1) throw new Exception("No file to plot"); Plotter.plot(args); }
1
@Override public void paint(Graphics g, Point position) { g.setColor(this.getColor()); g.fillRect(position.x, position.y, this.width*POSITION_MULTIPLYER, this.height*POSITION_MULTIPLYER); }
0
@SuppressWarnings("unchecked") private void extendStack(int argSize) { T[] newStack = (T[]) Array.newInstance(sClass, argSize); if (stack != null) { System.arraycopy(stack, 0, newStack, 0, size); } for (int i = 0; i < newStack.length; i++) { try { if (params != null) { ne...
9
public void setDefaultValues(FileConfiguration config, Map<String, Object> configParams) { if (config == null) return; for (final Entry<String, Object> e : configParams.entrySet()) if (!config.contains(e.getKey())) config.set(e.getKey(), e.getValue()); }
3
public void add(double value) { totalCount++; compCount++; if (value < start) { others++; return; } else if (value > end) { compCount++; others++; return; } compCount++; latestInRange = value; // binary search int low = 0; int high = rangeCount - 1; compCount...
7
public Piece getPiece(Position pos){ return board[pos.getY()][pos.getX()]; }
0
public SchlangenGlied getLastGlied() { if (nextGlied != null) { return nextGlied.getLastGlied(); } else { return this; } }
1
@Test public void testGetProductCode() throws Exception { assertTrue(product.getProductCode()=='A'); }
0
private List<String> getValues (String key) { if (null == key) throw new NullPointerException( "key must not be null" ); List<String> values = keys.get( key ); if (values != null) return values; if (validate) this.validateKey( key ); synchronized (keyLock) { // it might have been created while ...
4
public boolean validateInput() { for(int i = 0; i < 9; i++) { for(int j = 0; j < 9; j++) { try { if(Integer.parseInt(entries[i][j].getText()) < 1) { return false; } } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "Invalid input. Enter an integer at row " ...
4
@Override public String process(List<String> params) throws Router.RedirectSystemError, IOException, Router.RedirectPageNotFound, Router.Redirect, SQLException, MessageException.ErrorMessage { AuthView view; switch (getActionByParam(params)) { case "register": view = new RegisterView(); if (null != Regi...
6
private static String leadz(int nr){ if(nr < 100 && nr > 10){ return("0"+nr); } else if(nr < 10){ return("00"+nr); } else{ return(""+nr); } }
3
public static void main(String[] args) throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); // StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); JavaSourceFromString javaSourceFromString = new JavaSourceFromString( ...
1
private CobolToken parseString(final CobolLine cobolLine, final int start) { final String line = cobolLine.getSource(); final int last = line.length() - 1; char startChar = line.charAt(start); int index = start + 1; // Check hexadecimal strings starting with H or X. if ...
8
@SuppressWarnings({"static-access"}) public static int amount (Player player, String[] args) { int spawnLimit = plugin.maxSpawnLimit; if ((args.length <= 2)) { return 1; } else { int amount = Integer.parseInt(args[2]); try { if (1 > amount)...
4
public void setFossil(String value) { this.fossil = value; }
0
static void fill_keybuf(String keybuf, KeyEvent event) { int modifier_state = event.getModifierState(); if (modifier_state == Event.STATE_SHIFT_MASK) keybuf += "<Shift>"; if (modifier_state == Event.STATE_LOCK_MASK) keybuf += "<Lock>"; if (modifier_state == Event.STATE_CONTROL_MASK) keybuf += "<Contr...
8
public void succeed() { if(cb != null) cb.run(); }
1
public void rMayusCentrosNoLocal(double paramDistancia) { Iterator elemFuente; Elemento entrada,salida; Iterator elemDestino = destino.listaElementos(); double sumaDistancias,sumaValores,distancia,ponderacion,rMayor; double dist[]; int count; while(el...
4
@Override public String getFieldValue(String name) { String s = map.get(name); if (s == null) { return ""; } return s; }
1
public static Destructor getDestructorById(String id, War war, String type) { Vector<Destructor> destructors = null; int size_launcher = 0; if (type.equals(main.Program.LAUNCHER)) { destructors = war.getMissileLauncherDestructors(); } else { destructors = war.getMissileDestructors(); } size_launcher...
3
@Override public int compare(Sample d1, Sample d2) { if (d1.fx < d2.fx) { return -1 * order; } else if (d1.fx == d2.fx) { return 0 * order; } else { return 1 * order; } }
2
@Override public W<DeltaSet> delta(DC obj) { if(obj instanceof Set) { Set that=(Set)obj; Set<Pair<T,T>> phiMax=getPhiMax(getAllPhis(this,that)); Equality equ=getPhiEqu(phiMax); int m=this.size(); int n=that.size(); double diffMeasure=(2*getPhiSim(phiMax).getValue()+Similarity....
4
private static void output(String out) { if (LIVE_PRINT) { System.out.print(out); } if (FILE_PRINT) { writeToFile(out); } }
2
protected void drawLists(Graphics g) { for (Drawable d : drawableList) { d.draw(g); } for (PowerUp p : powerUpList) { p.draw(g); } }
2
public void bet(String b) { try { this.bet = Integer.parseInt(b); } catch (Exception e) { this.validBet = false; } while (this.money == 0) { JOptionPane .showMessageDialog(null, "Cannot bet, Out of money!\nRestart Program to play again!"); } if (this.bet > this.money || this.bet <= ...
8
public void genWin() { for(int i=0; i< win.length; i++) { for (int j=0;j<win[0].length;j++) { win[i][j] = false; } } for(int i=Partie.DEF_DEPART[0];i<win.length;i++) { for(int j= Partie.DEF_DEPART[1];j<win[0].length;j++) { if (!win[i][j]) { i...
8
public void setjButtonDetails(JButton jButtonDetails) { this.jButtonDetails = jButtonDetails; }
0
public static int[][] exempleCarte() { final int[][] carte = new int[LARGEUR_GRILLE][HAUTEUR_GRILLE]; int i; int j; for (i = 0; i < LARGEUR_GRILLE; i++) { carte[i][0] = 0; carte[i][HAUTEUR_GRILLE - 1] = 0; } for (j = 0; j < HAUTEUR_GRILLE; j++) { carte[0][j] = 0; carte[LARGEUR_GRILLE - 1][j] =...
4
@Test public void testConstructorValid(){ // Create a PlayerInfo, and test that our construction works accordingly. IPlayer player = new DummyPlayer(); PlayerInfo playerInfo = new PlayerInfo(player); assertEquals("Player instance did not set properly in PlayInfo.", player, playerInfo.getPlayer()); // Chec...
2
private byte[] readDataFromFile(String filePath) throws Exception { File file = new File(filePath); long fileLength = file.length(); byte[] dataBuffer = new byte[(int) fileLength]; InputStream inputStream = new FileInputStream(file); try { int offset = 0; int numRead = 0; while (true) { if (off...
4
@Override public void run() { String msg = "!auction-ended " + getHighestBidder().getName() + " " + printHighestAmount() + " " + getDescribtion(); try { // if owner is online- send notification if (userManagement.getUserByName(owner.getName()).isOnline()) { // AuctionServer_UDPSocket.getInstamce().sendMe...
8
public static void main(String[]args){ String Train = args[0]; //String Test = args[1]; //Naive naive = new Naive(); topwordsLogOdds naive = new topwordsLogOdds(); try { naive.train(Train); } catch (IOException e) { e.printStackTrace(); } ...
7
synchronized void doneWork() { boolean doneTicking = true; if (timer.isRunning) doneTicking = false; for (TickThread thread : this.threadPool) { if (thread.isWorking) doneTicking = false; } if (!doneTicking) { try { wait(); } catch (InterruptedException e) { e.printStackTrace(); } } else...
9
@Override public boolean handleAfterCall(int currentAddress, int callAddress, CPUState s, boolean reachable) { if(callAddress == 0x10) { // rst $10: BankSwitch if(s.rMask[CPUState.A] == 0xFF) s.loadedBank = s.r[CPUState.A] & 0x7F; else s.loadedBank = -1; return true; } if...
4
private void placeWarMachine(WarMachine warMachine, Koordinate koord, Ausrichtung ausrichtung) throws InvalidPlacementException { Koordinate min = getMin(warMachine, koord, ausrichtung); Koordinate max = getMax(warMachine, koord, ausrichtung); for (int i = min.getY(); i <= max.getY(); i++) { // Pruefen ob ...
4
public T get(PK id) { T entity = (T) hibernateTemplate.get(this.persistentClass, id); if (entity == null) { log.warn("Uh oh, '" + this.persistentClass + "' object with id '" + id + "' not found..."); throw new ObjectRetrievalFailureException(this.persistentClass, id); } ...
1
public void setFirst(T newValue) { first = newValue; }
0
static private int jjMoveStringLiteralDfa0_0() { switch(curChar) { case 40: return jjStopAtPos(0, 20); case 41: return jjStopAtPos(0, 21); case 45: return jjMoveStringLiteralDfa1_0(0x1000000L); case 60: return jjMoveStringLiteralDfa1_0(0x2000000L); ...
9
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
static void updateWinCount() throws IOException { if(computer) { console.setText(winC()+" wins!"); if(winC()=="Red") { redwins++; reds.save(redwins+""); } else if(winC()=="Blue") { bluewins++; blues.save(bluewins+""); } } else { if(player==0) { console.setText(...
4
public void sipsSigmoidFit(){ if(this.nAnalyteConcns<4)throw new IllegalArgumentException("Method sipsSigmoidFit requres at least 4 data points; only " + this.nAnalyteConcns + " were supplied"); this.methodUsed = 6; this.sampleErrorFlag = true; this.titleOne = "Sips sigmoid fitting: r = ...
4
public void error(Throwable e, String message) { if (verbose && (e != null)) e.printStackTrace(); if (!quiet) System.err.println(message); }
3
public void saveScores() { try { File file = new File( "scores.txt"); if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); for (Person p : people) { bw.write(p.getName() + "\n"); bw.write(p...
3
public Object pop() throws EmptyException { if (list.isEmpty()) { throw new EmptyException(); } return list.popBack().getItem(); }
1
private byte[] readStream(InputStream fin) throws IOException { byte[] buf = new byte[4096]; int size = 0; int len = 0; do { size += len; if (buf.length - size <= 0) { byte[] newbuf = new byte[buf.length * 2]; System.arraycopy(buf, ...
2
public static void main(String[] args){ log.info("--Start"); log.info("Read application config"); Config config = getConfig(); // ArgumentParser parser = ArgumentParsers.newArgumentParser("rni") .description("Process rni load testing"); Subparsers subpars...
6
public static ArrayList<Pet> arrayList(int size) { return creator.arrayList(size); }
0
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; User other = (User) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false;...
9
private final void init (boolean flag) { int i; int a, b, c, d, e, f, g, h; a = b = c = d = e = f = g = h = 0x9e3779b9; // The golden ratio for (i = 0; i < 4; ++i) { a ^= b << 11; d += a; b += c; b ^= c >>> 2; e += b; c += d; c ^= d << 8; f += c; d += e; d ^= e >>> 16; g += d; e += f; e ^= ...
5
public static String formatTime(long diffLongTime) { StringBuffer buf = new StringBuffer(); long hours = diffLongTime / (60 * 60 * 1000); long rem = (diffLongTime % (60 * 60 * 1000)); long minutes = rem / (60 * 1000); rem = rem % (60 * 1000); long seconds = rem / 1000; if (hours != 0) { buf.append(hou...
2
private void checkEnableButtons() { boolean bool = this.typeName.getText().length() > 0 && this.roomType.getText().length() > 0 && ((Integer)this.minHour.getValue() + (Integer)this.minMin.getValue() > 0) && ((Integer)this.maxHour.getValue() + (Integer)this.maxMin.getValue() > 0); //System.out.print(bool); this...
4
@Override public boolean addPostToMainForum(MainForum mf) { { Session session = null; boolean succses = true; try { session = factory.openSession(); session.beginTransaction(); session.save(mf); session.getTransaction().commit(); log.info("succseed to add post to main forum"); } catc...
3
private static File promptForFtlPath() { String steamPath = "Steam/steamapps/common/FTL Faster Than Light"; String gogPath = "GOG.com/Faster Than Light"; File[] paths = new File[] { // Windows - Steam new File( new File(""+System.getenv("ProgramFiles(x86)")), steamPath ), new File( new File(""+System....
9
@Test public void testInfixToPostfix6() throws DAIllegalArgumentException, DAIndexOutOfBoundsException, ShouldNotBeHereException, BadNextValueException, UnmatchingParenthesisException { try { infix.addLast("-"); infix.addLast("5"); infix.addLast("/"); infix.addLast("5"); QueueInterface<String> p...
5
public boolean open() { if (isOpen()) { return true; } GameObject box = ctx.objects.getNearest(new Filter<GameObject>() { @Override public boolean accept(GameObject element) { for(int id :DEPOSIT_BOX_IDS) { if(id == element.getI...
6
public String map2QcTestName(ITestResult res) { String methodName = res.getMethod().getMethodName(); String testName = res.getTestClass().getName(); String qcTestName = ("test".equals(methodName) ? testName : testName + "-" + methodName); //TestGroup method. return qcTestName; ...
1
@Override public void topicVisibilityChanged(boolean visible) { for (ChannelTab channel : channelTabs) channel.setTopicPanelVisibility(visible); }
1
public void addComponents(HBox layout) { cbMechanics.setItems(FXCollections.observableArrayList("Physics", new Separator(), "Projectile Motion", "Friction")); cbWaves.setItems(FXCollections.observableArrayList( "Optics, Waves and Modern Physics", new Separator(), "Simple Harmonic Motion", "Doppler Effec...
9
RGBA(Color c) { switch(c) { case BLACK: r = g = b = 0; a = 255; break; case RED: r = 255; g = 0; b = 0; a = 255; break; case BLUE: ...
6
public static String cppChangeCase(GeneralizedSymbol symbol, Keyword caseconvention) { { MemoizationTable memoTable000 = null; Cons memoizedEntry000 = null; Stella_Object memoizedValue000 = null; if (Stella.$MEMOIZATION_ENABLEDp$) { memoTable000 = ((MemoizationTable)(Stella.SGT_STELLA_F_C...
6
public void validarIniciado(String dataInicial, String horaInicial) throws NumberFormatException { limpaCamposCasoAberto(); String dtHoraFinalLote = retornaUltimaHoraFinalLoteLancado(jTJob.getText().trim(), Integer.parseInt(jTOperacao.getText())); jFTDataFinalLote.setText(""); i...
9
public static List<Employee> execQueryEmployees (String query) { Statement statement = null; Connection dbConnection = null; ResultSet rs = null; List<Employee> emp = new ArrayList<Employee>(); try { dbConnection = getDBConnection(); statement = dbConnect...
6
private void expand(double[] array, int lay) { int k = 0; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < HEIGHT; j++) { yCbCr[i][j][lay] = array[k++]; } } }
2
* @param localP * @return Cons */ public static Cons callListUndefinedRelations(Module module, boolean localP) { { Cons undefined = Stella.NIL; Logic.finalizeObjects(); { Stella_Object term = null; Iterator iter000 = Logic.allNamedTerms(module, localP); while (iter000.nextP()) ...
6
private void alertOf(String message, byte type) { messageLabel.setText(message); messageScrollPane.getHorizontalScrollBar().setValue(0); switch (type) { default: case PLAIN_MES: messageIconLabel.setIcon(null); break; case INFO_MES: messageIconLabel.setIcon(inf...
5
@Override public int hashCode() { int hash = 7; hash = 13 * hash + (this.varname != null ? this.varname.hashCode() : 0); hash = 13 * hash + (this.value != null ? this.value.hashCode() : 0); hash = 13 * hash + (this.inQuotes ? 1 : 0); return hash; }
3
private ArrayList<Node> getValidSurroundingNodes(Node n) { ArrayList<Point> tempArrayList = new ArrayList<Point>(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { if (!((x == 0) && (y == 0))) { tempArrayList.add(new Point(n.x + x, n.y + y)); } } } ...
7
public String getTexte() { return texteRech; }
0
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setText(value.toString()); if (index % 2 == 0) { setBackground(new Color(155,215,231)); } else setBackground(new Color(162,232,217)); if (isSelected) { setBackground(new Col...
2
public static final boolean isValid(String artifactType) { for (int i = 0; i < artifactType.length(); i++) { char c = artifactType.charAt(i); if (!(Character.isLetter(c) || Character.isDigit(c))) { return false; } } return true; }
3
public int SearchEndString(String TargetString, int CharNumStart, char EndStringChar) { int FileTextPointer = 0; try { FileTextPointer = CharNumStart; while (true) { FileTextPointer = TargetString.indexOf(EndStringChar, FileTextPointer + 1); if (Fi...
4
protected void appendLabel(final Label l) { String name = (String) labelNames.get(l); if (name == null) { name = "L" + labelNames.size(); labelNames.put(l, name); } buf.append(name); }
1
private node maxValue(node localHead, double alpha, double beta) { ArrayList<node> ch = localHead.getChildren(); double temp = -100; //terminating state if (localHead.getValue() == 5 || localHead.getValue() == -5) { return localHead; } //leaf node if...
9
public static int[] kMinst(int[] a, int k){ int n = a.length; // tabellens lengde if (k < 1|| k > n){ // Tester at k er minst 1 og ikke lengre enn lengden på array a. throw new IllegalArgumentException ("Valgte antall minimums verdier samsvarer ikke med leng...
6
private Object handleCopr(Object tos) { if ((tos instanceof Header && ((Header)tos).getCopyright() == null) || (tos instanceof GeneratorData && ((GeneratorData)tos).getCopyright() == null)) { return new FieldRef(tos, "Copyright"); } return null; }
4
private int findNextFarthestPoint(Matrix features , Set<Integer> farthestPoints) { int nextFarthestPoint = -1; double max = 0; List<Double> distances = new ArrayList<Double>(); for (int i = 0; i < features.rows(); i++) { if (!farthestPoints.contains(i)) { distances.clear(); double[] c...
5
public static String md5(String s) { try { java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); byte[] array = md.digest(s.getBytes()); StringBuffer sb = new StringBuffer(); for (int i = 0; i < array.length; ++i) { sb.append(Integer.toHexStrin...
2
public void run() { movingObject.run(); }
0
public void run() { Selector selector = SocketIoProcessor.this.selector; for (;;) { try { int nKeys = selector.select(1000); doAddNew(); doUpdateTrafficMask(); if (nKeys > 0) { ...
8
public static void insertAllLocationTypes(){ boolean[][] activityTypes = new boolean[numLocations+1][9]; try { Connection con = dbConnect(); PreparedStatement getActivity = con.prepareStatement( "SELECT COUNT(*) FROM "+actTbl+" WHERE locationID = ? AND purpose = ?"); for (int location=1; location <= n...
8
public String getSenha() { return senha; }
0
public boolean isDestroyed() { return solidObject.isDestroyed(); }
0
public void setCellInfo(int x, int y) { //get the grid from operator Grid grid = request.operator.getGrid(); Point p = new Point(x,y); int depth = 0; //strings to be displayed String owner, oil, gas, layers, rocktype; //if the grid location exists (not null) if(grid.exists(p)) { ...
7