method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
291f5b45-dedf-4818-9ab5-469c118cca6f
2
public User getUser(Integer i) { User result = new User(); Iterable<Entry> userQuery = this.query("{id:" + i + "}"); if (userQuery.iterator().hasNext()) { for (Entry user : userQuery) { result = (User) user; } } return result; ...
625aa5de-bd06-4f98-a03f-024e958092d3
4
public void update(Graphics g) { Graphics gImg = null; Dimension dmImg = null; Dimension dm = getSize(); int wndWidth = dm.width; int wndHeight = dm.height; if((dmImg == null) || (dmImg.width != wndWidth) || (dmImg.height != wndHeight)) { dmImg = new Dimension(wnd...
5e63a8de-96e3-4845-9b80-f4c974135e25
8
public void moveCameraToScene(Scene scene, boolean immediately) { Scene previous = scene.getPrevious(); if (previous != null) { String s = previous.getDepartInformation(); if (s != null) { runScriptImmediatelyWithoutThread("set echo bottom center;color echo yellow;echo \"" + s + "\""); } else { ...
2c92daa2-26cf-4a22-9a15-b74c90e6dbb6
5
@SuppressWarnings("unchecked") public int addTag(String filename, String tagType, String tagValue) { Tag t = new Tag(tagType, tagValue); Iterator it = GuiView.control.getCurrentUser().getAlbumList().entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, Album> pairs = (Map.Entry<String, Album>) it.ne...
55b8d927-d812-4fb5-87c6-4a2fa66ab6ed
2
public static void readStandardInput() { if (readingStandardInput) return; try { in.close(); } catch (Exception e) { } emptyBuffer(); // Added November 2007 in = standardInput; inputFileName = null; readingStandardInput = true; inputErrorCou...
5a902ac1-8965-442a-9ccd-d0e3e2f54a6d
2
public LoginWindow(ClientGUI clientInterface) { mInterface = clientInterface; setTitle("Login"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 190, 304); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayo...
19e2819c-cb61-4109-93aa-e85a7a12191b
8
public boolean batchFinished() throws Exception { if (getInputFormat() == null) throw new IllegalStateException("No input instance format defined"); Instances toFilter = getInputFormat(); if (!isFirstBatchDone()) { // filter out attributes if necessary Instances toFilterIgnoringAttri...
ab92e27c-54b4-4af0-b666-2ce771545c2f
3
public double getTempRange(String type){ double t=0; if (type.equals(MASHOUT)) t = MASHOUTTMPF; else if (type.equals(SPARGE)) t = SPARGETMPF; if (tempUnits.equals("C")) t = BrewCalcs.fToC(t); return t; }
213d8e95-5744-4e71-9995-6c6c84f3accd
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof ClassAce)) return false; ClassAce other = (ClassAce) obj; if (canonicalTypeName == null) { if (other.canonicalTypeName != null) return false; } else if (!canonical...
71862572-e8a7-4e46-947e-3e86f3eda7ea
7
public List<Character> getCharacterList(String path) { List<?> list = getList(path); if (list == null) { return new ArrayList<Character>(0); } List<Character> result = new ArrayList<Character>(); for (Object object : list) { if (object instanceof Charac...
27398307-0f20-45ce-9210-fa3ed58e7850
7
private static StructureComponent getNextComponentVillagePath(ComponentVillageStartPiece par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) { if (par7 > 3 + par0ComponentVillageStartPiece.terrainType) { return null; ...
06d86d65-d3a8-417b-a919-ade079952a16
6
@Override public void printReception() { if (!readTemplate()) return; // Заполняем то, что необходимо заменить fillMappings(); JOptionPane.showMessageDialog(null, "Заменяем данные ", "Инфо", JOptionPane.INFORMATION_MESSAGE); // Очищаем документ try { org.docx4j.model.datasto...
008b1993-4350-4165-abf5-78dcaa160c7c
7
@Override public void run() { try { while(run) { testCase.update(); if(testCase.getAvgFitness() == Double.POSITIVE_INFINITY) { correctSolutions++; totalGenerations += testCase.getGener...
71a300da-f2d5-40df-9476-aba1ac47c89d
2
public static void disposeFonts() { // clear fonts for (Font font : m_fontMap.values()) { font.dispose(); } m_fontMap.clear(); // clear bold fonts for (Font font : m_fontToBoldFontMap.values()) { font.dispose(); } m_fontToBoldFontMap.clear(); }
3e62f432-9b93-4f8a-87b7-62bbd4db09fa
7
public static void main(String[] args) { int counter = 0; int start = 22; long sum = 0L; while (counter < 11) { int currentLeft = start; int currentRight = start; while (isPrime(currentLeft) && currentLeft > 0) { currentLeft = leftShift(currentLeft); } while (isPrime(currentRight) && curre...
2060965c-1955-4c9e-ba2f-8c9a4ebcffba
0
public void onTick(Instrument instrument, ITick tick) throws JFException { // 各通貨ペアのティック情報を受信した際に呼ばれます。 // LOGGER.info("onTick"); }
71e6c14a-27a4-475c-a8be-f46ef92362b8
6
public static int jump(int[] A) { if (null == A || 0 == A.length) return -1; int len = A.length; int[] step = new int[len]; step[len - 1] = 0; for (int i = len - 2; i >= 0; i--) { int min = len + 1; for (int j = i + 1; j <= i + A[i] && j < len; j++) { if (min > 1 + step[j]) ...
8069830e-5e09-436e-ad2a-aa9470b6fea3
8
public BellmanFordAlgorithm(IWeightedGraph<N, Number> graph, N source) { for(N node : graph) { nodes.put(node, new Node<N>(node, Double.MAX_VALUE)); } nodes.get(source).distance = 0; List<WeightedEdge<N, Number>> edges = graph.getEdges(); for(int i = 1; i < graph.size(); i++) { for(WeightedEdge<N, Nu...
4e8bd921-475c-40e5-9fc3-36bce6934ddd
4
public String encode(String plain) { //int period=key.length(); String plain_u=plain.toUpperCase(); int left=plain_u.length()%(key.length()*2); int add_x=0; if(left!=0) { add_x=key.length()*2-left; } for(int i=0;i<add_x;i++) { plain_u+='X'; } ...
ebcb2ddf-1d7a-4bd9-8eb0-31db6bb11164
4
public static StatusWapper constructWapperStatus(Response res) throws WeiboException { JSONObject jsonStatus = res.asJSONObject(); //asJSONArray(); JSONArray statuses = null; try { if(!jsonStatus.isNull("statuses")){ statuses = jsonStatus.getJSONArray("statuses"); } if(!jsonStatus.isNull("reposts...
73690a3a-8d86-4732-b1df-2b7c90e659f0
7
private static void loop() { String menu[] = {"Quitter", "Statistiques", "Personnalisée", "Supérieur", "Prédéfini"}; int choix; int quit; Jeu jeu = new Jeu(); quit = -1; do { choix = JOptionPane.showOptionDialog( null, "Quelle action voulez-vous faire?", "Banque", JOptionPane.YES_NO_OPTIO...
6a9c4ad3-481a-4f2a-8a78-3e0197c5388b
6
public boolean newCompraAction(String id_compras, String costo, String descripcion, String nombre, String cantidad, String fecha) throws SQLException, EmptyFieldException { boolean res; conn = ConexionBD.getInstance(); if(id_compras.isEmpty() || costo.isEmpty() |...
09812a58-3a26-4674-953d-14562fe7d229
3
public int lengthOfLongestSubstring(String s) { int length = s.length(); int max = 0; int index = -1;// 为了保证length =1 时正确。 Map<Character,Integer> map = new HashMap<Character,Integer>(); for (int i =0; i < length;i++){ char key = s.charAt(i); if(map.contain...
73981096-1078-433e-ab6b-72ccc26b076a
8
@Override public void transform(double[] src, double[] dst) { // TODO Auto-generated method stub for (int i = 0; i < 3; i++) temp2[i] = src[i]; temp2[3] = 1; for (int i = 0; i < 3; i++) { dst[i] = 0; for (int j = 0; j < 4; j++) { dst[i] += matrix[i][j] * temp2[j]; } } for (int i = ...
cbdf3714-88ef-4b89-8603-e6f4452501d8
1
public Organism createOrganism(List<Gene> genes) { List<Gene> copyGenes = new ArrayList<>(); for (Iterator<Gene> it = genes.iterator(); it.hasNext();) { copyGenes.add(new Gene(it.next())); } Genome newGenome = new Genome(nextEnabeledGenomeID(), copyGenes); //refresh N...
09c58472-a957-4bd1-961b-a74d3fa88a46
5
public UserStoreImpl(String userListFilename, String level3ElectorateFilename, String level5ElectorateFilename ){ storeFile = new File(userListFilename); if (storeFile.exists()){ try{ users = new HashMap<String, User>(); Scanner scanner = new Scanner(storeFile); while (scanner.hasNextLine()) { ...
af713570-f785-40b0-b358-8f3a901e0b01
4
public void sendChannelMSGExclude(Client excludeme, String message){ if(excludeme != null){ for(Client c: usershere){ if(!(excludeme.equals(c))){ c.sendMessage(message); } } } else { for(Client c: usershere){ c.sendMessage(message); } } }
37929af4-6b20-4c05-9929-a02fa10609b1
6
protected boolean initBehavior() { java.lang.Class cl; if (behavior == null) return true; if (!super.initBehavior()) return false; if (!super.initBehavior()) return false; if ((cl = getMyBehavior()) == null) return true; ...
379442f7-3380-41e8-9299-f3de99bf63f6
4
@Override public int doStartTag() throws JspException { handleEventualEvictCache(); RestletResourceFactory factory = new RestletResourceFactory(); Logger logger = Context.getCurrentLogger(); String fullSearchUri = buildSearchUriToUse(); logger.log(Level.FINEST, "fullSearchUri: " + fullSearchUri); Lis...
8714b8dc-9aa8-44b8-997f-f1cec81cc9bb
8
public void possibleMoves() { int[] top = { 0, 0, 0 }; for (Pin p : pins) { if (!p.isEmpty()) top[p.id] = p.getTopDisc().getSize(); } System.out.println((top[0] < top[1] ? "[L -> C]" : "[ ]") + " " + (top[0] < top[2] ? "[L -> R]" : "[ ]") + " " + (top[1] < top[0] ? "[C -> L]" : "[ ...
c45f2c37-929c-4d01-a939-fa1720fba0a8
0
public String getColumnName(int column) { return COLUMN_NAMES[column]; }
af838b39-51ba-4476-9c47-d6cfedc08300
1
@Override public boolean action() throws JSONException { if (getResult().getJSONObject("char").getString("viergewinnt").equals( "4")) { Output.printTabLn("Vier gewinnt steht auf 4: " + getResult().getJSONObject("char").getString("var1"), Output.INFO); } else { Output.printTabLn("Vier gewinnt",...
c0dcd2f5-c8e8-4cb7-bb48-73aad8e831b4
5
public Population select(Population population){ Config config = Config.getInstance(); if (selectionType == null){ return population; } switch(selectionType){ case ROULETTE: return rouletteWheel(population, config.populationSize); case SUS: return stochasticUniversalSampling(population, config....
e64ff70c-b850-4203-853d-14b37a270e06
2
private int getNumberOfNewLinesTillSelectionIndex(String allLogText, int selectionIndex) { int numberOfNewlines = 0; int pos = 0; while((pos = allLogText.indexOf("\n", pos))!=-1 && pos <= selectionIndex) { numberOfNewlines++; pos++; } return numberOfNewlines; }
0239de08-58c6-480e-a0ab-40362d8e4992
2
public double observe() { RandomVariable unif = null; try { unif = new ContinuousUniform(0, 1); } catch (ParameterException e) { e.printStackTrace(); } double u = unif.observe(); int observed = 0; double cumulativeMass = 0; while (cumulativeMass < u) { cumulativeMass += mass(observed); obser...
b71e63eb-20f2-4351-bf51-d6e5e186703b
7
private static TspPopulation[] generate(){ Graph g = new Graph(INDIVIDUAL_SIZE); TspPopulation[] h = new TspPopulation[GLOBAL_STEPS]; for (int i = 0; i < GLOBAL_STEPS; ++i){ h[i] = new TspPopulation(POPULATION_SIZE, INDIVIDUAL_SIZE, g.getGraph()); } resultsRandom = ne...
67af2196-507d-4d99-b37b-3e0f7308fbba
0
public String getName(){ return Name; }
454b80e2-f072-454d-a509-f8ca0000cc99
0
public synchronized void setSharedCounter(int sharedCounter) { this.sharedCounter = sharedCounter; }
5000b1c9-aa05-4c61-8fe9-17c7faa271d1
3
public static void loadLevel(final int level, final World world) { BufferedReader breader = new BufferedReader(new InputStreamReader(Main.class.getResourceAsStream("/level_" + level + ".lvl"))); Tile[][] tiles = new Tile[World.TILE_Y][World.TILE_X]; try { world.setDescription(breader.readLine()); for...
3cfb536e-69f0-4b06-856d-52c293357dbd
2
public boolean exist(int searchId) { ListElement current = this.getHead(); while (current != null) { if (current.getId() == searchId) { return true; } current = current.getNext(); } return false; }
4d6ede3d-035f-4a39-b3da-33d4dca66eb3
9
public Shader (String s) { shader= ARBShaderObjects.glCreateProgramObjectARB(); if(shader!=0){ vertShader=createShader(loadCode("Shaders/"+s+".vert"), ARBVertexShader.GL_VERTEX_SHADER_ARB); if (hardDebug) System.out.println("[Shader] Vertex shader code loaded: "+s); f...
819e42fc-2900-4c74-bb57-3c7b77b2ec60
9
void checkFrameValue(final Object value) { if (value == Opcodes.TOP || value == Opcodes.INTEGER || value == Opcodes.FLOAT || value == Opcodes.LONG || value == Opcodes.DOUBLE || value == Opcodes.NULL || value == Opcodes.UNINITIALIZED_THIS) { return; ...
7bba2a1f-a3bc-476f-a6b3-b572977159fb
8
@Override public void mouseDragged(MouseEvent e) { Point pt = e.getPoint(); JComponent parent = (JComponent) e.getComponent(); if (startPt != null && Math.sqrt(Math.pow(pt.x - startPt.x, 2) + Math.pow(pt.y - startPt.y, 2)) > gestureMotionThreshold) { startDragging(parent, pt); startPt = null; ...
a1097643-1057-426c-a715-46841c9738b7
8
private Component cycle(Component currentComponent, int delta) { int index = -1; loop : for (int i = 0; i < m_Components.length; i++) { Component component = m_Components[i]; for (Component c = currentComponent; c != null; c = c.getParent()) { if (component == c) { index = i; break loop; } ...
792a57e4-6be0-48dc-9e6a-102d9c2b22aa
6
public void setVision(Coords coords, int size) { int xLoc = coords.getX(); int yLoc = coords.getY(); int y = 0 - size; int x = 0; for (int i = 0; i<=size*2; i++) { x = (int)Math.sqrt((size*size) - y*y); int dist = Math.abs(-x)+ x; ...
0aa88bec-0907-4ea7-8f19-4906649ab00d
2
protected void teeTilaus(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Otetaan sessiosta vastaan sinne tallennettu tilaus-olio. Tilaus tilaus = (Tilaus) request.getSession().getAttribute("tilaus"); int tilausID = 0; // Tallennetaan saatu tilaus tietoka...
5f901f98-c2af-4348-be61-e8bc914398e5
0
public Comparator getDirectoryComparator() { return directoryComparator; }
2c1054c6-d2c2-4a70-b764-926dfd22714d
1
private boolean jj_2_50(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_50(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(49, xla); } }
e15e15bd-05db-4c24-b29b-8491f611c98b
9
public void warn(Event event) { String c = ""; switch(event.getTypeEvent()) { case WHITE_DETECTED : c = "White"; case COLOR_DETECTED : if(event.getName().equals(color) || c.equals(color)) { if(state == 3) { state = 4; } else ignore(); } else ignore(); break; case GOFORWAR...
0f8c05b1-7602-43bd-b0bd-09d17a5d73d9
3
public T pop(){ if(size == 0) throw new NoSuchElementException(); T value = arr[--size]; arr[size] = null; if(size > 0 && size == arr.length / 4) resize(arr.length / 2); return value; }
6a52387c-fe45-44b6-8d27-ccf7dbff8a8c
3
public static ArrayList<Position> findPieces(Board b, int piece) { ArrayList<Position> pieces = new ArrayList<Position>(); for (int rank = 0; rank < b.board.length; rank++) { for (int file = 0; file < b.board[rank].length; file++) { if (b.board[rank][file] == piece) { pieces.add(new Position(rank, file...
c4f97b3c-72d4-47c8-8b72-8f97119067e8
4
public static Object toReflectType(String typeSig, Object value) { switch (typeSig.charAt(0)) { case 'Z': return new Boolean(((Integer) value).intValue() != 0); case 'B': return new Byte(((Integer) value).byteValue()); case 'S': return new Short(((Integer) value).shortValue()); case 'C': return ne...
4102cd03-5cb7-4fd2-bddf-af84051a8c48
4
@Override public String getFileName() { return getName() + "_x" + planeCenterX + "_y" + planeCenterY + "_w" + planeWidth + "_h" + planeHeight + "_it" + mits + (crossHairs ? "_ch" : "") + (drawBox ? "_box(" + boxCenterX + "," + boxCenterY + ")(" + boxWidth + "x" +...
51b8f0a9-8153-4229-b94e-e39f6d9f49dc
2
public double cdfUpEq(double p, int k, int n) { if (k < 0) return 1.0; if (k > n) return 0; double cdf = cdfUp(p, k, n) + pdf(p, k, n); cdf = Math.min(1.0, cdf); return cdf; }
9989f40e-4377-4b2f-91cc-b04a11cf024b
6
public static int guessLoomDefinitionArity(int arity, Stella_Object definition, Cons constraints) { if ((arity == -1) && (definition != null)) { arity = Logic.computeLoomDescriptionArity(definition); } if (arity == -1) { { Stella_Object c = null; Cons iter000 = constraints; ...
1574547d-f872-4b7d-a4cd-ccabb229b15b
1
public boolean isEmpty() { boolean retVal = false; if (backPtr == -1) { retVal = true; } return retVal; }
fd78511e-e106-4dac-a7ee-9b8ff919c6f1
4
public static void writeToFile(List<String> lines, File f) throws IOException { System.out.println("writeToFile function started."); String encoding = code(f); encoding = "UTF-16LE"; FileOutputStream fos = new FileOutputStream(f); OutputStreamWriter writer = new OutputStreamWriter(fos, encoding); // Outpu...
c372c762-a9a6-4efe-a94e-7faeb53526ac
1
public void write(final DataOutputStream out) throws IOException { out.writeShort(modifiers); out.writeShort(name); out.writeShort(type); out.writeShort(attrs.length); for (int i = 0; i < attrs.length; i++) { out.writeShort(attrs[i].nameIndex()); out.writeInt(attrs[i].length()); attrs[i].writeData...
5d896bd8-52cb-4ad2-9c57-d41ea3cfab6d
3
public final void translate(double x, double y, double z) { if (DIRS[0] != x || DIRS[1] != y || DIRS[2] != z) { // Cache it! DIRS[0] = TRANSLATE.entry[0][3] = x; DIRS[1] = TRANSLATE.entry[1][3] = y; DIRS[2] = TRANSLATE.entry[2][3] = z; } premultiply(TRANSLATE); }
f91f8c8c-a359-4ed1-a486-6a15994c918a
6
public synchronized void start() throws Exception { if (thread != null) { throw new Exception("ProcessRunner already started."); } thread = new Thread(new Runnable() { @Override /** run() * * The run function of the runnable object within the thread * Checks to see if any ProcessChildren...
d5ca1f0b-d208-4b6e-9882-a6c0f5d1d0fb
3
public boolean deleteEvidence(Evidence c) { Element evidenceE; boolean flag = false; for (Iterator i = root.elementIterator("evidence"); i.hasNext();) { evidenceE = (Element)i.next(); if (evidenceE.element("id").getText().equals(c.getId())) { evidenceE.element("isDelete").setText("true"); // Write t...
a9401622-4e3a-4b8d-a3d0-5952d3aaf931
2
public EqualDivisionNormalDistributedOrdersGenerator( int numberOfForerunPeriods, int offSet) { if (numberOfForerunPeriods < 0 || offSet < 0) throw new IllegalArgumentException(); this.forerun = numberOfForerunPeriods; this.offSet = offSet; }
6fec74c7-926a-4134-9e00-a57add060478
1
public ListModel<ICPBrasilCertificate> getChainListModel() { DefaultListModel<ICPBrasilCertificate> lmodel = new DefaultListModel<>(); for (ICPBrasilCertificate c : this.getCertificate().getChain()) { lmodel.addElement(c); } return lmodel; }
95da984d-718b-4660-9845-4684927a6a3c
6
public String login() { User fetchUser = userHelper.getUser(username, password); if (fetchUser != null) { // success user = fetchUser; loggedIn = true; if (user.getType().equals("admin")) { admin = true; librarian = true; } if (user.getType().equals("librarian")) librarian = true; // ...
622d3cd1-90f7-4f4a-8e36-16cd37cc31ca
2
public void setupCommands() { PluginCommand cs = plugin.getCommand("cs"); CommandExecutor commandExecutor = new CommandExecutor() { public boolean onCommand( CommandSender sender, Command command, String label, String[] args ) { if (args.length > 0) { cs(s...
af1c9691-6e6e-4a92-9446-d5acdd855a35
8
public static String decodeJavaEscape(String encoded){ if(encoded.indexOf('\\') == -1) return encoded; StringBuffer buf = new StringBuffer(); for(int i = 0; i < encoded.length(); i++){ if(encoded.charAt(i) == '\\'){ char c = encoded.charAt(++i); switch(c){ case 't': buf.append('\t...
95b41d60-785e-4550-974f-78311d4fb463
5
@Override public void actionPerformed(ActionEvent e) { if( e.getSource() == boton_alta_empleado ){ Controlador.getInstance().accion(EventoNegocio.GUI_ALTA_EMPLEADO,GUIPrincipal_Empleado.this); } else if( e.getSource() == boton_baja_empleado){ ...
f5e7542c-7a73-4957-a1d4-4ec7af8cb9b3
2
public int setBusy() { for(int i=0; i<this.docStates_IsBusy.length;i++) if(!this.docStates_IsBusy[i]) { this.docStates_IsBusy[i] = true; return i; } return -1; }
d626b5c1-6610-41ce-b18b-6e8d021a98f3
0
public void setName(String name) { this.name = name; }
e74fadb7-1430-42a9-9b35-5dcfaea8fc2e
5
public void gameRender(ScreenManager screenmanager, ClientStreamReader reciever) { sm = screenmanager; recieveDataHandler = reciever; init(); while(running){ Graphics2D g = sm.getGraphics(); try{ networkTransmit(); }catch(Exception e){ System.err.println("network transmission"); ...
7b8cbbad-4bd6-4a21-826e-92cb73808d6c
9
public static void main(String ... args) throws AWTException, InterruptedException { TetrisSensor sensor = new TetrisSensor(); Point p = sensor.getBoardPosition(); Point [][] points = sensor.getGridPointArray(p); if (p != null) { int width = 0; int height = 0; ...
53ced38a-e343-4722-a597-81ef614e9886
5
public void checkEvent(){ // for(String script : haltables.keySet()) // System.out.println(script+": "+haltables.get(script)); for(String script : scripts.keySet()) if(!triggered(script)){ // System.out.println("CondMet: \""+script+"\"\t"+ // main.evaluator.evaluate(scripts.get(script).getKey())+"\ttrig...
8db31443-9659-4678-9859-e668defeb9a9
9
public Forest<T> build(Iterable<T> values) { /* * 1. split by cardinality * 2. from low cardinality to high: append nodes * */ Map<Integer, Map<List<E>, T>> byCardinality = Maps.newTreeMap(); for (T value : values) { List<E> path = funnel.getPath(value); ...
6fed1686-2c65-4380-9b89-c2a4b0118164
1
private String showOpenDialog(){ JFileChooser fc = new JFileChooser(); int rc = fc.showDialog(null, "Select Data File"); if (rc == JFileChooser.APPROVE_OPTION){ File file = fc.getSelectedFile(); return file.getAbsolutePath(); } return null; }
ebd27676-13ed-4cc2-aebc-91b84dda8fc2
2
public void decrementLifetime() { lifetime--; if(lifetime == 0) for(PositionChangedObservable o : hoveringElements) { o.accept(new DeactivatePowerFailureVisitor()); } }
98fcdab0-527c-426e-aaad-705685fe43f1
8
public boolean commandPASS(String nombreUsuario, String passwordUsuario) { if (nombreUsuario == null || passwordUsuario == null) { out.println("autentication_error"); return false; } else { try { // Leer el listado de Usuarios y contrasenas BufferedReader reader = new BufferedReader(new F...
580a1f9b-c181-47e6-9065-dfc9706f5c02
5
public static String createContact(String name, String email, String publicKey, String memo) { String contactID = "error"; System.out.println("in createContact"); AddressBook addressBook = Helpers.getAddressBook(); if (addressBook == null) { System.out.println("createContact...
7058a876-2f27-4b81-bdcc-c5574fcacb70
1
public JsonArray getArray(int index) { Object value = get(index); if (value instanceof JsonArray) { return (JsonArray) value; } return new JsonArray(); }
42b1531f-9b9c-41e2-8ceb-9cd4ec458f7f
3
@Override public boolean isRelevant(GameState inState){ boolean isLiveSeer = (inState.playerTest(this.Player) == 2); boolean isDeadSeer = (inState.playerTest(this.Player) == -2); int TimeOfDeath = inState.getTimeOfDeath(this.Player); if(isLiveSeer){ return true; } else { if(isDeadSeer && (this.Round...
eba336c0-53e6-4446-b2ad-26f51494290a
4
public int bestPolynomialFit(){ this.methodUsed = 3; this.sampleErrorFlag = true; this.titleOne = "Best polynomial fitting: r = c[0] + c[1].a + c[1].a^2 + ... + c[n].a^n; best fit degree (n) = "; if(!this.setDataOneDone)this.setDataOne(); ArrayList<Object> al = super.bestPolynom...
d2347a2b-dba7-433b-8605-651b2aaf52e2
7
@Override public ArrayList<String> getTopStreak() { ArrayList<String> top_Players = new ArrayList<String>(); PreparedStatement pst = null; ResultSet rs = null; try { pst = conn.prepareStatement("SELECT player_name FROM `ffa_leaderboards` ORDER BY `killstreak` DESC"); rs = pst.executeQuery(); int count...
c8e07355-e872-4ff3-bebc-f76dd98b7ec5
4
public void fadeOut() { stopFadeIn(); if(fadeTime > 0.0f) { if(fadeOut != null) { if(!fadeOut.isFading()) { stopFadeOut(); fadeOut = new GameMusicFade(this, currentGain, getMinGain(), fadeTime, 0.0f); } } els...
5cd0e05f-8e2c-4cc3-a82c-03088a878b29
5
private float[] normalize(byte[] pixels, float[] normComponents, int normOffset) { if (normComponents == null) { normComponents = new float[normOffset + pixels.length]; } // trivial loop unroll - saves a little time switch (pixels.length) { case 4: ...
d5b1b4b6-93da-4b0b-a023-198472b1d84c
7
public synchronized void valueChanged(TreeSelectionEvent e) { if (decompileThread != null) return; TreePath path = e.getNewLeadSelectionPath(); if (path == null) return; Object node = path.getLastPathComponent(); if (node != null) { if (hierarchyTree && hierModel.isValidClass(node)) lastClassName...
49d425ce-2554-4f61-a313-2a88e7d47bc5
2
public void run() throws IOException { //Setup Logging environment FileHandler file = new FileHandler(config.serverLog); file.setFormatter(new SimpleFormatter()); LOG.setLevel(Level.INFO); LOG.addHandler(file); // create server socket and set timeout to 0 ServerSocket ss = new ServerSocket(config.port,...
3d3b6caf-a79a-4cab-8b19-46a47e0f8bca
6
private Image getImage(AffineTransform transformation) { if (cachedImage == null || lastZoom != pModel.getZoom() || lastOffsetX != pModel.getViewOffsetX() || lastOffsetY != pModel.getViewOffsetY() || lastCanvasWidth != pModel.getCanvasWidth() || lastCanvasHeight != pModel.getCanvasHeight()) ...
4053f33e-a457-433e-a723-c179d98dd3f6
1
static boolean isBoardElementEmpty(char boardElement) { return boardElement != NEXT_LINE_FIELD_CHAR && boardElement == EMPTY_FIELD_CHAR; }
695831a5-1b84-425f-befe-953a923d477e
7
private int goTowardsTargetDirection(){ if (target.getX() == this.getX()){ int yDistance = target.getY() - this.getY(); if (yDistance <= 0){ return Standards.NORTH; } else { return Standards.SOUTH; } } else if (target.getY() == this.getY()){ int xDistance = target.getX() - this.getX(); if...
7c0f87f2-cc49-40d1-b0d9-88efe66e84e0
1
@Override public void mouseClicked(MouseEvent event, Rectangle bounds, Row row, Column column) { Boolean enabled = (Boolean) row.getData(column); row.setData(column, enabled.booleanValue() ? Boolean.FALSE : Boolean.TRUE); }
f1fa5459-10ee-4533-833e-c92f3f509304
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; BankClient other = (BankClient) obj; if (accounts == null) { if (other.accounts != null) return false; } else if (!accounts.equals(other...
6c187409-31d3-4a7b-b1d5-2e3fffb70cd0
7
@Override public double membership(double x) { if (Double.isNaN(x)) { return Double.NaN; } //from Octave smf.m double a_b_ave = (bottomLeft + topLeft) / 2.0; double b_minus_a = topLeft - bottomLeft; double c_d_ave = (topRight + bottomRight) / 2.0; ...
568a15ef-5454-46bb-ac06-502919080e03
2
private static boolean isValidPrice(Float price) { return price != null && price >= PRICE_MIN && price <= PRICE_MAX; }
e6fb567c-3234-477a-b9ac-07f7b2398282
0
public Main() throws Exception { Config.glAvoidTextureCopies = true; Config.maxPolysVisible = 1000; Config.glColorDepth = 24; Config.glFullscreen = false; Config.farPlane = 4000; Config.glShadowZBias = 0.8f; Config.lightMul = 1; Config.collideOffset ...
7f209dcb-89c9-4f63-b129-71dbbf362a60
4
public MinuetoImage flip(boolean horizontal, boolean vertical) { if (horizontal == false && vertical == false) { // Have Nothing To Do But Return Original Image return (MinuetoImage) this.clone(); } else { /* What we want to flip */ int iFlipX = 1, iFlipY = 1; /* Test our Arguments and Convert to ...
76ad012e-c5af-4504-b54d-c3294a516494
0
public void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; }
ff04e552-6920-4cfb-a257-5995c7b55bfe
2
public synchronized void status(HTSMsg msg, int clientId){ Subscription s = getSubscription((Long) msg.get("subscriptionId"), clientId); HTSPServerConnection c = monitor.getServerConnection(s.serverConnectionId); msg.put("subscriptionId", s.serverSubscriptionId); try { c.send(msg); } catch (IOException e) ...
bd4eb960-240c-44c8-8461-14b8e6bfd232
7
public static String checkForBootstrapperUpdates(boolean verbose, String currentVersion, JSONObject versionsConfig) { if (Util.versionIsEquivalentOrNewer(currentVersion, versionsConfig.get("latestmupdate").toString())) { //Jump out if the launcher is up to date Logg...
898f26c7-f362-4cde-9474-cadafd4b21ce
2
public static QuenchThirst getSingleton(){ // needed because once there is singleton available no need to acquire // monitor again & again as it is costly if(singleton==null) { synchronized(QuenchThirst.class){ // this is needed if two threads are waiting at the monitor at the ...
158ad57a-2506-47b7-bf35-f61dcfaf4b9c
7
public static void startupLiterals() { if (Stella.currentStartupTimePhaseP(0)) { Stella.ZERO_WRAPPER = IntegerWrapper.newIntegerWrapper(0); Stella.ONE_WRAPPER = IntegerWrapper.newIntegerWrapper(1); Stella.FALSE_WRAPPER = BooleanWrapper.newBooleanWrapper(false); Stella.TRUE_WRAPPER = BooleanW...
68d46c55-7434-47a0-ade5-301e92b71b07
8
public Function parse() { System.out.println(s); StringTokenizer tokenizer = new StringTokenizer(s); while (tokenizer.hasMoreTokens()) { String str = tokenizer.nextToken(); last = operation_stack.peek(); if (str.equals("(")) { operation_stac...