method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
fad79130-98e9-4041-a79a-b7226d551d99
7
private Tela navegarTelaVisualizarDadosAlunos(NavigationEvent event) { if(dbController != null && event != null && event.getArg("Aluno") != null){ Aluno aluno = (Aluno) event.getArg("Aluno"); AlunoTurmaDAO alunoTurmaDAO = new AlunoTurmaDAO(dbController); Collection<? extends...
3c2f28a4-2733-4d49-8103-dc85c504bb50
0
public void paintConfiguration(Component c, Graphics2D g, int width, int height) { super.paintConfiguration(c, g, width, height); FSAConfiguration config = (FSAConfiguration) getConfiguration(); // Draw the torn tape with the rest of the input. Torn.paintString((Graphics2D) g, config.getInput(), RIGHT_ST...
a1c4353e-8430-4495-a9b2-d8a7797410c8
0
@Override public String toString() { return name; }
bab356af-c523-4504-9aa2-4f048d6e9aab
2
@EventHandler(priority = EventPriority.LOW) public void onPlayerChat(AsyncPlayerChatEvent e) { if (e.getMessage().startsWith(ft.chatColorPrefix) && e.getPlayer().hasPermission("fasttitles.colorchat")) { String baseMsg = e.getMessage().substring( ft.chatColorPrefix.length()); // get rid of chat prefix ...
f741191f-8c43-42bb-99bc-02e5b8c551a7
9
@Override public SpaceObject getSpaceObject(CMObject o, boolean ignoreMobs) { if(o instanceof SpaceObject) return (SpaceObject)o; if(o instanceof Item) { if(((Item)o).container()!=null) return getSpaceObject(((Item)o).container(),ignoreMobs); else return getSpaceObject(((Item)o).owner(),ignoreM...
867ea30b-2e81-401f-89b8-5b17fcedd3cd
5
private Double evaluate(LinkedList<Token> s, Queue<Integer> variablePosition, double x) throws EmptyStackException{ LinkedList<Token> temp = new LinkedList<Token>(s); for (Integer j : variablePosition) { temp.set(j, new Token(Double.toString(x))); } Stack<Token> stack = new Stack<Token>(); for (Token toke...
3dda4dfb-bbe9-43fd-8455-541f87a8a043
3
private Token fetchKey () { if (flowLevel == 0) { if (!allowSimpleKey) throw new TokenizerException("Found a mapping key where it is not allowed."); if (addIndent(column)) tokens.add(Token.BLOCK_MAPPING_START); } allowSimpleKey = flowLevel == 0; forward(); tokens.add(Token.KEY); return Token.KEY; }
79e084db-e69c-45ce-8662-c3dfbf605b55
2
public void put(String name, Object value){ if (map != null){ map.put(name,value); }else{ Class propType = getType(name); // Convert only if we have a propTargetType (otherwise, it is a map value, so, as is) Object propValue = (propType != null)?mapper.as(propType, value):value; classInfo.setValue(ob...
f7ca2949-7139-44fa-abec-a296a764648b
1
public boolean containsID(int id){ return (first_city.getID() == id || second_city.getID() == id); }
d5698867-fc99-4fc3-820e-b808a1a7f2e8
3
public int readAns() { boolean readAns = true; int ans = getInt( "Enter 1 if yes, enter 2 if no." ); while (readAns ) { if ( ans != 1 && ans != 2 ) { System.out.println( "Oops, your answers must be 1 or 2, try again." ); ans = getInt( "Enter 1 if yes, enter 2 if no." ); } else { readAns = false...
afe6e406-e31f-4e81-bcc8-3e353d05e525
7
public boolean needsGui() { if (inNeedsGui) { return false; } inNeedsGui = true; try { if (getBeanContextPeer() != this) { if (getBeanContextPeer().needsGui()) { return true; } } Object c...
b48f6806-88f0-46d1-81db-8eeb5a014581
6
public AvailableGroup getDifference(AvailableGroup group) { if (group == null) group = new AvailableGroup(); Map<Integer, Integer> ret = new HashMap<>(items); for (Entry<Integer, Integer> ent : group.items.entrySet()) { int amnt = get(ret, ent.getKey()); if (amnt < ent.getValue()) continue; update...
5964309b-32e1-4833-8351-e9c45ccbe7a1
0
public void addHeader(String name, String value) { header.put(name, value); }
61a5e4fa-99c2-4021-b775-d727c660634a
3
public static BookItemStatusEnum getStatusByName(String name) { if (StringUtils.isEmpty(name)) { return null; } for (BookItemStatusEnum status : values()) { if (StringUtils.equals(status.name(), name)) { return status; } } return null; }
6d54a769-e43e-48ce-914a-96b90c3f0b10
0
public int getY(){ return y; }
9d0a99be-779a-4b7c-a618-d1a020e30ddb
8
public boolean hasSameFourValue(int x, int y) { if (hasNorth(y) && hasSouth(y) && hasEast(x) && hasWest(x)) { if (checkSameNorth(x, y) && checkSameSouth(x, y) && checkSameEast(x, y) && checkSameWest(x, y)) { return true; } return false; ...
2ed05b5b-da68-4e81-9987-4c8cc13db67d
5
*/ public void removeGroup( short group ) throws Exception { // remove the actual group groups.remove( (short)(group-1) ); // update all the versions to reflect the change HashSet<Integer> delenda = new HashSet<Integer>(); for ( int i=0;i<versions.size();i++ ) { Version v = versions.get( i ); if ( v...
e86a7022-f780-4019-80c2-38b11ca17df3
4
public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("New")) game.newGame(); else if (e.getActionCommand().equals("Check")) game.checkGame(); else if (e.getActionCommand().equals("Exit")) System.exit(0); else if (e.getActionComm...
b745646a-3de0-4305-9cf7-633b3da1eb3e
1
public void start() { tick = 0; switch(type) { case 1: break; } }
863d1d04-f041-429b-b17b-7dd5e0d005fb
4
public void pressedDecrypt() { String imgPath = txtImage.getText(); if (imgPath.isEmpty()) { displayError("Error", "Choose an image!"); return; } String imageSuffix = imgPath.substring(imgPath.lastIndexOf('.'), imgPath.length()); if (!(imageSuffix.equalsIgnoreCase(".png"))) { displayError("Error", ...
6e1de610-8d44-477f-8b32-d9e9f55992b7
5
public static void main(String[] args) throws Exception{ Scanner keyboard; String dictionary = "words.txt"; String corpus = "enron-skilling.txt"; String output = "output.txt"; HashSet<String> wrongWords = new HashSet<String>(); Trie trie = new Trie(); if(args....
c7437b73-a8d7-48de-8040-0d86e7b46454
1
public void save(){ try{ File outFile = new File(filePath); FileOutputStream outFileStream = new FileOutputStream(outFile); ObjectOutputStream outObjectStream = new ObjectOutputStream(outFileStream); outObjectStream.writeObject(this); outObjectStream.close(); } catch (IOException e){ System.out.pr...
a4a27273-d2d1-4fce-b858-4d5adcf29e11
3
public String envoyerRequete(String cmd) { String reponse = ""; try { socket = new Socket(host, port); socket.setSoTimeout(10000);//Timeout de 10 secondes PrintWriter printWriter = new PrintWriter(socket.getOutputStream(), true); BufferedReader inStream = new BufferedReader(new InputStreamReader(soc...
ed5212bb-3eb2-4662-9587-48344e7bca74
0
public static boolean isLink(File f) throws IOException { return Files.isSymbolicLink(Paths.get(f.getPath())); /* if (f.getName().toUpperCase().endsWith(".LNK")) return true; return ! (f.getAbsolutePath().equals(f.getCanonicalPath()));*/ // this doesn't seem to work on rela...
3fd43fe3-1719-47ce-902f-6bf507b917d6
9
public static void main(String[] args) throws IOException { if (args.length == 3) { // read the training and evaluation databases Vector<Map<Integer,Double>> training = Train.readDB(new File(args[0])); Vector<Map<Integer,Double>> evaluation = Train.readDB(new File(args[2])); //...
41ad38cc-2529-47aa-89b6-5062ee1b13e9
5
private void addPoint(){ double ansd = 0; String ans = null; ans = (String)JOptionPane.showInputDialog(this, "New point", "Add New Point", JOptionPane.PLAIN_MESSAGE, null, null, ""); if ((ans != null) && (ans.length() > 0)) { ansd = (Double.valueOf(ans)).doubleValue(); try{ if ...
fc80d518-01cb-4aa9-9883-ccff4f14ac57
1
public synchronized void disconnect() throws SQLException { if (connection != null) connection.close(); connection = null; }
46637268-e0a1-4c42-9a04-74dd29c6ffdb
3
private Item getRandomItem() { int num = _random.nextInt(3); Item item; switch (num) { case 0: item = null; break; case 1: item = new PinkPlant(); break; case 2: item = new GreenPlant(); break; default: item = null; break; } return item; }
5266a37d-02fd-4c07-8b8b-1f1e0dc08c25
2
public void visitEnum( final String name, final String desc, final String value) { buf.setLength(0); appendComa(valueNumber++); if (name != null) { buf.append(name).append('='); } appendDescriptor(FIELD_DESCRIPTOR, desc); buf.append...
5c709164-4bf5-42da-980e-d85719d673d8
1
@Override public boolean isEmpty() { return w==0 && h==0; }
fcd5415a-a1a1-4dbb-846f-f876d3c6535a
0
public PropertyTreeObjNode(Property prop,PropertyTree parent) { super(prop,parent); this.obj=null; }
cf038979-ae88-487b-bfe4-b21c2fe34e5c
0
@Test public void testCreditCardString() { assertEquals("Madalin Ignisca", this.card1.getCardHolder()); assertEquals(500, this.card1.getCreditLimit()); assertEquals(0, this.card1.getBalance()); }
926dd4e7-07b1-454b-bc1b-d7da03974997
6
private void checkEmployeeID() { if(evaluationResults[0].getText().length() > 0) { String [][]fieldPlacementData = ReadFromFile.getCompanyRelationship(); try { int employeeID = Integer.parseInt(evaluationResults[0].getText()); if(employeeID > 0) { if(employeeID < ReadFromFile.getNumberFromFile("emp...
9eb5c2d5-ad2c-4bf0-90b4-c16bcca4f4ac
2
public static void asm_swapf(Integer akt_Befehl, Prozessor cpu) { // Decode Integer adresse = getOpcodeFromToBit(akt_Befehl, 0, 6); Integer W_F_Switch = getOpcodeFromToBit(akt_Befehl, 7, 7); // Fetch Integer k = cpu.getSpeicherzellenWert(adresse); Integer w = cpu.getW(); Integer result = k; PIC_Logg...
47f85e67-f353-4cbf-883b-7babb85ea6e3
8
void setTransform() { //Center the image //Third Transform if(orientation == 0) { at = AffineTransform.getTranslateInstance(x, y); } else if(orientation == 1) { at = AffineTransform.getTranslateInstance(x, y); } else if(orientation == 2) { ...
1396bd23-0471-41a8-95c5-767b228ac098
9
public T n(){ if(m==12){ if(d==day[m])return new T(y+1,1,1); else return new T(y,m,d+1); } if(m!=2){ if(d==day[m])return new T(y,m+1,1); else return new T(y,m,d+1); } if(y%4==0&&(y%100!=0||y%400==0)){ if(d==29)return new T(y,m+1,1); else return new T(y,m,d+1); } if(d==day[m]...
380eba88-1efa-44e6-92e7-f39cd67b1b91
7
public void testDajZauzeteSobeDioPerioda() { java.util.Date datumOD= new java.util.Date(); java.util.Date datumDO= new java.util.Date(); java.util.Date rezervisanoOD= new java.util.Date(); java.util.Date rezervisanoDO= new java.util.Date(); java.util.Date rezervisanoOD1= new java.util.Date(); java.util.Da...
23831dca-2b6a-4146-a577-6bc7f9bd068b
6
public void update(GameContainer container, int delta) { Input input = container.getInput(); int newX = x; int newY = y; timer += delta; if (timer > 50) { timer = 0; if (input.isKeyDown(Input.KEY_W)) { newY--; } else if (input.isKeyDown(Input.KEY_S)) { newY++; } else if (input.isK...
78273657-8f04-4634-b419-7371b93d30cf
6
public String Rank(float dToan, float dVan ){ if(dToan < 0 || dToan > 10 || dVan < 0 || dVan >10){ return "error"; }else{ if(dToan >8 && dVan >7) return "pass"; else return "fail"; } }
6bb4bf21-e943-4374-9bc0-a235defcec16
6
private static void checkForGLErrors(GL2 gl) { int errno = gl.glGetError(); switch (errno) { case GL2.GL_INVALID_ENUM: System.err.println("OpenGL Error: Invalid ENUM"); break; case GL2.GL_INVALID_VALUE: System.err.println("OpenGL Er...
e60f2a02-fc3d-4f75-99a2-b5bec7402e64
6
public void doReproduction() { // We first put the new bacteria into a list and add them afterwards. // That way the new bacteria won't be run in the loop. ArrayList<Bacteria> newBacteria = new ArrayList<Bacteria>(); for (Bacteria b : bacteriaList) { // If it meets the reproduction criteria a...
a5903941-ac96-4155-8a8d-4cc748c8ce14
4
public static void screenshot() { int width = CobaltApp.getWidth(); int height = CobaltApp.getHeight(); glReadBuffer(GL_FRONT); ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); BufferedImage image = new Buffere...
fcd39e27-0eaf-4e5e-a8e5-fd230753330e
8
private void setupLeftPanel() { view.leftPanel.leftList.setCellFactory(new Callback<ListView<ComponentMenuItem>, ListCell<ComponentMenuItem>>() { @Override public ListCell<ComponentMenuItem> call(ListView<ComponentMenuItem> list) { return new LeftListCellFactory(view); ...
57a4da30-06a8-43fb-8269-a91f0efd895b
1
@Test(expected = OutOfStockSpaceException.class) public void testPickTraysOverfilled() throws OutOfStockSpaceException, InconsistencyException, StockNotCompatibleException, PickTooEarlyException, PickTooLateException { Stock destination = new Stock("Test stock", StockType.SEMI, 1, 16, 1); StorageUnit su = ne...
14e9e490-4974-42f1-a63e-86e07c35c9aa
5
@Override public void putAll(final Map<? extends GKey, ? extends GValue> map) { for (final Entry<? extends GKey, ? extends GValue> entry: map.entrySet()) { this.put(entry.getKey(), entry.getValue()); } }
80caa471-1dcc-42e1-9ba4-82c10c5edd1a
8
public static void main(String[] args) { String datamodel = args[0]; String testfile = args[1]; String predictionsOutput = args[2]; DataModel model = null; try { model = new FileDataModel(new File(datamodel)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); re...
66e581b9-1dc8-491b-ada2-94029198193e
7
public String compile(String text) { vars = new HashMap<String, Variable>(); Variable.reset(); String code = text; code = code.replaceAll("(?m)//(.*?)$", ""); code = code.replaceAll("(?m)\\n", ";"); code = code.replaceAll("(?m)\\r", ""); code = code.replaceAll("/\\*(.*?)\\*/", ""); code = code.replace...
5221d5c7-1404-4f4f-ae14-752ea09e73c7
6
public static void main(String[] args) { System.out.println("Welcome to Insight's Blackjack Game!"); // Create a new deck of cards for this game. gameDeck = new Deck(); // Create a new Dealer for this game. Dealer dealer = new Dealer(); // Create a new Player for this game. Player player = new Player...
ea5c4c49-c4d8-4d15-802c-6206a17a664d
4
public int readSimpleGamma() throws InvalidGammaValue, EOFException { int gamma = readUint8(); if (bitmask(gamma, 0x80)) { gamma &= ~0x80; if (bitmask(gamma, 0x40)) { gamma &= ~0x40; if (bitmask(gamma, 0x20)) { gamma &= ~0x20; if (bitmask(gamma, 0x10)) { throw new InvalidGammaValue();...
2dd36ee4-4b4d-4d68-942f-6c61c3baa587
8
public Transfer get_data (ByteBuffer buffer) { if (buffer == null) buffer = buf; buffer.clear(); while (buffer.hasRemaining ()) { // If there are no more data to return, run the state machine. // If there are still no data, return what we alr...
cbd84baf-373a-4704-8503-1b1615377739
3
public ItemSet GetUniqueItems() { ItemSet uniqueItems = new ItemSet();/*uniquely constructed itemSet*/ for (int j = 0; j < transactionSet.size(); j++) {/*loop through the first transactionSet object*/ for (int i = 0; i < transactionSet.get(j).getTransaction().getItemSet().size(); i++) {/*doubly loop through each...
b7c9412c-9e50-498d-b6aa-dd101ab8a9ea
4
@Override public String cryptage(String texte) { String texteCrypte =""; int positionDansCle = 0; int caractereAAjouter = 0; int codeAsciiDeA = this.convertisseur.codeAsciiDuCaractere('A'); for (int lettreCourante = 0; lettreCourante < texte.length(); lettreCourante++) { int lettre = this.c...
561623ec-64aa-4649-a141-9cea1f641b86
4
public void deleteTask(String id, String name) throws JAXBException, IOException{ Boolean deleted=false; //trying to write into file FileInputStream stream = new FileInputStream("C:/Users/Efrin Gonzalez/Documents/task-manager-xml.xml"); String path="C:/Users/Efrin Gonzalez/Documents/task-manager-xml.xml";...
49137836-7ebf-475d-8f2a-e49015c74b56
0
@Override public void setValidator(Validator validator) { this.validator = validator; }
4256257e-0b86-40d4-9613-fe169e58dd9c
1
public void mouseReleased(MouseEvent e) { GameAction gameAction = getMouseButtonAction(e); if (gameAction != null) { gameAction.release(); } }
f6b48d56-f786-4a35-abbf-23cb756059eb
0
public String getImageUrl() { return imageUrl; }
fb2364c5-10cb-4ca4-9983-e9317f69e004
4
public static void main(String[] args){ int result=0; for (int i=1;i<Integer.MAX_VALUE;i++){ int j; for (j=1;j<21;j++){ if (i%j != 0){ break; } } if (j == 21){ result = i; break; } } System.out.println(result); }
390df0f4-36aa-4bec-b07e-94fd17a2448d
5
public final static Document create(String input) throws CreateDocException { try { DocumentBuilderFactory dbf= DocumentBuilderFactory.newInstance(); DocumentBuilder db= dbf.newDocumentBuilder(); return db.parse(new InputSource(new StringReader(input))); } catch (ParserConfigurationException e) ...
54f3559f-6db8-494c-8162-9700ecaec12e
7
public static void main(String[] args) { // TODO code application logic here int size = 2000000; long sum = 0; boolean[] Chis = new boolean[size]; for (int i = 2; i < size; i++) { Chis[i] = true; } for (int i = 2; i < Math.sqrt(size); i++) { ...
e1b8bf72-caf5-4e45-9d0f-42993b8baebf
4
protected void cellsMoved(Object[] cells, Point location) { if (cells != null && location != null) { mxIGraphModel model = getGraph().getModel(); // Checks if a layout exists to take care of the moving for (int i = 0; i < cells.length; i++) { mxIGraphLayout layout = getLayout(model.getParent(cells...
e869de90-e786-4e33-9aa3-97c3aee5fd3c
6
final void method431(int i, int i_29_, byte i_30_) { anInt712++; if (((Widget) this).anIntArray706 == null || ((((Widget) this).anIntArray706.length ^ 0xffffffff) >= (i ^ 0xffffffff))) { int[] is = new int[1 + i]; if (((Widget) this).anIntArray706 != null) { for (int i_31_ = 0; ((((Widget) t...
b15852a4-1073-417e-a7bd-2a33bf70d62f
4
public static float ratePromotion(Background next, Actor actor) { float rating = 1 ; // // Check for similar skills. for (Skill s : next.baseSkills.keySet()) { rating += rateSimilarity(s, next, actor) ; } final Batch <Skill> skills = actor.traits.skillSet() ; for (Skill s : actor.trai...
77f78353-45e7-4b72-a852-7b496401aba5
1
@Override public Writer printHeader() throws IOException { if (!columnTitlesWritten) { this.writeColumnTitles(); columnTitlesWritten = true; return super.nextRecord(); } return this; }
6cecc712-75a5-4e19-b932-b0bfdb04e4ae
3
public List<WebAccessory> getCapes() { // Capes, to be used until Capes are moved into the AccessoryType Class List<WebAccessory> toRet = new ArrayList<WebAccessory>(); File adr = new File(getDataFolder(), "capes.yml"); if (!adr.exists()) { try { adr.createNewFile(); YamlConfiguration temp = YamlCo...
47895643-a46b-42cc-b7b3-40c4ffe42ad7
4
public void restoreWorkSpaces() throws Exception { XMLDecoder d = null; try { FileInputStream fis = new FileInputStream(configFileFullName); d = new XMLDecoder(fis); Object o = d.readObject(); if(o instanceof java.util.Hashtable) { java.uti...
a93b6d0b-a003-4ed5-9419-541510691823
3
public void gameEnd(boolean won) { State outcome; if (won) outcome = new WinState(true); else outcome = new LossState(true); if (oldPlayState != -1) playStates[oldPlayState].updateReward(outcome, oldPlayAction); if (oldDrawState != -1) drawStates[oldDrawState].updateReward(outcome, oldDrawAction)...
09f15e54-c833-452c-a83c-6b9137f74e2d
0
private void desactivarDatos(){ descripFt.disable(); refFt.disable(); precioFt.disable(); combFt.disable(); }
a14b543b-714d-49c3-95c4-f77f561020e3
8
static void setComboBox(JComboBox cb, int k) { ActionListener[] al = cb.getActionListeners(); if (al != null) { for (ActionListener i : al) cb.removeActionListener(i); } ItemListener[] il = cb.getItemListeners(); if (il != null) { for (ItemListener i : il) cb.removeItemListener(i); } cb.setS...
8a554483-5a64-4c6f-bab6-977aca80ca37
0
@Override public void modifiedStateChanged(DocumentEvent e) {}
80d7774d-4dd8-40e3-aeba-588642324ee7
5
public String getLowAgent() { Map<String,Integer> pMap = new HashMap<String,Integer>(); String agent_path = null; try { List<String> regionList = ControllerEngine.gdb.getNodeList(null,null,null); //System.out.println("Region Count: " + regionList.size()); for(String region : regionList) { Li...
5545bd6e-51c0-46ac-a450-73031423bc11
5
private void buildWalls() { Random random = new Random(); int procentWalls = random.nextInt(19) + 2; while (getWallCoverage() < procentWalls && (procentWalls - getWallCoverage()) >= 2) { int directionInt = random.nextInt(2); int randomLength = 1; int randomX = 0; int randomY = 0; Direction dir; ...
7f63100a-4c57-4f19-b013-d12e99d702de
6
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { config = plugin.getConfig(); if (args.length == 1 ){ if (sender instanceof Player) { if (sender.hasPermission("darkcommand.slap")){ if (commandLabel.equalsIgnoreCase("slap")){ Player player = (P...
9d5746a0-3fb7-40ad-bf20-f519b82f04c8
2
private void updateTableColumn(int column, int width) { final TableColumn tableColumn = table.getColumnModel().getColumn(column); if (! tableColumn.getResizable()) return; width += spacing; // Don't shrink the column width if (isOnlyAdjustLarger) { width = Math.max(width, tableColumn.getPreferredWi...
5ba9c60f-bfd6-4019-83c6-f3e568e71c67
4
public static Map func_27177_a(String var0) { HashMap var1 = new HashMap(); try { String var2 = "local"; StringBuilder var3 = new StringBuilder(); J_JsonRootNode var4 = (new J_JdomParser()).parse(var0); List var5 = var4.getArrayNode(new Object[]{"stats-ch...
ad73d3b4-2a46-4103-8108-53cd1ef8c93d
9
public void run() { System.out.println("Elevator " + getID() + " has started"); running = true; while (running) { synchronized(this) { if (!hasDestinations(floorDestinations)) { try { ...
40736870-3656-44cd-a214-5518afea44d1
3
public void inserisci(T x) { AlberoBin<T> padre = cercaNodo(x); if (padre == null) { // inserisco la radice coll = new AlberoBinLFB<T>(); coll.setVal(x); } else if (!padre.val().equals(x)) { AlberoBin<T> figlio = new AlberoBinLFB<T>(); figlio.setVal(x); if (x.compareTo(padre.val()) < 0) padre.se...
e6c8b282-95ab-4ed7-a149-dcc5b1b79d59
2
public void search(File file) throws IOException { Scanner in = new Scanner(new FileInputStream(file)); int lineNumber = 0; while (in.hasNextLine()) { lineNumber++; String line = in.nextLine(); if (line.contains(keyword)) System.out.printf("%s:%d:%s%n", file.getPath...
fc4c7455-fd6d-4887-a9c8-e51b53da80d7
0
public void setId(Long id) { this.id = id; }
58db27a9-547b-4923-9b9e-21fd15bc657d
9
private static int getReturn(Class type) { if(type.equals(Void.TYPE)) return 0xb1; if(type.equals(Boolean.TYPE) || type.equals(Byte.TYPE) || type.equals(Character.TYPE) || type.equals(Short.TYPE) || type.equals(Integer.TYPE)) return 0xac; if(type.equals(Long.TYPE)) return 0xad; if(ty...
03ade9d0-d3b9-47d1-bdaf-8505921b45ba
3
public boolean isWithinBounds(double x) { if (B.getX() < A.getX()) { return ((x >= B.getX()) && (x <= A.getX())); } else { return ((x >= A.getX()) && (x <= B.getX())); } }
885c17ae-e885-4e1e-8e0d-c88f61cabf6b
1
public void render(float delta) { spriteBatch.begin(); spriteBatch.draw(this.name2texture.get("background"),0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight()); for(GameButton gameButton : buttons){ spriteBatch.draw(this.name2texture.get(gameButton.getName()),gameButton.getX(),gameButton.getY(),gameButton.ge...
2dd181b9-9113-4ab4-9606-2dc8d1ca8847
0
public TalkingClock(int interval, boolean beep) { this.interval = interval; this.beep = beep; }
b9078cfa-b1a2-4f4d-ab5d-1980a68a446e
5
@Override protected void layoutSelf(Rectangle bounds) { Rectangle compBounds = new Rectangle(bounds); if (!mOnlyPreferredSize) { Dimension size = LayoutSize.MINIMUM.get(mComponent); if (compBounds.width < size.width) { compBounds.width = size.width; } if (compBounds.height < size.height) { comp...
d9e2cc89-d25c-4d49-a170-dc466c73b147
1
private String[] getAllPossibleTranslations(String content) { Document doc = Jsoup.parse( content.replaceAll("<br />", "<span>#</span>") ); Element fastMeanings = doc.getElementById("fastMeanings"); if (fastMeanings != null) { String text = fastMeanings.text().replaceAll(" ,", ","); ...
e937a514-1a03-462e-a56e-a098f7a37b74
9
private void setSelectedIndex(JComboBox cb, int iSelected, boolean execute) { if (execute) { cb.setSelectedIndex(iSelected); } else { ActionListener[] al = cb.getActionListeners(); if (al != null) for (ActionListener x : al) cb.removeActionListener(x); ItemListener[] il = cb.getItemListeners(...
b29be6ef-4476-418b-9d18-4fde68787ef3
4
@Override public boolean add(T element) { T smallestElement = priorityQueue.peek(); //Smaller than our smallest item. Do not add. if(smallestElement != null && (size() == maxSize) && element.compareTo(smallestElement) < 0){ return false; } //Delete the previous ...
a7842037-1a8c-47a0-9f22-0b4a5658bc7d
8
public int run() { int curInstAddress = instructionAddress; while (cycles < Integer.MAX_VALUE) { cycles++; // Fetch new instruction if (!instructionBuffer.isFull()) { int instIndex = (instMemory.read((short) curInstAddress)) .getData(); if (!(instIndex < 0 || (curInstAddress-instructionAddres...
7578ae00-aadb-4c09-861c-abce22a6fa88
7
public void setHealth(int type){ if(type == 1){ if(health+20<100) health += 20; else health = 100; } else if(type == 2){ if(health+40<100) health += 40; else health = 100; } else if(type == 3){ if(health+60<100) health += 60; else health = 100; }el...
e52f1199-6778-4b97-98f0-bd906e71b792
8
void buildInstances(Document doc, String sName) throws Exception { NodeList nodelist; // Get the name of the network nodelist = selectAllNames(doc); if (nodelist.getLength() > 0) { sName = ((CharacterData) (nodelist.item(0).getFirstChild())).getData(); } // Process va...
53bc0a65-960a-4d98-9486-e62311bcac99
3
public void getAllSpaces(final ArrayList<Space> spaces, final Criterion criterion) { switch(getCriterionReponse(criterion)) { case PASS: spaces.add(this); break; case DISBURSE: disburse(); assert !isLeaf(); ...
cbccfa4b-6204-489b-88d4-ddb620a2998c
2
public static boolean isValidPostcode(String postcode) { if (postcode == null) return false; return postcode.matches("[a-zA-Z]{2}\\d{1,2}\\s*\\d{1,2}[a-zA-Z]{2}") && postcode.length() <= 10; }
7d013c95-2eec-436c-b29e-9de48245cfb4
3
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final OutputSpEmployee other = (OutputSpEmployee) obj; if (!Objects.equals(this.szEmployeeId, other.szEmployeeI...
e501fd8c-0eb2-46dd-aca9-f4b5230f4087
9
public void searchRecursive(Node node){ //permet de récupérer noeud et arc associé pour effectuer //la bonne unicité this.level_current++; if(this.level_current <= this.level_max || this.level_max == -1){ HashMap<Node, Edge> pairs_son_edge = this.getSonsApplyFilter(node); ...
e2a610f1-20ab-4e05-96d4-39a589b110c1
2
@Override public void run() { for (Player player : Bukkit.getServer().getOnlinePlayers()) { if (this.plugin.getNCDatabase().hasHepatitis(player.getName())) { EffectFactory.getInstance().applyHepatitisEffect(player); player.sendMessage("You have Hepatitis."); } } }
8ed48c52-e18a-47fc-8a88-b93713b1d974
0
public void setjButtonChercher(JButton jButtonChercher) { this.jButtonChercher = jButtonChercher; }
a83c749f-b211-494c-9011-c32b6bb093ce
1
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { GUI window = new GUI(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
be281721-f023-4b3e-8ee4-ce862c918d29
4
public Notcher findUnitByIP(String pIP) { for (int i = 0; i < numberOfNotchers; i++) { if (notchers[i] != null && notchers[i].ready) { if (pIP.equals(notchers[i].ipAddrS)) { return (notchers[i]); } } } return(null); }//end of NotcherGrou...
896a4307-46ea-42d4-a5f6-3d8a3b75f34f
5
protected final String getClipboardContents() { if (canAccessSystemClipboard) { String result = ""; Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); // odd: the Object param of getContents is not currently // used Transferable contents = clipboard.getCont...
68fc58c9-304d-42f3-9a15-7b6a17c93d48
8
public void moveSecretPassage() throws InvalidMoveException { if (gameFinished) { throw new InvalidMoveException("Cannot move once the game is over!"); } else if (!currentPlayer.inCornerRoom()) { throw new InvalidMoveException("Current location doesn't have a secret passageway!"); } else if (hasEnteredRoom)...
d5047fb3-0b88-4091-827c-cc6cfbf446f4
8
double maxPurity(HashMap<String, Integer> count) { //--- // Find the amino acid with max count //--- // Count all amino acid HashMap<String, Integer> countAa = new HashMap<String, Integer>(); for( String key : count.keySet() ) { int cnt = count.get(key); String aa = key.split(KEY_SEPARATOR)[0]; a...