method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
0ade924a-6d09-43ab-aca7-7b16a105b0aa
8
private static void parseImage(Node node, Channel channel, boolean updateChannel) throws MalformedURLException { NodeList imageNodes = node.getChildNodes(); int numImageNodes = imageNodes.getLength(); for (int i = 0; i < numImageNodes; i++) { Node child = imageNodes.item(...
81bfb302-dc1b-461e-a3aa-f9f249a93ab4
1
public void substract(Polynomials p){ for(int i = 0; i < p.polynomial.size() - 1; i++){ Term t = p.polynomial.get(i); t.factor = -t.factor; p.polynomial.set(i, t); } }
361d445a-0181-442f-a968-abe6c578f1c7
4
public void publish(final int n) { ActiveMQConnection connection = null; try { ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(Publisher.BROKER_URL); connection = (ActiveMQConnection) cf.createConnection(); connection.start(); TopicSession sessio...
726ec903-98c1-40d7-b354-0a1129a76c15
8
public List<Compound> getCompoundList(Integer precursor1, Integer precursor2, int ionMode, List<Integer> instrumentIds, List<Integer> msTypeIds) { StringBuilder sb = new StringBuilder(); sb.append("SELECT * FROM " + Compound.TABLE + " C"); List<String> whereClauses = new ArrayList<String>(); if (precu...
70a50b75-f21d-4890-8086-3aecd23dea91
7
public void run() { //This method keeps listening the socket TaskMessage message; try { while(true){ message = (TaskMessage) input.readObject(); System.out.println("Message received"); if(message != null){ toRun.add(message); } Thread.sleep(Constants.LISTEN_INTERVAL); } } catch...
e4632db3-88a3-4cb9-8c8b-6152428c66f8
6
public static double computeQpDelta(double slope, double prevSlope, double prevDelta) { { double delta = 0.0; if (prevDelta > Logic.$MODE_SWITCH$) { if (slope > 0.0) { delta = Logic.$LEARNING_RATE$ * slope; } if (slope > (Logic.$SHRINK_FACTOR$ * prevSlope)) { delta...
c0bd2c34-71c4-45d8-b531-6f00c3fe7e98
9
public static boolean isMagicSquare(int[][] arr) { final int n = arr.length; final int nSquare = n * n; final int M = (n * n * (n * n + 1) / 2) / n; int sumOfRow = 0, sumOfColoumns = 0, sumOfPrimaryDiagonal = 0, sumOfSecondaryDiagonal = 0; boolean[] flag = new boolean[n * n]; ...
0fbcdc41-34ee-4249-a2b2-c519e3be9d10
2
public void testPropertySetDay() { YearMonthDay test = new YearMonthDay(1972, 6, 9); YearMonthDay copy = test.dayOfMonth().setCopy(12); check(test, 1972, 6, 9); check(copy, 1972, 6, 12); try { test.dayOfMonth().setCopy(31); fail(); } catch...
f32ef2bf-d549-49fb-a2ad-eca665efddb9
2
public Object[] execute(Fact fact) throws UnknownKeyException { for(Rule rule : rules) { if (rule.isValid(fact)) { return rule.getActions(); } } return null; }
706b85ca-01c5-4b9f-9f3e-ea1f1ebe0cec
0
public void setY(int y) { this.y = y; }
c1501f9b-afe1-42a1-83f5-082f85706c54
6
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; }
be87b6df-a826-4fee-a6d2-c66deb81b136
0
public String getNick() { return _nick; }
6841d8b4-78b3-4589-a58e-df2f5f27d209
0
public URI getUri() { return this.uri; }
9036d4b6-1499-40b5-9351-f237550a93aa
4
public void logCheck() { new File(directory).mkdir(); new File(subdirectory).mkdir(); new File(subsubdirectory).mkdir(); if (!chatfile.exists()) { try { chatfile.createNewFile(); } catch (Exception ex) { ex.printStackTrace(); ...
b9f934c9-46d0-4b19-94a2-ab9c01c808d8
7
public String docount () // maka a local count and return result string { clearmarks(); getinformation(); int i, j; int tb = 0, tw = 0, sb = 0, sw = 0; P.getterritory(); for (i = 0; i < S; i++) for (j = 0; j < S; j++) { if (P.territory(i, j) == 1 || P.territory(i, j) == -1) { markterrit...
53a77cee-d94a-4847-b57e-7bb9c8ed38b7
2
public void keyPressed(KeyEvent e) { //sets the motion of the balls int key = e.getKeyCode(); //gets the key pressed if (key == KeyEvent.VK_LEFT) { //if it's left, the ball changes its position with -2x (-1x direction == left) dx = -2; } if (key == KeyEvent.VK_RIGHT) { //...
69e8da1c-872e-46cc-bc27-f58f526df2b6
8
public Effect[] randomizeEffects(double effectModifier) { int effects = 0; if (r.nextInt(100) < 40) { effects++; if (r.nextBoolean()) { effects++; } else { if (r.nextBoolean() && r.nextBoolean()) { effects++; if (r.nextBoolean()) { effects++; if (r.nextBoolean()) { effe...
8ddd7969-aea1-4381-b2db-1ce128a4f5bf
3
private ArrayList<Integer> getNumbers(Scanner sc){ ArrayList<Integer> num = new ArrayList<Integer>(); String next = sc.next(); String line = next; try{ line += sc.nextLine(); } catch(java.util.NoSuchElementException e){ } sc = new Scanner(line); while(sc.hasNext()){ try{ ...
b1a5c230-c291-4409-ac1b-7ee5bad17ca5
4
public static void validateLogin(String login) throws TechnicalException { if (login == null || login.isEmpty() || login.length() > LOGIN_SIZE) { throw new TechnicalException(LOGIN_ERROR_MSG); } String regex = "[\\S]{4,}"; Pattern p = Pattern.compile(regex); Matcher m...
171c1789-5f0d-44d2-b22e-8bc6de6e1ccd
0
public Object getParamValue() { return this.paramValue; }
c3b9820d-5df3-4784-bfbf-72d9a30b8b22
7
public static Webservice SearchServiceByID (String id, File Services){ Webservice Waux = new Webservice(); String aux, aux2, idaux =""; try{ BufferedReader in = new BufferedReader(new FileReader(Services.getAbsolutePath())); do{ aux = in.readL...
5db8132f-6182-4771-a0fc-acdf62d65b9d
0
public void deleteList (String name) { usernames.remove(name); model.removeElement(name); }
0dafb443-f437-49c1-b8d8-623d9a4532d4
1
public ArrayList<String> getProfileNames() { ArrayList<String> profileNames = new ArrayList<String>(); for (String name : profiles.keySet()) { profileNames.add(name); } return profileNames; }
c20b490f-b373-4be5-807d-89f20c85ce67
8
public void run() { try { System.out.println("Processing Request"); ObjectInputStream ois = new ObjectInputStream(socket.getInputStream()); StringContainer curJob = (StringContainer)ois.readObject(); MessageDigest digest = MessageDigest.getInstance("S...
2fb2e17e-b2a2-4802-9b96-cd035e1feeb6
3
@Override public void mousePressed(MouseEvent e) { if (e.isConsumed()) { return; } // Initiate Drag and Drop targetNode = getNodeFromSource(e.getSource()); componentType = getUIComponents(e.getSource()); if ((componentType == ICON) && targetNode.isSelected()) { isDragging = true; } else { ...
f5d3acd4-e63a-4051-b720-de6bce68073f
3
public void doTimerActions() { if (createNotcherControllersTrigger) { createNotcherEventHandlers(); } if (notcherEventHandlers == null) { return; } control(); for (NotcherEventHandler notcherEventHandler : notcherEventHandlers) { notcherEventHandler.doTimerActions(); } ...
1f16d892-4768-432f-b3b6-ff9a046d2b13
3
public Simulator(SimState state, ArrayList<Event> events, SimView view) { //Store variables this.state = state; this.view = view; this.queue = new EventQueue(); this.state.setQueue(this.queue); //Loop trough and add supplied events for(Event ev : events) { ev.setState(this.state); this.queue.a...
76686ff8-0e44-46ba-99c7-43472d5a3099
2
private int getType(byte[] key){ if(key[8]=='d') return HostKey.SSHDSS; if(key[8]=='r') return HostKey.SSHRSA; return HostKey.UNKNOWN; }
ab71acf9-2937-4fdf-b960-b34a9b0fc009
2
public synchronized boolean removeItem(FieldItem item, Position position) { if (insideBounds(position) && this.getItemType(position) == item.getType()) { //MIRAR EL MISMO OBJETO, NO SOLO QUE SEA UN PATO field[position.getX()][position.getY()] = null; return true; } return...
6cab49fa-0671-4aba-b478-a23dfa35ff80
2
public void setBlock(Point one, Point two, Type type) { for (int x = (int) one.getX(); x < two.getX(); x++) { for (int y = (int) one.getY(); y < two.getY(); y++) { chunk[x][y].type = type; } } }
c21a3dae-405f-4e07-b22b-0eb0d8b66f32
8
private int searchIndex(int numero, boolean activa){ int index = -1; if(activa){ for (int i = 0; i<cuentas.length; i++) { if(cuentas[i] != null && cuentas[i].validarCuenta(numero) && cuentas[i].isActiva()){ index=i; break; ...
0bb287e9-7a02-47ea-8090-8ec863d7a95d
1
public static String escapeQuoteChars(String string) { if (string == null) { return null; } return string.replaceAll("\\\"", "\\\\\\\""); }
5eabff38-6025-45e2-9d4d-8d5c9cfbaf11
5
private void processValue(Entry entry, String key, String content) { switch (key) { case Constants.TITLE: entry.title = content; break; case Constants.USERNAME: entry.username = content; break; case Constants.PAS...
aae72466-261b-4749-b4ff-4a588f0c71d3
5
public void run() { groundWaterLevel = new float[Globals.width][Globals.height]; float startingWater = Globals.getSetting("Starting water", "Water"); for(int x = 0; x < Globals.width; x++) for(int y = 0; y < Globals.height; y++) groundWaterLevel[x][y] = startingWater; Globals.registerGraph("Ground water...
f83ba2cd-3244-4a3d-bb31-2eeba3bb8c47
3
private static int[][] rotateBoard(int times, int[][] board) { //TODO fix multiple rotations functionality final int[][] buffer = new int[4][4];//rows then columns, 0,0 at bottom left corner //will rotate board right "times" times for (int i = 0; i < times; i++) { for (int row = 0; row < 4; row++) { //f...
0c980c39-594c-45e3-97ce-103d1c026a15
4
public JSONObject toJSONObject(JSONArray names) throws JSONException { if (names == null || names.length() == 0 || length() == 0) { return null; } JSONObject jo = new JSONObject(); for (int i = 0; i < names.length(); i += 1) { jo.put(names.getString(i), this.opt(i...
d7e55465-2237-456e-be88-b76b2499ca1a
9
public String gen() { int ano = 1960 + g.nextInt(40); int mes = g.nextInt(12); int dia = 1; if (mes == 2 && ano % 400 == 0) { dia = 1 + g.nextInt(27); } else if (mes == 2 && ano % 4 == 0 && ano % 100 != 0) { dia = 1 + g.nextInt(28); } else if (mes...
f48497f4-26dc-47f5-a371-8903b7aa3b30
0
public void draw(Graphics g) { Rectangle bounds = getAbsoluteRect(); g.setColor(new Color(255, 245, 230)); g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g.setColor(Color.black); g.drawRect(bounds.x, bounds.y, bounds.width, bounds.height); }
4bbed89c-bfed-407b-a618-f2bf3fe7b5e3
0
private RequestMessage(ByteBuffer buffer, int piece, int offset, int length) { super(Type.REQUEST, buffer); this.piece = piece; this.offset = offset; this.length = length; }
f423f40b-91a7-4724-8cb6-b86427225598
1
public static String identifyLock(String lockResponse) { String[] items = lockResponse.split("\\s+"); String response = ""; for (int i=1; i<items.length; ++i){ response += items[i]; } return response; }
ee375c60-4061-496a-8f3e-bbd90460c123
4
private static void dump(StringBuilder buffer, int depth, DockLayoutNode node) { if (node instanceof DockLayout) { DockLayout layout = (DockLayout) node; pad(buffer, depth); buffer.append(layout); buffer.append('\n'); depth++; for (DockLayoutNode child : layout.getChildren()) { if (child != null...
b77304b8-b8b1-41af-8f75-639ee58123c4
2
public Connection getConnection() { if (conn == null) { if (openConnection()) { System.out.println("Connection opened"); return conn; } else { return null; } } return conn; }
cb627189-9067-40f6-a8f7-59bc37f6e117
9
public boolean skipPast(String to) throws JSONException { boolean b; char c; int i; int j; int offset = 0; int n = to.length(); char[] circle = new char[n]; /* * First fill the circle buffer with as many characters as are in the * to str...
5e1f8ffc-67a3-4747-b5b6-cd7764a7b046
3
public static int findKey(String[] line) { for(int i = 0; i < line.length; i++) { if(line[i].equalsIgnoreCase("[" + Config.SIGN_TEXT + "]") || line[i].equalsIgnoreCase("["+ Config.SIGN_TEXT_COLOR + Config.SIGN_TEXT + ChatColor.BLACK + "]")) { return i; } } return -1; }
f58d382c-8760-40a3-9c58-e3b6326087d9
5
public CustomerGUI() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 573, 420); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JPanel panel = new JPanel(); panel.setBounds(0, 0, 571, 391); ...
f98ebdec-7a1a-491f-af70-d6cd706163ad
9
public static JsonDeserializer newFieldDeserializerFor(Class<?> type) { JsonDeserializer encoder = null; if (type.equals(String.class)) { encoder = new StringDeserializer(); // } // else if (type.equals(Integer.class) || type.equals(int.class)) { // encoder = new Int...
000330cc-f545-475e-b884-952544a5b89a
2
public void render(Graphics g) { if (image != null && !isDirty) { int xPos = projectileManager.mapToPanelX(mapX); int yPos = projectileManager.mapToPanelY(mapY); //flip the yPos since drawing happens top down versus bottom up yPos = projectileManager.getPHeight()...
d7115aef-2c34-4f2a-858f-3ac987fca9bc
4
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed // TODO add your handling code here: javax.swing.JFileChooser jFileChooser1 = new javax.swing.JFileChooser(); int rVal = jFileChooser1.showSaveDialog(this); String path; ...
b832dd80-ef63-42e2-84f1-5f3461ff9712
4
@Override public void keyReleased(KeyEvent ke) { /* System.out.println(searchField.getText()); LinkedList tempStudentLinkedList = new LinkedList(); for(int i=0;i<Student.studentListText.size();i++) { Student currentStudent=Student.studentListText.get(i); if(currentStudent.studentName.indexOf(searchFi...
77899d5f-5001-466d-add4-42f1bd02b747
1
private void setDeviation() { /* ** Compute the proportional deviation from the mean for each ** individual parameter value. */ proportional_dev = new double[data.length]; for (int i = 0; i < proportional_dev.length; i++) { proportional_dev[i] = (data[i] ...
5909c51f-5bed-49ae-b1ff-86356c9ec8a1
8
public void messageReceived(MessageEvent e) { if(e.getMessage().contains("You remove")){ made++; } if(Variables.glass || Variables.needleAndThread) { if(e.getMessage().contains("make")) { made++; } } if(Variables.bars) { if(e.getMessage().contains("retrieve")) { made++; } } if(Variables.g...
686de4f5-7e69-40aa-9ced-352637a77a12
7
public static char unescape(char c) { switch (c) { case 'r': return '\r'; case 'n': return '\n'; case 't': return '\t'; case '0': return '\0'; case '\'': return '\''; case '"': return '"'; case '\\': return '\\'; def...
e385e294-1a66-41ac-b937-745f62da2781
8
private static String getSourceFromFile(Class<?> testClass, String methodName, String fileType) { Path currentRelativePath = Paths.get(""); String workingDirectory = currentRelativePath.toAbsolutePath().toString(); String className = testClass.getSimpleName(); File file = new File(work...
8124d861-4a33-4cf0-8f33-9ad1b68b0324
2
@Override public void playYearOfPlentyCard(IPresenter presenter,ResourceType resource1, ResourceType resource2) { MoveResponse response=presenter.getProxy().playYearOfPlentyCard(presenter.getPlayerInfo().getIndex(), resource1, resource2, presenter.getCookie()); if(response != null && response.isSuccessful()) { ...
3fbb207a-b44e-487d-aa3f-f531d9cfe28e
7
@Override public void run() { // TODO Auto-generated method stub isNew = false; while(true) { if (model.getSchedThread() != null && model.getSchedThread().isAlive()) { setMessage("Please Wait..."); isNew = true; } else { if (model.getBestSchedule() == null || model.getBestSchedule()....
94690ccb-6feb-4a06-a608-28b9253b22e6
1
public boolean exists(Row row) { return rows.contains(row) || hasRowWithNumber(row.getNumber()); }
1415783c-9b68-4696-9cf7-1a2d0e787fb2
6
public static void main(String args[]) { try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); ...
2077079e-93fe-4ca6-857d-65f5bf782b92
3
public boolean inRenderView(int thatX, int thatY) { int halfWidth = viewWidth / 2; float halfHeight = (viewHeight / zScaler()) / 2; return thatX >= x - halfWidth && thatX < x + halfWidth && thatY >= y - halfHeight && thatY < y + halfHeight; }
e5f9400e-9cbc-42f6-ab9c-7057b0fd21cf
5
static private boolean jj_3R_13() { if (jj_scan_token(BEHAVIOR)) return true; if (jj_scan_token(BEHAVIORIDENT)) return true; if (jj_scan_token(LPAREN)) return true; Token xsp; xsp = jj_scanpos; if (jj_3_6()) jj_scanpos = xsp; if (jj_scan_token(RPAREN)) return true; return false; }
7cbd0ef1-3b30-495f-bd50-19e69dfdd7e6
1
public void abort() throws java.io.IOException { if (!(getStatus() == SubLWorkerStatus.WORKING_STATUS)) { return; } CycAccess cycAccess = getCycServer(); synchronized (cycAccess) { cycAccess.getCycConnection().abortCommunication(this); } }
a18cf96f-90ad-4b37-8264-0f2f4dcaa192
5
@Override public void update(long d) { if (state == OPEN || state == CLOSED) { return; // no update needed } if (operated + d < TIME) { operated += d; return; // update operated } operated = 0; // operation finished, update state... if (state == OPENING) { state = OPEN; } if (state == CLOSI...
f241692c-8414-40e4-b65b-23c80952c419
2
@Override public void removeProductType(ProductType productType) { if (productType != null && productTypes.contains(productType)) productTypes .remove(productType); }
cb031eb9-0c16-46d2-9fd6-c38c391a3f84
3
private int readBytes(byte[] b, int offs, int len) throws BitstreamException { int totalBytesRead = 0; try { while (len > 0) { int bytesread = source.read(b, offs, len); if (bytesread == -1) { break; } totalBytesRead += bytesread; offs += bytesread; len -= bytesread; }...
467e26fc-cd86-4349-9da7-cacb4468458c
1
private String display() { String mbrDisplay = ""; if (registerContents == null) { mbrDisplay += ""; } else { mbrDisplay += this.registerContents.toString(); } return mbrDisplay; }
6ab45425-891d-4f34-b855-db2e0dc89523
3
public KruskalMST(EdgeWeightedGraph G) { PriorityQueue<WeightedEdge> pq = new PriorityQueue<WeightedEdge>(); for (WeightedEdge e : G.edges()) pq.add(e); UnionFind uf = new UnionFindWQU(G.V()); mst = new LinkedList<WeightedEdge>(); while (!pq.isEmpty()) { WeightedEdge e = pq.remove(); int v = e.e...
20ba8752-4695-46b0-a62b-35b637a0a562
1
public void setDuration(int duration) { if (duration <= 0) { throw new IllegalArgumentException("Duration should be bigger than zero."); } this.duration = duration; }
0096a2b1-42a7-4793-9fc6-b125a7fedf25
6
public boolean SetLcLpPb(int lc, int lp, int pb) { if (lp < 0 || lp > Base.kNumLitPosStatesBitsEncodingMax || lc < 0 || lc > Base.kNumLitContextBitsMax || pb < 0 || pb > Base.kNumPosStatesBitsEncodingMax) { return false; } _numLiteralPosSta...
bdc5847b-7db8-41f8-9073-c011021b9527
5
@Override public List<Titre> findAll() { List<Titre> listT = new ArrayList<Titre>(); Statement st = null; ResultSet rs = null; try { st = this.connect().createStatement(); rs = st.executeQuery("select * from Titre"); System.out.println("recherche g...
17e08988-e28f-454c-bc3b-7b7ea696c8e2
1
private static void showMenu(){ Object seleccion = JOptionPane.showInputDialog( null,"Selecciona opcion","Selector de opciones", JOptionPane.QUESTION_MESSAGE,null, opcionesMenu, opcionesMenu[0]); if (seleccion!=null){ defineSeleccion(selecc...
4bc262c5-30a7-4d4b-a7dc-61181a306804
8
private void listenForMessages() { // loop and read input while (true) { // get message from client final String received = receiveMessage(); if (received == null) break; // we received a message from the client, now parse it and decide on // how to react try { // parse ...
3b2d4c5f-11c2-4d20-bc85-52e89b9dba20
4
@Override public void deserialize(Buffer buf) { super.deserialize(buf); int limit = buf.readUShort(); charactersToRecolor = new CharacterToRecolorInformation[limit]; for (int i = 0; i < limit; i++) { charactersToRecolor[i] = new CharacterToRecolorInformation(); ...
ef0b85d1-cea5-42f0-a034-46d40ae553ea
9
public boolean execute(Action a) throws IOException { boolean rc=false; QState state; if(a instanceof EnterMessageBoard) { // seems strange that we get this and that we need to send ANOTHER MC back. _session.send(new MC()); if(checkEmail()) _session.send(new NewMail()); rc=true; } else if(a i...
cdea5eea-62a4-4514-8f03-bbe2e285ed32
3
public static void main (String[] args) throws Exception { List<String> list = new ArrayList<String>(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); SecretDecoder decoder = new SecretDecoder(); String line = br.readLine().trim(); System.out.prin...
792509af-b027-4fc4-bd92-d37a1a4c1c34
2
public Paar getPaar(int id){ if(id < 0) return null; if(id >= 30) return null; return paare[id]; }
b48d9943-aa26-49e0-a003-e316ee9237e9
6
public HashMap dbDoubleHashing(String query) throws SQLException { Connection connection = null; Statement statement = null; ResultSet result = null; String key = ""; String val1 = ""; String val2 = ""; HashMap doubleHash = new HashMap(); HashMap hashedList1 = new HashMap(); HashMap hashedList2 = ne...
6ad102cc-2f78-40b6-9639-6a9868d9e5ad
5
public void body() { //////////////////////////////////////////////// // wait for a little while for few seconds. // This to give a time for GridResource entities to register their // services to GIS (GridInformationService) entity. super.gridSimHold(3.0); LinkedList ...
2e6f1a23-1560-4d35-ab13-b34cefbe945c
4
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; SSAVar other = (SSAVar) obj; if (version != other.version) return false; return true; }
71215ffd-45b5-435a-9bf5-89814701e335
2
public void setNumberOfAgents (int numberOfAgents) { if (this.numberOfAgents != numberOfAgents) { this.numberOfAgents = numberOfAgents; angle = 360.0 / (double)numberOfAgents; makeAgents(); canvas.setAgents(agents); // If we're already showing the first agents, repaint. ...
7452d691-39e8-42a0-8380-1b496cd99913
5
public void act() { super.act(); // Progress caret blinking animation. if (++blink == 20) blink = -20; oldCaret = caret; handleCopyCutPaste(); handleMouse(); if (hasFocus()) { if (Gr...
f14101c7-8e47-4c4b-bd28-62670cafb809
5
private Block[][] generateMap() { for(int i = 0; i < width; i++) { for(int j = 0; j < height; j++) { //goes through the map, generating a layer of air, layer of dirt, and then a mixed layer of stone 1 and stone 2 if(j < 6) { theMap[i][j] = new Block(0); } else if(j >= 6 && j <= 8)...
991dfc28-decf-46e5-ae46-7047309c18b3
7
public void handleGameStatus(GameStatus status, GameStatusCaretaker caretaker) { handleMemento(status, caretaker); status.setRounds(status.getRounds() + 1); status.setLevel(handleLevel(status.getLevel())); if (isLevelStateChangeRequired()) { if (status.getLevel() % EVALUATE...
af5d6c0b-1d44-4bc4-977c-e8aa7e1e7579
8
public static void main(String[] args) { Attribute a = new Attribute("a"); Attribute b = new Attribute("b"); FastVector fv = new FastVector(3); fv.addElement("check"); fv.addElement("raise"); fv.addElement("fold"); Attribute c = new Attribute("c", fv); FastVector attrs = new FastVector(3); attrs...
da1d5719-5c9c-48e8-8f22-37465727ec1a
7
public static void main(String[] args) { BufferedReader in; PrintStream out; Socket myClient; try { myClient = new Socket(hostname, port); in = new BufferedReader(new InputStreamReader(myClient.getInputStream())); out = new PrintStream(myClient.getOutputStream()); String line = ""; String[] stu...
cfda2a2b-b865-4b34-94e9-f377ce482f84
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...
1e7e06cb-3743-4410-9748-11f3444e7704
3
public static void createTable(Object[] what) { //Object[] what; String tableName = (String) what[0]; ArrayList<String> matches = (ArrayList) what[1]; ArrayList<String> names = (ArrayList) what[2]; ArrayList<String> types = (ArrayList) what[3]; ArrayList optional = (ArrayList) what[4]; String phrase...
9bc182c0-a313-451c-a724-87caac8d719b
5
private byte[] getRawCode(boolean includeDebug) { byte[] result = new byte[getCodeLength(includeDebug)]; short offset = 0; for (String name : componentNames) { if (!includeDebug && (name.equals("Debug") || name.equals("Descriptor"))) continue; byte[] currentComponent = (byte[]) capComponents.get(name); ...
a023adb8-286a-4358-b424-602a178aed4a
2
@Override public final Class<?> getColumnClass(final int columnIndex) { if (columnIndex == 0) { return Integer.class; } else { return Program.class; } }
0f8e5ce9-e910-4912-8865-da9a5eee72a0
1
@Test public void resolve() { Primes.isPrime(20); Map<Integer, Integer> factors = new HashMap<Integer, Integer>(); for (int i = 2; i <= 20; i++) { merge(factors, Utils.factorization(i)); } print(factors, mul(factors)); }
765fffe5-3ee5-4389-9977-9fa967d1c2a7
0
@Test public void testPlay() { // use implementation knowledge, to verifiy Game's behaviour. // Knowledge: Paper > Rock _underTest = new Game(_paperPlayer, _rockPlayer); assertEquals(_paperPlayer, _underTest.play()); // vice versa: _underTest = new Game(_rockPla...
c0c62862-8799-4396-9215-a35c5b745884
5
public void Init(){ Start start = new Start(); MapPointList.add(start); //空地 MapPointDisplayList.add(start.GetDisplayNow()); MapPointDisplayListNow.add(start.GetDisplayNow()); for(int i=1;i<=13;i++) { MapPointList.add(new Land(i,200,0)); MapPointDisplayList.add(TerritoryBsc.AREA);...
8adcc0e4-79d1-4dc8-911e-6ee59da5ba27
0
public String toCSV() { return super.toCSV(); }
21d82214-db03-4296-867b-c548fffb813d
2
public DBLPCleansing(String path) { write2db = new BaseDBLPInfos(); filepath = new File(path); try { reader = new BufferedReader(new InputStreamReader( new FileInputStream(filepath), "utf-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e....
19e1e91a-1313-43d2-aa9a-8718931dd9d1
8
@Override public void mouseMoved(MouseEvent e) { if (e.getSource().equals(this.pnLeftImage) || e.getSource().equals(this.pnRightImage)) { JPanelPicture currentPanel = (JPanelPicture) e.getSource(); Point currentAnchor = null; Point currentOffset = new Point(); Point currentSize = new Point(); if ...
5c6ca5e5-2cb6-413b-812a-5867be06f1e7
3
public Outline getBestOutlineForRowIndex(int index) { Outline outline = getRealOutline(); for (Outline other : outline.mProxies) { if (other.mFirstRow <= index && other.mLastRow >= index) { return other; } } return outline; }
6e39bda1-2309-4582-bb55-6be516d92bca
8
public static void main(String[] args){ int grade; grade = Integer.parseInt(args[0]); if (grade <= 100 && grade >= 85) System.out.println("HD"); else if (grade <= 84 && grade >= 75) System.out.println("D"); else if (grade <= 74 && grade >= 65) System.out.println("C"); else if (grade...
55af64b9-f5b6-448f-8b2c-785ef6035931
5
public boolean checkGoal(State state) { for (int k = 0; k < state.getData().size(); k++) { for(int m = 0; m < state.getData().get(k).size(); m++) { if (state.getData().get(k).get(m).equals("$") || state.getData().get(k).get(m).equals(".")) { return false; } } } endTime = System.nanoTime(); ...
d9abf0c1-d678-48c8-9c88-ba09ad06cb89
5
@BeforeTest @Test(groups = { "Two-Three Tree", "Insertion" }) public void test23TreeInsertion() throws DuplicateKeyException { Integer count; Reporter.log("[ ** 2-3 Tree Insertion ** ]\n"); try { timeKeeper = System.currentTimeMillis(); for (int i = 0; i < seed; i++) { // System.out.println(i); ...
2272e53c-a155-4365-8572-c3e6c9c39152
7
private void multipoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipoActionPerformed if (imageActual == null) { JOptionPane.showMessageDialog(null, "No existe una imagen cargada previamente, por favor, cargue una en Archivo->Cargsr..", "Error", JOp...
a5483fda-5856-4bec-a301-2512b34546a6
9
@Override public void paint( Graphics g ) { if( hdrImage == null ) { g.setColor(Color.BLACK); g.fillRect(0, 0, getWidth(), getHeight()); } else { int scale = 2; while( hdrImage.getWidth()*scale <= getWidth() && hdrImage.getHeight()*scale <= getHeight() ) { ++scale; } --scale; int left ...
71167746-32e5-4a90-bed9-d44122c3b7cb
8
public void checkItemsOfLeveledListsForPatching() { // Creating new RBS LeveledList containing exchanged Armor Entries with corresponding new RBS Armors of all bodytypes String ID; MajorRecord MJNew; SPProgressBarPlug.setStatus("getting leveledItemsWithArmorEntries"); Li...