method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
aa27cec7-4895-4272-b2cd-4e9e085137b0
0
public void testReadWrite() throws Exception { byte[] data = FileUtils.read("g:\\test\\a.jpg"); FileUtils.write(data, "g:\\test\\aa.jpg"); data = FileUtils.read("g:\\test\\t.txt"); FileUtils.write(data, "g:\\test\\tt.txt"); FileUtils.write(data, "utf-8", "g:\\test\\tutf-8.txt"); }
119de6b0-d957-494a-90c4-96a57300ea81
2
public static void main(String[] args) throws Exception{ String strExcelDate ="01-11-2013"; SimpleDateFormat excelDateFormat = new SimpleDateFormat("dd-MM-yyyy"); SimpleDateFormat uiDateFormat = new SimpleDateFormat("MMMM yyyy"); WebDriver driver = new FirefoxDriver(); driver.manage().win...
c40a323f-78a6-4f11-b2aa-d29b8568faa3
2
public static ArrayList<MusterDistance> findMusterDistanceByTestId(ArrayList<MusterDistance> musterDistances, int id) { ArrayList<MusterDistance> outputDistances = new ArrayList<MusterDistance>(); for(MusterDistance md:musterDistances) { if(md.muster==id) { outputDistances.add(md); } } return outputDi...
1438f28d-68c3-4bc0-9048-487bee6bf6da
4
private void alaPaastaLaitojenYli(Pelihahmo h){ if (-1 > h.getMinX()){ h.setX(h.getX() - h.getMinX()); } else if (kentanLeveys + 1 < h.getMaxX()) { h.setX(h.getX() - (h.getMaxX() - kentanLeveys)); } if (-1 > h.getMinY()){ h.setY(h.getY() - h.g...
a4c7c4e3-83b6-4b2b-979d-2a75f76b2362
0
public String getPosicion() { return posicion; }
f32c4ca2-8fa6-4865-a0f0-e7cb3083591c
5
public boolean sendeTerminvorschlag(Termin termin) { Terminvorschlag vorschlag = new Terminvorschlag(termin, termine); Termin.TypSelektor auftritte = new Termin.TypSelektor( Termin.Typ.Auftritt); Mitglied.TypSelector ersatzmitglieder = new Mitglied.TypSelector(true); if (auftritte.select(termin)) { // E...
8eb7bfb1-7774-4dd7-a1fe-fc83a69eb8a4
6
private void kreirajPredracun() throws Exception { boolean kreiraj = false; if(oznaceniBoravak !=null && Double.parseDouble(tf_ukupno.getText()) >= 0 ){ if(predracun==null){ kreiraj = true; predracun = new Predracun(); } if(Double.parseDouble(tf_popust.getText()) >=0 && Double.parseDouble(tf_po...
99e5541e-21be-4b74-85e8-a845496490ea
9
private void init() { if (Double.compare(getSkinnable().getPrefWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getPrefHeight(), 0.0) <= 0 || Double.compare(getSkinnable().getWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getHeight(), 0.0) <= 0) { if (Orientation.HORIZONTAL == ge...
e56aa91d-d456-411d-a7b3-d881f61dc6e3
4
public void run(){ while(true){ Socket client = null; try { client = server.accept(); handleConnection( client ); } catch ( IOException e ) { System.err.println( "Error in ServerImpl " + e.getMessage() ); e.printStackTrace(); } finally { if ( client != null ) try { clien...
27be6e80-f952-4064-900f-e506bb089e98
3
@Override public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { refreshTab(productComboBox.getSelectedIndex()); } if (event.getItemSelectable().equals(customerComboBox)) { if (customerComboBox.getItemAt((customerComboBox.getSelectedIndex())).equals( "<html...
b9cbd998-6878-4a64-9e15-805ebdee04bc
6
@Override public int getTaxeAt(Vehicle vehicle, int year) { Type vehicleType = getManagerTypeAt(year).getVehicleType(vehicle); Calendar calendar = new GregorianCalendar(); calendar.setTime(vehicle.getStartDate()); int startYear = calendar.get(Calendar.YEAR); switch (vehicl...
90cbb085-ef71-4e2e-979e-a69ac7cdc306
5
public TokenString removeWhitespace() { boolean finished = false; if (empty()) { return this; } while (!finished) { for (int i = 0; i < tokenList.size(); i++) { if (tokenList.get(i).type == TokenType.WHITESPACE) { tokenList.re...
99e8b60a-40a7-41d9-8aff-50eb2fcd6f21
2
@Override public void send() { if(getMessage() == null) { throw new NullPointerException("message"); } else if(channel == null) { throw new NullPointerException("channel"); } else { channel.write(getMessage()).addListener(this); setIsSent(true); } }
b1df2ec4-82de-4841-878e-10553c277ee3
9
@Override public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) { MOB target=mob; if((auto)&&(givenTarget!=null)&&(givenTarget instanceof MOB)) target=(MOB)givenTarget; if(target.fetchEffect(this.ID())!=null) { mob.tell(target,null,null,L("<S-NAME> alread...
12d7b7f3-f2d9-4586-8d83-773d3a4625d9
5
public void reduce(IntWritable key, Iterable<Text> value, Context context) throws IOException, InterruptedException{ List<ArrayList<Double>> assistList = new ArrayList<ArrayList<Double>>(); String tmpResult = ""; for (Text val : value){ String line = val.toString(); S...
d06254e2-9fce-44e8-9bd4-3930927dcd8e
4
private VDKInnerDirectory readInnerSequence(long nextOffset) { VDKInnerDirectory vdkInnerDirectory = null; VDKRandomAccessFile raf = null; boolean isDirectory; try { raf = new VDKRandomAccessFile(vdkFilePath, "r"); isDirectory = raf.readBoolean(nextOffset, VDK1FilePattern.IS_DIRECTORY); ...
75025516-4925-4a3e-92a4-bc105587adee
2
private void setUp() { try { Class.forName("org.sqlite.JDBC"); Connection conn = DriverManager .getConnection("jdbc:sqlite:../DB/ccworkshop.db"); conn.close(); } catch (ClassNotFoundException ex) { Logger.getLogger(CCWorkshopManager.cla...
9b1f38c4-680a-4a40-99ac-a4be39daf3e9
5
public boolean areAnagrams(String s1, String s2){ Map<Character, Integer> characterIntegerMap = new HashMap<Character, Integer>(); for(int i=0; i<s1.length(); i++){ if(characterIntegerMap.containsKey(s1.charAt(i))){ characterIntegerMap.put(s1.charAt(i), characterIntegerMap.ge...
022e9136-8cec-4e85-971a-33db00f58169
1
public String getColumnName(int col) { try { return file.getColumnName(col); } catch (Exception err) { return err.toString(); } }
867d4263-f031-44e7-be7b-50217524b442
5
public Object getValueAt(int nRow, int nCol) { if (nRow < 0 || nRow >= current.size()) return ""; if (nCol == 0) return current.get(nRow).identifer; if (nCol == 1) return current.get(nRow).time.toString(); else if (nCol == 2) return current.get(nRow).line; return ""; }
c05df616-4473-4ad9-bdf5-4ceb7a428aa8
8
@Override public boolean equals(Object obj) { // TODO Auto-generated method stub if(obj instanceof PageData) { PageData pd = (PageData)obj; if(id.equals(pd.id) && parentId.equals(pd.parentId) && title.equals(pd.title) && title4menu.equals(pd.title4menu) && keywords.equals(pd.keywords) && description.e...
fedc3a6c-8036-4a99-b5f8-98a02f7c60d7
6
@EventHandler public void CaveSpiderHeal(EntityDamageByEntityEvent event) { Entity e = event.getEntity(); Entity damager = event.getDamager(); String world = e.getWorld().getName(); boolean dodged = false; Random random = new Random(); double randomChance = plugin.getCaveSpiderConfig().getDouble("CaveSpide...
d408d6f9-53ef-48fe-a9d9-cde43a529c4f
8
protected String toJSONFragment() { StringBuffer json = new StringBuffer(); boolean first = true; if (isSetType()) { if (!first) json.append(", "); json.append(quoteJSON("Type")); json.append(" : "); json.append(quoteJSON(getType() + "")); ...
46c40089-39fb-4aa8-aef3-ee9248baa395
2
public Object opt(int index) { return (index < 0 || index >= this.length()) ? null : this.myArrayList .get(index); }
08f6bb95-62e9-464f-a9a8-d1df25bf32bb
8
public static String zuseConvDecFloatingPointToBinFloatingPointString( String decAsString, int expLength, int manLength) { if (!decAsString.contains(".")) { decAsString += ".0"; } String sigPart = decAsString.contains("-") ? "1" : "0"; decAsString = decAsString.replace("-", ""); String expPart = Binar...
91e40104-63a7-4776-b370-5533574a0b5d
1
@Override public Storeable put(final String keyStr, final Storeable storeableValue) { checkKey(keyStr); if (storeableValue == null) { throw new IllegalArgumentException("Wrong put value = null!"); } DirFile node = new DirFile(keyStr.getBytes()[0]); DataBaseFile fi...
e8bd5f50-ae61-4e6c-954c-97fb7c191ae6
8
@Override public void startDoc(int docID, int termDocFreq) throws IOException { // Have collected a block of docs, and get a new doc. // Should write skip data as well as postings list for // current block. if (lastBlockDocID != -1 && docBufferUpto == 0) { skipWriter.bufferSkip(lastBlockDocID, ...
ba561230-c337-47c0-803b-51955a9eb35f
4
private Matrix getDCTMatrix() { //compute constants double k = Math.PI/numberFilters; double w1 = 1.0/(Math.sqrt(numberFilters));//1.0/(Math.sqrt(numberFilters/2)); double w2 = Math.sqrt(2.0/numberFilters);//Math.sqrt(2.0/numberFilters)*(Math.sqrt(2.0)/2.0); //create new matrix Matrix matrix ...
25cb240c-a167-43eb-b2f3-c11d05e111d4
6
public static Object add(Object o1, Object o2){ if (o1 instanceof List){ List newList = new ArrayList((List)o1); if (o2 instanceof List){ newList.addAll((List)o2); } else { newList.add(o2); } return newList; } if (o1 instanceof String || o2 instanceof String){ return new StringBuilder()....
2265bd7a-de09-4bc2-b798-578199773a6e
2
private ListNode midNode (ListNode head) { ListNode n1 = head; ListNode n2 = head; while ( n2.next != null &&n2.next.next != null ) { n1 = n1.next; n2 = n2.next.next; } return n1; }
26e7c64b-563f-419a-a7ab-887412f3214f
2
private boolean validMove(Piece piece) { // Just ignore moves on spots that are already taken. if(pieces[piece.getX()][piece.getY()] != null) { return false; } ArrayList<Piece> moves = getValidMoves(piece.getColor()); if(!moves.contains(piece)) { return false; } re...
28ece229-fecd-4b13-9457-58bc97115cd1
1
public WallObject getWallObject(int z, int x, int y) { GroundTile groundTile = groundTiles[z][x][y]; if (groundTile == null) { return null; } else { return groundTile.wallObject; } }
b3e8caab-d2d6-4355-8553-a9379f9a1d65
3
private void put(final Item i) { if (index > threshold) { int ll = items.length; int nl = ll * 2 + 1; Item[] newItems = new Item[nl]; for (int l = ll - 1; l >= 0; --l) { Item j = items[l]; while (j != null) { int index = j.hashCode % newItems.length; Item k = j.next; j.next = newIte...
a9d4947d-098b-4370-acc8-0c0a0e86b250
2
private void configureMenuItem(JMenuItem item, String resource, ActionListener listener) { configureAbstractButton(item, resource); item.addActionListener(listener); try { String accel = resources.getString(resource + ".accel"); String metaPrefix = "@"; ...
f7aacbd7-d411-43d5-9c06-1eaeef56100b
6
public static Critter getNearestPrey(Critter self, Environment envi){ synchronized(envi.lock_critter){ List<Critter> critters = getViewableCritters(self, envi); if(critters.isEmpty()){ return null; } Critter closest = null; double min = 100000000; Iterator<Critter> iter = critters.listIterato...
5b4e6028-031a-454f-b7e8-08948d6cef0b
3
MsgDumperMgr() { is_init = false; dumper_facility = MsgDumperCmnDef.MSG_DUMPER_FACILITY_LOG; // Check the parameter setting is correct assert (dev_name.length == facility_size) : "The facility name size is NOT identical"; assert (dev_flag.length == facility_size) : "The facility flag size is NOT identical";...
4b1ab9ab-06a3-4e77-b5a1-f7c07ce3b376
8
public static Matrix read(BufferedReader input) throws java.io.IOException { StreamTokenizer tokenizer= new StreamTokenizer(input); // Although StreamTokenizer will parse numbers, it doesn't recognize // scientific notation (E or D); however, Double.valueOf does. // The strategy here is to disable Stre...
c3228b77-3488-4e9f-8f75-33798a9abc8b
9
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed String date = ((JTextField) jDateChooser1.getDateEditor().getUiComponent()).getText(); String ost = jTextField1.getText(); String nal = jTextField3.getText(); String merchT = j...
0a0b550e-6123-4074-9416-cfb2513cf8cc
9
public static void demoFile(String file, boolean pauseP) { { String temp000 = Stella.findFileInLoadPath(file, Logic.$POWERLOOM_KB_FILE_EXTENSIONS$); file = ((temp000 != null) ? temp000 : file); } Stella.ensureFileExists(file, "demo-file"); { int currentlevel = ((Integer)(Logic.$DEMO_LEVEL$.get())...
286f8761-30c4-4273-a38e-27ff42d679ec
9
public int compareTo(Object o) { int row1 = modelIndex; int row2 = ((Row) o).modelIndex; for (Iterator it = sortingColumns.iterator(); it.hasNext();) { Directive directive = (Directive) it.next(); int column = directive.column; ...
22ec5b12-e767-4742-82c6-d897948780cf
7
@Override public void keyPressed(KeyEvent Key) { double zoomIncrement = 0.1; // Offset is a factor divided by scale and a fraction of the zoom factor so moving around is according to the airport scale and zoom factor double offset = offsetFactor/(airport.scale*(1/airport.zoomFactor)); //Zoom in with '...
e4de41eb-4c67-4722-8ea7-8181446edf5d
5
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Piece other = (Piece) obj; if (x != other.x) { return false; } if (y != other.y) { return false; } ret...
5e1e7f1e-5950-43a3-bb1c-c1fc16e3c3d8
3
public RoomCell getRoomCellAt(int row, int col){ int index = calcIndex(row, col); if (index >= 0 && index < cells.size() && cells.get(index).isRoom()){ return (RoomCell) cells.get(index); } else{ return null; } }
138e6a91-b29f-40f2-8ec9-0024e058b92d
4
private void fsTreeValueChanged(javax.swing.event.TreeSelectionEvent evt)//GEN-FIRST:event_fsTreeValueChanged {//GEN-HEADEREND:event_fsTreeValueChanged DefaultMutableTreeNode node = (DefaultMutableTreeNode) evt.getPath().getLastPathComponent(); Object obj = node.getUserObject(); String text...
67327870-2d4e-4faf-85b2-42372002777c
1
@Override public boolean equals(Object obj) { if (obj == null) return false; return ((Sentence) obj).getId().equals(getId()); }
e5549f02-19ab-46dc-a26b-0904569f1c1e
5
private void readFromLine(String tempLine) { if (tempLine == null) { return; } Vector currentLine = new Vector(); m_fileContent.add(currentLine); m_rowsCount++; // setRowsCount(getRowsCount() + 1); if (tempLine.trim().length() == 0) { return; } int ...
870a5331-bf32-4296-ab25-02e79237a0bd
7
protected void prepare_sample_reading(Frame header, int allocation, //float[][] groupingtable, int channel, float[] factor, int[] codelength, float[] c, float[] d) { int channel_bitrate = header.bitrat...
b32998b0-41e3-4d43-8db4-98d496a9c0ac
9
public static void main(String[] args) { Meses mes; mes = Meses.DECEMBER; System.out.println("mes: " + mes.name() + " ordinal: " + mes.ordinal()); //----Asignar por medio de una String String m = "MARCH"; mes = Meses.valueOf(m);...
35bd71d9-71cf-4d0a-bb88-fa467482ba5f
5
@Override public void endElement(String uri, String localName, String qName) throws SAXException { switch (qName) { case "ResearchGroup": servers.add(server); break; case "LongName": server.setLongName(content); break; case "Name": server.setName(content); break; case "Prefix": if (St...
450d437c-5412-4c39-84b5-971f7b038db4
8
public void add(Item item) { if (item.getId() == null || item.getId() == "" || list.size() == 0) { list.add(item); } else { for (int i = 0; i < list.size(); i++) { if (Integer.parseInt(list.get(i).getId()) > Integer .parseInt(item.getId()) || i == list.size() - 1) { if (i == list.size() - 1 ...
279006d5-aecc-4f7f-bc9c-6ff6433964ac
8
protected Array(Element arrayE) throws Exception { String arrayS = arrayE.getTagName(); // get the type of the array if (arrayS.equals("Array")) { String type = arrayE.getAttribute("type"); if (type.equals("int")) { m_type = ArrayType.INT; } else if (type.equals("real")) { ...
dec0ac89-9fa3-437d-9fd0-7d175d4a2964
0
public MedicoFacade() { super(Medico.class); }
211312de-90a7-44de-aede-f276e9b4b9ad
5
private double getSample() { double value; double phase = sampleNumber / (double) samplesPerPeriod; switch (waveform) { default: case SIN: value = Math.sin(2.0 * Math.PI * phase); break; case TRI: value = (2.0 *...
16b544cf-8cc5-4bbb-85a2-4a13d8968a21
2
public Lift getLift(int LiftID){ for(int i=0;i<lifts.size();i++){ if(lifts.get(i).getLiftID()==LiftID){ return lifts.get(i); } } return null; }
dac62b58-4c64-4a04-859d-1eb30b38404b
0
public static void main(String[] args) throws Exception { Config.glVerbose = true; Main cd = new Main(); cd.init(); cd.loop(); System.exit(0); }
187e2f58-e145-4d27-a900-3d7f6703a71b
9
private static List<String> getAllSimilarStrings(String str, List<String> dictionary) { List<String> similar = new ArrayList<>(); for(int i = 0; i < str.length(); i++) { char c = str.charAt(i); char[] array = str.toCharArray(); // change for(char j = 'a...
3ad1dfd8-b127-4344-ae9e-d458aed091c7
9
@Override public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { // render background images background.draw(0, 0); foreground.draw(0, 0); // draw the pit for(int line=0; line<pit.getNumberOfLines(); line++) { for(int col=0; col<pit.get...
a066927d-6b77-4902-8aa6-e466609570ca
6
public String[] runMinecraft() { File target = VersionInfo.getMinecraftFolder(); File versionTarget = new File(target + File.separator + "versions", VersionInfo.getModpackName()); String[] lastLogin; String mcUsername = getParameter("username"); lastLogin = MinecraftLoginRead...
cc103968-d75b-495b-895c-41265a0fa6e0
1
public void removeOneProduct() { if (quantity > 0) quantity--; }
154c593b-a982-4328-b7c1-299944df19df
6
@Override public InboundPacket[] decode(ChannelHandlerContext context, ByteBuf in) throws Exception { if (!context.channel().isOpen()) { return null; } List<InboundPacket> requests = new LinkedList<>(); IsaacRandom decoder = context.channel().attr(Constants.KEY_CLIENT) .get().getDecoder(); do ...
4bba65fd-e50b-4761-8558-0ab2bf07da58
3
public void run() { try { ServerSocket server = new ServerSocket(RTSP_PORT); while (true) { try { Socket connection = server.accept(); threadPool.execute(new RTSPWorker(connection, this)); } catch (IOException e) { e.printStackTrace(); } } } catch (IOException e) { e.printStackTrace()...
a96239c9-d60e-4863-9de7-ec94dbbaa057
2
public String toString() { int numberOfRPoints = this.allOutbreakLocations.size(); if (numberOfRPoints == 1) { return this.allOutbreakLocations.get(0).shortString(); } else { String result = "Outbreak with " + numberOfRPoints + " OutbreakLocation(s): "; for (int i=0; i<numberOfRPoints-1; i++) { resul...
abfae18a-4192-4202-aa8d-9dccd52ed0f4
5
public ArrayList<Gebruiker> getAlleKlantenBlok(){ SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy"); Calendar test = Calendar.getInstance(); test.add(Calendar.DATE, -90); if(alleKlantenBlok.isEmpty()){ alleKlantenBlok = new GebruikersDAO().getAlleGebruikersDB(); ...
3ee1b9ab-25a1-470b-9215-2159ddec6a24
8
public OthelloBoardBinary placeDisk(String position){ long binPosition = positionStringToBin(position); byte binFlippableDirection = binCanFlipDirection(binPosition); byte UPPER_LEFT = (byte)0x80; byte UPPER = (byte)0x40; byte UPPER_RIGHT = (byte)0x20; byte LEFT ...
8d50de28-aae5-40b1-bd1d-3c64ded9a8cc
7
public List<Member> getMethodsToDisplay() { if (blocDisplayProxy != null) { return blocDisplayProxy.getMethodsToDisplay(); } final List<Member> result = new ArrayList<Member>(); for (int i = 0; i < rawBody.size(); i++) { final String s = rawBody.get(i); if (isMethod(i, rawBody) == false) { continue...
4a1db5f8-6a41-4b54-b1d2-8f3bc2880aed
7
public static double incompleteBetaFraction2( double a, double b, double x ) { double xk, pk, pkm1, pkm2, qk, qkm1, qkm2; double k1, k2, k3, k4, k5, k6, k7, k8; double r, t, ans, z, thresh; int n; k1 = a; k2 = b - 1.0; k3 = a; k4 = a + 1.0; k5 = 1.0; k6 = a + b; k7 = a + 1....
de885fb9-bef0-4555-827c-1f3d6332c15b
5
public double decreaseAdjustableKomi(int minX, int minY, int ex, int ey) { if (ex > 490 && ex < 490 + minX) { if (ey > 280 && ey < 280 + minY) { if (adjustableKomi > 0) { adjustableKomi -= (.5); return adjustableKomi; } ...
49aa5f66-ec63-49d0-84e5-298e7d19ced9
1
public void visitFieldExpr(final FieldExpr expr) { if (expr.object == from) { expr.object = (Expr) to; ((Expr) to).setParent(expr); } else { expr.visitChildren(this); } }
a1c9da12-6152-44e5-83ac-cdf4e94f1a15
5
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Cidade other = (Cidade) obj; if (this.idCidade != other.idCidade && (this.idCidade == null || !this.idCid...
26a55d57-3746-4b66-af39-f50642bfda40
8
public boolean equalsID (Object chunk) { if(chunk == this) return true; if(!(chunk instanceof AbstractChunk)) return false; if(ID == null && ((AbstractChunk)chunk).ID == null) return true; if((((AbstractChunk)chunk).ID == null && ID != null) || (ID == null && ((AbstractChunk)chunk).ID != null)) ret...
a88449a3-1da3-421d-9a00-a4d013a5b1ac
7
private void getNbIrreversiblePiece(int currentPlayer) { int mine = 0, his = 0; for(int i = 0; i < BOARD_SIZE; ++i) for(int j = 0; j < BOARD_SIZE; ++j) if(board[i][j] != Empty) { if(board[i][j] == currentPlayer && isIrreversiblePiece(i, j, currentPlayer)) ++mine; else if(board[i][j] == -...
9dc04ef3-7249-4230-a512-0fa26276031d
9
protected void configureCurrentConverter(int dialogType) { String filename; File currFile; if ( (getSelectedFile() == null) || (getSelectedFile().isDirectory()) ) return; filename = getSelectedFile().getAbsolutePath(); if (m_CurrentConverter == null) { if (dialogType == LO...
eecc6ad5-1f94-483c-9d81-acc219866804
1
public void run(){ for(Runnable r : runnables){ r.run(); } runnables.clear(); }
426716a3-e3c8-4ec4-9df3-e5eef2a2e6ed
4
public static int findeMaxTeilsumme1(int[] array) { int maxsum= Integer.MIN_VALUE; for (int i=0; i< array.length; i++) { for (int j=i; j< array.length; j++) { int tmpsum= 0; for (int k=i; k<=j; k++) { tmpsum += array[k]; } if (tmpsum > maxsum) { maxsum = tmpsum; } } } retu...
591154d9-3bc4-4677-a21c-1d5a8197904f
7
public void step() throws IncorrectNodeException { super.step(); //Get the agent Object agent = m_tree.getAgent(); GEBT_MarioAgent mario = (GEBT_MarioAgent)agent; int marioPos = mario.getCellsRun(); m_detectedTrapPos = (mario.inTrap() && !mario.isRightTrap...
05152b50-8ab7-4bbc-be33-de6f9ee6944e
3
private AlbumLogger() throws LogException { AlbumLogger.log= Logger.getLogger(AlbumLogger.class.getName()); FileHandler fh= null; try { fh = new FileHandler("LogAlbum " + new Date().toString()); AlbumLogger.log.addHandler(fh); AlbumLogger.log.setUseParentHandlers(false); } catch (Secu...
0f157940-ed9c-49c0-8e81-bbb92fd208b3
6
public static String calculateTotalSize(List<String> sizeList) { double sizeKB = 0; for ( String strSize : sizeList ) { String [] tokens = strSize.split(" "); if ( tokens[1].toLowerCase().equals("mb") ) { sizeKB+= Double.valueOf(tokens[0]) * 1024.0; ...
fb057cda-9317-4098-9bc4-4d7883f218c2
8
private void checkInput() { switch(state) { case INTRO: if(Keyboard.isKeyDown(Keyboard.KEY_RETURN)) { state = State.MAIN_MENU; } if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { Display.destroy(); System.exit(0); ...
f0232196-bf2d-4641-ac62-cb4162ab9eeb
3
public boolean parseFile(String filepath) { boolean result = true; logger.info("Read config file:"+filepath); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; try { db = dbf.newDocumentBuilder(); Document doc = db.parse(filepath); result...
92e62c56-e8f5-47af-b090-d0bf25ccde2c
7
public List<Pilot> getRecentPilot() { try{ List<Pilot> pilots = DatabaseDataObjectUtilities.getPilots(); List<Pilot> recentPilotList = new ArrayList<Pilot>(); if(instance == null) { return null; } else { ...
5fc3008a-c611-4a6d-8b26-1ccbc49419ed
1
public String[] tcp2String(Packet packet) { //Takes apart a tcp Packet TCPPacket tcpPacket = (TCPPacket) packet; //Creates a tcpPacket out of the recieved packet EthernetPacket ethernetPacket = (EthernetPacket) packet.datalink; //Creates a ethernet packet to get the ether layer stuff src_macInEnglish = ethe...
f4a8d6ba-2777-4f69-ac43-133eb71e242d
9
public int generate(int period) { //we generate paths with length 'period' and check whether the first and //last node is the same. this gives us cycles of length period-1 period++; if (graph == null) graph = new StateGraph(balls, max_height); int patterns = 0; ...
689029ef-bc44-46b8-9a80-1745bae0d9e6
0
public PBKDF2ParameterType.Salt getSalt() { return salt; }
a3cff9eb-69bb-42f3-aefc-cefc081a6ef3
5
@Override public int fruit() { if (!grown()) { return 0; } final FarmingDefinition definition = definition(); final BushType type = type(); if (type == BushType.BARBERRY) { return definition.containsModel(BARBERRY_FRUIT_MODEL) ? 1 : 0; } for (int i = 0; i < MODELS_FRUIT.length; i++) { if (def...
6421b8a2-6cc3-45fe-88d1-68a6818ca9eb
1
public void begin() { if(drawing) { throw new IllegalStateException("You are already drawing!"); } drawing = true; program.use(); idx = 0; renderCalls = 0; texture = null; }
d36aee43-d434-4b91-9940-f11820335d98
1
public String environmentifyDirectory(String directory) { //todo has to be fixed for linux, will silently work, //is intended for windows but won't bother linux unless % are used Pattern pattern = Pattern.compile("%(.*?)%"); Matcher matcher = pattern.matcher(directory); while (ma...
f0643107-5519-42be-9b1d-4cc1589227f8
8
public void run() throws IOException { List<Stack> stacks = opsworksUtil.getStacksByName(stackName); if (stacks.isEmpty()) { throw new IllegalArgumentException("No stack found with name '" + stackName + "'"); } for (Stack stack : stacks) { List<App> apps = opswor...
ecad0aba-ef44-4535-bebe-562842776f03
9
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; Attendance other = (Attendance) obj; if (date == null) { if (other.date != null) return false; } else if (!date.equals(other.date...
dbcc0936-e0b1-4ea8-acee-139d30641247
1
private DocumentBuilder init () { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder; } catch (ParserConfigurationException e) { System.out.println(e.getMessag...
9c94549f-96de-48e5-ab6c-f798e9efe3d0
1
public Game(FullGridFactory gridFactory) { if (gridFactory == null) throw new IllegalArgumentException("Gamefactory can't be null!"); this.gridFactory = gridFactory; init(); }
b40cf869-9ffc-46a9-ad4a-e9d7d8d2967a
9
public void dfs(int index, int sum) { if (sum > target) return; if (sum == target) { StringBuilder key = new StringBuilder(); ArrayList<Integer> result = new ArrayList<Integer>(); for (int i=0; i<st.size(); i++) { result.add(st.get(i)); ...
a32e3079-335d-418c-ab4f-11f6edc21d4f
2
public Customer searchViaName(String name){ for (Customer customer : customers) { if (customer.getName().equals(name)){ return customer; } } return null; }
0a677a1a-acf6-4a13-bb11-491468dcb8eb
8
@Override public void Parse(Session Session, EventRequest Request) { (new LeaveRoomEvent()).Parse(Session, Request); int ID; if (Session.OverideID == 0) { ID = Request.PopInt(); } else { ID = Session.OverideID; Session.OverideID = 0; } if (Grizzly.GrabHabboHotel().GrabRoomHandler()...
3b9f13c4-4c12-4c6b-b9ce-002da709e443
1
@DELETE @Path("/v2.0/quotas/{tenantId}") public Response resetQuota(@PathParam("tenantId") String tenantId) throws MalformedURLException, IOException{ HttpURLConnection conn=HTTPConnector.HTTPConnect(new URL(this.URLpath+"/"+tenantId), OpenstackNetProxyConstants.HTTP_METHOD_DELETE, null); int responseCode=conn.ge...
abc4fed8-5532-42ca-bdd3-e33bccda7c8d
6
public int solution(int[] a) { int result = 0; int[] left = new int[a.length]; //discs left border int[] right = new int[a.length]; //discs right border for (int i = 0; i < a.length; i++) { left[Math.max(0, i - a[i])]++; if (a.length - 1 < a[i] || a.length...
b3e4dffb-c52c-41ba-94c9-b0d9491def63
1
public static BoardGenerator getInstance() { if(instance == null) instance = new BoardGenerator(); return instance; }
44690e30-9ffd-4551-8ee2-2e6a30461a50
2
@Override public void handle(ActionEvent event) { if (sMax.getText().isEmpty()) { System.out.println("You must set number first!"); } else { String userInput = sMax.getText().trim(); int newSmax; try { newSmax = Integer.parseInt(userInput); road.setSmax(newSmax); System.out.println("Done!")...
3b81e315-646d-43b4-9f94-09b29f0ac921
4
ChangedFile(final char c, @SuppressWarnings("hiding") final String s) { this.changeTypeC = c; switch (c) { case '+': this.changeType = "<font color=green>+</font>"; this.removed = false; break; case 'M': this.changeType = "M"; this.removed = false; break; case '-': this.change...
9491e629-8950-474c-992b-aaee9088bb39
0
public PumpingLemmaEnvironment(PumpingLemmaChooser lemma) { super(lemma); }
aa4e3107-fa70-48c5-8a8a-e8d0400471d9
1
public String dealWith(Long testObject) { if (testObject > 8) { return "大于8跳出了!"; } return handler.dealWith(testObject); }