method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
550c811f-4337-4669-abab-5b97c1a8b8b8
0
public void exceptionalMethod() { throw new TestException(); }
d10c2c10-682e-43a3-9a52-89abd63eac25
1
public String updateOffline(Product p) { try { String sql = "UPDATE stock SET productName = ?, count = ?, price = ?, feature = ? where productId = "+p.getpId(); PreparedStatement ps = StatusController.connection.prepareStatement(sql); ps.setString(1, p.getpName()); ps.setInt(2, p.getAmount()); ps...
e829a34c-0a2e-43d0-be65-17731ad5ac8e
4
public int logIn(String username, String password) { try { String host = "localhost"; socket = new Socket(host, 2001); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); out = new PrintWriter(socket.getOutputStream(), true); ...
2fa6d097-37ee-40a0-aef0-6f3816a182e1
7
public boolean isSameTree(TreeNode p, TreeNode q) { if (p == null) return q == null; if (q == null) return p == null; TreeIterator ip = new TreeIterator(p); TreeIterator iq = new TreeIterator(q); while (ip.hasNext() && iq.hasNext()) { if (!eq...
5a0491df-fdea-45c5-8e42-c2ce1ab97304
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; AdjacencyListElement other = (AdjacencyListElement) obj; if (target == null) { if (other.target != null) return false; } else if (!targe...
484a0145-8e29-4a05-8e6a-38ce26c9f573
3
public List<ObjectiveObj> getObjectiveTable(PreparedStatement pre) { List<ObjectiveObj> items = new LinkedList<ObjectiveObj>(); try { ResultSet rs = pre.executeQuery(); if (rs != null) { while (rs.next()) { ObjectiveObj item = new ObjectiveObj(...
b314c762-63a2-4a16-bd4d-9476b92acadd
5
public ArrayList<Copy> getAllCopies(){ try { if(conn == null || conn.isClosed()){ conn = DatabaseConnection.getConnection(); } } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ArrayList<Copy> copyList = new ArrayList<Copy>(); try...
cb33621f-bd8f-4ace-8359-dfd73b44d415
7
protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) { JPopupMenu result = new JPopupMenu("Chart:"); boolean separator = false; ...
25881960-b21d-42ff-9757-3dc8f3f40eb6
1
@Test public void resolve() { BigDecimal n1=new BigDecimal(1); BigDecimal n2=new BigDecimal(1); BigDecimal num=new BigDecimal(3); int count=2; while(num.toString().length()<1000){ count++; num=n2.add(n1); n1=n2; n2=num; } print(count); }
523113dd-4640-4c17-9f73-753dfec7e8b4
0
public void setNameFromTextField() { firstNameText.setText((Name.getInstance().getFirstName())); middleNameText.setText((Name.getInstance().getMiddleName())); lastNameText.setText((Name.getInstance().getLastName())); }
71d42186-677a-4ac6-9dc2-7e1fe2befcd0
4
public List<Double> getDoubleListFromString(String xArg) { if (xArg == null || xArg.equalsIgnoreCase("")) return null; List<Double> d = new ArrayList<Double>(); char[] c = xArg.toCharArray(); int lastPos = 0; for (int i = 0; i < c.length; i++) { if (c[i] == ',') { d.add(Double.valueOf(re...
42456ce8-1586-4b46-a595-bc795cb218d8
2
private boolean has6Neighbors(PieceCoordinate butterflyPos) { int neighbors = 0; Iterator<Entry<PieceCoordinate, HantoPiece>> pieces = board.entrySet().iterator(); PieceCoordinate next; while(pieces.hasNext()) { Entry<PieceCoordinate, HantoPiece> entry = pieces.next(); next = entry.getKey(); if (nex...
179dd8d9-ecd8-46f1-b1f7-b98c809aabaf
1
public static BufferedImage loadImage(String path){ try { return ImageIO.read(new FileInputStream("res/" + path + ".png")); } catch (IOException e) { e.printStackTrace(); } return null; }
5e283e1b-83d8-4c91-bc82-dc97a0ea493f
5
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final SanitizeEvent other = (SanitizeEvent) obj; ...
bacd689d-00cc-49e9-8740-00343468a79d
1
public void submitMode(boolean isSubmitMode) { if (isSubmitMode) { submissionPane.setViewportView(new SubmitView(this)); } else { submissionPane.setViewportView(submissionView); } }
bb606329-06b3-470d-b5a7-f4017c899fb2
7
private void getResponseBipolarList() { titleDLM.removeAllElements(); bipolarQuestionList = bipolarQuestion.getResponseBipolarList(fileName, publicFileName, counterTeamType); if (bipolarQuestionList.size() != 0) { for (int i = 0; i < bipolarQuestionList.size(); i++) { titleDLM.addElement(bipolarQuestionLis...
00fee885-628c-4e28-b4da-be347fecc5a9
7
private Class _clazz(Class clazz){ switch(clazz.getName()){ case "boolean": return java.lang.Boolean.class; case "int": return java.lang.Integer.class; case "float": return java.lang.Float.class; case "double": return java.lang.Double.class; case "long...
3dca291d-3a1d-48c1-95db-d5e1536f70b1
6
private boolean compruebaImpactoMisil(Nave jugador){ for (int i=0;i<sprites.size();i++) if (sprites.get(i).getClass()==Misil.class) { Misil laserEnemigo=(Misil)sprites.get(i); if ((laserEnemigo.getX()>jugador.getX() && laserEnemigo.getX()+laserEnemigo.getWidth()<j...
b75a042e-3a46-4f58-a086-1995b05596ea
8
private void updateClaim(boolean choice1) { switch (claim.getStatus()) { case UnRanked: claim.rank(choice1 ? Claim.Rank.Complex : Claim.Rank.Simple); JOptionPane.showMessageDialog(form, "The claim has been ranked " + (choice1 ? Claim.Rank.Complex : Claim.Rank.Simple))...
943159d5-e526-4522-b5d9-3d86be79e4a2
4
public BrickBreaker() { panel = new BrickBreakerPanel(); //build the frame and attach everything to it. frame = new GameFrame( "Brickbreaker by Jeremy", GAMEHEIGHT, GAMEWIDTH, new BrickBreakerMenu( GAMEWIDTH ...
3f4d5ecd-7ec4-4d1d-8aba-9bcabf03aca5
8
public void testContext() { int min = -80; int max = 80; int size = max - min; for (double v : new double[] { -15D, -10D, -5D, 5D, 15D }) { double[] table = new double[2]; char[][] data = new char[size][size]; int i = 0; int j = 0; for (double x = min; x < max; x++, i++) { j = 0; for (d...
6d5a4467-8664-4e98-aed6-4cc7045af8fc
8
public void update() { if (walking) animSprite.update(); else animSprite.setFrame(0); if (fireRate > 0) fireRate--; double xa = 0, ya = 0; double speed = 1.0; if (input.up) { ya -= speed; animSprite = up; } else if (input.down) { ya += speed; animSprite = down; } if (input.left) { xa -=...
16bdd834-eca6-4d18-afeb-88770bf94ea9
2
public static String getSuffixWithDot(String s){ if(s == null || s.isEmpty()){ return null; } int lastDotIndex = s.lastIndexOf("."); int length = s.length(); String suffix = s.substring(lastDotIndex, length); return suffix; }
afdd34cc-a621-4958-99ee-3f2ff6a84b00
4
public void run() { try { Synthesizer synthesizer = MidiSystem.getSynthesizer(); synthesizer.open(); MidiChannel channel = synthesizer.getChannels()[0]; while (true) { if (play == true) { channel.programChange(instType); channel.noteOn(pitch, velocity); pause = 350; play = false...
9c9cc191-ff26-4f0e-b53f-8850bf669c5a
0
public int getPort() { return port; }
eb75f3fd-012c-4cc2-838f-1a64a5417ba5
1
protected String getTag() { return newArray ? "new[]" : "new"; }
5d8f4d39-a8d8-4cc7-a9b9-839d56599fc5
1
public boolean containsNode(String idRef) { return terminals.containsKey(idRef) || nonterminals.containsKey(idRef); }
777c399c-c8e1-4f48-91ec-9f616b8e4afc
9
public void run() { /* forall v in V doe label(v) <- EMPTY; * for i<-n downto 1 do * let v be an unnumbered vertex with largest label; * number(v); * forall unnumbered neighbours of v do * label(w) <- label(w) + {i} */ NVertexOrder<D> order = new NVertexOrder<D>(); int bestUpperBound = Int...
a28b852e-1b6d-4d87-a686-60582e51227c
0
public void setNext(Items next) { this.next = next; }
943938b2-7477-4890-b342-b9ecda398e46
5
public Player getNextLocatorPlayer(){ ArrayList<Player> onlineFriends = getOnlineFriends(); if(onlineFriends.size() == 0) return null; int index = 0; if(playerLocator != null){ Player currLocator = Bukkit.getPlayerExact(playerLocator); System.out.print("1"); if(currLocator != null && onlineFriends.cont...
64cc0e67-31f3-49da-99c3-698558d6cc3a
8
protected void handleExpandStateChanged() { if (isExpanded()) { if (scrollpane.getParent() != this) add(scrollpane); } else { if (scrollpane.getParent() == this) remove(scrollpane); // collapse all pinnable palette stack children that aren't pinned for (Iterator iterator = getContentPane().getC...
6c8ec12c-feda-4bdc-b059-19d2f823436f
3
private void paintNaves(Graphics2D g2d){ int nNaves = juego.getnNaves(); List<Nave> nav=naves; List<Nave> list = (nNaves==2) ? nav : nav.subList(0, 1); for (Nave n : list) { if(n.isVivo()) n.paint(g2d); } }
b4769592-9df0-4527-98d8-7fc104e707ce
7
public void setZeroes(int[][] matrix) { boolean[] row = new boolean[matrix.length]; boolean[] col = new boolean[matrix[0].length]; for(int i=0; i<matrix.length; i++) { for(int j=0; j<matrix[i].length; j++) { if(matrix[i][j] ==0) { ro...
771a7c62-f0e0-465a-9cee-726e149d8922
2
public static boolean commitToFile(ArrayList<Employee> employees, String filePath) { try { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); Document employeeDoc; DocumentBuilder docBuilder = dbFactory.newDocumentBuilder(); employeeDoc = docBuilder.newDocument(); Element roo...
9a574749-d964-49e1-9a1a-667f3165cf4c
0
public void mouseDragged(MouseEvent e) { //System.out.println("============= mouseDragged ============"); moveCamera(e); }
50786d44-e673-47fb-8d6b-df1f0591da8b
0
private static void init(){ // создание и заполнение списка list.add(new Cube(3,0,0)); list.add(new Orb(1,2,5,5)); list.add(new Tetrahedron(1,2,3,12)); list.add(new Cylinder(1,1,5)); //list.add(new Cube(2,0,0)); // list.add(new Orb(3,4,1,0)); ...
8fb139a2-8350-46c4-811c-c416027b4800
6
public void renderHUD(Box2D bounds) { super.renderHUD(bounds) ; if (selection.selected() != null) { camera.setLockOffset(infoArea.xdim() / -2, 0) ; } else { camera.setLockOffset(0, 0) ; } camera.updateCamera() ; if (currentPanel != newPanel) { beginPanelFade() ; ...
06eee5ea-1d23-4b54-94f4-bfcc1b4bbca6
5
public final void processFFT(double pitchShift, double[] gFFTworksp) { int k, qpd, index; double real, imag, magn, phase, tmp; double[] gAnaMagn = this.gAnaMagn; double[] gAnaFreq = this.gAnaFreq; double[] gSynMagn = this.gSynMagn; double[] gSynFreq = this.gSynFreq; /* this is the analysis step...
48e8552d-7f71-480c-a136-e87ebc7ccd27
7
private static void printHubDetails (int indent, Device dev) { try { Hub h = new Hub (dev); int ports = h.getNumPorts (); boolean indicator = h.isIndicator (); indentLine (indent, (h.isRootHub () ? "Root " : "") + "Hub, " + ports + " ports" ); indentLine (indent, "overcurren...
6a91a8d5-000a-49d0-9e7f-18be08cc9427
3
public ParticleGenerator(Class<? extends T> impl, actor.interfaces.Movable source) { try { ctor = impl.getConstructor(); } catch (SecurityException e) { e.printStackTrace(); return; } catch (NoSuchMethodException e) { e.printStackTrace(); ...
ee034fb8-6ad5-4a14-a70f-94abf7012fe7
4
public void downloadJarFromJenkins(String urlPrefix, String localPath) { InputStream input = null; FileOutputStream writeFile = null; try { String path = getJenkinsRelativePath(urlPrefix); URL url = new URL(urlPrefix+"lastStableBuild/artifact/"+path); System.out.println(url...
19a68011-1e51-4ae9-94be-20f3dcf52fd8
6
private Node merge(Node startLeft, int leftLength, Node startRight, int rightLength) { int leftCounter = 0; Node leftCursor = startLeft; int rightCounter = 0; Node rightCursor = startRight; Node startCursor = null; Node mergeCursor = null; int totalLength = leftLength + rightLength; for (int i ...
c25a356a-a88f-4c27-88f3-352ed1a716d0
5
public double pow2(double x, int n){ // deal with negativity separately if(n == Integer.MIN_VALUE) return 1.0/(pow2(x, n+1) * pow2(x, -1)); if(n < 0) return 1.0 / pow2(x, -n); // can not handle the case where n = MIN_VALUE if(n == 1) return x; if(n == 0) return 1.0; double y = po...
e0ae2f33-cf46-4ff1-9fdb-aab1374ba9bb
1
public void updateUniforms(Matrix4f worldMatrix, Matrix4f projectedMatrix, Material material) { if(material.getTexture() != null) material.getTexture().bind(); else RenderUtil.unbindTextures(); setUniform("transform", projectedMatrix); setUniform("color", material.getColor()); }
13c3a5d6-cf08-4f29-8fce-58992c79c94f
2
public void enable() throws IOException { // This has to be synchronized or it can collide with the check in the task. synchronized (optOutLock) { // Check if the server owner has already set opt-out, if not, set it. if (isOptOut()) { configuration.set("opt-out", ...
15e4cb79-9432-4cc0-82da-18262bb905b7
2
private void Equipa2_RadioButtonItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_Equipa2_RadioButtonItemStateChanged if(Equipa2_RadioButton.isSelected()) Jogador_ComboBox.setEnabled(true); if(Equipa2_RadioButton.isSelected()== false) Jogador_ComboBox.setEnabled(f...
af032b44-4eb9-4f19-ba52-aaf58c901dc8
7
@SuppressWarnings("unchecked") private<PType extends IPerformances> List<GenericTestResults<Double, CTDiscreteNode, ICTClassifier<Double,CTDiscreteNode>, PType>> executeTests( List<ITestFactory<Double, CTDiscreteNode, ICTClassifier<Double,CTDiscreteNode>, PType>> testFactories, List<ITrajectory<Double>> dataset,...
d2490ba4-2fe2-4c2a-957e-a7be10dbda99
2
public void PlayAgain(){ System.out.print("Do you wish to play again? Y or N: "); Scanner input = new Scanner(System.in); String answer = ""; answer ="n";//input.nextLine(); if (answer.equalsIgnoreCase("y")) { input.close(); new Game(); } else if (answer.equalsIgnoreCase("n")) { input.clo...
82ff5c30-0922-4b3e-a290-3cb29dd9b793
9
public void configureOtherEtcProperties(){ if (getDebug()) System.out.println(getProperties().size()+" property updates found"); for (Map.Entry<String, String> e:getProperties().entrySet()){ File file=new File(getFuseHome(), "etc/"+e.getKey().split("_")[0]+".cfg"); if (!file.exists()) throw ...
0c956c53-ac0d-4b73-9cef-813ccc5b3323
7
public String[] mapTypes(String[] types) { String[] newTypes = null; boolean needMapping = false; for (int i = 0; i < types.length; i++) { String type = types[i]; String newType = map(type); if (newType != null && newTypes == null) { newTypes =...
5be1fec4-6b96-4a3b-9654-2f5c4246a87e
8
public void putAll( Map<? extends Float, ? extends Integer> map ) { Iterator<? extends Entry<? extends Float,? extends Integer>> it = map.entrySet().iterator(); for ( int i = map.size(); i-- > 0; ) { Entry<? extends Float,? extends Integer> e = it.next(); this.put( e....
8894e576-b96d-4b0b-96a3-385de2ed96a6
1
@Override public void restartMachine(IMachine machine) throws InvalidObjectException, ConnectorException { try { CloudStackClient client = ClientLocator.getInstance().getClient(machine.getComputeCenter().getProperties(), controllerServices); client.rebootVirtualMachine(machine.getName()); } catch ...
f3d834bb-2306-4103-b065-46a57cbfda35
9
public Interactable.Result keyboardInteraction(Key key) { try { switch(key.getKind()) { case ArrowDown: return Result.NEXT_INTERACTABLE_DOWN; case Tab: case ArrowRight: return...
87ed6018-0682-4886-8726-b10ed9b0086a
6
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Hill other = (Hill) obj; if (field == null) { if (other.field != null) return false; } else if (!field.equals(other.field)) return fa...
96fd7db9-5e2f-4e5d-883e-bb88c9bb5ac8
4
private static void populateEntities(World world, String uin, int loops){ TileMap tm = world.tileMap; for(int i = 0; i < loops; i++){ EntityLiving el = (EntityLiving) Entity.createEntityFromUIN(uin, tm, world); int x = new Random().nextInt(tm.getXRows()); int y = new Random().nextInt(tm.getYRows()); ...
6571a33d-60a6-43ad-b711-51c417902b22
5
protected void restoreButtonBorder(AbstractButton b) { Object cp = b.getClientProperty("paintToolBarBorder"); if ((cp != null) && (cp instanceof Boolean)) { Boolean changeBorder = (Boolean)cp; if (!changeBorder.booleanValue()) { return; } } ...
19066e8b-453e-4761-a2f3-a895daff48ea
1
public void setNametextFontsize(int fontsize) { if (fontsize <= 0) { this.nametextFontSize = UIFontInits.NAME.getSize(); } else { this.nametextFontSize = fontsize; } somethingChanged(); }
674bc0b4-bd3e-4619-8864-812c87b4ef47
8
void parseOtherServersList(String list) { // Splitlist String[] temp = list.split(";"); String IP = null; String BindingName = null; int Port = 0; for (int i = 0; i < temp.length; i++) { switch (i % 3) { case 0: IP = temp[i]; // System.out.println("IP: "+IP); break; case 1: Binding...
fdd57b67-8d7a-4e7d-84e5-eec083239646
1
public static void init3dCanvas(int x, int y) { Rasterizer.lineOffsets = new int[y]; for (int i = 0; i < y; i++) { Rasterizer.lineOffsets[i] = x * i; } Rasterizer.centerX = x / 2; Rasterizer.centerY = y / 2; }
dc04a0e8-a613-43a8-bb04-1d18e4e8868e
1
public Declaration(String jsonFile) throws FileNotFoundException, IOException, Exception { String JSONInfo = FileReader.loadFileIntoString(jsonFile, "UTF-8"); json = JSONObject.fromObject(JSONInfo); nomCycle = json.get("cycle").toString(); NumeroPermis = json.get("numero_de_permis").toS...
3e8dbc2a-71bd-42b1-9c0b-b1d9c0efc982
4
public int removeDuplicates(int[] A) { int MAX_REPEAT = 2; if( A.length <= MAX_REPEAT ) return A.length; int p = 0; int r = 1; for( int i = 1; i < A.length; i++ ) { if( A[i] != A[p] ) { A[++p] = A[i]; r = 1; } else { ...
d87cd807-f01e-4549-b151-ddd07a0a83f3
3
public void run() { String producedData = ""; try { while (true) { if (producedData.length()>75) break; producedData = new String("Hi! "+producedData); sleep(1000); // It takes a second to obtain data. theBuffer.putLine(producedData); } } catch (Exception e) { // Just let thread termina...
090ff37a-fd88-49cf-81e5-4f75a348bab4
7
private Object popupCombo(Object combobox) { // combobox bounds relative to the root desktop int combox = 0, comboy = 0, combowidth = 0, comboheight = 0; for (Object comp = combobox; comp != content; comp = getParent(comp)) { Rectangle r = getRectangle(comp, "bounds"); combox += r.x; comboy += r.y; Recta...
5e12ed9a-824f-4fcf-ac20-7c8f949ee3a4
7
public static void main(String[] args) { // TODO Auto-generated method stub Class clsObj=null; try{ clsObj = Class.forName("UsingAnnotation"); } catch(ClassNotFoundException cnfe){ cnfe.printStackTrace(); } try { Method mthd = clsObj.getMethod("fun", null); if(mthd.isAnnotationPresent(MyAnnota...
aa3875e0-d1f8-49c5-b091-a16f0a67f2ac
8
@Override public void analyzeCoverage() { // in this analysis, skip and count the read pair where either read // or mate are flagged as unmapped if (this.getSamRecord().getReadUnmappedFlag() || this.getSamRecord().getMateUnmappedFlag()) { readMateUnmappedCount++; return; } // in this analysis, ski...
5d77fc66-2ab4-4d4a-807d-f9d51ff7e917
9
final public SimpleNode Start() throws ParseException { /*@bgen(jjtree) Start */ SimpleNode jjtn000 = new SimpleNode(JJTSTART); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1)); try { booleanSentence(); jj_consume_token(0); jj...
d7bb4a1f-4787-4c92-b04c-3be3f761dc39
0
public int getMouseX() { return mouseLocation.x; }
939a881b-c870-4bd3-bf12-64dd6a28a4ed
8
static void write(Command cmd, OutputStream out) throws UnsupportedEncodingException, IOException { encode(cmd.getCommand(), out); for (Parameter param : cmd.getParameters()) { encode(String.format("=%s=%s", param.getName(), param.hasValue() ? param.getValue() : ""), out); } ...
4817f473-3c5a-4eec-a38d-6e41fd50e14d
5
public void begin() { final ObjectInputStream in; final ObjectOutputStream out; try { in = new ObjectInputStream(socket.getInputStream()); out = new ObjectOutputStream(socket.getOutputStream()); Thread input = new Thread() { @Override public void run() { while(true) { readMessage(in)...
688fbffb-c266-40e5-bf79-7b7978a2d7f0
5
private void checkAttribute() { ExpressionDecomposer ed=new ExpressionDecomposer(); //check select Iterator<Expression> s=select.iterator(); while(s.hasNext()) { ArrayList<String> selectAttrs=ed.getIdentifiers(s.next()); Iterator<String> selectIterator=selectAttrs.iterator(); while(selectIterator.ha...
02aef370-d73d-4514-8821-265228536325
2
@Override public boolean removeLockByResources(Set<String> resources) { boolean thereturn = false; for (String resource : resources) thereturn = removeLockByResource(resource) || thereturn; return thereturn; }
5fe5075d-e89f-4574-b7f0-2b316c2f8f55
5
public boolean checkForBookIssuedOrNot(IssueBookVO issueBookVO) throws LibraryManagementException { boolean returnValue = true; ConnectionFactory connectionFactory = new ConnectionFactory(); Connection connection; try { connection = connectionFactory.getConnection(); } catch (LibraryManagementException...
02aa2864-c85b-4199-a59f-7ad39c04cbc0
4
private void checkForRemovedMarkers() { markersToRemove.clear(); for (Node node : pane.getChildren()) { if (node instanceof Marker) { if (getSkinnable().getMarkers().keySet().contains(node)) continue; node.setManaged(false); node.removeEventHan...
5e122e53-6631-43d7-af2e-23151613255f
8
public static void start() { System.out.println("MAYBE IT WORKS?"); try { try { new ServerClassLoader(). //ServerRestarter.class.getClassLoader(). loadClass("server.Server").getConstructor(int.class).newInstance(port); return; } catch (InstantiationException e) { e.printStackTrace(); }...
94de4be7-d8a0-4f10-b90c-cfa8c72c0a45
2
@Override public void Parse(Session Session, EventRequest Request) { if (Session.GrabActor().Frozen) { return; } int X = Request.PopInt(); int Y = Request.PopInt(); Session.GrabActor().GoalPosition = new Position(X, Y, Session.GrabActor().CurrentPosition.Z); if (Session.GrabActor().IsMoving...
f411f8b8-7f7d-4c8d-9a45-19e59b9a6beb
9
static void sortWith0(int[] a, int fromIndex, int toIndex, IntComparator cmp) { final int length = toIndex - fromIndex + 1; if (length < 2) return; if (length == 2) { if (cmp.gt(a[fromIndex], a[toIndex])) { int x = a[fromIndex]; a[fromIndex...
fb0570da-a2fd-49c7-9e91-96e2518b059f
6
private void validate() throws RrdException { boolean ok = true; if(timestamps.length != values.length || timestamps.length < 2) { ok = false; } for(int i = 0; i < timestamps.length - 1 && ok; i++) { if(timestamps[i] >= timestamps[i + 1]) { ok = false; } } if(!ok) { throw new RrdException("I...
cfb3416b-d1c8-41c0-9043-74d1a46ef4f9
5
public Archive(File file) throws IOException { // Initialize this.file = file; files = new HashMap<String, ArchiveFile>(); if (!file.exists()) return; // Open the file to read RandomAccessFile raf = null; try { raf = new RandomAccessFile(file, "r"); // Read the header int filecnt = changeEndian...
616861d5-d72c-41d5-8bb0-ba5b7bd461de
3
@Override public boolean store() throws SQLException{ if(super.store()== false){ return false; } else if(super.getID()==-1) { return false; } SQLiteJDBC db = new SQLiteJDBC(); String sql = String.format( ...
7d10f17a-9304-4b21-8a84-a2f9554187dc
4
public static PrivateKey getPrivateKey(String pem) throws IOException, GeneralSecurityException { PrivateKey key = null; byte[] bytes = getFragmentOfPEM(pem, RSA_PRIVATE_KEY_PEM_HEADER, RSA_PRIVATE_KEY_PEM_FOOTER); String rsa = new String(bytes); String spli...
89a1af35-f471-45b6-a4c3-2e3792ef3a9c
5
public ObjectDefinition method580() { int i = -1; if (varbitFileId != -1) { VarBit varBit = VarBit.cache[varbitFileId]; int j = varBit.configId; int k = varBit.anInt649; int l = varBit.anInt650; int i1 = Client.anIntArray1232[l - k]; ...
f705de00-f4ad-4a04-837e-ef5450f71d00
2
@Override public boolean evaluate(T t) { if(firstSearchString.evaluate(t) || secondSearchString.evaluate(t)){ return true; } else{ return false; } }
a5bcf1f1-e17c-4410-a4b6-08d205082794
5
public boolean actionDisinfest(Actor actor, Crop crop) { final Item seed = actor.gear.bestSample( Item.asMatch(SAMPLES, crop.species), 0.1f ) ; int success = seed != null ? 2 : 0 ; if (actor.traits.test(CULTIVATION, MODERATE_DC, 1)) success++ ; if (actor.traits.test(CHEMISTRY , ROUTINE_DC , 1...
473f7569-2648-416e-b252-84e4bff8b71b
0
public static void main(String[] args) { /* * try { // Set cross-platform Java L&F (also called "Metal") * //UIManager * .setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); * UIManager. * setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); * } catch (UnsupportedLookAndFeelE...
ce3ec1bf-bbbb-4aea-a484-90db9562ecfe
7
private ListNode insertIntoSortedList(ListNode target, ListNode source){ //initialize if(target == null){ target = new ListNode(source.val); }else{ ListNode p = target; //if source is the smallest one. if (target.val > source.val) { target = new ListNode(source.val); ...
354e97bb-7e97-4f03-ab70-3b7165684ef6
7
@Override protected ERGameEvent readEventStream(InputStream inputStream) throws IOException { ObjectInputStream ois = new ObjectInputStream(inputStream); switch(ois.readInt()){ case (ERGameEvent.EVENT_MESSAGE_C): return ERGameEvent.EventMessageClient(ois.readUTF()); case (ERGameEvent.EVENT_MESSAGE)...
23b8ce7e-7aad-4a01-aaf0-69fe8e75e4ae
9
public static void main(String[] args) { int startPort = 8000; int endPort = 8001; int TIMESPAN = 10; String serverIp = "localhost"; String output = "y"; for (int i = 0; i < args.length - 1; i++) { if (args[i].equals("-sp")) { startPort = Integer.parseInt(args[i + 1]); } if (args[i]...
c66f6d5d-0ce7-4445-97db-85325fba3b4b
0
public boolean getJumpKeyPressed() { return jumpKeyPressed; }
b3293b81-640b-46bc-81f3-57a797e23f5f
0
public void setZ(int z) { this.z = z; }
b288b356-8205-45b9-b829-07e6270e1d45
3
public void stop() { if (!loading()) { // Make sure there is a sequencer: if (sequencer == null) return; try { // stop playback: sequencer.stop(); // rewind to the beginning: sequencer.setMicrosecondPosition(0); // No need to listen any more: sequencer.removeMetaEventListener(thi...
2da4a376-ca86-4c9c-a2dc-57888fe1a1d8
2
public static String byteToHexString(byte[] data) { // convert the byte to hex format method 2 StringBuffer hexString = new StringBuffer(); for (int i = 0; i < data.length; i++) { String hex = Integer.toHexString(0xff & data[i]); if (hex.length() == 1) hexString.append('0'); hexString.append(hex); ...
7e0dca14-6562-4c46-98c6-02be3b5c4a48
9
private static Path processPath(final List<String> PATH_LIST, final PathReader READER) { final Path PATH = new Path(); PATH.setFillRule(FillRule.EVEN_ODD); while (!PATH_LIST.isEmpty()) { if ("M".equals(READER.read())) { PATH.getElements().add(new MoveTo(READER.nextX()...
b4315476-c31f-43ab-98c8-6d167cce7fd4
7
public static void main(String[] args) { // Load the project properties Properties properties = new Properties(); try { properties.load(new FileInputStream("src/main/resources/threadedMerge.properties")); } catch (IOException e) { System.out.println("Error: could...
c988d162-9079-4488-9ff7-1f40e67b8888
1
public List<Element> getElementsOnGrid() { final List<Element> elements = new ArrayList<Element>(); for (Square square : squares.values()) elements.addAll(square.getElements()); return elements; }
e25f8bae-c6c7-47a1-80ee-a255a7c996ed
9
@Override public void init (AbstractQueue<QueueElement> queue, Properties props) throws MalformedURLException, ParserConfigurationException, TransformerConfigurationException { this.queue = queue; this.props = props; String strInputURL = System.getPr...
c1343184-5bc8-4eb3-8fcd-11bafa726330
4
@Override public boolean execute(AdrundaalGods plugin, CommandSender sender, String... args) { // Grab the argument, if any. String arg1 = (args.length > 0 ? args[0] : ""); if(arg1.isEmpty()) { plugin.reloadConfigs(); plugin.reloadDataFiles(); Messenger.sendMessage(sender, Ch...
aef73deb-91dc-4695-8c55-269f7d7755a6
5
public void personDetailsForm() { super.personDetailsForm(); // If fields not empty if (name != null && address != null && email != null && contactNumber != null) { // Edit mode selected if (editMode) { driver.getPersonDB().changePersonDetails(person, name, email, contactNumber, address, 0, null...
332b1194-1028-420c-b07b-0efccc8acec3
0
public Air() { super(Color.white, false); }
a9f9d66d-a9af-4557-8a9e-6628f5492fb0
5
public void testCompare2Spreadsheets( WorkBookHandle bk1, WorkBookHandle bk2 ) throws Exception { WorkSheetHandle[] s1 = bk1.getWorkSheets(); WorkSheetHandle[] s2 = bk2.getWorkSheets(); if( s1.length != s2.length ) { log.info( "These Workbooks do not have the same sheet count. Original: " + s1.length + "...
e4e038a5-b41f-452e-942d-12d4b5a25bc1
7
private void readGrid() throws FileNotFoundException, IllegalArgumentException, ArrayIndexOutOfBoundsException{ boardReader = new Scanner(startBoard); String row = ""; int rowCount = 0; while (boardReader.hasNext()) { row = boardReader.next(); rowCount++; } boardReader = new Scanner(startBoard); gri...