text
stringlengths
14
410k
label
int32
0
9
@Override public String getColumnName(int column) { switch(column) { case ID : return "ID"; case MEDECIN : return "Médecin"; case SPECIALISATION : return "Spécialisation"; case DATE : return "Date"; case HEURE : return "...
5
private String cleanFontName(String fontName) { // crystal report ecoding specific, this will have to made more // robust when more examples are found. if (fontName.indexOf('+') >= 0) { int index = fontName.indexOf('+'); String tmp = fontName.substring(index + 1); ...
9
public Object retrieve(String key) { if(key == null) { return null; } totalAccess++; if(entryMap.containsKey(key)) { LFUEntry entry = entryMap.get(key); pq.remove(entry); entry.hit++; pq.add(entry); if(debug) System.out.println("Hit cache entry: " + key); return entry.value; } else...
8
@Override public void unInvoke() { // undo the affects of this spell if(affected instanceof CagedAnimal) { final CagedAnimal target=(CagedAnimal)affected; final MOB mob=target.unCageMe(); super.unInvoke(); if(canBeUninvoked()) { final Ability A=mob.fetchEffect(ID()); if(A!=null) mob....
8
public static void main(String[] args) { Factory factory; if (args.length > 0) { factory = new PCFactory(); } else { factory = new NotPCFactory(); } for (int i = 0; i < 3; ++i) { System.out.print(factory.makePhrase() + " "); } S...
2
@Override public void actionPerformed(ActionEvent e) { /* When combo box changed, redraw preview panel. */ if (e.getSource()==m_mapList) { m_previewContainer.removeAll(); m_previewPanel = DrawSwatches(m_mapList.getSelectedIndex()); ...
5
@Override public List<BankRequiredItem> getItemsNeededFromBank() { List<BankRequiredItem> list = new ArrayList<BankRequiredItem>(); if (ctx.equipment.select().id(ids).isEmpty() && ctx.backpack.select().id(ids).isEmpty()) { if (ctx.bank.opened()) { final Item item = ctx.bank.select().id(ids).sort(new Compar...
4
@Override public int attack(double agility, double luck) { if(random.nextInt(100) < luck) { System.out.println("I just did a sonic blow!"); return random.nextInt((int) agility) * 2; } return 0; }
1
public static String getStackTrace(Throwable t) { String stackTrace = null; try { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.close(); sw.close(); stackTrace = sw.getBuffer()...
1
private void processGridResource_Polling(Sim_event ev) { Integer res_id_Integer; int res_id; AvailabilityInfo resAv = null; // Polls the resources that are available right now, as those // which are out of order were totally removed for (int i = 0; i < resList_.size(...
8
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String fct = request.getParameter("fct"); // Remplir BDD if(fct.compareTo("create")==0) { UserModel user = DataStore.getUser("user001"); if(user==null) { // Users UserModel usermod001 ...
6
public void clean(){ try{ socket.close(); }catch(Exception e){ } }
1
private void connect() { send(0, Main.player.getName()); String data = recive().trim(); String[] text = data.split("/"); if (!(text.length < 2)) { if (text[1].equalsIgnoreCase("success")) { System.out.println("Connected to Server"); connected =...
4
* @param offset * @param kindofsym * @return GeneralizedSymbol */ public static GeneralizedSymbol internBootstrapSymbolAt(String name, int offset, int kindofsym) { { ExtensibleSymbolArray symbolarray = null; GeneralizedSymbol symbol = null; switch (kindofsym) { case 0: sym...
7
public void load() throws IOException { boolean before = SoundStore.get().isDeferredLoading(); SoundStore.get().setDeferredLoading(false); if (in != null) { switch (type) { case OGG: target = SoundStore.get().getOgg(in); break; case WAV: target = SoundStore.get().getWAV(in); break; cas...
9
public boolean pointVisibleTest(Point p){ boolean ret=false; if( angleBetween(this.forward,p.difference(this.location))<this.maxangl && distanceToPoint(p)>mindistance && distanceToPoint(p)<maxdistance) { double[] transform=this...
7
public List findByEmail(Object email) { return findByProperty(EMAIL, email); }
0
public void sortByCost() { Collections.sort( images, new Comparator<Card>() { public int compare(Card a, Card b) { if (a instanceof Climax) { //climaxes should sort to be after all level cards if (b instanceof Climax) { return 0; } return 1...
3
public void Solve() { HashMap<String, HashSet<Integer>> results = Compute(new ArrayList<Integer>(), _maxDigits); String result = ""; int max = 0; for (Map.Entry<String, HashSet<Integer>> entry : results.entrySet()) { int number = 1; while (entry.getValue().contai...
5
private static void addToMap(File file, HashMap<String, Holder> map) throws Exception { System.out.println(file.getAbsolutePath()); boolean human = file.getName().indexOf("Human") != -1; String[] splits = file.getName().split("_"); String fileName = splits[1] + "_" + splits[2]; Holder h = map.get(fileN...
8
private void showSong(Song song) { lblSongTitle.setText(song.getTitle()); if (!song.getArtists().isEmpty()) { String artists = "by "; for (int i = 0; i < song.getArtists().size(); i++) { if (i < song.getArtists().size() - 2) { artists += song.getArtists().get(i) + ", "; } else if (i < song.getAr...
8
public void print() { int y = 10; // local variable declaration System.out.println(x+""+y); }
0
public static List<String> getFolder(File dict) { List<String> files = new ArrayList<String>(); if (dict.listFiles().length > 0) for (File file : dict.listFiles()) { if (file.isDirectory()) { files.add(file.getName()); } } return files; }
3
private void getCityCollection(AbstractDao dao, List<Direction> directions) throws DaoException { for (Direction dir : directions) { Criteria crit = new Criteria(); crit.addParam(DAO_ID_DIRECTION, dir.getIdDirection()); List<LinkDirectionCity> links = dao.findLinkDirectionCit...
1
public FactoryOfCapturingsForCpuForPiece(Position position, Player cpu, int largestCapture){ super(position,cpu,largestCapture); }
0
private static double getMedianPixel(Image image, ChannelType color, int x, int y, int maskWidth, int maskHeight) { List<Double> pixelsAffected = new ArrayList<Double>(); for (int i = -maskWidth / 2; i <= maskWidth / 2; i++) { for (int j = -maskHeight / 2; j <= maskHeight / 2; j++) { if (image.validPixel(...
4
public final String getSHA(String s) { try { MessageDigest md5 = MessageDigest.getInstance("SHA"); md5.update(s.getBytes(), 0, s.length()); signature = new BigInteger(1, md5.digest()).toString(16); } catch(NoSuchAlgorithmException e) { ...
1
private void createButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createButtonActionPerformed String first = firstNameTextField.getText(); String last = lastNameTextField.getText(); String maristID = maristUsernameTextField.getText(); String pw1 = UserModel.enco...
2
public String searchForCost(ArrayList<String[]> actualNode, String IPComing){ String returnValue = "0"; String[] tempStringArray = null; for(int i=0; i<actualNode.size(); i++){ tempStringArray = actualNode.get(i); if(tempStringArray[0].equals(IPComing) && tempStringArray[...
3
public void undo() { if (DEBUG) log("Attempting to undo TaskRemoval"); if (taskViewsToUpdate != null) { if (DEBUG) log("Get existing tasks from TaskCommander"); ArrayList<Task> tasks = TaskCommander.getTasks(); if (DEBUG) log("Add the task contained in this command to the existing tasks ...
7
public boolean testCollisions( Tester t ) { LinkedList<Explosion> explosionList1 = new LinkedList( ); LinkedList<Explosion> explosionList2 = new LinkedList( ); LinkedList<Enemies> scaryList1 = new LinkedList( ); LinkedList<Enemies> scaryList2 = new LinkedList( ); LinkedList<Enemies> scaryList3 = new LinkedLi...
3
private static void validatePassport(String passport) throws TechnicalException { if (passport == null || passport.isEmpty() || passport.length() > PASSPORT_SIZE) { throw new TechnicalException(PASSPORT_ERROR_MSG); } String regex = "[A-Z]{2}\\d{7}"; Pattern p = Pattern.compil...
4
private static boolean haveItem(String string) { for(ItemLabel item : stack){ if(item.item.name.equals(string)) return true; } return false; }
2
public String[] getBorderColors() { try { String[] clrs = new String[5]; if( borderElements.get( "top" ) != null ) { clrs[0] = borderElements.get( "top" ).getBorderColor(); } if( borderElements.get( "left" ) != null ) { clrs[1] = borderElements.get( "left" ).getBorderColor(); } if( ...
6
public void visitIincInsn(final int var, final int increment) { buf.setLength(0); buf.append(tab2) .append("IINC ") .append(var) .append(' ') .append(increment) .append('\n'); text.add(buf.toString()); if (m...
1
private void pelaajanAmmustenOsumatunnistusKokonaisuus(Iterator it, Kuti kuti, int kutiX, int kutiY) { while (it.hasNext()) { ufo = (Ufo) it.next(); int ufox = ufo.getX(); int ufoy = ufo.getY(); if (ufo.isVisible() && kuti.isVisible()) { if (ufonO...
4
private RequestData getRequestData(HttpServletRequest request){ RequestData rd = new RequestData(); rd.page = request.getParameter("page"); if (request.getParameter("id") == null){ rd.id = Long.valueOf(0); } else{ try{ rd.id = Long...
2
public void initialize() throws ResourceInitializationException { // extract configuration parameter settings String oPath = (String) getUimaContext().getConfigParameterValue("outputFile"); // Output file should be specified in the descriptor if (oPath == null) { throw new ResourceInitialization...
5
public void promptMove(GoEngine g){ int bestValue=Integer.MIN_VALUE; List<Coord> bestMoves = new ArrayList<Coord>(); Board testBoard = new Board(); int alpha=Integer.MIN_VALUE; int beta=Integer.MAX_VALUE; for(int r=0;r<9;r++){ for(int c=0;c<9;c++){ g.board.calculateTerritory(); if(g.board.checkVa...
7
private void drawWest(Terrain[][] currentBoard, Entities[][] currentObjects, Graphics g) { //This is the opposite of east, so easy to figure out when you figure out east :) Location playerDir = boardState.getPlayerCoords(); for (int i = 0; i < currentBoard.length; i++) { for (int j = 0; j < currentBoard[0]....
6
public void move(){ // Is this enemy one of the inital 3 switch(priority){ case 1: case 2: case 3:{ initialEnemyMove(); break; } case 4:{ attackingMove(); break; } ...
4
public static void unJar(File jarFile, File toDir) throws IOException { JarFile jar = new JarFile(jarFile); try { Enumeration entries = jar.entries(); while (entries.hasMoreElements()) { JarEntry entry = (JarEntry) entries.nextElement(); if (!entry...
5
public boolean isCorrectPassword(Account a) { Account tempAccount = null; for (int i = 0; i < al.accountList.length; i++) { if (al.accountList[i].getiban().equals(a.getiban()) && al.accountList[i].getOwner().equals(a.getOwner())) { tempAccount = al.accountList[...
4
public Tile(byte[] buf) { t = (char) Utils.ub(buf[0]); id = Utils.ub(buf[1]); w = Utils.uint16d(buf, 2); try { img = ImageIO.read(new ByteArrayInputStream(buf, 4, buf.length - 4)); } catch (IOException e) { throw (new LoadException(e, Resource.this)); } if (img == null) throw (new...
2
public void sendAddUser() throws IOException{ String str = new String("adduser"+ "," + hostFld.getText()+ ","+ jobFld.getText() + "," + pwdFld.getText()); System.out.println(str); InetAddress serverAddr= null; try { serverAddr= InetAddress.getByName(GlobalV.serverIP); } catch (UnknownHostExcep...
4
public int clearRows() { // piece has NOT been placed // if committed is already false, then we've // backed up already. WE only need to clear rows. if (committed) { saveBackup(); committed = false; } int rowsCleared = 0; // make array of rows that are filled, falsify such rows boolean[]...
5
public static Boolean isSlotMachinePart(Block b) { Set<String> keys = null; try { keys = Global.config().getConfigurationSection("machines").getKeys(false); } catch(Exception e) { return false; } for(String k : keys) { SlotMachine s = new SlotMachine(k); if(s.getFirstItemFrame().equals(b.getLocation())...
6
@Override public void loadMemory(Data[] programCode) { for (Data line : programCode) { MEMORY[pointer] = line; //Load pointer location with line of program code pointer++; } fireUpdate(display()); }
1
public boolean isCheckedIcon(String name) { Component comp = fetchComponent(null, name); if (comp instanceof JRadioButton) { JRadioButton radioButt = (JRadioButton) comp; return radioButt.isSelected(); } return false; }
1
public void onAction(String sender, String login, String hostname, String target, String action) { if (target.equalsIgnoreCase(DarkIRC.currentChan.name)) { GUIMain.add_line("*" + sender + " " + action); } else { for (int i = 0; i < DarkIRC....
3
public Color getColor() { return color; }
0
protected void launch(AppDesc appDesc) throws LaunchException { //create new appcontext if required if(appDesc.useNewAppContext()) { try { Class cls = Class.forName("sun.awt.SunToolkit"); //Method m = cls.getMethod("createNewAppContext", new Class[]{}); //...
9
@Override public void mouseDragged(MouseEvent e) { Point dragged = e.getLocationOnScreen(); int dragX = getDragDistance(dragged.x, pressed.x, snapSize.width); int dragY = getDragDistance(dragged.y, pressed.y, snapSize.height); int locationX = location.x + dragX; int location...
4
@Override public void selectionChanged(TreeSelectionEvent e) { calculateEnabledState(e.getTree()); }
0
public static NumberWrapper minusComputation(NumberWrapper x, NumberWrapper y) { { double floatresult = Stella.NULL_FLOAT; { Surrogate testValue000 = Stella_Object.safePrimaryType(x); if (Surrogate.subtypeOfIntegerP(testValue000)) { { IntegerWrapper x000 = ((IntegerWrapper)(x)); ...
6
public static boolean writeUserSelectedFile() { if (fileDialog == null) fileDialog = new JFileChooser(); fileDialog.setDialogTitle("Select File for Output"); File selectedFile; while (true) { int option = fileDialog.showSaveDialog(null); if (option != JFileChooser.APPR...
8
@Override public Object getPropertyDefault(String key) { return default_values.get(key); }
0
public PDFFontEncoding(String fontType, PDFObject encoding) throws IOException { if (encoding.getType() == PDFObject.NAME) { // if the encoding is a String, it is the name of an encoding // or the name of a CMap, depending on the type of the font if (fontType.equa...
4
public void setR(float r) { this.r = r; }
0
public ArrayList returnTree() { if(isEmpty()) return null; ArrayList<Node<Word>> list1 = levelOrderTraversal(root); ArrayList<Word> list2 = new ArrayList<Word>(); for(int i=0;i < list1.size();i++) { if(list1.get(i) != null) { list2.add(list1.get(i).data()); } else { list2.add(nu...
3
void resetColorsAndFonts () { super.resetColorsAndFonts (); Color oldColor = itemForegroundColor; itemForegroundColor = null; setItemForeground (); if (oldColor != null) oldColor.dispose(); oldColor = itemBackgroundColor; itemBackgroundColor = null; setItemBackground (); if (oldColor != null) oldColor...
6
public static void main(String[] args) throws Throwable{ BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); for(StringTokenizer st;(st=new StringTokenizer(in.readLine()))!=null;){ M=parseInt(st.nextToken());L=parseInt(st.nextToken()); if(M==0&&L==0)...
9
public OutputStream getOutputStream() { return os; }
0
public Distance add(Distance second) { double sum = number + second.number; return new Distance(sum, unit); }
0
public static int discrete(double[] a) { double EPSILON = 1E-14; double sum = 0.0; for (int i = 0; i < a.length; i++) { if (a[i] < 0.0) throw new IllegalArgumentException("array entry " + i + " is negative: " + a[i]); sum = sum + a[i]; } if (sum > 1.0 + EP...
7
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setText(value.toString()); setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); setForeground(isSelected ? list.getSelectionForeground() : l...
3
public void checkCredentials (String userName, String passWord) { HttpConnector request = new HttpConnector(); try { stream = request.authenticate(userName, passWord); try { JSONObject json = new JSONObject(stream.toStri...
5
@Override public void run() { if (validArgs) { zip(); } else { try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
2
public Map<?, ?> getMap() throws IOException { return (Map<?, ?>)getValue(); }
4
public static void main(String[] args) { // args[0] = Number of times to complete - default 10 try { n = Integer.parseInt(args[0]); } catch (Exception e) { n = 10; } // Set up fractal FractalColourScheme scheme = FractalColourScheme.DEFAUL...
5
public void run() { for (int i = 1; i <= ConcurrentHashMapDemo.NUMBER; i++) { map.get(key); } synchronized (lock) { counter--; } }
1
public boolean isElement() { if(miniCompounds.length == 1 && miniCompounds[0].isElement()) return true; return false; }
2
@Test public void testDeleteByKey() { fail("Not yet implemented"); }
0
public void receive() { try { MulticastSocket socket = new MulticastSocket(DPORT); socket.joinGroup(InetAddress.getByName(ADDRESS)); byte[] buf = new byte[SIZE]; DatagramPacket packet = new DatagramPacket(buf, buf.length); socket.receive(packet); Object o = toObject(pack...
2
private boolean checkParameters(int high, int width, int minesNumber) { if (high < 9 || high > 24) return false; if (width < 9 || width > 30) return false; if (minesNumber < 10 || minesNumber >= high * width || minesNumber > 668) return false; return true; }
7
public int getNumberOfTeamPlayers(String teamName, String matchName){ try { cs = con.prepareCall("{ call GET_TEAM_PLAYERCOUNT(?,?,?) }"); cs.setString(1, teamName); cs.setString(2, matchName); cs.registerOutParameter(3, Types.INTEGER); cs.executeQuery(); //System.out.println("number of players in te...
1
public static boolean isNullOrEmpty(final String s){ boolean isEmpty = false; if(s == null){ isEmpty = true; } if(!isEmpty){ if(s.toCharArray().length == 0){ isEmpty = true; } } return isEmpty; }
3
public void shotFired(){ try { file = new FileInputStream("sound/cannonshot.wav"); } catch (FileNotFoundException ex) { System.out.println("file not found apparently"); Logger.getLogger(Sounds.class.getName()).log(Level.SEVERE, null, ex); } ...
3
@Override public void actionPerformed(ActionEvent emain) { Object links = emain.getSource(); if(links==quitapp){ quitApp(); } else if(links==newmember) { boolean b=openChildWIndow("Add New Record"); if(b==false){ ...
9
public void close() { for(Map.Entry<ObjectName, Set<ObjectNameAwareListener>> entry: registeredNotificationListeners.entrySet()) { for(ObjectNameAwareListener listener: entry.getValue()) { try { removeNotificationListener(listener.getObjectName(), listener); } catch (Exception e) {} } entry.getV...
9
public static HTTPResponse doHTTPRequest(HTTPRequest request) throws Exception{ HTTPResponse response = new HTTPResponse(); try{ HttpURLConnection conn; URL url = new URL(request.getURL()); // Open connection if (url.getProtocol().equalsIgnoreCase("https")){ conn = (HttpsURLConnection)url.op...
9
private void debugMode(String s, boolean ln) { if (debug) { if (ln) { System.out.println(s); } else { System.out.print(s); } } }
2
public void measure(long time) { updateMessages(); if (list.size() > 0) { double defdist = 1.0 / list.size(); Message prevMessage = null; for (Message message : list) { message.defDist = defdist; message.prevM = prevMessage; ...
4
public void act(){ if (clicked){ if (counter >= 10){ counter = 0; clicked = false; } else{ counter++; hoverCounter = 0; this.setImage (bg[2]); } } else if (selected){ ...
4
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 Selector duplicate(Object selectionObject, Class<?> selectionClass) throws SQLException { try { Constructor<? extends Selector> constr = getClass().getConstructor(Object.class,Class.class,boolean.class); return constr.newInstance(selectionObject,selectionClass,this.isStrictInheritance()); } ...
3
private boolean check() { if (!isBST()) StdOut.println("Not in symmetric order"); if (!isSizeConsistent()) StdOut.println("Subtree counts not consistent"); if (!isRankConsistent()) StdOut.println("Ranks not consistent"); if (!is23()) StdOut.println("Not a 2-3 tree"); if (!isBalanced()) ...
9
public VertexSet copy(){ VertexSet tmp = new VertexSet(); tmp.addVertexSet(this); return tmp; }
0
public boolean collide(Actor player) { if(loc.contains(player.getBox().getCenterX(), player.getBox().getCenterY())) { return true; } return false; }
1
public void gridletPause(int gridletId, int userId, boolean ack) { boolean status = false; // Find in EXEC List first int found = gridletInExecList_.indexOf(gridletId, userId); if (found >= 0) { // updates all the Gridlets first before pausing updateG...
8
protected void catchException(Object object, Exception exception) { fireServerExceptionEvent(new ExceptionEvent(object, exception)); }
0
public void add(String letter) { boolean found = false; Probability proTemp = null; for (Probability pro : probs) { if (pro.afterLetter == letter) { found = true; proTemp = pro; } } if (found) { proTemp.incProb(); } else { probs.add(new Probability(letter)); } }
3
public void testFactory_standardHoursIn_RPeriod() { assertEquals(0, Hours.standardHoursIn((ReadablePeriod) null).getHours()); assertEquals(0, Hours.standardHoursIn(Period.ZERO).getHours()); assertEquals(1, Hours.standardHoursIn(new Period(0, 0, 0, 0, 1, 0, 0, 0)).getHours()); assertEqual...
1
public TextureRegion getRegion(int i, int j) { if(i < 0 || j < 0 || i >= regions.length || j >= regions.length) throw new ArrayIndexOutOfBoundsException(); return regions[i][j]; }
4
public List<Tuple<Integer,Integer>> aStar ( Tuple<Integer,Integer> start, Tuple<Integer,Integer> goal) { this.callsToAStar++; log.debug("A* is looking for a path from " + start + " to " + goal); // Set closedSet = empty set HashSet<Tuple<Integer,Integer>> closedSet = new HashSet<Tuple<Integer,Integer>>(); //...
8
public synchronized void playbackLastMacro() { if (currentMacro!=null) { Action[] actions = getActions(); int numActions = actions.length; List macroRecords = currentMacro.getMacroRecords(); int num = macroRecords.size(); if (num>0) { undoManager.beginInternalAtomicEdit(); try { for (int i...
6
@Override public void onWake() { System.out.println("\n" + agent.getLocalName() + " is done waiting for offers, " + "picking best offer for " + item.getName()); Map<AID, Integer> offers = agent.pullOffers(item); if (offers.size() == 0){ System.out.println("We've r...
5
protected void readScaleFactorSelection() { for (int i = 0; i < num_subbands; ++i) ((SubbandLayer2)subbands[i]).read_scalefactor_selection(stream, crc); }
1
public void hit(int damage) { if (dead || flinching) return; health -= damage; sfx.get("enemyhit").play(); if (health < 0) health = 0; if (health == 0) { LevelCompletedState.eDead++; LevelCompletedState.score++; dead = true; } flinching = true; flinchTimer = System.nanoTime(); }
4
public void removeValue(Comparable rowKey, Comparable columnKey) { setValue(null, rowKey, columnKey); // 1. check whether the row is now empty. boolean allNull = true; int rowIndex = getRowIndex(rowKey); DefaultKeyedValues row = (DefaultKeyedValues) this.rows.get(rowInde...
7