method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
10f1e91e-d6a8-4c6a-9a39-20ac5caa34da
4
private void readFile(File diffMapperFile) { try { BufferedReader reader = new BufferedReader(new FileReader(diffMapperFile)); String[] title = reader.readLine().split("\t"); String line; while((line = reader.readLine()) != null) { String[] value = line.split("\t"); for(int i = 0; i < title.le...
ceccf490-2607-4aa4-8376-e2f2eedce09f
0
public boolean getCompressWhiteSpace() { return _compressWhiteSpace; }
d692b054-efdf-4ed2-be69-db8ab28fbcdc
0
@Override public boolean isManagingFocus() { return true; }
cecc84bf-0724-4c2b-9968-fd8a9e9e80b7
7
private void processPair(Pair pair) { int l = pair.left; int r = pair.right; if (out[l] || out[r]) return; if (prev[l] != l && next[r] != r) { next[prev[l]] = next[r]; prev[next[r]] = prev[l]; int l2 = prev[l]; int r2 = next[r]; ...
5a8eeeff-da24-4aae-a892-1d8d8f1ccf0f
9
public int[] findLongestPalindrome(String s,int i) { int start = i-1; int end = i+1; while (start>=0&&end <s.length()){ if (s.charAt(start) == s.charAt(end)){ start --; end ++; } else break; } in...
6b6ebc21-2ec0-4835-84cf-d04ba8ce9ed8
8
@Override public void move(Entity e) { if (!dead) { x += xv; y += yv; shape.setCenterX(x); shape.setCenterY(y); } Damageless--; // cull if neccesary if (x >= FORM_WIDTH || x <= 0 || y >= FORM_HEIGHT || y <= 0) { death((byte) 0); } for (BulletBounce en : b) { en.move(e); } // cull ...
351cbca4-8b2d-46c6-b30b-e99fbedd7772
8
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Connection connection = null; try { Type type = Type.JDBC; if (type == Type.JDBC) { Class.forName("oracle.jdbc.driver.OracleDriver"); connection = DriverManager.getConnection("j...
514fa6a2-1e08-4e8c-bd34-0956e5335c23
8
public void drawArray(Graphics g) { // white keys for (int i = 0; i < 45; i++) { if (whiteSpaces[i] == 1) { if (whiteSpacesColor[i] == 0) g.setColor(Color.BLUE); else if (whiteSpacesColor[i] == 1) g.setColor(Color.RED); g.fillRect(i * widthWhite + leftOffset, offset + keylength + 5, ...
6b540d1f-727f-4aba-9bec-afc75a5410a4
6
public String longestCommonPrefix(String[] strs) { // Start typing your Java solution below // DO NOT write main() function StringBuilder sb = new StringBuilder(); if (strs == null || strs.length == 0) return sb.toString(); for (int i = 0; i < strs[0].length(); i++) { char x = strs[0].charAt(i); for ...
3e023657-eb02-4f80-aedc-440a1edc80b1
8
public void instanceProduced(InstanceEvent e) { Object source = e.getSource(); if (source instanceof InstanceProducer) { try { InstanceProducer a = (InstanceProducer) source; switch (e.getID()) { case InstanceEvent.FORMAT_AVAILABLE: if (b_Debug) { System.err.println(this.getClass().getNam...
e46a3e53-760b-4059-90b9-985f346f68bf
0
public T getFirst() { return first; }
ede368d3-d953-4a23-abae-045cc826113c
0
@Override public void documentRemoved(DocumentRepositoryEvent e) {}
a7486a13-be4c-4cdd-b118-d612c2e2866c
4
boolean NORTHdiagnoalHasCraftedBlock(Location startLocation) { boolean res = false; // Check NORTH 45 degrees ========================================================= // Check if there is a valid crafted ceiling block in 45 degrees upwards to the player within given distance Location check...
ca082451-bddb-49a3-a3a0-a06fe87f7d56
3
public void Deltas(){ for(int i=0; i<outputNodes.length; i++){ outputNodes[i].delta(); } Node tek= outputNodes[0]; //.brnI[0].leftNode() for(int j=0; j<hiddenLayersNo; j++){ for(int i=0; i<tek.brnI.length; i++) tek.brnI[i].leftNode().delta(); tek=tek.brnI[0].leftNode(); } }
88b13227-8111-48e1-abd2-fc3026339f22
2
public static UUID parseId(String data) { String[] lines = data.split("\n"); for (String line : lines) { String[] parts = line.split(":", 2); if (parts[0].equals("id")) { return UUID.fromString(parts[1]); } } return null; }
d7b4f2ba-31e2-4bc0-82e0-02cb6334eb7b
9
static boolean isBlackPiece(int i, int j) { if ((i < 0) || (j < 0)) { return true; } if ((i > 11) || (j > 11)) { return true; } return (board[i][j] == 'p') || (board[i][j] == 't') || (board[i][j] == 'n') || (...
401797fc-392e-4ab7-a8dd-4d207ee98455
3
@Override public void mouseReleased(MouseEvent e) { Rectangle rect = bounds; reset(); if (!e.isConsumed() && rect != null && graphComponent.isSignificant(rect.width, rect.height)) { select(rect, e); e.consume(); } }
6f478a66-29b0-43d9-a41d-cffb7b5aa938
0
public boolean isItemReceived(Auction auction){ return auction.isItemReceived(); }
bfe69609-47f8-4ed3-adf2-2364c6b1e9e9
8
public boolean writeFile(String filename) { List<String> categories = this.reader.getTags(); try { FileWriter writer = new FileWriter(new File("./data/results/" + filename + ".txt")); BufferedWriter bw = new BufferedWriter(writer); for (int i = 0; i < this.results.size(); i++) { int j = 0; Stri...
42df62e6-ca7f-4301-9666-349a91cd002e
5
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Book)) return false; Book book = (Book) o; if (!authorname.equals(book.authorname)) return false; if (!bookName.equals(book.bookName)) return false; if (!year.equals(book.year...
0185661f-3df6-4b3d-9d1b-2be56fb88d1e
8
private List<Cell> getNeighborCells(int row, int col){ List<Cell> neighborList = new ArrayList<Cell>(8); if( isValidCell(row-1, col-1) ) // top-left neighborList.add(gameCell[row-1][col-1]); if( isValidCell(row-1, col ) ) // top neighborList.add(gameCell[row-1][col ]); if( isValidCell...
05ef4910-4ecd-47a4-9daf-69b77b2e3b52
8
public Bag fillBag(ProblemInstance problemInstance) { if(problemInstance == null){ throw new IllegalArgumentException("Parameter problemInstance is null"); } initialFill(problemInstance.getItems(), problemInstance.getMaxBagWeight()); long bestBagValue = getBagValue(this.bes...
669b41b8-6d41-4521-ab9e-f10168ebe009
8
@Override public void e(float sideMot, float forMot) { if (this.passenger == null || !(this.passenger instanceof EntityHuman)) { super.e(sideMot, forMot); this.W = 0.5F; // Make sure the entity can walk over half slabs, // instead of jumping return; } EntityHuman human = (EntityHuman) this.passe...
d0c906f0-90d8-4f18-a4ee-8aa6112f8e27
9
public void updateActual(){ timer++; if(player==null) System.out.println("Player is null! :: Level1State"); player.update(blocks,this); player.finalizeMovementNew(this); double dx=player.getDx(); for(int i=0;i<blocks.size();i++){ // This line will ...
e6e5075c-f032-41ef-ad52-cc4566dcb074
2
public Matrix4f mul(Matrix4f r) { Matrix4f res = new Matrix4f(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { res.set(i,j, m[i][0] * r.get(0, j) + m[i][1] * r.get(1, j) + m[i][2] * r.get(2...
076af9d7-d8d5-4149-a775-b362efcdfabc
4
@Override public void use(Player player) { if (cooldownTimer > 0) return; if (bulletsLoaded == 0) tryReload(player); if (bulletsLoaded == 0) return; double angle = player.getShootingAngle(); for (int i = 0; i < Math.min(numBullets, bulletsLoaded - numBullets); i++) { double offangle = random.nex...
3599a3d7-6c10-4362-810e-30579a1f0074
4
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final Habitat another = (Habitat) obj; if (getCuboidID() == another.getCuboidID()) { return true; } return false; }
2facbd80-d444-42d5-bba7-6bf1273a8014
0
public void setLive(boolean l){ this.live = l; }
eb6387c3-3269-42a7-9ab7-08c3061a15de
3
public static String formatTimes(int i) { String line = ""; if ((i / 360) < 10) { line += "0"; } line += i / 360 + ":"; if (((i % 360) / 60) < 10) { line += "0"; } line += (i % 360) / 60 + ":"; if ((i % 60) < 10) { lin...
5130003f-fb57-4bab-b624-f6c33709787a
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
a5108002-ee82-4098-a5ec-0899c5330631
9
@Action public void openfile() {int c =0; JPasswordField pf = new JPasswordField(); JOptionPane.showConfirmDialog(null, pf, "Enter Password(max 6 char)", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); String pass = new String(pf.getPassword()); try { BufferedReader br = new Buffered...
bef33c4b-665e-4dee-b791-e911202ee626
9
@Override public void run() { // The number of documents that has been found long count = 0; try { // Keep running until we are interrupted while (isInterrupted() == false) { // Check to see if there is a user checked in and tweeting is // enabled if ((myUserLoggedIn == true) && (isTweetingE...
9d64d07c-238e-486d-9d3b-66491f89f330
2
public FontChooserBean() { setLayout(new BorderLayout()); add(mNameSelector = new Choice(), BorderLayout.CENTER); for (int i = 0; i < sFontNames.length; ++i) { mNameSelector.addItem(sFontNames[i]); } mNameSelector.select(mFont.getName()); mNameSelector.addItemListener(this); add(mSizeSelector = n...
0a5c4690-9c5f-404f-8cbf-f7f1abe6c0d3
1
private static String getSourcefileName(String qname) { int index = qname.lastIndexOf('.'); if (index >= 0) qname = qname.substring(index + 1); return qname + ".java"; }
6c15fa2b-68b5-4eab-a45d-263a2f6eded5
2
private void sortByFitness() { Collections.sort(getOrganisms(), new Comparator<Organism>() { @Override public int compare(Organism o1, Organism o2) { return o2.getFitness() > o1.getFitness() ? 1 : o2.getFitness() < o1.getFitness() ? -1 : 0; ...
a7a6df4d-8bfd-4618-8bd1-c2c7020ac740
8
private void initiateLoseSequence(int x, int y) { timer.cancel(); gameFinished = true; hasLost = true; Square[][] b = board.getBoard(); for (int i = 0; i < b.length; i++) { for (int j = 0; j < b[i].length; j++) { if (i == x && j == y) continue; Square s = b[i][j]; if (s.isFlagged() && !s...
67f42897-d613-403b-a489-d74d0832c0fc
3
public static Image applyMedianMask(Image original, int maskWidth, int maskHeight) { if (original == null) { return null; } Image image = original.shallowClone(); for (int x = 0; x < image.getWidth(); x++) { for (int y = 0; y < image.getHeight(); y++) { image.setPixel( x, y, RED, ...
aadf7ba9-bf0a-4e09-9316-6ffe53230d4f
7
private BinomiNode merge(BinomiKeko eka, BinomiKeko toka) { //Tarkistetaan onko toisen juuri null, jos on palautetaan vain toisen juuri. if (eka.root == null) { return toka.root; } else if (toka.root == null) { return eka.root; } //Kumpikaan ei ole...
e4a58f3c-277c-4193-8470-cfbf809529c8
6
public String print () { String toMe; // see if it is a literal type for (int i = 0; i < valueTypes.length; i++) { if (myType.equals (valueTypes[i])) { toMe = myValue; return toMe; } } // see if it is a unary type for (int i = 0; i < unaryTypes.length;...
6eed5c0d-fb39-4fbc-80c0-64ce66d38470
4
@Override public void send(MidiMessage incomingMessageWrapper, long timestamp) { byte[] midiMessage = incomingMessageWrapper.getMessage(); command = midiMessage[0] & 0xFF; if (command >= 144 && command <= 159) { //note on synth.noteOn(midiMessage[1] & 0xFF, midiMessage[2] & 0xF...
60f26196-fec6-4998-9ca6-39c7388fef34
7
public Map<UUID, Long> findVotes( List<UUID> uuidList ) { if ( null == uuidList || uuidList.isEmpty() ) { return Collections.emptyMap(); } MultigetSliceCounterQuery<UUID, String> q = HFactory.createMultigetSliceCounterQuery(keyspace, UUIDSerializer.get(), StringSerializer.get()); ...
89a3caa9-ff36-4560-bb3f-f7c57964c39d
2
public static byte[] whirlpool(byte[] data, int off, int len) { byte source[]; if(off <= 0) { source = data; } else { source = new byte[len]; for(int i = 0; i < len; i++) source[i] = data[off + i]; } Whirlpool whirlpool = new Whirlpool(); whirlpool.NESSIEinit(); whirlpool.NESSIEadd(source, l...
d438bd8e-af2b-4620-9a15-c73708fcd0dd
2
public Builder name(String receivedName) { if (receivedName == null || receivedName.equals("")) { log.warn("Wrong Name. receivedName ={}", name); throw new IllegalArgumentException("Name must be not null. Received value =" + receivedName); } this.name ...
2000d803-342e-4df1-be7b-415339cf114f
2
private int determineRowSwap(Double[][] mat, int row, int col) { for (int i = row + 1; i < mat.length; i++) { if (mat[i][col] != 0) return i; } return -1; }
8892d95b-1692-412f-8e4c-81e875cb59bf
5
static private int jjMoveStringLiteralDfa1_1(long active0) { try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { return 1; } switch(curChar) { case 42: if ((active0 & 0x40000000000000L) != 0L) return jjStopAtPos(1, 54); break; case 47:...
dca19ee8-4fe6-4d65-818d-37226e7ca65c
7
@Deprecated private void writeSystemObject(Serializer serializer, SystemObject systemObject, long queryId, String queryPid) throws IOException, ConfigurationException { if(systemObject instanceof DynamicObject) { DynamicObject object = (DynamicObject)systemObject; serializer.writeByte(1); // dynamisches Ob...
d5d50f44-4f25-4889-b00b-2a3a9eec9e50
5
public static int waysOfCents ( int n, int[] k ) { // temporary array to store the immediate ret int[][] s = new int[n+1][k.length]; // initialize the s Matrix // 1. init the bottom row for ( int i=0; i != k.length; i++ ) { s[1][i] = 1; s[0][i] = 1; } // 2. init the left column to j for ...
c0be78fc-1b32-4178-afcb-f8110a81deab
3
public void preencherTabela() throws Exception { ArrayList<String> colunas = new ArrayList<String>(); colunas.add("id"); colunas.add("palavra"); Object linhas[][] = new Object[list.size()][]; int i = 0; for (PalavraChave palavrachave : list) { linhas[i] = formatoTabela(palavrachave); i++; } vie...
cd8215dc-ffcd-4ad2-957b-4bb48dd2f8f0
9
public Program fileToProgram(File file) { ArrayList<ArrayList<String>> program = new ArrayList<ArrayList<String>>(); try { String s; BufferedReader reader = new BufferedReader(new FileReader(file.getAbsolutePath())); while((s = reader.readLine()) != null) { s += "\n"; ArrayList<String> line = new ...
575dc9c3-081b-407d-b01c-782926fb620b
1
private void turnInfo() { clearScreen(); System.out.println("P1 POINTS: " + p1.getPoints() + " P2 POINTS: " + p2.getPoints()); System.out.println("WE ARE NOW COLLECTING POINTS FOR " + ((p1Turn) ? "P1" : "P2") ); }
3e47a093-8bf0-42f5-b0ac-a45d0211cb9f
8
public void runCoreLogic(String[] args) throws IOException { long baganAt = System.currentTimeMillis(); List<ChessBoard> boards = new ArrayList<ChessBoard>(); // TODO get board dimensions from parameters // DataInputReaderSimple dataInputReaderSimple = new DataInputReaderSimple(ne...
c3dec571-679d-43a6-8a53-ba467e543f61
4
public void calculateMST() { visit(0); while (!pq.isEmpty()) { Edge edge = pq.popMin(); if (used[edge.getV()] && used[edge.getW()]) { continue; } tree.add(edge); if (!used[edge.getV()]) { visit(edge.getV()); ...
cf2293e5-b056-4baa-adc1-b80631de881e
7
public static VideoThumbnail[] generateThumbnails(int idealNumber, File source, File workingDir, int w, int h) { FfmpegFileInfo info = getFileInfo(source, workingDir); if (info == null) { return null; } double duration = info.getDuration(); int width = info.getW(); int height = info.getH(); int calcula...
fd2710e8-73c0-4405-b928-66b721b99202
0
public Pair(double f, double s) { first = f; second = s; }
fb32fd6f-d278-4167-ae3e-505cbd52d28c
3
private int getValienMaara(int korkeus) { if (korkeus == 1) { return 1; } if (korkeus == 2) { return 3; } int eka = 3; int toka = 1; int palautettava = 0; for (int i = 2; i < korkeus; i++) { palautettava = eka * 2 + toka...
877df197-3708-4e7d-b7b9-0af2e4f44ab3
4
private boolean read() { try { final URLConnection conn = this.url.openConnection(); conn.setConnectTimeout(5000); if (this.apiKey != null) { conn.addRequestProperty("X-API-Key", this.apiKey); } conn.addRequestProperty("User-Agent", "U...
87761fac-969e-464d-9edd-4f98b8e37bce
4
public static void main(String[] args) { CPBenchmark bench = new CPBenchmark(); if (args.length > 0 && args[0].equals("blending")) { bench.blendingBenchmark(args); } else if (args.length > 0 && args[0].equals("dabs")) { bench.brushDabsBenchmark(args); } else { System.out.println("no valid benchmark se...
899a3a2b-5dcb-4abf-9f57-de6248f6a9d6
8
public void run() { data[0] = (Long.MAX_VALUE/crewObj.getThreads()) * id - crewObj.getRandomOne(); long speed = 0; int time; int time_prev = 0; while(!isStopped) { if(crewObj.isDone()) break; if(Utils.isHashAccepted(crewObj.hashFunction.computeHash(Utils.createBytes(data)), crewObj.getDiff())) ...
248c7af3-0600-49b0-9efb-379f4cbda15a
3
public static Integer getIntNullable(ByteBuffer in) { int a = in.get() & 0xFF; if (a == NULL) { return null; } int sign = (a & BYTE_SIGN_NEG); int value = (a & 0x1f); int shift = -2; while ((a & BYTE_MORE) != 0) ...
ac900729-b04e-491f-986d-bd820d4a4f2e
5
public void closeEntityManagers(long ownerId) { List<ScopedEntityManager> ems; if (ownerId==0) { // close all instances, entire app context was destroyed ems = new ArrayList<ScopedEntityManager>(); synchronized(this) { for(List<ScopedEntityManager> list : emList.values()) ems.addAll(list); emL...
a7c0a553-94b7-4fb1-89f9-e6c8b822174d
9
public void printMatrixString(){ int[][] networkMatrix; //int[INPUT][OUTPUT] networkMatrix = new int[numNodes][numNodes]; //initialise for(int i=0; i<numNodes; i++){ for(int j=0; j<numNodes; j++){ networkMatrix[i][i] = 0; } } Node node; for(int i=0; i<numNo...
be2a1490-cf80-4548-8fca-1b115bc25880
9
private void doAnim(Graphics g, double timeDiff, ImageObserver observer) { Player c = EntityStore.self().getCombatant(entityID); int facing = c.getDirection(); boolean moving = c.isMoving(); if(animCount <= 0){ //Slows down animation if (!moving) { //If he is standing still imageIndex = (facing + 3) / 2 ...
bbd0d443-eec8-4c4b-8bd6-b5f0946ba55a
0
public Agent() { neighbours = new Vector(); }
8ce7c717-d4b6-4b38-a77d-9b779685650e
4
public boolean validateInput () { int i = 0, j = 0; /* Uses nested for loops to check that all input is valid */ for (i = 0; i < 9; i++) { for (j = 0; j < 9; j++) { try { if (Integer.parseInt(entries[i][j].getText()) < 1) { return false; } } catch (Num...
592ec798-d72d-41bc-9584-0ef953815115
3
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) @Override public void create(Medicine medicine) { EntityManager em = emf.createEntityManager(); Query q = em.createQuery("Select m from Medicine m where m.name=:name and m.releaseForm=:releaseForm and m.ages=:ages and m.qua...
569c4ecf-6cf5-47ee-b8a3-36cd59d2910d
2
public static boolean isProductionInGrammar(Production production, Grammar grammar) { Production[] productions = grammar.getProductions(); for (int k = 0; k < productions.length; k++) { if (production.equals(productions[k])) return true; } return false; }
3051c6cb-21a1-4c0e-95dd-0078747375d8
4
public void getSpeared(int otherX, int otherY) { int x = c.absX - otherX; int y = c.absY - otherY; if (x > 0) x = 1; else if (x < 0) x = -1; if (y > 0) y = 1; else if (y < 0) y = -1; moveCheck(x,y); c.lastSpear = System.currentTimeMillis(); }
5e055731-332a-4df4-8e34-163fae8dda08
7
protected void processConditionalSection(IXMLReader reader, IXMLEntityResolver entityResolver) throws Exception { XMLUtil.skipWhitespace(reader, null); String str = XMLUtil.read(reader, '%'); char ch = str.charAt(0); if (ch != 'I') {...
21959679-355f-4653-afbf-e47fbc46b82a
8
public static void replaceControlCharacters(Node node, char replacement) { String value = node.getNodeValue(); if (value != null) { boolean modified = false; byte[] bytes = value.getBytes(); for (int b = 0; b < bytes.length; b++) { if (!isRegularChar(...
a7c3eca7-ee1a-4b02-bbaf-b53a1a35c0ef
9
public FilterDef.Source asSource() throws IOException, FilterDefFormatException { final Map<FilterDTO.Type, List<String>> patternsByType = new HashMap<FilterDTO.Type, List<String>>(); LineNumberReader input = new LineNumberReader(new InputStreamReader(getInputStream(), TEXT_CHARSET)); // read lines until eof ...
d717d933-2fa5-4ed6-bcb1-a34dbabc57dd
9
void drawVectorPart(Grid grid, int type,int h,int l){ if(grid == null) return; if(h == 85) return;//ぬるぽ対策 int height = h;//高さ80 int test = grid.getNumGridPoint()[0]*height;//描画する最初の要素 int next = grid.getNumGridPoint()[0]*grid.getNumGridPoint()[1];//描画する次の列 int num = 0; double[] gpos = new double[3]; do...
aeebf472-4def-4090-9746-6e3836c86a41
4
@Override public String toString() { StringBuilder output = new StringBuilder(); output.append(getClass().getSimpleName()); output.append(" "); output.append(getId()); output.append(" {"); for (Field f : getClass().getDeclaredFields()) { if ((f.getModifiers() & (Modifier.STATIC | Modifier.FINAL)) != 0) ...
d7cf2c37-c698-4e39-9ecf-0d9b5fd41eb4
5
public void move(Direction dir) { int x = 0, y = 0; if (dir == Direction.LEFT) x = -1; else if (dir == Direction.RIGHT) x = 1; else if (dir == Direction.UP) y = -1; else if (dir == Direction.DOWN) y = 1; setLocation(location().x + x, location().y + y); for (Point p : attachedPoints) { p.x = p.x + x; ...
13d9fc8e-d895-4dab-b210-7df3f13c5878
8
public synchronized void getAttacked(AtomicInteger power, StateActor state){ life.getAndAdd(-power.get()); //Deals the damage. switch(state){ //Knockback effect. case ATTACKINGUP : if(getPosition().getY()-15>24*2*GameManager.SCALE){ position.setXY(position.getX(), position.getY()-15); } break; ca...
e321ba95-648b-4500-aa92-c074b9e9f390
6
private static void doCopyFile (File srcFile, File destFile, boolean preserveFileDate) throws IOException { if (destFile.exists() && destFile.isDirectory()) throw new IOException("Destination '" + destFile + "' exists but is a directory"); FileInputStream fis = null; FileOutputStrea...
d484e012-f5a2-4aef-9e0b-96f2edca96f7
2
public final double getDouble(String key) throws JSONException { Object o = get(key); try { return o instanceof Number ? ((Number)o).doubleValue() : Double.valueOf((String)o).doubleValue(); } catch (Exception e) { throw new JSONException("J...
b4028cc6-bf3e-45c7-9edf-b40223444cc0
5
public String toString() { String print=""; // Print the day if (this._day < 10 & this._day >= 1) print += "0"+this._day+"/"; else if (this._day == 0) // If Day zero don't print it print += ""; else print += this._day+"/"; if (this._month < 10 & this._month >= 1) print += "0"+this._month+"/...
f8ec61b5-7b0f-4d38-bfe3-1ab881edbc6c
3
public static void checkAllPositives(String customerId) { // External iteration boolean allPositives = true; for (BankAccount account: christmasBank.getAllAccounts()) if ( account.getCustomerId().equals(customerId) && (account.getBalance().signum() < 0) ) { allPositi...
751d9ffc-35d5-492f-9e93-9b54b8448155
8
private boolean initLocale(String language) { boolean success=false; String iso839_1_lang; if(language == null) { this.loc = null; } else if(language.isEmpty() || language.equalsIgnoreCase("xxx") || language.equalsIgnoreCase("xx")) { this.loc = null; success=tr...
3e8630ad-bdc6-4735-8670-5ad6f60c61c9
9
public static boolean ordinalNumberStringP(String teststring) { { int len = teststring.length(); boolean teenP = (len > 3) && ('1' == teststring.charAt((len - 4))); String suffix = "th"; if (len < 3) { return (false); } { char c = Stella.NULL_CHARACTER; Strin...
3af6e6db-4b37-4131-ae83-9a998fb197a9
9
private void dialogoConfirmarAlta(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dialogoConfirmarAlta if (jTextField1.getText().isEmpty() || jTextField1.getText().equals("Título") || jTextArea1.getText().isEmpty() || jTextArea1.getText().equals("Descripción") || jTextField2.g...
528a7bc3-5bd1-47ee-940a-9beac388d34d
8
public void cariPembeli(javax.swing.JTextField no_beli){ if (!no_beli.getText().equals("")){ if (pembeli.baca(no_beli.getText())){ FormUtama.formKwitansi.setNama(pembeli.getNama()); FormUtama.formKwitansi.setAlamat(pembeli.getAlamat()); FormUtama.formK...
2a85b857-19c5-4504-8e87-41a118a2dcbc
3
public static long getMaxRectangleSum() { int ROWS = m.length, COLS = m[0].length; long[] comp = new long[ROWS]; long maxArea = 0; for (int left = 0; left < COLS; left++) { Arrays.fill(comp, 0); for (int right = left; right < COLS; right++) { for (int r = 0; r < ROWS; r++) comp[r] += m[r][right];...
daede82b-fa2b-4924-b114-3cf331c2e987
9
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession sess = request.getSession(false); String reqURI = request.getRequestURI() ; AccessPointName apn = this.ni.inspect(reqURI); log.debug("Request url: " + reqURI); if (StringUtils.isNotEmpty(a...
d71acc38-9680-45db-9a0b-24462e070e59
5
@Override public void run() { super.run(); RUN = true; String data =""; while(RUN){ try { if(server.getLigneALL().size()>0) if((data=ConnexionType.BUS.recevoirUDP(socket)).equals("QUIT")) { }else{ JSONObject json = (JSONObject)JSONValue.parse(data.toString().trim()); Sys...
bcb4449b-e060-4eba-94df-f231ad9888b3
8
public String print(){ char s[][] = new char[w][h]; for( int i=0;i<w;i++) for (int j=0;j<h;j++){ if (anet[i][j]==AGENT){ s[i][j]='0'; } else{ switch (net[i][j]) { case DIRTY: s[i][j]='*'; break; case CLEAN: s[i][j]='_'; break; ...
cfc394ea-7d66-451b-823c-c39b6c7f0c5f
8
public void resetPositionOnCollision(Rect rect) { // Helper.log(this.getClass().getName() + ": resetPositionOnCollision()"); // Helper.log("xCollision: " + xCollision + " yCollision: " + yCollision); boolean movedUp = false; boolean movedDown = false; boolean movedLeft = false; boolean movedRight = false; ...
424c2c4a-f516-4141-8ecc-3df123dd380c
9
public void gas(MOB mob) { if(CMLib.dice().rollPercentage()<mob.charStats().getSave(CharStats.STAT_SAVE_TRAPS)) mob.location().show(mob,affected,this,CMMsg.MSG_OK_ACTION,L("<S-NAME> avoid(s) a gas trap set in <T-NAME>.")); else if(mob.location().show(mob,affected,this,CMMsg.MSG_OK_ACTION,L("<S-NAME> trigger(s...
70150a88-ac8b-40c4-b402-76e83a4c05d7
9
public static String interruptThread(String threadNamePattern) throws Exception { ThreadGroup root = Thread.currentThread().getThreadGroup(); final StringBuilder msg = new StringBuilder(); boolean found = false; for (; root.getParent() != null; root = root.getParent()) ; ...
40af3a32-edf2-407e-b459-3597b0e74fa9
1
public void visitForceChildren(final TreeVisitor visitor) { if (visitor.reverse()) { bits.visit(visitor); expr.visit(visitor); } else { expr.visit(visitor); bits.visit(visitor); } }
b06c58da-d2fa-4569-9ec8-1f6029ffe25c
7
private String apply(String name, Rule rule, Case $case) throws CantApplyRuleException, UnknownCaseException { StringBuilder result = new StringBuilder(name.length() + 5).append(name); CharacterIterator itr = new StringCharacterIterator( modificatorFor($case, rule) ); char $...
740d69c3-4922-4b42-bfd6-7c4ff6cd5a2b
2
boolean thesameowner(Point pt, Pair tmp) { for (int i=0; i<pt.ownerlist.size(); i++){ if (pt.ownerlist.get(i).x==tmp.x) return true; } return false; }
4ccbc53e-1945-456c-9cf3-e6dd0b204354
9
public String getFriendlyName() { switch (bestRank) { case FLUSH: return "Flush"; case FOUR_OF_A_KIND: return "Four of a kind: " + high.capitalise() + "s"; case FULL_HOUSE: return "Full house: " + high.capitalise() + "s full of " + ...
1cf5ead9-e05d-4912-9212-23c9c67d5e7b
9
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof OFMessage)) { return false; } OFMessage other = (OFMessage) obj; if (length != o...
bf3a1806-d63c-4efc-b646-1a13f2c717cf
3
@Override public void action() { if(agente.getPasso() == 7){ System.out.println("Passo 7 AI - " ); Iterator<ListaDeCupons> it = agente.getCuponsASeremComprados().iterator(); while(it.hasNext()){ ListaDeCupons lista = it.next(); ACLMessage mensagem = new ACLMessage(ACLMessage.ACCEPT_PROPOSA...
a722d5d8-e4b1-4227-a35a-526a4bb30a1f
2
public static ArrayList<Product> showAll() { ArrayList<Product> products = new ArrayList<Product>(); Database db = dbconnect(); try { db.prepare("SELECT * FROM product ORDER BY PID"); ResultSet rs = db.executeQuery(); while(rs.next()) { products.add(ProductObject(rs))...
37d0f7e3-8399-410a-b092-6d6a72adb61f
7
private void createTask(HashMap<Keyword, String> parameters) { String value; Task task = new Task(); for (Keyword key : parameters.keySet()) { value = parameters.get(key); if (key.equals(Keyword.CONTENT)) { task.setValue(key, value); } else if...
28744b32-068c-4a22-beed-7d7adad7b13b
5
public void setOutputParamReal(final int paramIndex, Object array) throws IllegalArgumentException, NullPointerException, ClassCastException { if (array==null) throw new NullPointerException(ARRAY_IS_NULL); OutputParameterInfo param = getOutputParameterInfo(paramIndex); if ((param==null)||(param...
c21e182e-9770-4f09-a595-3e8d995a1869
2
public boolean copyLibraries() { File mine = VersionInfo.getMinecraftFolder(); File oldLib = new File(mine, "libraries"); File newLib = new File(mine, "launcher"); if (oldLib.exists()) { try { FileUtils.copyDirect...
6d065a66-d31a-4d1b-8e4c-74d4328842b6
3
public void actionPerformed(ActionEvent arg0) { if(arg0.getSource() instanceof JButton) { JButton source = (JButton) arg0.getSource(); if(source.getText().equals("Start Game")) { yamg.runApplication(); } else if(source.getText().equals("Exit")) { System.exit(0); } } }