method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
0258934b-b613-4f41-81d0-bda42aac9d9e
7
public static void build(String inputDir, String outputDir) throws ParseException, IOException { final ReadLine rl = new ReadLine(inputDir+"/matrix.def", "UTF-8"); try { // 一行目はサイズ: [左文脈IDの数] [右文脈IDの数] String s = rl.readEof(); final int leftNum = Integer.valueOf(s.substring(0,s.indexOf(' '))); fi...
89feb320-0058-4c0c-b4e1-3e28fd91fffe
4
@Test public void builderTestRandom() { final Random rng = new Random(42); final ArrayDeque<Integer> deque = new ArrayDeque<>(); for(int len = 0; len < 10_000; len++) { deque.clear(); final IntArrayBuilder builder = new IntArrayBuilder(); for(int i = 0; i < len; i++) { final Int...
b1a81867-568a-43ba-9ed1-bb2410ff9057
1
private BufferedImage createImage() { BufferedImage img = null; try { img = ImageIO.read(new File("image.jpg")); } catch (IOException e) { } BufferedImage image = new BufferedImage(1024, 1024, BufferedImage.TYPE_INT_RGB); ...
8cc6f027-fb8f-4114-bb81-214d5b1b0b9b
5
public void insert(int key) { if (!contains(key)) { Node_Nunez newNode = new Node_Nunez(key); // insert parent node if (size() == 0) { binaryTree.add(newNode); } else { Node_Nunez parentNode = getRootNode(); Node_Nunez currentNode = getRootNode(); // search for next available...
5ac8b363-fb73-45c0-a6c3-5b3b51c8b017
5
private boolean isNotFiltered(String host) { return ((hostToIgnore == null) && (hostToShow == null)) || ((hostToIgnore != null) && !hostToIgnore.equals(host)) || ((hostToShow != null) && hostToShow.equals(host)); }
818dec07-d3d3-4022-bd58-f33d5003ed9e
1
public String llenaCatalogo(ArrayList<String> elementos) { String opcion = "<option label='"; String opcion_ = "/>"; String res = ""; for (String elem : elementos) { res += opcion + elem + "' " + "value='" + elem + "' " + opcion_ + "\n"; } return res; }
680f9775-11b6-49d1-a6c5-1f8cdbd6dadb
5
public boolean subsEquals(Operator other) { if (this == other) return true; if (other.subExpressions == null) return (subExpressions == null); if (subExpressions.length != other.subExpressions.length) return false; for (int i = 0; i < subExpressions.length; i++) { if (!subExpressions[i].equals(oth...
ac54f19c-0c24-43d6-94a3-09e1e03c71ff
2
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); UserModel usermod = null; if(user!=null) { usermod = DataStore.getUser(user.getUserId(...
46220742-33f3-48b1-b91e-aee0c5b60afb
5
ParticleTimer(WonderBow plugin) { this.plugin = plugin; this.plugin.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, new Runnable() { @Override public void run() { tick++; Iterator<ParticleTrack> iterator = tracking.iterator(); ...
1cb5a6cd-6ec7-48ac-aaaa-0b5939c8aaf3
9
private void viewDetailsJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewDetailsJButtonActionPerformed // TODO add your handling code here: int selectedRow = workQueueJTable.getSelectedRow(); if (selectedRow < 0) { JOptionPane.showMessageDialog(null, "Sel...
919cefc6-9507-4784-8370-98d601e08494
5
public void body() { // a loop that is looking for internal events only Sim_event ev = new Sim_event(); while ( Sim_system.running() ) { super.sim_get_next(ev); // if the simulation finishes then exit the loop if (ev.get_tag() == GridSimTags.END_O...
d44e95e2-e806-4f82-9e44-a4ec9b536cd3
5
private String searchGameDetailsOther(String str) { String tmp = str, res = ""; int start, end; start = tmp.indexOf("<div class=\"game_area_details_specs\">"); end = tmp.indexOf("<div class=\"details_block\"><a class=\"linkbar\""); if (start >= 0) { tmp = tmp.substring(start, end); while (tmp.length() >...
cab4ae9c-09b8-4360-9908-947f534b946f
3
@Override public void run() { getNetworkHandler().fireNetworkEvent(new NetworkEvent(NetworkEvents.START_SERVER, "Starting server...")); // tries to open up a socket on PORT, returns if fail if ((serverSocket = setUpServer(port)) == null) return; setServer(true); setClient(false); // tries to initiate...
a24f2839-12e9-499d-ba6a-ff761dd0856a
8
@Override protected void runConnect() { int attempts=0; Thread me = Thread.currentThread(); while (me==_listenerThread && !destroy) { if(attempts==0) { System.out.println("["+_host+":"+_port+"] connecting ..."); } try { _socket=new Socket(_host,_port); System.out.println("["+_host+":"+_port+...
9259dd94-8655-4230-b5aa-6c2245077e86
9
public static void expandQuoteMacroToken(StellaToken quotedlist) { { String quotestring = quotedlist.content; { StellaToken self000 = StellaToken.newStellaToken(); self000.type = Stella.KWD_SYMBOL; self000.logicalTokenType = Stella.KWD_SYMBOL; self000.content = (Stella.stringEqlP(quo...
d1c866ea-e94d-43e8-a778-6c13f5ad8041
2
@Override protected void paintComponent(Graphics graphics) { super.paintComponent(graphics); Graphics2D g = (Graphics2D) graphics.create(); Dimension size = getSize(); int topY = verticalGap; int bottomY = size.height - verticalGap; int barX = horizontalGap; int tickX = horizontalGap+ba...
7a3e7e13-f93d-4c61-a37a-b7dac20ea123
5
public int maximalRectangle(char[][] matrix) { int res = 0; if(matrix == null) return res; int[] height = new int[matrix[0].length]; for(int i = 0; i < height.length; ++i){ height[i] = matrix[0][i] - '0'; } res = largestRectangleArea(height); for(int ...
1f36df7c-78a3-4852-8dc4-36bb74543399
6
public void disablePlayerTwoSpaces() { for (int x = 0; x < checkersSpaces.length; x++) { for (int y = 0; y < checkersSpaces.length; y++) { if(checkersSpaces[x][y].getIcon() != null && checkersSpaces[x][y].getIcon().equals(playerTwoCheckerPiece)) { checkersSpaces[x][y].setDisabledIcon(playerTwoChecker...
6cd1412b-7a48-4525-8b3e-49cb53b4a4e7
9
private GedcomRecord parseLine(String line) throws GedcomReaderException { StringTokenizer st = new StringTokenizer(line); String strlevel; Integer intlevel; int level; int firstAt = -1, lastAt = -1; try { strlevel = st.nextToken(); intlevel = Integer.valueOf(strlevel); level = intlevel.intValue(...
b0aae174-307b-4da2-9d5f-80c1ae356b59
4
private int jjMoveStringLiteralDfa7_0(long old0, long active0){ if (((active0 &= old0)) == 0L) return jjStartNfa_0(5, old0); try { curChar = input_stream.readChar(); } catch(java.io.IOException e) { jjStopStringLiteralDfa_0(6, active0); return 7; } switch(curChar) { case 116: ...
f4003762-9a0c-4d68-a78e-eff470393af3
3
public static void main(String[] args) { //En scanner Scanner in = new Scanner(System.in); //Man får mata in hur många tal man vill räkna med System.out.println("Hur många tal vill du skriva in?"); int antal = in.nextInt(); System.out.println("Skriv in dina " + antal + " värden."); int min = 0; //Forlo...
fcd592c1-f22a-4642-aac1-d7c00c05afba
4
public boolean containsMatchingLoad(CombineableOperator comb) { Operator combOp = (Operator) comb; if (comb.getLValue().matches(this)) { if (subsEquals((Operator) comb.getLValue())) return true; } for (int i = 0; i < subExpressions.length; i++) { if (subExpressions[i].containsMatchingLoad(comb)) r...
ca51885e-919c-4476-b708-8562e3ecb1f9
8
private void btprestarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btprestarActionPerformed // TODO add your handling code here: String sql="SELECT COUNT(cod_prest) FROM prestamo WHERE cod_cliente="+txcodigo.getText(); ResultSet con; int total=0,cant=0,faltantes=0,prestar=1...
9dda82f8-6b33-47f4-8d38-fcd54445e1e9
8
private void readFrequencies() throws Exception, IOException { String[] tokens; String[] symmetries; String[] frequencies; String[] red_masses; String[] frc_consts; String[] intensities; while (readLine() != null && line.indexOf(":")<0) { } if (line == null) throw (new Exception("...
f9e93997-4504-44c5-bf93-d93f0f9f998c
6
private static void add(Map<Class<?>, Class<?>> forward, Map<Class<?>, Class<?>> backward, Class<?> key, Class<?> value) { forward.put(key, value); backward.put(value, key); }
8fa6ec9d-0b38-46ec-8cc1-4c292e518c8c
4
@Override public boolean equals(Object object) { if (object == null) return false; WorkUnit other = (WorkUnit) object; if (this.projectId == other.getProjectId() && this.workLoad == other.getWorkLoad() && this.workerId == other.getWorkerId()) return true; return false; }
e7a66a20-71bb-46b1-8e57-c39cddba554f
4
@Test public void testResetDrawOutput() { // as defined in method-comment in Player, by default a random Output is // returned. assertNotNull(_underTest); // set up reference list with valid outputs: ArrayList<Output> possibilities = new ArrayList<>(); for (Outpu...
23a52248-ea61-444f-8563-b0546920abf0
0
public LetThereBeLightCommand(String label, Panel p) throws HeadlessException { super(label); this.p = p; }
b913e6bd-2b6c-49ac-b204-e7c7da20ed7d
2
public void addScoreFor(User user, int newScore) { for (Score score : this.scores) { if(score.getID() == user.getID()){ score.addNewScore(newScore); } } }
2d812509-10c1-409e-a96f-0c33c29ee3ea
3
public Invoice getInvoice(String invoiceId) { String url = BASE_URL + "invoice/" + invoiceId; HttpGet get = new HttpGet(url); get.addHeader("Authorization", "Basic " + this.auth); try { HttpResponse response = client.execute(get); return createInvoiceObjectFromResponse(response); } c...
f1ee8d12-2fcb-4db8-9d81-33318a7b3f3f
7
public void readFromBitmap(FileInputStream resourceImage) { try { BufferedImage bitmap = ImageIO.read(resourceImage); pos = new BufferUtils().createFloatBuffer(bitmap.getWidth() * bitmap.getHeight()); coordinate = new boolean[bitmap.getWidth()][bitmap.getHeight()...
d49fbb31-edae-4312-80df-c5e9fa1c45d9
6
public static String unescape(String string) { int length = string.length(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; ++i) { char c = string.charAt(i); if (c == '+') { c = ' '; } else if (c == '%' && i + 2 < length) { ...
9ada4edb-4758-40c2-921b-56ba8e527c36
5
@SuppressWarnings("unchecked") protected int hashFields(int hash, Map<FieldDescriptor, Object> map) { for (Map.Entry<FieldDescriptor, Object> entry : map.entrySet()) { FieldDescriptor field = entry.getKey(); Object value = entry.getValue(); hash = (37 * hash) + field.getNumber(); if (field...
827f86ad-afa1-44b9-a867-069aeb6a78c6
4
public boolean isEmpty() { return (this.gainAlbum_dB==null && this.gainReference_dB==null && this.gainTrack_dB == null && this.peakAlbum == null && this.peakTrack==null); }
8093ebc1-e7fa-4614-8862-c9847a4f6974
6
public void flee(){ int xHunter = predator.getX(); int yHunter = predator.getY(); int diffX = xPos - xHunter; int diffY = yPos - yHunter; int operatorX = 1; int operatorY = 1; if(diffX != 0){ operatorX = diffX/Math.abs(diffX); } if(diffY != 0){ operatorY = diffY/Math.abs(diffY); } ...
3b547c2c-9baf-4e19-beca-79f8676ef599
4
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Year year1 = (Year) o; if (year != year1.year) return false; return true; }
a3fb6a52-0e2d-4247-bd5a-50678a9976f1
4
public static void main(String[] args) { Game g = new Game(); Menu m = new Menu(g); SwingUtilities.invokeLater(m); while (true) { try { Thread.sleep(500); } catch (Exception e) { } if (!m.isActive()) { g.s...
e48be81d-16a8-4250-9a2f-db2ae2141ef4
3
private String formatSearchResults(String content) { String buf = ""; // clean up the contents so less content to go through (faster) content = content.substring( content.indexOf("<div class='searchresults'>"), content.indexOf("<div class=\"printfooter\">")); content = content.replaceAll("\\{", ""); content = ...
59a0a14e-5d42-4351-a990-879a94f849a5
2
public static String[] removeEmptyStrings( String[] data ) { ArrayList<String> result = new ArrayList<String>(); for ( String aData : data ) if ( !aData.equals( "" ) ) result.add( aData ); String[] res = new String[result.size()]; result.toArray( res ); return res; }
de873cac-aab6-4514-a696-8990e3d3a5eb
1
private void testUnmodifiableCycListAdd(final CycList frozenList) { UnsupportedOperationException x = null; try { frozenList.add(4); } catch (UnsupportedOperationException e) { x = e; } assertNotNull(x); }
ed355548-acce-4207-9c7c-a1150b6a16e2
8
public static Module createTuple(int n) { if (n <= 1) { return null; } ModuleName modName = new ModuleName(n+"TUPLE"); Module result = new Module(Module.INITIAL, modName); try { result.importModule(createBool()); // create n parameters Module triv = createTriv(); for (int i=1; i<=...
73d844d7-a4d1-49ed-aaca-9df5794f5096
1
public int getParkSize(int no) { if(no >= this.parkList.size()) { throw new ParkException("找不到你需要的停车场!"); } return this.parkList.get(no).getEmptyNum(); }
8970627a-1e80-4f61-a0ac-9e79772a4254
0
private static void printCompact(String sourceName, ImageInfo imageInfo) { final String SEP = "\t"; System.out.println( sourceName + SEP + imageInfo.getFormatName() + SEP + imageInfo.getMimeType() + SEP + imageInfo.getWidth() + SEP + imageInfo.getHeight() + SEP + imageInfo.getBitsPerPixel() + SEP...
f46c507e-b2b2-4a70-be88-4034d0ecf1e9
1
private Point getKey(List<Point> cluster) { Point p = cluster.get(0).clone(); for (Point point : cluster) { p.add(point); } return p.minus(cluster.get(0)); }
dde52f40-f1bd-4ee3-8565-a7e21720f1d4
5
@Override public MoveResult makeMove(HantoPieceType pieceType, HantoCoordinate from, HantoCoordinate to) throws HantoException { MoveResult result = null; if (from == null && to == null){ System.out.println("Checking for moves left."); if(gameManager.getCellManager().isLegalMovePresent(gameManager.getPl...
99f5c2e7-b8d8-4660-9dcd-5624bb5e66a9
2
public IntroUI(){ setTitle("Introduction"); setResizable(false); setDefaultCloseOperation(DISPOSE_ON_CLOSE); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Dimension realSize = getContentPane().getSize(); setLocation((screen.width - realSize.height) / 2, (screen.height - realSize....
53c61cf2-158c-4bd5-8fc0-53cc66c6eeff
0
public String getCitta() { return citta; }
2e6f41e9-c68f-4dc5-8a0e-7433e8dd42c8
0
private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed setVisible(false); }//GEN-LAST:event_btnCerrarActionPerformed
216a368a-d46a-45f8-8a15-cd8273ed3707
6
static public String encode(final byte[] bytes) { int i = 0, index = 0, digit = 0; int currByte, nextByte; StringBuffer base32 = new StringBuffer((bytes.length + 7) * 8 / 5); while (i < bytes.length) { currByte = (bytes[i] >= 0) ? bytes[i] : (bytes[i] + 256); // unsign ...
3bb8d811-5cbc-407d-8aa5-6d4b9c7b05cc
7
public StringGraph(String filename, String delim) { In in = new In(filename); // Create the index st = new HashMap<String, Integer>(); while (in.hasNextLine()) { StringTokenizer tokenizer = new StringTokenizer(in.readLine(), delim); while (tokenizer.hasMoreTokens()) { String s = tokenizer.nextT...
b33dda88-bf20-4d88-b717-d3549821d675
0
public ArrayList<Este> getEsteet() { return esteet; }
96b384a9-ff2f-4494-b815-ce1b81651bbc
2
@Override public void propertyChange(PropertyChangeEvent evt) { if(evt.getPropertyName().equals(REMOVED_OBJECT) && evt.getOldValue() instanceof Enemy) { this.addScore(100); } //Sends the event down this.pcs.firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue()); }
33f00118-5be2-4d56-9975-bd4496efc798
3
void cancelTransaction(Connection connection){ try {//tenta cancelar transação if(connection != null && connection.isClosed() == false){ System.out.println("Cancel transaction!"); dataController.cancelTransaction(connection); } } catch (Exception e...
fc73e22a-e15f-485c-9a9e-70516cfc20a7
7
@Override public int compare( Object o1, Object o2 ) { if( (o1 == null) || !(o1 instanceof XLSRecord) || (o2 == null) || !(o2 instanceof XLSRecord) ) { throw new ClassCastException(); } XLSRecord rec1 = (XLSRecord) o1; XLSRecord rec2 = (XLSRecord) o2; if( !rec1.isValueForCell() || !rec2.isValueForCel...
f7f33474-736f-4154-ab0c-91fc8dafed4f
0
public ArrayList getVertices() { return vertices; }
5810ed35-dba3-4148-a0ca-456c8f063ede
6
public void update() { time++; if (lifeTime - 10 > time) { alpha -= 0.1f; } if (time > lifeTime) { removed = true; return; } xa = (float) ((rx + direction.x) * speed); ya = (float) ((ry + direction.y) * speed); int xStep = (int) Math.abs(xa * 100); for (int i = 0; i < xStep; i++) { if (...
06062707-c67e-4ca6-8017-7e36bb27aec2
8
@Override public void mouseClicked(MouseEvent e) { boolean selectedTarget = false; int mouseColumn = e.getX() / SIZE; int mouseRow = e.getY() / SIZE; if(!humanPlayer.isTurnFinished()){ //Compares mouse row and column to possible targets for (BoardCell b : targets) { if (mouseRow == b.getRow() && ...
b1554615-9ab4-4446-8a9f-6ada440f1dd4
7
public void hideUnnecessaryArtificialEdges() { //EdgeList edgelist = graph.getEdgeList(); //System.out.println(graph.nodeCount()); //System.out.println(graph.edgeCount()); for (Edge edge : artificialEdges) { Node source = edge.source(); PathCaseShapeNodeRealizer...
00c06959-d59d-4005-8023-50362469b522
1
public Builder population(long receivedPopulation) { if (receivedPopulation < 0) { this.population = -receivedPopulation; return this; } this.population = receivedPopulation; return this; }
14604995-b9ca-4fc3-b2a1-10f748a07023
5
private void generateSwaggerFiles(ResourceParser resourceParser) { File dir = new File(project.getBuild().getOutputDirectory() +apiListing.getOutputWebDir()); if( !dir.exists() ) { dir.mkdir(); } if( dir.isDirectory() ){ try{ //write t...
2eb9ff9d-054e-4ae5-bc55-af5a63cb3480
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof Content)) return false; Content other = (Content) obj; if (title == null) { if (other.title != null) return false; } else if (!title.equals(other.title)) return...
cfaa81db-e61a-430d-9e70-b6dfcb4be163
6
public synchronized void demoWithDateMasterTableInSchema(String pStn, Date fromDate, Date toDate){ PreparedStatement pstmt = null; Double avgTemp = 0.0; DateMasterVO dateMasterVOObj = null; HashMap<String, DateMasterVO> hm = new HashMap<String, DateMasterVO>(); ResultSet rs = null; int count = 0; try{ ...
c28fbf8a-b15c-4433-b898-454d6bc657dd
5
private double gainForSugarValue(double val) { double leSize = 0.0; double leGood = 0.0; double leBad = 0.0; double gtSize = 0.0; double gtGood = 0.0; double gtBad = 0.0; for (Tea t : trainingSet) { if (t.getSugar() <= val) { leSize++; if (t.isDrinkable()) { leGood++; } else { leB...
ac216a64-092b-464c-9fd4-dc710983e793
6
public void body() { // Process events Object obj = null; while ( Sim_system.running() ) { Sim_event ev = new Sim_event(); super.sim_get_next(ev); // get the next event in the queue obj = ev.get_data(); // get the incoming data ...
3df34d5e-cb9b-45ef-b66b-0d89bb6769dd
4
private static void disconnectOnly(int player) { if (socket[player] != null) { Debug.p("Server: Player " + player + " (" + names[player] + ") disconneced"); if (serverListeningThreads[player] != null) { serverListeningThreads[player].interrupt(); } ...
fb4cebc0-9214-44b1-8d5d-d573355f07f9
8
@Override public String convertSelfToString() { Integer lackLength; String idStr = String.valueOf(id); if(idStr.length() <= 6){ lackLength = 6 - idStr.length(); for(int i = 0; i < lackLength; i++){ idStr = "0" + idStr; } } else{ idSt...
fe7037df-e015-45a6-9a4f-72632e4d6a85
8
public ArrayList<Employee> getAllEmployees(Connection conn) { ArrayList<Employee> employees = new ArrayList(); PreparedStatement statement = null; Employee es = null; boolean tjek = false; int employeeNo = 0; String SQLString = "SELECT * FROM medarbejder NATURAL...
9ac94ebf-0a94-4f78-bd97-d893907f53cd
9
public ArrayList<Restaurant> getAllRestaurants() throws IOException { Document doc; String url; ArrayList<Restaurant> rList = new ArrayList<>(); Set<String> names = new HashSet<>(); int prevSize = -1; for (int i = 1; i <= pages; i++) { if (names.size() == ...
6849ad6f-4572-4d20-b004-8eaeb130a8cd
0
public void setRatingId(int ratingId) { this.ratingId = ratingId; }
9c802b60-b1b1-4ff5-a63d-6cb2c0874add
6
private void clicked_eval() { String query = queryField.getText().trim(); switch (query) { case "lsp": query = getTableQuery("PHRASES"); break; case "lsperf": query = getTableQuery("PERFORMANCES"); break; case "lsd": query = getTableQuery("DICTIONARIES"); break; case "lsu": query = g...
032fc146-4f0c-4a31-ad6d-6db06bfba2e4
2
public static double clamp(double v, double lo, double hi) { if (v < lo) return lo; if (v > hi) return hi; return v; }
ce08365b-9a61-4579-a938-280718f5aff9
6
private byte[] getData(ScrollPane pane, TextArea area) { byte[] data = null; switch (pane.getEditorType()) { case ASCII: data = this.getDataASCII(area); break; case UTF8: data = this.getDataUTF8(area); break; case HEX: data = this.getDataHex(area); break; case BINARY: data = this.getDat...
27fbded4-bc5a-4250-9328-350cd4581563
2
public static float maxIndex(float[] arr){ float max = 0; float maxVal = Float.MIN_VALUE; for (int i = 0 ; i < arr.length; i++){ if (arr[i] > maxVal) max = i; } return max; }
60dc3d6c-49ee-4d4a-822c-fcfeab5ca803
4
@Override public boolean createTable(String query) { Statement statement = null; try { //this.connection = this.open(); if (query.equals("") || query == null) { this.writeError("SQL query empty: createTable(" + query + ")", true); return false; } statement = connection.createStatement();...
4d6b5966-0488-4cd3-b663-2a7f14bde614
1
private void onGameEnd(int result, Player p) { for (GameEventListener l : this.gameEventListeners) { l.onGameEnd(result, p); } this.board.clear(); }
7b26e868-a4b9-473b-9282-dbebae162c3d
6
@EventHandler public void WolfWither(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getWolfConfig().getDouble("Wolf.Wither.DodgeCh...
a558d9d3-f00f-46f3-b4f1-c791f83cd048
4
public void mousePressed(MouseEvent e) { if (!e.isConsumed()) { int tmp = getIndexAt(e.getX(), e.getY()); if (!isIgnoredEvent(e) && tmp >= 0 && isHandleEnabled(tmp)) { graphComponent.stopEditing(true); start(e, tmp); e.consume(); } } }
c9c79627-4097-45a9-b89b-1dd4319964d4
2
@SuppressWarnings("unchecked") protected static void rollback() { try { getSession().getTransaction().rollback(); } catch (HibernateException e) { System.out.println(e.getMessage()); } try { getSession().close(); } catch (HibernateException e) { System.out.println(e.getMessage()); } DAO.sessi...
f1875b9c-4291-4dc8-b8aa-6a6e65a4894b
1
static Tile randomTile() { return Math.random() < 0.15 ? FOUR : TWO; }
c34314c2-2ada-4294-a4b8-46db1c29bb29
3
@Override public void render(Graphics g) { super.render(g); if (shouldRender) { BlockManager bm = registry.getBlockManager(); if (bm != null) { int sizeX = 160; int sizeY = 160; int x = registry.getGameController().getGamePanel(...
2dddfecb-41c3-4164-9b23-0737daf360ee
1
public GeocoderResponse directGeocode(String geocode) throws IOException { String url = GEOCODER_HOST + "?geocode=" + URLEncoder.encode(geocode, "UTF-8"); HttpUriRequest request = new HttpGet(url); request.addHeader(refererHeader); HttpResponse response = httpClient.execute(request); ...
77b5330c-e7d9-4001-9ac4-cbe95d9cee8c
8
public final ByteList transform(byte[] src, int off, int size) { ByteList ob = null; int i = 0, org; while (i < size) { org = i; while (i < size && src[off + i] != AMPER) { i++; } if (i > org) { if (org == 0) { ...
3b56f962-17e0-4ace-b783-3c3ba49855df
7
public boolean openURL(String url) { String osName = System.getProperty("os.name"); try { if (osName.startsWith("Mac OS")) { //doc Class fileMgr = Class.forName("com.apple.eio.FileManager"); Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class }); openURL.invoke(...
98b98b53-68dd-46ef-968b-4c445c9a7398
7
PreselectionDialog askForObjectAndAttributeGroup(Component parentComponent) { final DataModel configuration = _connection.getDataModel(); PreselectionDialog dialog = null; PreselectionListsFilter listFilter = new PreselectionListsFilter() { public List applyFilter(int whichList, List list) { final Lis...
98fc3e38-54cc-48f2-b896-1bdbd3acdccc
3
public void recognize() { if (!active) return; if (points.size() == 0) //the recognizer will crash if we try to process an empty set of points... return; result = recognizer.Recognize(points); // points.removeAllElements(); if (listener != null) listener.dollarDetected(this); }
6a6c48d1-4a79-4a6d-9c28-01b5b1cd2b9c
4
public Direction getRightDirection() { switch(this) { case NORTH: return EAST; case SOUTH: return WEST; case WEST: return NORTH; case EAST: return SOUTH; default: return this; } }
38e17f83-135a-4d02-879d-f897af249900
2
public User loginuser(User loginUser) { User foundUser = null; try { // PreparedStatement für den SQL-Befehl String sqlStatement = "SELECT * FROM bookworm_database.users WHERE username = '" + loginUser.getUserName() + "' AND userpassword = '" + loginUser.getUserPassword() + "';"; // SQL-Be...
12ee0730-37f8-406d-aea3-ee5917df9019
1
public final void newGame() { if (SlidingPuzzlePiece.getPuzzlePiece() != null) { SlidingPuzzlePiece.getPuzzlePiece().clear(); } Group newGroup = new Group(); newGroup = createGameBoard(); thisStage.setTitle("Sliding Puzzle - " + userName); thisStage.sizeToSc...
96e20e03-3aa9-4433-ade7-26ae8a1f77c6
8
public String toString() { String []relations=null; int relationidx=0; if(this.image!=null && this.image!="") { this.image=this.image.trim(); relations=this.image.split("\\s"); } StringBuilder result=new StringBuilder(); int childIdx=0; if(((SimpleNode)this.jjtGetChild(childIdx)).getId()==E...
67ff4b5f-a244-4e0f-a219-b0a4f90cf6d2
4
private void saveSongTxt(FileOutputStream f_out, StaffSequence out) throws IOException { PrintStream pr = new PrintStream(f_out); ArrayList<StaffNoteLine> theLines = out.getTheLines(); TimeSignature t = out.getTimeSignature(); if (t == null) { t = TimeSignature.FO...
20c0a0e9-ad80-45c8-a0bd-b5584ca0e064
9
public void testJson () throws IOException { fail = null; final Data dataTCP = new Data(); populateData(dataTCP, true); final Data dataUDP = new Data(); populateData(dataUDP, false); final Server server = new Server(16384, 8192, new JsonSerialization()); startEndPoint(server); server.bind(tcpPort, udp...
8cd322ba-14cb-40d6-8b29-6daf6b7c225a
4
private boolean isEdited(KeyEvent e) { return !e.isActionKey() && !e.isAltDown() && !e.isAltGraphDown() && !e.isControlDown() && !e.isShiftDown(); }
c74a43c8-9f09-4cb5-8e02-a9110f00303d
6
@Override public void move(Excel start, Excel finish) { if (start.getX() == begin.getX() && start.getY() == begin.getY()) { begin = finish; setColoredExes(); return; } if (start.getX() == end.getX() && start.getY() == end.getY()) { end = finish; setColoredExes(); return; } ...
9682f459-ce65-458b-8c2a-d310b2df7931
2
public void printCurrentPage() { try { PrinterJob pj = PrinterJob.getPrinterJob(); pj.defaultPage(pg.getPageFormat(0)); pj.setPrintable(new PsuedoPrintable()); javax.print.attribute.HashPrintRequestAttributeSet pra = new javax.print.attribute.HashPrintRequestAttributeSet(); if(pj.printDialog(pra)) pj...
5e89e777-49c6-4186-a3ab-55ae21a51356
7
public void printCluster2(StringBuilder sb, Collection<Line> lines) { // System.err.println("Cluster::printCluster " + this); final Set<String> rankSame = new HashSet<String>(); for (Line l : lines) { final String startUid = l.getStartUid(); final String endUid = l.getEndUid(); if (isInCluster(startUid)...
95a644c4-2049-4f3d-9278-6d792087f6f8
3
public static Integer countSoup(Inventory inv) { int i = 0; for(ItemStack item : inv.getContents()) { if(item == null) continue; if(item.getType().equals(Material.MUSHROOM_SOUP)) i++; } return i; }
807f701b-bc91-4efc-b047-e21bd41b7e1f
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ExtendedProperty other = (ExtendedProperty) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equalsIgnore...
d630bbe4-783f-45ee-ab48-3fd74a83bf33
1
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { ParkMain frame = new ParkMain(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
b165c79f-2965-4aec-8478-f100018adb10
8
public void equip(int inventoryIndex){ Sound.equip.playAsSoundEffect(1, Options.FXVolume, false); Armor wearing = null; switch(this.type){ case HEAD: wearing = Game.PLAYER.getEquip().getHead(); Game.PLAYER.getEquip().setHead(this); Inventory.remove(inventoryIndex); break; case SHOULDERS: ...
3d59ba4a-b0e6-4124-9dce-0191109bfaff
3
public void fusionWithScreenFullAlpha(CPLayer fusion, CPRect rc) { CPRect rect = new CPRect(0, 0, width, height); rect.clip(rc); for (int j = rect.top; j < rect.bottom; j++) { int off = rect.left + j * width; for (int i = rect.left; i < rect.right; i++, off++) { int color1 = data[off]; int alpha1 =...