method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
6eafed5d-ebda-4a12-b05f-ca4c31f11ca3
7
public String strStr(String haystack, String needle) { // Start typing your Java solution below // DO NOT write main() function int m = haystack.length(); int n = needle.length(); if (n == 0) return haystack; if (m == 0 || m < n) return null; int[] next = getNext(needle); int i = 0, j = 0; whil...
904a2143-491f-4d0e-9347-13b2189426b5
8
@Override public boolean execute(MOB mob, List<String> commands, int metaFlags) throws java.io.IOException { if((mob==null)||(mob.playerStats()==null)) return false; if(commands.size()<2) { final String wrap=(mob.playerStats().getWrap()!=0)?(""+mob.playerStats().getWrap()):"Disabled"; mob.tell(L("Ch...
9b31d3ef-7767-46c4-9063-5d76e74faa47
5
public void getImportLines( String fileName ) { File exportFile = new File( fileName ); BufferedReader br = null; try { br = new BufferedReader( new FileReader( exportFile ) ); String line = ""; // find start of protected imports while ( !line....
0aacf392-63d4-408c-aefd-7594c63ab80e
9
private void processLine(RdpPacket_Localised data, LineOrder line, int present, boolean delta) { if ((present & 0x01) != 0) line.setMixmode(data.getLittleEndian16()); if ((present & 0x02) != 0) line.setStartX(setCoordinate(data, line.getStartX(), delta)); if (...
c08eca70-622d-4a86-91ba-d5d6156abd55
5
public void mouseDragged(MouseEvent e) { if (mouseDown == true) { if (e.getX() < mouseX) cube.rotateXZ(ROTATIONSPEED); else if (e.getX() > mouseX) cube.rotateXZ(-ROTATIONSPEED); mouseX = e.getX(); if (e.getY() < mouseY) cube.rotateYZ(ROTATIONSPEED); else if (e.getY() > mouseY) ...
23cab06e-3d51-4d52-89c9-9071d6c6b02b
3
public static void sendRemainingTime(CommandSender sender, Main main) { Date date = main.getDM().getNextArena(); String time = ""; if (!date.isTomorrow()) { Time comparedTime = Time.compareInaccurate(date.getInaccurateTime(), Time.currentInnacurateTime()); System.out.println(comparedTime); if (compare...
c3a8f2e2-5a13-4160-906b-02cc55e11df7
3
private boolean touchWall(double xt, double yt) { return (xt <= (Board.WIDTH - this.width)) && (xt > this.width) && (yt <= Board.HEIGHT - this.height) && (yt > 0); }
79ce14d8-b49c-4158-ac47-4c5b741e2ddf
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final WhoHasRequest other = (WhoHasRequest) obj; if (limits == null) { if...
91610271-96c3-4d92-b9a7-d693b49434cd
7
private String useRbondVariables(String s, int frame) { int n = model.getRBondCount(); if (n <= 0) return s; int lb = s.indexOf("%rbond["); int rb = s.indexOf("].", lb); int lb0 = -1; String v; int i; RBond bond; while (lb != -1 && rb != -1) { v = s.substring(lb + 7, rb); double x = parseMath...
b02f4c50-9756-4005-96cb-01a4862c4943
3
void setImage(Path image, Brandingsize size) { switch (size) { case SMALL: this.imgSmall = image; break; case MEDIUM: this.imgMedium = image; break; case LARGE: this.imgLarge = image; ...
e3549aae-4d89-48be-9ea3-fc507495f25d
4
public static void main(String[] args) { boolean check; long i = 21; while(true) { check = true; for(int j = 1; j < 21; j++) { if(i % j != 0) check = false; } if(check) { System.out.println(i); break; } i++; } }
d03953f8-679f-4ec1-8e46-ce80798f6e6a
1
public void print() { while (q.size() != 0) { System.out.println(getNumber()); } }
e7190cf1-cf0b-460e-bf4a-d950e581653a
5
@Override public void paintComponents(Graphics g) { if (!this.skin.getAccButtonPosition().equals(Position.NONE)) { Graphics g2 = g.create(); int x, y; int w, h; Rectangle bounds = this.parent.getBounds(); if (this.skin.isChanged() || (this.ground...
30249fd3-3b0f-486d-a26e-0f88a07c426b
4
@Override public void run() { while (runGameLoop) { if (traced()) { System.out.println("game loop:"); } updateGameStatus(); handleCollisions(); frame.repaint(); if (is(TraceFlag.DRAWS)) { System.out.println("\trepaint"); } try { Thread.sleep(frameTime); } catch (InterruptedExce...
af7a775e-8330-4718-a014-68724ac0adf2
2
private void convertPixelToRGB() { rgbArray = new int[height][width][3]; int rgb; for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { rgb = img.getRGB(col, row); rgbArray[row][col][0] = (rgb >> 16) & 0xff; //red ...
5851a932-3fd6-49b1-8a85-3bb4e4d07b57
0
public int f() { return 1; }
fbeab8ea-504a-469d-ae7a-d19d283edc82
2
public MemberValue getMemberValue(String name) { if (members == null) return null; else { Pair p = (Pair)members.get(name); if (p == null) return null; else return p.value; } }
01eb8b49-5997-4eda-91e2-8d81ff591bd1
9
public static TUnit doLeverage(TUnit inputUnit, ArrayList<TUnit> translationMemories, int fuzzyLimit, boolean checkFile, boolean checkID) { //Check fuzzy limit if (fuzzyLimit<0) { fuzzyLimit=0; }else if (fuzzyLimit>100) { fuzzyLimit=100; } if (inputUnit==null || translationMemories==null ) return inputU...
8123d861-5a99-49d9-ae19-80427e4b6c65
7
public static Cons cppGetStaticVariableDefinitions(Stella_Class renamed_Class) { { Cons staticmembervardefs = Stella.NIL; { Slot slot = null; Iterator iter000 = renamed_Class.classSlots(); while (iter000.nextP()) { slot = ((Slot)(iter000.value)); if (Stella_Object.storage...
162ed396-cd61-40c1-8536-072d553a1412
8
String exceptionMessage(ExceptionEvent event) { ObjectReference exc = event.exception(); ReferenceType excType = exc.referenceType(); try { // this is the logical approach, but gives "Unexpected JDWP Error: 502" in invokeMethod // even if we suspend-and-resume the thread ...
aad1d568-7d9f-49cc-824a-a89216ed53b8
8
private void pushTerm(BytesRef text) throws IOException { int limit = Math.min(lastTerm.length(), text.length); //if (DEBUG) System.out.println("\nterm: " + text.utf8ToString()); // Find common prefix between last term and current term: int pos = 0; while (pos < limit && lastTerm.byteAt(pos) == tex...
55c80179-0f2e-4ef6-b8ef-62e5c42a67e5
5
@Test public void depthest11opponent5() { for(int i = 0; i < BIG_INT; i++) { int numPlayers = 6; //assume/require > 1, < 7 Player[] playerList = new Player[numPlayers]; ArrayList<Color> factionList = Faction.allFactions(); playerList[0] = new Player(chooseFaction(factionList), new SimpleAI()); ...
c2ecd6cc-8746-409a-9e10-f8a1ee9a6862
3
public static void allocateHuffmanCodeLengths (final int[] array, final int maximumLength) { switch (array.length) { case 2: array[1] = 1; case 1: array[0] = 1; return; } /* Pass 1 : Set extended parent pointers */ setExtendedParentPointers (array); /* Pass 2 : Find number of nodes to rel...
a814b640-c1ad-471c-83a3-a527e5853878
5
private void addJob(ArrayList<String> players, String job, CommandSender sender) { job = job.toLowerCase(); if (PlayerJobs.getJobsList().get(job) == null) { sender.sendMessage(ChatColor.RED + _modText.getAdminCommand("exist", PlayerCache.getLang(sender.getName())).addVariables(job, "", sende...
b6013701-b0ef-4597-8e31-1013d3043ba2
7
public Object nextContent() throws JSONException { char c; StringBuffer sb; do { c = next(); } while (Character.isWhitespace(c)); if (c == 0) { return null; } if (c == '<') { return XML.LT; } sb = new Str...
60ac5036-08bd-4606-8c0b-609b2d081ad1
2
@Override public void actionPerformed(ActionEvent e) { OutlinerDocument doc = (OutlinerDocument) Outliner.documents.getMostRecentDocumentTouched(); OutlinerCellRendererImpl textArea = doc.panel.layout.getUIComponent(doc.tree.getEditingNode()); if (textArea == null) { return; } Node node = textArea.n...
34772488-f1e9-4fa8-9e0b-3932afe67f85
3
public static void main(String[] args) { Display.setTitle("This is a game."); try { Display.setDisplayMode(new DisplayMode(1280, 720)); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.out.println("Failed to initialize the display"); } GL11.glDisable(GL11.GL_DEPTH_T...
953e8d7c-9d18-4c76-8417-85b296e284e2
0
public int getMarq(int indice){ return tabMarq[indice]; }
0c648a75-47f3-407f-8884-9e50afb83eca
2
public static boolean anyKeyPress(){ for(int i = 0; i < NUM_KEYS; i++) if(keys[i]) return true; return false; }
6522d39c-294c-4932-b44f-7c1a7209da8f
1
private void toFastboot_adbMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toFastboot_adbMenuActionPerformed try { adbController.rebootDevice(selectedDevice, RebootTo.BOOTLOADER); } catch (IOException ex) { logger.log(Level.ERROR, "An error occurred while r...
d1a1e703-1502-4234-8aed-8fd455b29e81
7
public static void main(String[] args) throws Exception //TODO handle exception differently? { engine = GameEngine.getInstance(); MapFactory mf = new MapFactory(50, 50); //this method is where an exception could, but won't, be thrown. GameMap map = mf.createDefaultSizeMap("LargeSwamp"); engine.bindMap(map); ...
13ce5d60-0f59-460b-9bf2-fb41462ab46b
5
public static ArrayList<Fine> getAllFines(){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ArrayList<Fine> fineList = new ArrayList<Fine>(); t...
eceb81b1-e1cd-4c21-ad50-a82d90325840
6
private static int partition(int[] a, int lo, int hi) { int i = lo; int j = hi; while(true) { while(a[++i] < a[lo]) { if(i == hi) break; } while(a[lo] < a[--j]) { if(j == lo) break; } if(i >= j) break; exch(a, i, j); } exch(a, lo, j); // Puts the low thin...
02a53c31-6def-48cd-8545-69adf483974d
3
@Override public void actionPerformed(int ID) { switch(ID){ case 0: this.setVisible(false); guiManager.startGame(); break; case 1: this.setVisible(false); guiManager.showOptionsMenu(); break; case 2: guiManager.closeGame(); break; } }
264454f1-9f30-4c85-820c-c8bea03c08f5
9
public int remap(int oldDocID) { if (oldDocID < minDocID) // Unaffected by merge return oldDocID; else if (oldDocID >= maxDocID) // This doc was "after" the merge, so simple shift return oldDocID - docShift; else { // Binary search to locate this document & find its new docID ...
de6cf386-5a7b-4408-9756-00959307f967
8
@Override protected void refreshFromRemote() throws IOException { CachedUrlResolver urlResolver = new CachedUrlResolver(); String urlRef = getUrl().getRef(); String partNum = PartFactory.getInstance().scrapeText(urlRef, startId, endId).toUpperCase(); String queryUrl = queryUrlTemplate.replaceAll("\\{P...
3fedfd1a-6a1a-46c9-87a7-1f855e6a94ff
5
private static int show(int t[]) { final char VIDE = '*'; // constante du charactère lorsque la case est vide int i; // contient un compteur String output = ""; // contient le tableau à être afficher // première ligne for(i = 0; i < t.length; i++) { out...
433eb9ff-1ebb-4dc8-ba72-f57e096db107
1
public void start(ClassPool pool) throws NotFoundException { classPool = pool; final String msg = "javassist.tools.reflect.Sample is not found or broken."; try { CtClass c = classPool.get("javassist.tools.reflect.Sample"); trapMethod = c.getDeclaredMethod("tra...
083e5ee5-236a-4693-8eb1-8ac081f71bd6
3
public static HashSet<Row> collectContainerRows(List<Row> rows, HashSet<Row> containers) { for (Row row : rows) { if (row.canHaveChildren()) { containers.add(row); if (row.hasChildren()) { collectContainerRows(row.getChildren(), containers); } } } return containers; }
4d9f3f18-72af-409d-be24-47fd4c411a39
3
public PrimaryApproach() { numGraph = new ArrayList<PositionGraph>(); boxProbability = new Probability [9][9]; for(int j=0;j<9;j++) { for(int k=0;k<9;k++) { boxProbability[j][k]=new Probability (); } } for(int i=0; i < 9; i++){ PositionGraph temp = new PositionGraph(); numGraph...
c11e9682-072a-4372-98b4-7c082579ed03
2
@Override public void updateIngredient(Ingredient c) throws IngredientRepositoryException { validate(c); for(int i = 0; i<ingredientRepository.size(); i++){ if(ingredientRepository.get(i).getIngredientId() == c.getIngredientId()){ c.setName(c.getName().toUpperCase()); ingredientRepository.set(i, c); ...
81faf190-5776-4648-8b0e-d8827e809460
5
private double calNocturnas(int h1, int m1, double h) { int horaEnt = h1; double minutoEnt = m1; double nocturnas; double horas = h; double ent = horaEnt + (minutoEnt / 60); if (ent <= 6) { nocturnas = (6 - ent); if (nocturnas > horas) { ...
b5b49b45-0576-4fde-bb1c-14cb0adc1e8b
4
public void generateWave() { int numStars,starPosX=0,starPosY=0,starWidth,starHeight,starVelocity, starHgap; int r,g,b; Color starColor; //generate num of stars numStars = MIN_NUM_STARS + (int) (Math.random()*(MAX_NUM_STARS-MIN_NUM_STARS)); //generate stars wave ...
7ff07676-2b70-4bfe-a400-2e5ef8be5d6f
0
public void setCtrFormaPago(String ctrFormaPago) { this.ctrFormaPago = ctrFormaPago; }
bb52a643-eb57-4ea3-b686-74984f395e15
8
public void addViewListener(final YController controller) { this.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { // checking if event is really triggered by user... if (!sett...
3ecd4f0c-41c8-4ca4-9fd7-fd69329f93ec
2
private void writeBit(int bit) throws IOException { if (bit == 0) this.bits <<= 1; else this.bits = this.bits << 1|1; this.offSet++; if (this.offSet == 8) { this.ecrire.write(this.bits); this.bits = 0; thi...
05a27880-7d37-46ad-9fc7-22c7cd02cc36
5
public void ejecutarComputadora(String mov){ if(mov != null){ switch(mov){ case "up": this.arriba(); break; case "down": this.abajo(); break; case "left": ...
72b85d8f-2cd2-48da-bee6-d4a4508ab35b
3
protected void _processWalks(WalkArray walkArray, int[] atVertices) { long[] walks = ((LongWalkArray)walkArray).getArray(); long t1 = System.currentTimeMillis(); for(int i=0; i < walks.length; i++) { long w = walks[i]; if (ignoreWalk(w)) { continue; ...
fda32e8c-1579-4cd1-85ca-97081cc38477
8
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) { MovingObjectPosition amovingobjectposition[] = new MovingObjectPosition[8]; int i = par1World.getBlockMetadata(par2, par3, par4); int j = i & 3; boolean flag =...
7ed75f6a-3ffa-4f1e-a812-ceefe93f266f
2
public static int arrayEqualUntil(char[] a, char[] b, int aStart, int bStart, int length) { for(int i=0;i<length;i++) { if(a[aStart+i] != b[bStart+i]) { return i-1; } } return length-1; }
a59826dd-ea22-4c4a-90fc-b80c123059b0
8
public void addToGroup(GroupAi g, Piece p) { if (p == null || g.pieces.contains(p) || (g.pieces.size() > 0 && g.pieces.toArray(new Piece[0])[0].team != p.team)) { return; } int row = p.where.row; int col = p.where.col; g.pieces.add(p); if (col > 0) { addToGroup(g, squares[row][col - 1].piece); ...
53ecd945-e135-40cc-affb-e257a9ec1cdb
6
public void runMenu () { //do while loop for the menu do { // initialise instance variables displayMainMenu (); promptChoice(); if (choice == 1) { //navigates the user to English to BLISS System....
23553142-09ed-4bb0-a7fb-2091ae3fed64
0
public static int getTotalGamesPlayed() { return totalGamesPlayed; }
687f2fb0-2537-4065-91fb-44b91c33777a
0
public void onTick(Instrument instrument, ITick tick) throws JFException { }
4db81604-7da7-476e-9af1-5cb0b3796dcc
7
public static void checkVersion(){ if(!global.checkUpdate) return; URLDownloader url=new URLDownloader("http://javablock.sourceforge.net/version", ""); //url.get1(); String v; v=url.get1(); String ver=""+global.version; if(true) return ; if(v!=null) ...
4457eeab-f692-4585-986a-c683cb79174d
5
private boolean legalMove(int from_x,int from_y,int to_x, int to_y) { int dir_x, dir_y; int dist; dir_x=(int)Math.signum(to_x-from_x); dir_y=(int)Math.signum(to_y-from_y); if ((dir_x==0) && (dir_y==0)) return false; dist=computeDistance(from_x,from_y,dir_x,dir_y); if (dir_x==0) re...
a0c9625a-8eef-4464-b008-6f8ec7baa2b5
2
public Board generateFromCharArray(char[][] input) { AState[][] map = new AState[input.length][input[0].length]; for(int rowNum = 0; rowNum < input.length; rowNum++) { for(int colNum = 0; colNum < input[rowNum].length; colNum++) { boolean block = input[rowNum][colNum] == 'x'; boolean start = inp...
0b1a126b-f284-4387-9983-dda34bb034e1
3
public static Double[] calculatePrecisionAndRecall() { Double[] precisionAndRecall = new Double[2]; double relevantDocumentsRetrieved = 0; double totalRetrievedDocuments = resultsDocPairs.size(); Iterator it = resultsDocPairs.entrySet().iterator(); while (it.hasNext()) { ...
71d846a8-648a-469c-b04e-aa5848433724
7
private static void manageExtends(ClassDiagram system, Map<String, RegexPartialMatch> arg, final Entity entity) { if (arg.get("EXTENDS").get(1) != null) { final Mode mode = arg.get("EXTENDS").get(1).equalsIgnoreCase("extends") ? Mode.EXTENDS : Mode.IMPLEMENTS; final String other = arg.get("EXTENDS").get(2); ...
ce9f0c0b-508f-40df-b345-368b719353c4
9
public synchronized void checkThread(Callable workToDo, Callable callback, Integer limitRate) throws DropCountExceededException { if (workToDo != null) { try { this.checkThread(null, callback, null); workToDo.call(); this.releaseThread(); ...
6ee0775c-1382-4827-ab1b-85bb5ae37c34
9
public void init(){ String incoming = null; int currentIndex = 0; BufferedReader input; Socket connectionSocket; boolean rulesSend = false; try{ serverSocket = new ServerSocket(port); System.out.println("Server is running at port " +port); while(true){ try{ if(serverSocket.isClosed(...
544a14b7-aa54-42e5-bad9-6e697c2666b4
0
public final AbstractHash<K> getHash() { return hash; }
532d9ccf-3cd7-4724-b6f9-dd2039e801cd
5
private Color verticalWinner() { for (int i = 0; i < board.length; i++) { Color current = Color.NONE; int length = 0; for (int j = 0; j < board[0].length; j++) { if (current == board[i][j]) { length += 1; } else { ...
d5e4a029-44ef-4b72-992a-69efd3fcc224
8
public ArrayList<SalesStaticsBean> querySales(String main_type,String name,String issue_date_begin ,String issue_date_end){ ArrayList<SalesStaticsBean> al = new ArrayList<SalesStaticsBean>(); Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; SalesStaticsBean s = null; try { con...
650bc1f5-70d6-45d1-8c55-232b5e5fb35c
3
public void actionPerformed(ActionEvent event) { // ActionEvent from "connect" Button if(event.getSource() == buttonConnect) { String host = txtHost.getText(); int port = Integer.parseInt(txtPort.getText()); try { // Generate a TCP Client and start it as a Thread tcpclient = new TCPClient(new So...
74342f28-a57a-4cf5-8429-2caa44354f7c
3
public static void main(String[] args) { // ResultSetHandler<Object[]> resultSetHandler = new ResultSetHandler<Object[]>() { // public Object[] handle(ResultSet rs) throws SQLException { // if (!rs.next()) { // return null; // } // // ResultSetMetaData meta = rs.ge...
9b2ed469-4c45-427a-aa9e-c8f551a9c794
1
public static void closeSession() throws HibernateException { Session session = (Session) threadLocal.get(); threadLocal.set(null); if (session != null) { session.close(); } }
425f93f4-b905-4526-863d-0d343361df25
8
public static void main(String[] args) { Assert.checkNonNull(inputFileName, "InputFileName cannot be null"); try { // String buffer for storing the output StringBuilder output = new StringBuilder(); // read and parse input file URL fileUrl = classLoader...
b3965bf9-6752-468e-9aed-7760519552ac
9
private byte[] loadCompressedBinaryData(InputStream is) throws IOException, UnsupportedEncodingException { ByteArrayOutputStream output = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int bytesRead; // load md5 sum MessageDigest md; try { md = MessageDigest.getInstance(DIGEST_MD52); ...
a0013efd-1212-4d05-8375-0ab0d4495b04
5
public void close() { if (_isAlive){ try { _clientSocket.close(); if (_in != null){ _clientSocket.shutdownInput(); _in.close(); } if (_out != null){ _clientSocket.shutdownOutput(); _out.close(); } } catch (IOException e){ if (!_serverStop.getValue()) System.out.p...
6ddcb3a7-e014-450a-bb33-1f9608b59ac1
0
public Status getByValue(String value) { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Status.class); criteria.add(Restrictions.eq("value", value)); return (Status) criteria.uniqueResult(); }
4fbd58c6-6bf1-4190-807a-791281353210
4
public boolean ColumnExists(Connection conn, String tname, String cname) { DatabaseMetaData md; ResultSet rs; try { md = conn.getMetaData(); } catch (SQLException e) { // This shouldn't really happen plugin.Warn("Unable to read DatabaseMetaData from DB connection!"); e.printStackTrace(); retur...
781eb604-2c5c-46b8-b530-201c5e2a08df
2
public void addMacro(String name, String command){ if(!macros.containsKey(name)) { // we have a new macro println("/"+name+" {"+command+"} def"); macros.put(name, command); } else { if(!macros.get(name).equals(command)){ //print it as it is different to the one specified before with the same name p...
87a85b5e-e938-45a2-9e35-7e22fe4c7549
6
* @param unit The <code>Unit</code> to load. * @param goods The <code>Goods</code> to load. * @return An <code>Element</code> encapsulating this action. */ public Element loadCargo(ServerPlayer serverPlayer, Unit unit, Goods goods) { ChangeSet cs = new ChangeSet()...
a18df3bf-7057-4821-b3ac-51e519932a64
4
@Override public ByteBuffer getMessage() { buffer.clear(); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putShort((short) 0xaaa6); // sig buffer.putShort((short) 40); // byte len buffer.put((byte) 1); // rcmNodeId; buffer.put((byte) 0); // reserved for (short val : pwm) { buffer.putShort(val)...
368b14b4-3236-41c7-afe8-09b3fd9a1ebe
4
AbstractNode term() { AbstractNode node = factor(); while (test(MUL) || test(DIV)) { if (test(MUL)) { read(MUL, "*"); node = new BinOpNode(MUL_OP, node, factor()); } else if (test(DIV)) { read(DIV, "/"); node = new BinOpNode(DIV_OP, node, factor()); } } return node; }
c750114c-2912-4930-88fc-f3e87baeaf16
5
@Override public void actionPerformed(ActionEvent e) { try { if (e.getSource() == this.view.getJbCancel()) { this.view.dispose(); } else if (e.getSource() == this.view.getJbLoad()) { if (this.view.getJtTable().getSelectedRow() >= 0) { i...
bfe8f0e0-3482-4d12-847b-30342a04892c
7
@Override public boolean save(News news) throws DaoException { if (null == news) { return false; } PooledConnection connection = null; PreparedStatement pStatement = null; try { connection = (PooledConnection) cp.takeConnection(); pStatement = connection.prepareStatement(NewsDaoStatement.crea...
cd63254d-3dc8-4550-9b7c-2c9187e3edec
8
@Override public void cover(ImageBit[][] list) { ImageBit ib = new ImageBit(); for (int i = 0; i < 50; i++) { for (int j = 0; j < 50; j++) { ib = list[i][j]; if (ib.isCovered()) { continue; } Leg...
ce18025c-8fea-4c28-bace-5b314f37ffca
6
@Override public void buttonClicked(ButtonEvent event) { switch (event.getButton().getType()) { case SERVER: if (event.getButton().isActive()) networkHandler.shutDown(); else networkHandler.startServer(port); break; case CLIENT: if (event.getButton().isActive()) networkHandler.shutDown();...
3c5a1b75-cc66-4ad6-ad29-d6118e711d0f
6
public Shape(SimpleFeature f, String tipo){ // Algunos conversores de DATUM cambian el formato de double a int en el .shp // FECHAALATA y FECHABAJA siempre existen if (f.getAttribute("FECHAALTA") instanceof Double){ double fa = (Double) f.getAttribute("FECHAALTA"); fechaAlta = (long) fa; } else if (f.g...
92ddd8f5-889f-4d03-a88f-cdf6d4dcd495
3
public static void getTraitDescription(Tidy tidy, Document doc, Trait[] traits) { try { XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression expr = xpath.compile("//div[@id = 'bodyContent']/p/text() |" + "//div[@id = 'bodyContent']/p/a/text()"); NodeList nodes = (Node...
4a56790c-661c-4a5c-96c0-dd2325fe2bef
2
public MWUizer(String resource) { InputStream myResource = getClass().getResourceAsStream(resource); if (myResource == null) { MWUSet=new HashSet<String>(); System.err.println("I couldn't open the resource "+resource); System.exit(0); } else { MWUSet = loadResource(myResource); ...
58431f0c-613e-41c3-a5ad-4b02c57c19be
0
public FromFileGridFactory(String filename) { this.filename = filename; }
72a0bd28-a292-4264-a807-d382714810fc
1
public final void unlink() { if (previous == null) { } else { previous.next = next; next.previous = previous; next = null; previous = null; } }
410ff6c3-5ef6-41db-b0ae-b03c7e6e639c
9
public static void parse(File csvFile) { BufferedReader br = null; String line = ""; String cvsSplitBy = " = "; try { HashMap<String, String> map = new HashMap<String, String>(); br = new BufferedReader(new FileReader(csvFile)); while ((line = br.readLine()) != null) { String[] property = l...
ae9e14fe-29ab-4009-8567-d33c7b5daa4c
0
@Override public void keyTyped(KeyEvent e) { unprocessedEvents.add(e); }
b40a7eb8-2a08-4b67-889e-1c083b79d6a4
3
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tests = sc.nextInt(); String []in = new String[tests]; int i=0; while(tests>0 && i<in.length){ tests--; in[i] = sc.next(); i++; } for (String str : in){ System.out.println(solve(str)); } sc.close()...
bfc7dc4e-6cde-4bf2-a9b1-8e2e07818cc5
7
public static LinkedList addlists(LinkedList a, LinkedList b){ LinkedList result=new LinkedList(); //Logic is to iterate node by node and do simple addition of the digits as you iterate through the nodes //create two iterator nodes Node ita=a.head; Node itb=b.head; int carry=0; while(ita!=null || itb!=nul...
44326dc7-847a-404a-baa5-6e0b358d86a9
3
private int italicHandler(char[] chars, int i) { basicText.append("\\i "); String plainWord = ""; while (chars[i] != ' ') i++; i++; while (chars[i] != '}' && i < chars.length) { plainWord = plainWord + chars[i]; i++; } basicText.append(pla...
1fed1586-2d0d-4c50-91d2-2e080f93bf15
2
public synchronized void recordAndAddSequenceNumberToOutgoingPacket(Packet packet) { //ignore null packets if(packet == null) return; //add sequence number to packet lastSentPacketSequenceNumber = Packet.nextSequenceNumber(lastSentPacketSequenceNumber); packet.setSequenceNumber(lastSentPacketSequenceNumbe...
ee42aaa8-4b76-4ea9-aff4-1f5ec5ce7da5
6
public boolean validationSplit(String input) { // initialise instance variables boolean validated = false; String[] firstValidationArray = input.split(";"); //for loop that has an array to validate bliss numbers. for(int i=0;i< firstValidationArray.length;i++) ...
9d733abf-81fd-40b0-b1b6-a140f3b5138c
0
public void setColumnValue(Object columnValue) { this.columnValue = columnValue; }
53b5e528-a2ee-4168-ad62-661e5f365ab6
9
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } TeamMapKey other = (TeamMapKey) obj; if (map == null) { if (other.map != null) { return false; } } else if (!map.eq...
f475b2a4-ea47-4bea-945f-e50e986dc3ca
4
@Test public void testTwitter() throws InterruptedException { try { loadDocument(); } catch (ParserConfigurationException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (IOException e) { e.pri...
8514fcf8-8df7-48bd-ab05-ba05fc1ebb6b
5
public TaskList read(File importFile) throws TaskIOException { if (importFile == null) { log.warn(ApplicationSettings.getInstance().getLocalizedMessage("log.err.file")); return new TaskList("Empty"); } m_taskList = new TaskList(importFile.getName()); log.info(ApplicationSettings.getInstance().getLocaliz...
a1ac0846-3c34-4c80-9f2c-932de7d6ab3b
2
public static void main(String[] args) { Random rand = new Random(47); Map<Integer, Integer> m = new HashMap<Integer, Integer>(); for (int i = 0; i < 10000; i++) { // Produce a number between 0 and 20: int r = rand.nextInt(20); Integer freq = m.get(r); m.put(r, freq == null ? 1 : freq + 1); } Syst...
780a3656-e52d-4e9b-92bb-ccafdf1ea740
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...
dc8281a3-ac63-4297-96ea-d1f7c9c33609
1
public static FavoritesWindow getInstance() { if (instance == null) instance = new FavoritesWindow(); return instance; }
7fb60671-f32f-4aba-b599-296c348ffa05
2
public ReachableFieldsOnChessboard() { Chessboard chessBoard = new Chessboard (); Chessboard.Chesspiece[] pieces = new Chessboard.Chesspiece[6]; pieces[0] = chessBoard.new Pawn ('w', 'P'); pieces[1] = chessBoard.new Rook ('b', 'R'); pieces[2] = chessBoard.new Queen ('w', 'Q'); pieces[3] = chessBoard.new B...