text
stringlengths
14
410k
label
int32
0
9
private Map<String, SMSThread> buildSMSThreadMap(String response) { Map<String, SMSThread> result = new HashMap<String, SMSThread>(); String jsonResponse = ParsingUtil.removeUninterestingParts(response, FilterResponse.JSON_BEGIN, FilterResponse.JSON_END, false); try { JSONObject json = new JSONObject(jsonR...
8
@Override public void actionPerformed(ActionEvent ae) { try { String op = ae.getActionCommand(); switch(op){ case "Editar CRLV": editarCrlv(); break; case "Adicionar CRLV": ...
9
private boolean evaluateBackgroundClause(String str) { if (str.toLowerCase().startsWith("color")) { Color c = parseRGBColor(str.substring(5).trim()); if (c == null) return false; view.setBackground(c); view.setFillMode(new FillMode.ColorFill(c)); } else if (str.toLowerCase().startsWith("image")) {...
7
public Section map() { if (original.getRepository() == null || original.getRepository().toString().isEmpty()) { logger.error("Cannot perform mapping procedure on section " + original.toString() + "! No repository for terminologies specified!"); } try { original.resolve...
6
public static void main(String[] args) { // Example of creating a set and partitioning it: System.out.println("Starting by creating a partitioned set of 4 elements:"); PartitionListElement<String> list = new PartitionListElement<String>(); list.add("one"); list.add("two"); list.add("three"); list.add("...
6
@Override public void draw(Graphics g) { super.draw(g); Rectangle masse = getAbsoluteRect(); //draw eyes g.setColor(Color.WHITE); g.fillOval((int)(masse.getX() + masse.getWidth() * 0.2), (int)(masse.getY() + masse.getHeight() * 0.4), (int)(masse.getWidth() / 6), (int)(masse.getHeight() / 6)); g.fillO...
0
public boolean unfollowUser(String followingUser, String id){ String userToUnfollow= _users.get(followingUser).getUserById(id); User userFound= _users.get(userToUnfollow); if ((userFound != null) && (userFound.checkIfCanRemoveFollowingUser(followingUser, id))){ return ((_users.get(followingUser).unfollowUser(u...
3
public boolean isAlive() { return this.getHealth() <= 0; }
0
public int maximalRectangle(char[][] matrix) { int row = matrix.length; if(row == 0) return 0; int col = matrix[0].length; int[][] m = new int[row][col]; for(int i = 0; i < row; ++i){ for(int j = 0; j < col; ++j){ if(matrix[i][j] == '1'){ if(j == 0) m[i][j] = 1; else m[i]...
9
public final NiklausParser.parameters_return parameters() throws RecognitionException { NiklausParser.parameters_return retval = new NiklausParser.parameters_return(); retval.start = input.LT(1); CommonTree root_0 = null; Token IDENTIFIER61=null; Token COMMA62=null; To...
9
public void getMenu(int menuIndex){ if (this.isAlive()){ switch (menuIndex){ case WELCOME_MENU: getMenu(welcome()); break; case BANKING_MENU: getMenu(banking()); break; case DEPOSIT_MENU: getMenu(deposit()); break; case WITHDRAW_MENU: getMenu(withdraw());...
8
public static int dehexchar(char c) { if (c >= '0' && c <= '9') { return c - '0'; } if (c >= 'A' && c <= 'F') { return c - ('A' - 10); } if (c >= 'a' && c <= 'f') { return c - ('a' - 10); } return -1; }
6
public static boolean doBootstrapperUpdate(Stack<String> updateQueue, JSONObject versionsConfig) { Logger.info("Updater.doBootstrapperUpdate", "Starting update..."); //Show progress GlobalDialogs.showProgressDialog(); GlobalDialogs.setProgressCaption("Cleaning..."); ...
6
public static Reminder create(long apptId, long userId, long reminderAhead) throws SQLException { Map<String, String> values = new HashMap<String, String>(); values.put("appointmentId", String.valueOf(apptId)); values.put("userId", String.valueOf(userId)); values.put("reminderAhead", String.valueOf(reminderAhea...
0
private void drawCoordinateStroke(int x0, int y0, int x1, int y1) { for(int x = x0; x <= x1; x++) { for(int y = y0; y <= y1; y++) { if(x < width && x > 0 && y < height && y > 0) { image.setRGB(x, y, Color.black.getRGB()); ...
6
public int checkSidwaysUp(int originLetter, int originNum, int newLetter, int newNum, Board b) { valid = 0; int diagnalUpLetter = originLetter; int diagnalUpNumber = originNum; if(originLetter > newLetter) //diagnal up left { int diagnalLeftValid = 0; for(int counter = 0; counter < ((originLetter-ne...
6
public Node insertItem(int key) { Node node = new Node(key); if (isEmpty()) root = node; else { Node current = this.root; while (true) if (current.getKey() > key && current.getLeft() != null) current = current.getLeft(); else if (current.getKey() <= key && current.getRight() != null) cu...
7
public void update1(float time){//@override Entity Vector2 tempForce; LinkedList<MyPoint> temp = new LinkedList<MyPoint>(); for (Link l : neighbors){ tempForce = Vector2.vecSubt(l.other.getPos(), this.pos); if (tempForce.length() > l.len * breakLength){ temp.add(l.other); } } for (MyPoint p : tem...
8
public static int[] maxProduct(int[] A) { int[] output = new int[2]; int[] min = new int[2]; Arrays.fill(output, Integer.MIN_VALUE); Arrays.fill(min, 0); for (int i = 0; i < A.length; i++) { if (A[i] <= 0) { if (A[i] < min[1]) { min[0] = min[1]; min[1] = A[i]; } else if (A[i] < min[...
7
public Card returnAndRemove(Card data) throws Exception { Node<Card> currNode; Node<Card> prevNode; Card returnCard = null; if (head == null) { throw new ListEmptyException(); } else { // find the node with the data in it // adjust the links so the Node is removed from the chain of Nodes currNode ...
5
public static int[] toIntA(byte[] data) { if (data == null || data.length % 4 != 0) return null; // ---------- int[] ints = new int[data.length / 4]; for (int i = 0; i < ints.length; i++) ints[i] = toInt( new byte[] { data[(i*4)], data[(i*4)+1], data[(...
3
@Override public void run() { try { // Eclipse doesn't support System.console() BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); ConfigManager config = NetBase.theNetBase().config(); String server = config.getProperty("net.server.ip"); if ( server == null ) { Sys...
9
String checkSecurity(int iLevel, javax.servlet.http.HttpSession session, javax.servlet.http.HttpServletResponse response, javax.servlet.http.HttpServletRequest request){ try { Object o1 = session.getAttribute("UserID"); Object o2 = session.getAttribute("UserRights"); boolean bRedirect = false; ...
7
private static <E extends Comparable<E>> void heapifyDown(E[] heap, int index, int startIndex, int endIndex) { int leftChildIndex = index * 2 + 1 - startIndex; int rightChildIndex = index * 2 + 2 - startIndex; int swapIndex = index; // if left child exists and greater than current node if (leftChildIndex <...
5
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Level)) return false; Level other = (Level) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; ...
6
private ReturnValue Helper(TreeNode p) { if (p == null) return new ReturnValue(Integer.MIN_VALUE,Integer.MIN_VALUE); if (p.left == null && p.right == null) return new ReturnValue(p.val,p.val); ReturnValue l = Helper(p.left); ReturnValue r = Helper(p.right); ...
9
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { renderButton.setForeground(table.getSelectionForeground()); renderButton.setBackground(table.getSelectionBackground()); } else { renderButton....
4
public void doWork(long time, TimeUnit unit) throws Exception { if (!lock.acquire(time, unit)) { throw new IllegalStateException(clientName + " could not acquire the lock"); } try { System.out.println(clientName + " has the lock"); resource.use(); } fi...
1
* @throws IOException if a data communication error occurs * @throws UnknownHostException if cyc server host not found on the network */ public boolean isOpenCyc() throws UnknownHostException, IOException { boolean answer; try { answer = converseBoolean("(cyc-opencyc-feature)"); } c...
1
public void deleteElement(ValueType value) throws NotExistException { ListElement<ValueType> previous = head; ListElement<ValueType> current = head.getNext(); if (exist(value)) { while (current != tail.getNext()) { if (current.getValue() == value) { ...
3
@Override public void run() { try { final BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); final PrintWriter out = new PrintWriter(socket.getOutputStream(), true); // display welcome screen out.println(Util.buildWel...
8
@Override public FileContent read(String fileName) throws FileNotFoundException, IOException, RemoteException { FileContent data = new FileContent(fileName); ReadWriteLock lock = null; if (!fileReadWriteLock.containsKey(fileName)) { lock = new ReentrantReadWriteLock(); fileReadWriteLock.put(fileName, lo...
3
public static void main(String[] args) throws IOException { long inicio = System.currentTimeMillis(); StringBuilder out = new StringBuilder(); BufferedReader in; File archivo = new File("entrada"); if (archivo.exists()) in = new BufferedReader(new FileReader(archivo)); else in = new BufferedReader(new...
8
int[] generateNormalDistSlots(int size, int avg, int stdDev){ int[] slot = new int[size]; for(int i=0; i<slot.length; i++){ slot[i] = (int) n.Normal(avg, stdDev); } return slot; }
1
private void getData(Graphics2D graphics) { int i = 1, slen; data = new ArrayList<String>(); if (scores.count() == 0) slen = 5; else slen = Math.max(5, scores.getHighest().getFormattedScore().length()); header = String.format("Place%" + (slen - 4) + "sScor...
4
public boolean canHaveAsBalance(BigInteger balance) { return (balance != null) && (balance.compareTo(this.getCreditLimit()) >= 0); }
1
public PostProcessingFileWriter(File file) throws IOException { super(file); }
0
public void automataStateChange(AutomataStateEvent e) { transformNeedsReform = true; repaint(); }
0
@Override public void showHelp(CommandSender sender) { sender.sendMessage(colour1 + "=== " + colour2 + getCommandName() + colour1 + " ==="); sender.sendMessage(colour1 + "Usage: " + colour2 + getCommandUsage()); sender.sendMessage(colour1 + "Desc: " + colour2 + getCommandDesc()); sen...
7
private void deleteFileServerSide() { try { client.connect("ftp.asite.com"); client.login("username", "password"); // Set a string with the file you want to delete String filename = "/coomons/footer.jsp"; // Delete file boolean exist = cl...
3
public int loopLevel(final Block block) { if (loopEdgeModCount != edgeModCount) { buildLoopTree(); } if ((block == srcBlock) || (block.blockType() != Block.NON_HEADER)) { final LoopNode loop = (LoopNode) loopTree.getNode(block); Assert.isTrue(loop != null, "no loop for " + block); return loop.level; ...
4
/* */ public String getParameter(String name) { /* 206 */ String custom = (String)this.customParameters.get(name); /* 207 */ if (custom != null) return custom; try /* */ { /* 209 */ return super.getParameter(name); /* */ } catch (Exception e) { /* 211 */ this.customParameters.p...
2
public static String formatIntoMessage(String topic, String subscription, String message){ StringBuilder sb= new StringBuilder("MESSAGE"); sb.append(StompFrame.endlineChar); if (!topic.equals("")) sb.append("destination:/topic/").append(topic).append(StompFrame.endlineChar); if (!subscription.equals("")) ...
3
public static void ImportDataBookCopies(){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try{ conn.setAutoCommit(false); ...
4
private static String getContentAsString(ContentStream stream) throws IOException { // from Jeff Potts guide InputStream in2 = stream.getStream(); StringBuffer sbuf = null; sbuf = new StringBuffer(in2.available()); int count; byte[] buf2 = new byte[100]; ...
2
private void senaoEspecial() { String senaoEsp = ""; if (comparaLexema(Tag.SENAO)) { senaoEsp = "_L" + label + ":"; ex.codigoInt(senaoEsp); consomeToken(); if (comparaLexema('{')) { consomeToken(); boolean c = true; while (c) { c = comeco(); } if (numeroErro == 0) { ...
9
private void lock( ) { try { SwingUtilities.invokeAndWait( new Runnable() { public void run( ) { mainFrame.setLock(true); } }); } catch( Exception exc ) { FastICAApp.exceptionDialog(exc); } }
1
private Double[] doFragmentation(double aMin, double aMax, int points){ Double[] array = new Double[points]; double eps = 0; for (int i = 0; i < points; i++) { eps = aMin + 1.0 * i * (aMax - aMin) / (points - 1); array[i] = eps; } return array; }
1
public Connection abrirConexao() { try { // Carregando o JDBC Driver padrão String driver = "com.mysql.jdbc.Driver"; //classe driver JDBC // String banco = "db_sistema"; //nome do banco // String host = "127.0.0.1"; //maquina onde está o banco // ...
2
public Record getRecord(Integer id) { Record record = null; PreparedStatement pStmt = null; ResultSet rs = null; try { pStmt = conn.prepareStatement("SELECT * FROM RECORD WHERE id = ?;"); pStmt.setInt(1, id); rs = pStmt.executeQuery(); while (rs.next()) { record = new Record(); ...
2
@Override public List<Match> findAll() { List<Match> listM = new ArrayList<Match>(); Statement st = null; ResultSet rs = null; try { st = this.connect().createStatement(); rs = st.executeQuery("select * from Matches"); System.out.println("recherche...
5
public static CollectionPerson getInstanceCollectionPerson() { if (collectionPerson == null) { collectionPerson = new CollectionPerson(); } return collectionPerson; }
1
public String toString() { String ret = ""; if(passes) { ret = "passes"; } else { if(callOnFirstRound) { if(callIndex != dealerIndex) { ret = "orders up the dealer"; } else { ret = "picks up"; } } else { ret += "declares "; if(this.trump.startsWith("S")) { ret += "...
8
private void startMetrics() { try { Metrics metrics = new Metrics(this); Metrics.Graph componentLineGraph = metrics.createGraph("Components Used"); for (final Component c : Component.values()) { String name = c.getFancyName(); // Line graph comparing component usage together compon...
5
protected SchlangenKopf(Rectangle masse, IntHolder unit, Color color) { super(masse, unit, color); direction = DIRECTION_START; }
0
public void visit_if_icmple(final Instruction inst) { stackHeight -= 2; if (stackHeight < minStackHeight) { minStackHeight = stackHeight; } }
1
public Object getDataForDataSection(DataSection dataSection) { if (DATA_SECTION_GENERAL == dataSection.getDataSectionName()) { return characterData.getCharacterDataData(); } else if (DATA_SECTION_SKILLS == dataSection.getDataSectionName()) { return cha...
9
@Override public ElementType next() { // if not initialized, initialize it first if (this.currentElementItr == null) { if (this.currentListItr.hasNext()) { // have lists this.currentElementItr = this.currentListItr.next() .i...
4
public static void main(String args[]) throws UnknownHostException, IOException { /* 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 fee...
7
@Override public int matches( ByteBuffer sequenceA, int indexA, ByteBuffer sequenceB, int indexB, int count ) { for (int i = 0; i < count; i++) { if (sequenceA.get(indexA + i) != sequenceB.get(indexB + i)) { return i; } } return count; }
2
@Override public void run() { super.run(); mUi.updateProgressState("Parser started", 0); try { if (mInputDictionary != null) addWordsFromInputStream(mInputDictionary, true, mTotalDictionaryChars, LOOKING_FOR_WORD_START); addWordsFromInputStream(mInput, (mInputDictionary == null), mTotalChars, LOOK...
3
private void printCommands(Player playerSender){ if(playerSender.hasPermission("sd")){ String pluginVersion = plugin.getDescription().getVersion(); String pluginName = plugin.getDescription().getName(); playerSender.sendMessage(ChatColor.YELLOW + "|---------- " + pluginName + " v" + pluginVersion + " ...
1
private void flaggedMinesCheck() throws IllegalStateException { if (flaggedMines < 0) throw new IllegalStateException("The number of flagged mines is below 0."); if (flaggedMines > mineCount) throw new IllegalStateException("The number of flagged mines is above the maximum, "+min...
9
public JMenuItem getExportDataMenuItem() { return exportDataMenuItem; }
0
public String toString() { if (top == 0) { return ""; } else { return new String(data, 0, top); } }
1
public void doGuess( String letter ) { if ( ! isReady() || ! letter.matches( "[A-Z]|[a-z]" )) return; if (usedLetters.contains( letter )) { onRedundantLetter.execute( letter ); return; } boolean isGoodGuess = guessLetterAndReveal( letter ); boolean isComplete = ! getWordFormatted()....
6
public void checkButtonsEnabled(){ topDecreaseButton.setEnabled(topSpinner.nextButton.isEnabled()); topIncreaseButton.setEnabled(topSpinner.prevButton.isEnabled()); bottomDecreaseButton.setEnabled(bottomSpinner.prevButton.isEnabled()); bottomIncreaseButton.setEnabled(bottomSpinn...
3
private boolean validateCutTimes() { for(VideoSectionPanel panel : results) { if (!panel.validateTimes()) { //warning window JOptionPane.showMessageDialog(frame, panel.errorMessage(), "Warning - wrong tim...
2
@Override public String getColumnName(int columnIndex) { switch (columnIndex) { case 0: return "Name"; case 1: return "Size"; case 2: return "Modified"; default: return ""; } }
3
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 static MaxSegments valueOf(byte id) { if (id == UNSPECIFIED.id) return UNSPECIFIED; if (id == UP_TO_2.id) return UP_TO_2; if (id == UP_TO_4.id) return UP_TO_4; if (id == UP_TO_8.id) return UP_TO_8; if (id == UP_TO_16.id) ...
8
@Override public List<PastMeeting> getPastMeetingList(Contact contact) { if(contactExists(contact)) { Iterator meetingIterator = allMeetings.iterator(); Meeting nextMeeting; //Calendar nextCal; List<PastMeeting> returnList = new ArrayList<>(); whil...
4
@Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ if(commandLabel.compareToIgnoreCase("portalboots") == 0){ if(sender.hasPermission("portalgel.portalboots")){ if(args.length == 1){ if(args[0].compareToIgnoreCa...
5
public void close(){ try { file.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
1
public Question randomQuestion() { int rndQuestion = random.nextInt(QUESTION_COUNT); int rndExc = random.nextInt(excDatas.length); ExcData excData = excDatas[rndExc]; switch (rndQuestion) { case 0: return new ByDescription(excData); case 1: ...
4
public void visitMultiANewArrayInsn(final String desc, final int dims) { buf.setLength(0); buf.append(tab2).append("MULTIANEWARRAY "); appendDescriptor(FIELD_DESCRIPTOR, desc); buf.append(' ').append(dims).append('\n'); text.add(buf.toString()); if (mv != null) { mv.visitMultiANewArrayInsn(desc, dims); ...
1
public void printPicture() { PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPrintable(new Printable() { public int print(Graphics graphics, PageFormat pf, int pageIndex) throws PrinterException { if (pageIndex > 0) { return 1; } Graphics2D g2d = ...
3
public void playersInWorldMessage(World world, Player player){ if (plugin.getPlayersInWorld(world, player) != "" && world != null){ List<Player> players = world.getPlayers(); if (players.size() == 1){ player.sendMessage(ChatColor.GOLD + "You're the only user in this world!"); }else{ player.se...
3
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 void closePopUp() { Parent parentRoot = ((Stage) stage.getOwner()).getScene().getRoot(); if (parentRoot instanceof StackPane) { ((StackPane) parentRoot).getChildren().remove(mask); } stage.close(); }
1
public Object eval(CallStack callstack, Interpreter interpreter) throws EvalError { publishLineNumber(); int numChild = jjtGetNumChildren(); // Order of body and condition is swapped for do / while final SimpleNode condExp; final SimpleNode body; if (isDoStatement) { condExp = (SimpleNode) jjtGetChild(...
9
private boolean isLegalPosition(Position p) { if ((p != null) && (p.row >= 0) && (p.row < TicTacToeBoard.SIZE) && (p.col >= 0) && (p.col < TicTacToeBoard.SIZE)) { return true; } else { return false; } }
5
PERangeList difference(PERange rangeb) { PERangeList difference = new PERangeList(); int s = (this.begin < rangeb.begin) ? this.begin : rangeb.begin; int e = (this.end < rangeb.begin) ? this.end : rangeb.begin - 1; if (s <= e) { difference.add(new PERange(s, e)); } s = (this.begin <= rangeb.end) ? ran...
7
public int[][] getVisual(){ int[][] visual = new int[shape.length][shape[0].length]; for (int i = 0; i<shape.length; i++){ for (int j = 0; j<shape[0].length; j++){ if (shape[i][j] != 0){ visual [i][j] = shape[i][j] != STRENGTH_MANA ? visualCode : -1; } } } return visual; }
4
public int moveRight(boolean findChange) { int total = 0; for (int y = 0; y < 4; y++) { for (int x = 0; x < 3; x++) { if (next.grid[x][y] != 0 && next.grid[x][y] == next.grid[x+1][y]) { next.grid[x+1][y] *= 2; next.grid[x][y] = 0; ...
7
static int hanoiMoves(int discs){ if(discs == 1){ return 1; } return hanoiMoves(discs-1) + 1 + hanoiMoves(discs-1); }
1
protected void togglePassword(boolean enabled){ if(enabled){ passwordChkbox.setSelected(true); serv_pswd.setEnabled(true); } else { passwordChkbox.setSelected(false); serv_pswd.setEnabled(false); } }
1
@Override public synchronized Fingerprint add(Fingerprint fprint) { Connection conn = db.getConnection(); Vector<PreparedStatement> vps = new Vector<PreparedStatement>(); ResultSet rs = null; try { conn.setAutoCommit(false); Measurement m = (Measurement)fprint.getMeasurement(); int measurementId =...
7
private void hbCreateDecodeTables(int[] limit, int[] base, int[] perm, char[] length, int minLen, int maxLen, int alphaSize) { int pp, i, j, vec; pp = 0; for (i = minLen; i <= maxLen; i++) { for (j = 0; j < alphaSize; j++) { if (length[j] == i) { perm[pp] = j; pp++; } ...
9
@Override public int decode( byte[] data, int offset, DecodeState ds, CerealDecoder context ) throws InvalidEncoding, ResourceNotFound { long propDecodeResult = NumberEncoding.readUnsignedBase128(data, offset); long props = NumberEncoding.base128Value(propDecodeResult); offset += NumberEncoding.base128S...
6
public JGImage toDisplayCompatible(int thresh,JGColor bg_col, boolean fast, boolean bitmask) { Color bgcol = new Color(bg_col.r,bg_col.g,bg_col.b); int bgcol_rgb = (bgcol.getRed()<<16) | (bgcol.getGreen()<<8) | bgcol.getBlue(); JGPoint size = getSize(); int [] buffer = getPixels(); // render image to b...
6
public void markInputOutput(){ int markIn; int stu = 0; int dist = 0; int pass = 0; int fail = 0; int inval = 0; do { System.out.print("Input a mark: "); String str = System.console().readLine(); markIn = Integer.parseInt(str); stu++; if (markIn >= 70 && markIn <= 100){...
7
public static ImageContentEnumeration fromValue(String v) { for (ImageContentEnumeration c: ImageContentEnumeration.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); }
2
public Object readValue() throws IOException, JSONException { int c = this.skipWSRead(); switch(c) { case -1: return JSONReader.EOF; case JSON.BEGIN_ARRAY: return this.readArray(); case JSON.BEGIN_OBJECT: return this.readObject(); case JSON.QUOTE_CHAR: return this....
4
public static String escape(String string) { char c; String s = string.trim(); StringBuffer sb = new StringBuffer(); int length = s.length(); for (int i = 0; i < length; i += 1) { c = s.charAt(i); if (c < ' ' || c == '+' || c == '%' ...
6
public static int dajUkupanBrojRazlicitihGostiju() { Session session = HibernateUtil.getSessionFactory().openSession(); Query q = session.createQuery("from " + Boravak.class.getName()); List<Boravak> sviBoravci = (List<Boravak>)q.list(); session.close(); List<Long> gostIds = new ArrayList(); for(Bor...
3
public void swapPaint(int var1) { if(var1 > 0) { var1 = 1; } if(var1 < 0) { var1 = -1; } for(this.selected -= var1; this.selected < 0; this.selected += this.slots.length) { ; } while(this.selected >= this.slots.length) { this.selected -= t...
4
public static int firstMissingPositive(int[] A) { if (null == A || 0 == A.length) return 1; int n = A.length; for (int i = 0; i < n; i++) { int elem = A[i]; while (elem > 0 && elem < n + 1 && elem != A[elem - 1]) { A[i] = A[elem - 1]; A[elem - 1] = elem; ...
8
public void loadCenter(FileSystem fs, Path path, Configuration conf){ SequenceFile.Reader reader ; try { //initializae centers with number of empty vector for(int i =0 ;i<Constant.K;i++) { Map<Integer, Float> centerVect = new HashMap<Integer, Float>(); centers.add(centerVect); } reader = new ...
7
public boolean equals( Object obj) { if ((obj == null) || !(obj instanceof SecretKeySpec)) { return false; } SecretKeySpec spec = (SecretKeySpec)obj; if (!this.algorithm.equalsIgnoreCase(spec.algorithm)) { return false; } ...
6