method_id
stringlengths
36
36
cyclomatic_complexity
int32
0
9
method_text
stringlengths
14
410k
9560409c-c7bd-46f0-acee-ad4a900a97d2
4
private int getMakeNextId() { String text = ctx.widgets.component(WIDGET_INSTRUCTION, WIDGET_INSTRUCTION_CHILD).text(); if (text.equals("Helm")) { return 20572 + options.ingotType.ordinal() - 1 + (20 * options.ingotGrade.ordinal()); } else if (text.equals("Boots")) { return 20577 + options.ingotType.ordinal() - 1 + (20 * options.ingotGrade.ordinal()); } else if (text.equals("Chestplate")) { return 20582 + options.ingotType.ordinal() - 1 + (20 * options.ingotGrade.ordinal()); } else if (text.equals("Gauntlets")) { return 20587 + options.ingotType.ordinal() - 1 + (20 * options.ingotGrade.ordinal()); } return 20572 + options.ingotType.ordinal() - 1 + (20 * options.ingotGrade.ordinal()); }
9338f429-5bb5-4eec-aa85-5fc0b10c53da
6
public boolean getBoolean(int index) throws JSONException { Object o = get(index); if (o.equals(Boolean.FALSE) || (o instanceof String && ((String)o).equalsIgnoreCase("false"))) { return false; } else if (o.equals(Boolean.TRUE) || (o instanceof String && ((String)o).equalsIgnoreCase("true"))) { return true; } throw new JSONException("JSONArray[" + index + "] is not a Boolean."); }
67c28e50-b0ed-4a23-bf75-945ec5489f6d
9
protected static String processShortQuote(String text) { StringBuilder output = new StringBuilder(400); QuoteOrigin Origin = Processors.getOrigin(text); text = RegEx.removeAll(text, SHORT_QUOTE_PATTERN); String[] arr; arr = text.split("\\|"); switch (Origin) { case ONKELOS: output.append(SPAN_QUOTE); output.append(arr[0]); output.append(QUOTATION_MARK); output.append(SPAN_CLOSE); output.append(SPAN_QUOTE_ORIGIN); output.append(" (ืื•ื ืงืœื•ืก ืขืœ "); output.append(arr[1]); output.append(" "); output.append(arr[2]); output.append(" โ€“ ืคืกื•ืง "); output.append(arr[3]); output.append('('); output.append(SPAN_CLOSE); break; case BAVLI: output.append(SPAN_QUOTE); output.append(arr[0]); output.append(QUOTATION_MARK); output.append(SPAN_CLOSE); output.append(SPAN_QUOTE_ORIGIN); output.append("ื‘ื‘ืœื™, ืžืกื›ืช "); output.append(arr[1]); output.append(" โ€“ ื“ืฃ "); output.append(arr[2]); output.append(", ืขืžื•ื“ "); output.append(arr[3]); output.append("ืณ)"); output.append(SPAN_CLOSE); break; case YERUSHALMI: output.append(SPAN_QUOTE); output.append(arr[0]); output.append(QUOTATION_MARK); output.append(SPAN_CLOSE); output.append(SPAN_QUOTE_ORIGIN); output.append("ื™ืจื•ืฉืœืžื™, ืžืกื›ืช "); output.append(arr[1]); output.append(" โ€“ ื“ืฃ "); output.append(arr[2]); output.append(", ืขืžื•ื“ "); output.append(arr[3]); output.append("ืณ)"); output.append(SPAN_CLOSE); break; case YERUSHALMI_HALACHA: output.append(SPAN_QUOTE); output.append(arr[0]); output.append(QUOTATION_MARK); output.append(SPAN_CLOSE); output.append(SPAN_QUOTE_ORIGIN); output.append("ื™ืจื•ืฉืœืžื™, ืžืกื›ืช "); output.append(arr[1]); output.append(" โ€“ ืคืจืง "); output.append(arr[2]); output.append("ืณ, ื”ืœื›ื” "); output.append(arr[3]); output.append("ืณ)"); output.append(SPAN_CLOSE); break; case RABBAH: output.append(SPAN_QUOTE); output.append(arr[0]); output.append(QUOTATION_MARK); output.append(SPAN_CLOSE); output.append(SPAN_QUOTE_ORIGIN); output.append(arr[1]); output.append(" ืจื‘ื”, ืคืจืฉื” "); output.append(arr[2]); output.append(", ืกื™ืžืŸ "); output.append(arr[3]); output.append(')'); output.append(SPAN_CLOSE); break; case TANAKH: output.append(SPAN_QUOTE); output.append(arr[0]); output.append(QUOTATION_MARK); output.append(SPAN_CLOSE); output.append(SPAN_QUOTE_ORIGIN); output.append(arr[1]); output.append(" "); output.append(arr[2]); if (arr.length == 5) { output.append(" โ€“ ืคืกื•ืงื™ื "); output.append(addQuotationMark(arr[3])); output.append('-'); output.append(addQuotationMark(arr[4])); } else { output.append(" โ€“ ืคืกื•ืง "); output.append(addQuotationMark(arr[3])); } output.append(')'); output.append(SPAN_CLOSE); break; case WITHOUT: output.append(SPAN_QUOTE.substring(0, SPAN_QUOTE.length() - 1)); output.append(arr[0]); output.append(SPAN_CLOSE); output.append(SPAN_QUOTE_ORIGIN); output.append(arr[1]); output.append(SPAN_CLOSE); output.append(')'); break; case EMPTY: output.append(SPAN_QUOTE); output.append(arr[0]); output.append('"'); output.append(SPAN_CLOSE); output.append(SPAN_QUOTE_ORIGIN); output.append(arr[1]); output.append(SPAN_CLOSE); output.append(')'); break; } return output.toString(); }
61f714d5-5c9b-4ad2-ae33-0c7bf3cc6118
5
public Object nextEntity(char ampersand) throws JSONException { StringBuffer sb = new StringBuffer(); for (;;) { char c = next(); if (Character.isLetterOrDigit(c) || c == '#') { sb.append(Character.toLowerCase(c)); } else if (c == ';') { break; } else { throw syntaxError("Missing ';' in XML entity: &" + sb); } } String string = sb.toString(); Object object = entity.get(string); return object != null ? object : ampersand + string + ";"; }
8ba1ed0f-29db-43b7-968e-a124896b99f4
1
public void switchBlockColor(int type) { if(this.type != -1){ this.type = -1; } else{ this.type = type; } }
52ff456b-fee0-4933-93ab-8cce45e57f52
8
public static Double[][] removeZeroCoefs(Double[][] a){ List<Double> coefs = new ArrayList<Double>(); List<Double> powers = new ArrayList<Double>(); for(int i = 0; i<a[0].length; i++){ if( a[0][i]!=null){ coefs.add(a[0][i]); powers.add(a[1][i]==null?0:a[1][i]); } } Double[][] res = new Double[2][coefs.size()]; for(int ind=0;ind<coefs.size();ind++){ res[0][ind] = coefs.get(ind); res[1][ind] = powers.get(ind); } if(isZero(res)){ Double[][] b = new Double[2][1]; b[0][0] = 0.0; b[1][0] = 0.0; return b; } coefs.clear(); powers.clear(); for(int i = 0; i<res[0].length; i++){ if( res[0][i] != 0 ){ coefs.add(res[0][i]); powers.add(res[1][i]); } } res = new Double[2][coefs.size()]; for(int ind=0;ind<coefs.size();ind++){ res[0][ind] = coefs.get(ind); res[1][ind] = powers.get(ind); } return res; }
cc49dedb-63e6-432e-a39a-72100010d825
0
@Override public boolean supportsDocumentAttributes() {return true;}
469418d0-fdfd-4cb6-8666-ec43700aba50
1
public void renderButton(Graphics g, Rectangle r, String s) { if(r.contains(Main.mse)) { g.drawImage(MenuRenderer.Button2, r.x, r.y, r.width, r.height, null); } else { g.drawImage(MenuRenderer.Button1, r.x, r.y, r.width, r.height, null); } g.setFont(new Font(Font.SANS_SERIF, 0, r.height/2)); g.drawString(s, r.x + (r.width/6), (int) (r.y+(r.height/1.25))); }
31904a90-5098-40a7-962b-73ce2001530f
9
private void genIfZeroStmt(final IfZeroStmt stmt) { int opcode; stmt.expr().visit(this); genPostponed(stmt); final int cmp = stmt.comparison(); if (stmt.expr().type().isReference()) { switch (cmp) { case IfStmt.EQ: opcode = Opcode.opcx_ifnull; break; case IfStmt.NE: opcode = Opcode.opcx_ifnonnull; break; default: throw new RuntimeException(); } } else { Assert.isTrue(stmt.expr().type().isIntegral(), "Illegal statement: " + stmt); switch (cmp) { case IfStmt.EQ: opcode = Opcode.opcx_ifeq; break; case IfStmt.NE: opcode = Opcode.opcx_ifne; break; case IfStmt.GT: opcode = Opcode.opcx_ifgt; break; case IfStmt.GE: opcode = Opcode.opcx_ifge; break; case IfStmt.LT: opcode = Opcode.opcx_iflt; break; case IfStmt.LE: opcode = Opcode.opcx_ifle; break; default: throw new RuntimeException(); } } method.addInstruction(opcode, stmt.trueTarget().label()); stackHeight -= 1; }
57e2ab55-b0e2-4a4c-9c20-9850bf7bf7b7
4
public Type getComponent() { if (this.clazz == null || !this.clazz.isArray()) return null; CtClass component; try { component = this.clazz.getComponentType(); } catch (NotFoundException e) { throw new RuntimeException(e); } Type type = (Type)prims.get(component); return (type != null) ? type : new Type(component); }
6964f71f-f4fc-4c43-8536-3c3046f42dee
5
public void attack(int attDir, int damage){ Rect weaponCollision = null; if(attDir == 0) weaponCollision = new Rect(x + 13, y - 16, 7, 16); if(attDir == 1) weaponCollision = new Rect(x + 29, y + 18, 22, 7); if(attDir == 2) weaponCollision = new Rect(x + 13, y + 32, 7, 24); if(attDir == 3) weaponCollision = new Rect(x - 19, y + 18, 25, 7); Mob attacking = dungeon.getMob(weaponCollision, this); if(attacking != null){ attacking.damage(damage, attDir, attacking, this); } }
7916e569-c9e0-468b-8467-52415142b40a
4
public int interseca( GrupCaselles grupB ) { int contador = 0; ArrayList<Casella> CasellesB = grupB.getGrup(); for ( int i = 0; i < grup.size(); i++ ) { if ( tauler.getEstatCasella( grup.get( i ) ) == EstatCasella.BUIDA ) { for ( int j = 0; j < CasellesB.size(); j++ ) { if ( grup.get( i ).equals( CasellesB.get( j ) ) ) { contador++; } } } } return contador; }
35b4728c-5eb3-400a-9bed-e12f329802fd
6
public static void merge(int[] array,int start,int mid,int end){ int[] left = new int[mid-start+1]; //need to add 1 ex: index is form 0 to 3 there are 4 elements; int[] right = new int[end - mid]; for(int i=0; i<left.length;i++){ left[i] = array[start+i]; } for(int i=0; i<right.length;i++){ right[i] = array[mid+1+i]; } //union int i = 0,j =0; for(int index = start;index<=end;index++){ //index shoude <= end because the end element shoud be sort if(i == left.length){ array[index] = right[j]; j++; } else if(j == right.length){ array[index] = left[i]; i++; } else if(left[i]<= right[j]){ array[index] = left[i]; i++; } else{ array[index] = right[j]; j++; } } }
76c2eef7-605f-4696-a2eb-5640cb26a82c
4
@SuppressWarnings("unchecked") public QuizServer decodeData() throws RemoteException { QuizServer serverState = null; XMLDecoder decode = null; if (!getSerializationFile().exists() || getSerializationFile().length() == 0) { return new QuizServer(); } try { decode = new XMLDecoder(new BufferedInputStream(new FileInputStream("." + File.separator + FILENAME))); serverState = (QuizServer) decode.readObject(); } catch (FileNotFoundException ex) { throw new RuntimeException("Shouldn't happen", ex); } finally { if (decode != null) { decode.close(); } } return serverState; }
6e44d859-e1fd-45ca-8c6d-e01ba52c981a
9
@Override public void tick(int time) { boolean inputChanged = false; for (int i = 0; i < input.length; i++) { if (events[i].isEmpty()) break; while(events[i].peek().time < time) events[i].poll(); Event e = events[i].peek(); if (e.time == time) { events[i].poll(); if (input[i] != e.value) { inputChanged = true; input[i] = e.value; } } } if (inputChanged) { for (int i = 0; i < output.length; i++) { boolean value = calculateOutput(i, input); if (value != output[i]) { output[i] = value; for (Listener l : listeners[i]) { l.notify(new Event(value, time+delay)); } } } } }
1248a73a-2041-4c0b-86ee-7e15bb5d5f8b
4
private void getParameters(String inputFileName){ new GetComments(); //first the number of rows and columns is retrieved String rowsN=TextIO.getWord(); //if(!rowsN.equals("Rows:")){ //throw new RuntimeException("The file format is not correct. Rows: keyword is absent"); //} //System.out.println(rowsN); rows=TextIO.getlnInt(); //System.out.println(rows); String colsN=TextIO.getWord(); //if(!rowsN.equals("Cols:")){ //throw new RuntimeException("The file format is not correct. Cols: keyword is absent"); //} //System.out.println(colsN); cols=TextIO.getlnInt(); //System.out.println(cols); //Here the variables names are retrieved String variablesNames=TextIO.getlnString(); //Here the units are retrieved String variablesUnits=TextIO.getlnString(); //The number of names must be equal to the number of cols + 1. The first field names followed by ':' (with no space) this.vnames=variablesNames.split(" "); for(int k=0;k<cols+1;k++){ vnames[k]=vnames[k].replaceAll("\\s", ""); //System.out.println("["+k+"] "+vnames[k]); } this.vunits=variablesUnits.split(" ",vnames.length); for(int k=0;k<cols+1;k++){ vunits[k]=vunits[k].replaceAll("\\s", ""); //System.out.println("["+k+"] "+vunits[k]); } String variables; this.vls=new double[rows][cols]; //All the values are retrieved as strings for(int i=0;i<rows;i++){ variables=TextIO.getlnString(); this.var=variables.split(" ",variables.length()); var[i]=var[i].replaceAll("\\s", ""); //All the variables retrieved are converted to double for(int k=0;k< cols;k++){ vls[i][k]=Double.parseDouble(var[k]); } } }
e5d1c167-b2df-4e1a-bad2-48b934256d46
2
double[][] compf(double[][] D, int m) { int s = D.length, r = 0; if (s == 0) { return null; } else { r = D[0].length; } double F[][] = new double[s][]; for (int i = 0; i < s; i++) { F[i] = compob(D[i]); } return F; }
be047cd3-fbda-4b56-b064-dbd404f66cc9
8
private void drawTooltip() { if(menuActionRow < 2 && itemSelected == 0 && spellSelected == 0) return; String s; if(itemSelected == 1 && menuActionRow < 2) s = "Use " + selectedItemName + " with..."; else if(spellSelected == 1 && menuActionRow < 2) s = spellTooltip + "..."; else s = menuActionName[menuActionRow - 1]; if(menuActionRow > 2) s = s + "@whi@ / " + (menuActionRow - 2) + " more options"; chatTextDrawingArea.method390(4, 0xffffff, s, loopCycle / 1000, 15); }
5fcf7ff6-20f1-4c77-9be2-601eb5c937a7
7
public void generateMaps() throws MaltChainedException { for (String groupname : optionGroups.keySet()) { OptionGroup og = optionGroups.get(groupname); Collection<Option> options = og.getOptionList(); for (Option option : options) { if (ambiguous.contains(option.getName())) { option.setAmbiguous(true); ambiguousOptionMap.put(option.getGroup().getName()+"-"+option.getName(), option); } else { if (!unambiguousOptionMap.containsKey(option.getName())) { unambiguousOptionMap.put(option.getName(), option); } else { Option ambig = unambiguousOptionMap.get(option.getName()); unambiguousOptionMap.remove(ambig); ambig.setAmbiguous(true); option.setAmbiguous(true); ambiguous.add(option.getName()); ambiguousOptionMap.put(ambig.getGroup().getName()+"-"+ambig.getName(), ambig); ambiguousOptionMap.put(option.getGroup().getName()+"-"+option.getName(), option); } } if (option.getFlag() != null) { Option co = flagOptionMap.get(option.getFlag()); if (co != null) { flagOptionMap.remove(co); co.setFlag(null); option.setFlag(null); if (SystemLogger.logger().isDebugEnabled()) { SystemLogger.logger().debug("Ambiguous use of an option flag -> the option flag is removed for all ambiguous options\n"); } } else { flagOptionMap.put(option.getFlag(), option); } } } } }
12576b2a-3cb8-4640-8e39-db68dcc91873
7
private void initNameListFontMenu(Color bg) { this.nametextListPanel = new JPanel(); this.nametextListPanel.setBackground(bg); this.nametextListPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT)); String initFontTmp = this.skin.getNametextFont(); int initFontSizeTmp = this.skin.getNametextFontsize(); Color initFontColorTmp = new Color(this.skin.getNametextFontcolor()[1], this.skin.getNametextFontcolor()[2], this.skin.getNametextFontcolor()[3]); boolean boldTmp = this.skin.getNametextFonttype() == Fonttype.BOLD; boolean underlineTmp = (this.skin.getNametextFontstyle() == Fontstyle.UNDERLINE) || (this.skin.getNametextFontstyle() == Fontstyle.SHADOWUNDERLINE); boolean shadowTmp = (this.skin.getNametextFontstyle() == Fontstyle.SHADOW) || (this.skin.getNametextFontstyle() == Fontstyle.SHADOWUNDERLINE); this.nametextFontfield = new FontField(bg, strFontFieldTitle, initFontTmp, initFontSizeTmp, initFontColorTmp, boldTmp, underlineTmp, shadowTmp) { private final long serialVersionUID = 1L; @Override public void fontChosen(String input) { if (!input.equals("")) { FontChangesMenu.this.skin.setNametextFont(input); updateFont(FontChangesMenu.this.skin.getNametextFont()); } else { FontChangesMenu.this.skin.setNametextFont(null); } } @Override public void sizeTyped(String input) { if (input != null) { FontChangesMenu.this.skin.setNametextFontsize(parseInt(input)); updateSize(FontChangesMenu.this.skin.getNametextFontsize()); } else { FontChangesMenu.this.skin.setNametextFontsize(-1); } } @Override public void colorBtnPressed(int[] argb) { FontChangesMenu.this.skin.setNametextFontcolor(argb); updateColor(new Color(FontChangesMenu.this.skin.getNametextFontcolor()[1], FontChangesMenu.this.skin.getNametextFontcolor()[2], FontChangesMenu.this.skin.getNametextFontcolor()[3])); } @Override public void boldPressed(boolean selected) { FontChangesMenu.this.skin.setNametextFonttype(selected ? Fonttype.BOLD : Fonttype.NORMAL); updateBold(FontChangesMenu.this.skin.getNametextFonttype() == Fonttype.BOLD); } @Override public void underlinePressed(boolean selected) { FontChangesMenu.this.skin.setNametextFontstyle(getUnderlineFontstyle(selected, FontChangesMenu.this.skin.getNametextFontstyle())); updateUnderline((FontChangesMenu.this.skin.getNametextFontstyle() == Fontstyle.UNDERLINE) || (FontChangesMenu.this.skin.getNametextFontstyle() == Fontstyle.SHADOWUNDERLINE)); } @Override public void shadowPressed(boolean selected) { FontChangesMenu.this.skin.setNametextFontstyle(getShadowFontstyle(selected, FontChangesMenu.this.skin.getNametextFontstyle())); updateShadow((FontChangesMenu.this.skin.getNametextFontstyle() == Fontstyle.SHADOW) || (FontChangesMenu.this.skin.getNametextFontstyle() == Fontstyle.SHADOWUNDERLINE)); } }; this.nametextListPanel.add(this.nametextFontfield); }
abc5ffbe-076a-425a-b6b9-b88afd917897
0
@Override public void finishPopulate() { }
76391333-39e7-401c-a905-011c02c1b8f8
0
public static String getServidor() { return servidor; }
c59d6902-821a-4ac8-a1fe-dd42fd94d15a
0
public void add(String name, Object prototype) { prototypes.put(name, prototype); }
b559f059-f359-4a04-a744-f6ed5847be2b
9
private MapperEstimatedJvmCost estimateBasedOnRules(JvmModel fMapPhaseMax, float fix, float eTempObj, boolean splitChanged) { // estimate the Perm Generation float ePermUsed = fMapPhaseMax.getPermUsed(); float ismb = newConf.getIo_sort_mb(); float eOU; float eNGU; float eHeapU = 0; String reason; if(ismb + fix + eTempObj <= gcCap.geteEC()) { if(ismb >= fConf.getIo_sort_mb() && splitChanged == false && fMapPhaseMax.getOldUsed() > 0 && gcCap.geteEC() <= gcCap.getfEC()) { eOU = ismb; eNGU = ismb + fix + eTempObj; eHeapU = eNGU; reason = "ismb >= fismb, fOU > 0, ismb + fix + eTempObj <= eEC"; } else { eNGU = ismb + fix + eTempObj; eOU = 0; reason = "ismb + fix + eTempObj <= eEC"; } } else { eOU = ismb + fix; float eNGCMX = gcCap.geteNGCMX(); if(newConf.getXms() == 0 && fConf.getXms() == 0 && fMapPhaseMax.getEdenUsed() <= gcCap.getfEC()) { eNGU = fMapPhaseMax.getEdenUsed(); reason = "eXms=0, fXms=0, fEU < fEC"; } else { eNGU = Math.min(eNGCMX, eTempObj); reason = "eOU = ismb + fix, eNGU = min(eNGCMX, eTempObj)"; } } MapperEstimatedJvmCost jvmCost = new MapperEstimatedJvmCost(); jvmCost.setPermUsed(ePermUsed); jvmCost.setNewUsed(eNGU); jvmCost.setOU(eOU); jvmCost.setTempObj(eTempObj); jvmCost.setFix(fix); if(eHeapU == 0) jvmCost.setHeapU(eNGU + eOU); else jvmCost.setHeapU(eHeapU); jvmCost.setReason(reason); return jvmCost; }
2afd4371-41d5-4b83-b364-c626d24972ea
6
@Override public void action() { TreeMap<Integer, Integer> answer = notWantedColor(100, couleurNonVoulue); String data = CentralIntelligenceAgency.treeToString(answer); ACLMessage msg = new ACLMessage(ACLMessage.REQUEST); msg.setContent(data); msg.addReceiver( new AID( arbitre, AID.ISLOCALNAME) ); agent.send(msg); ACLMessage arbiterAnswer = agent.receive(); if(arbiterAnswer!=null) { if(arbiterAnswer.getPerformative() == ACLMessage.REQUEST) { String content = arbiterAnswer.getContent(); if(content != null) { addBadColorToMap(couleurNonVoulue, CentralIntelligenceAgency.stringToGraph(content)); } } else if(arbiterAnswer.getPerformative() == ACLMessage.INFORM) { String content = arbiterAnswer.getContent(); if(content != null && content.indexOf("Beaucoup de sang.") != -1) { done = true; } } } else { block(); } }
93ec9c69-13ec-42ab-9bf9-5c692577ce09
6
public static void main(String[] args){ int a = 0; int b = 0; int c = 0; // range, die durchlaufen wird int range = 10; // durch die verschachtelte Schleifen werden alle // Wertkombination in range // durchlaufen und jeweils das maximum errechnet while(a < range){ while(b < range){ while(c < range){ // finde das Maximum der Zahlen // (Gleichheit wird vernachlaessigt) System.out.println("a: " + a + " | b: " + b + " | c: " + c); if(a > b){ if(a > c){ System.out.println("max a: " + a); } else{ System.out.println("max c: " + c); } } else{ if(b > c){ System.out.println("max b: " + b); } else{ System.out.println("max c: " + c); } } c++; } c = 0; b++; } b = 0; c = 0; a++; } }
1f42b2fa-6f3d-4bf3-83af-4763970ad65f
0
public static List<Offrir> selectOneByRapNum(EntityManager em, int rap_num) throws PersistenceException { List<Offrir> desOffrirs=null; Query query = em.createQuery("select v from Offrir v where v.rap_num = :rap_num "); query.setParameter("rap_num", rap_num); desOffrirs=query.getResultList(); return desOffrirs; }
0c3132b1-a52e-4441-9226-9c1207acbc9f
0
public void setDataEvasione(Date dataEvasione) { this.dataEvasione = dataEvasione; }
8a917aa4-17f4-4113-bbfd-d730c09e6e92
0
public void setFunUsuario(String funUsuario) { this.funUsuario = funUsuario; }
89a4e438-724a-4b5f-8e37-ad635b031784
7
protected void genArmorCode(MOB mob, CharClass E, int showNumber, int showFlag, String FieldDisp, String Field) throws IOException { if((showFlag>0)&&(showFlag!=showNumber)) return; mob.tell(showNumber+". "+FieldDisp+": '"+CharClass.ARMOR_LONGDESC[CMath.s_int(E.getStat(Field))]+"'."); if((showFlag!=showNumber)&&(showFlag>-999)) return; final String newName=mob.session().prompt(L("Enter (@x1)\n\r:",CMParms.toListString(CharClass.ARMOR_DESCS)),""); String newStat=""; for(int i=0;i<CharClass.ARMOR_DESCS.length;i++) { if(newName.equalsIgnoreCase(CharClass.ARMOR_DESCS[i])) newStat=""+i; } if(newStat.length()>0) E.setStat(Field,newStat); else mob.tell(L("(no change)")); }
6ffe04b3-7bfb-4509-98e7-9fa771cb11f9
9
private boolean buildFriendsListMenu(Interface component) { int i = component.contentType; if (i >= 1 && i <= 200 || i >= 701 && i <= 900) { if (i >= 801) { i -= 701; } else if (i >= 701) { i -= 601; } else if (i >= 101) { i -= 101; } else { i--; } menuActionName[menuActionCount] = "Remove @whi@" + friendsNames[i]; menuActionOpcode[menuActionCount] = 792; menuActionCount++; menuActionName[menuActionCount] = "Message @whi@" + friendsNames[i]; menuActionOpcode[menuActionCount] = 639; menuActionCount++; return true; } if (i >= 401 && i <= 500) { menuActionName[menuActionCount] = "Remove @whi@" + component.message; menuActionOpcode[menuActionCount] = 322; menuActionCount++; return true; } else { return false; } }
66529879-b56f-4118-bcf3-5ece477a5c68
4
public String toString() { MyStack<E> temp = new ArrayStack<E>(); StringBuffer sb = new StringBuffer(); sb.append("front [ "); /*print elements of out */ while(!out.isEmpty()){ sb.append(out.peek() + " "); temp.push(out.pop()); } sb.append("| "); while(!temp.isEmpty()){ out.push(temp.pop()); } /* print elements of out*/ while(!in.isEmpty()){ temp.push(in.pop()); } while(!temp.isEmpty()){ sb.append(temp.peek()+ " "); in.push(temp.pop()); } sb.append("] back"); return sb.toString(); }
01aaaaa8-13a5-4c01-ac9b-de61cdcdc599
5
private void sendSharesToOthers(ShamirShare shamir) throws IOException { try { otherServerIP = getOtherServerIP(); } catch (UnknownHostException e) { System.out.println("Cannot get other server's IP."); e.printStackTrace(); } ArrayList<SendingThread> sendingThreads = new ArrayList<SendingThread>(); for (int i=0; i<otherServerIP.size(); i++) { Socket socket = new Socket(otherServerIP.get(i), 4444); SendingThread serverthread = new SendingThread(socket, shamir, i); serverthread.start(); sendingThreads.add(serverthread); } try { Thread.sleep(5000); //1000 milliseconds is one second. } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } for (int i=0; i<sendingThreads.size(); i++){ if (sendingThreads.get(i).isSent()){ System.out.println("File splitting done."); sendingThreads.get(i).getSocket().close(); break; } } }
8c53d5c6-0ec0-403b-97ed-6e2dffd6fd38
3
public static void main(String[] args) { // print all permutations method 1 generatePermutations(new int[3], 2); // print all permutations method 2 int[] p = {0, 1, 2, 4}; int cnt = 0; do { System.out.println(Arrays.toString(p)); if (!Arrays.equals(p, permutationByNumber(p.length, numberByPermutation(p))) || cnt != numberByPermutation(permutationByNumber(p.length, cnt))) throw new RuntimeException(); ++cnt; } while (nextPermutation(p)); System.out.println(5 == numberByPermutation(p)); System.out.println(Arrays.equals(new int[]{1, 0, 2}, permutationByNumber(3, 2))); //System.out.println(0b1101 == nextPermutation(0b1011)); //System.out.println(decomposeIntoCycles(new int[]{0, 2, 1, 3})); }
9d1ee95d-125d-4990-b7f9-5550acfb77be
1
public Map<String, String> check() throws IOException { IDGrabber grabber = new IDGrabber(link); grabber.grab(); Map<String, String> updates = grabber.writeToFile(); if (updates.isEmpty()) { System.out.println("Scanning......"); } else { System.out.println(updates.size() + " new entries!"); } return updates; }
5c6ac356-2512-4d7b-9851-cb9c9151cd08
4
@Test public void testMonsterDiff(){ charTest.setPlayerLvl(2); testMons.genMonster(charTest.getPlayerLvl()); if (testMons.getName().equalsIgnoreCase("Valefor")){ assertEquals(350, testMons.getHealth()); assertEquals(20, testMons.getDamage()); } else if (testMons.getName().equalsIgnoreCase("Ifrit")){ assertEquals(300, testMons.getHealth()); assertEquals(35, testMons.getDamage()); } else { assertEquals(250, testMons.getHealth()); assertEquals(40, testMons.getDamage()); } //Test when character level is at 4 charTest.setPlayerLvl(4); testMons.genMonster(charTest.getPlayerLvl()); if (testMons.getName().equalsIgnoreCase("Valefor")){ assertEquals(550, testMons.getHealth()); assertEquals(40, testMons.getDamage()); } else if (testMons.getName().equalsIgnoreCase("Ifrit")){ assertEquals(500, testMons.getHealth()); assertEquals(55, testMons.getDamage()); } else { assertEquals(450, testMons.getHealth()); assertEquals(60, testMons.getDamage()); } }
1734750a-8be7-4a56-80a5-f8dc0abe21d9
8
private void lookForVariableAccess(OptFunctionNode fn, Node n) { switch (n.getType()) { case Token.DEC : case Token.INC : { Node child = n.getFirstChild(); if (child.getType() == Token.GETVAR) { int varIndex = fn.getVarIndex(child); if (!itsNotDefSet.test(varIndex)) itsUseBeforeDefSet.set(varIndex); itsNotDefSet.set(varIndex); } } break; case Token.SETVAR : { Node lhs = n.getFirstChild(); Node rhs = lhs.getNext(); lookForVariableAccess(fn, rhs); itsNotDefSet.set(fn.getVarIndex(n)); } break; case Token.GETVAR : { int varIndex = fn.getVarIndex(n); if (!itsNotDefSet.test(varIndex)) itsUseBeforeDefSet.set(varIndex); } break; default : Node child = n.getFirstChild(); while (child != null) { lookForVariableAccess(fn, child); child = child.getNext(); } break; } }
e01a9d62-ba32-4a89-8d43-7ecd4bd75a48
5
private void stressDistribution(Node from, Node to, Dijkstra dijkstra) { for(Node n : graph.getNodes()) { if( n.getId() == from.getId() || n.getId() == to.getId()) continue; ArrayList<Integer> al = dijkstra.getPathTo(to); if(al.contains(n.getId())) { Integer count = stressDistribution.get(n.getId()); if (count == null) { stressDistribution.put(n.getId(), 1); } else { stressDistribution.put(n.getId(), count + 1); } } } }
66d5954a-6b47-4d66-9ef7-e20d29e36f0f
1
@Override public void run() { Loader loader = new Loader(); try { loader.setUrl(url); loader.load(); System.out.println(i); } catch (Exception e) { e.printStackTrace(); } }
ac6d8f51-ffd7-4ec4-9734-b3e42cc4489a
9
public boolean equals(HPDAddressModel address) { if (address == null) { return false; } return StringUtils.equalsIgnoreCase(this.getAddressTypeId(), address.getAddressTypeId()) && StringUtils.equalsIgnoreCase(this.getAddressLine1(), address.getAddressLine1()) && StringUtils.equalsIgnoreCase(this.getAddressLine2(), address.getAddressLine2()) && StringUtils.equalsIgnoreCase(this.getStreetName(), address.getStreetName()) && StringUtils.equalsIgnoreCase(this.getStreetNumber(), address.getStreetNumber()) && StringUtils.equalsIgnoreCase(this.getLocality(), address.getLocality()) && StringUtils.equalsIgnoreCase(this.getState(), address.getState()) && StringUtils.equalsIgnoreCase(this.getPostal(), address.getPostal()) && StringUtils.equalsIgnoreCase(this.getCountryCode(), address.getCountryCode()); }
1f6d2984-3a71-4847-84ac-fc23d536d1d2
1
public void testIsAfter_TOD() { TimeOfDay test1 = new TimeOfDay(10, 20, 30, 40); TimeOfDay test1a = new TimeOfDay(10, 20, 30, 40); assertEquals(false, test1.isAfter(test1a)); assertEquals(false, test1a.isAfter(test1)); assertEquals(false, test1.isAfter(test1)); assertEquals(false, test1a.isAfter(test1a)); TimeOfDay test2 = new TimeOfDay(10, 20, 35, 40); assertEquals(false, test1.isAfter(test2)); assertEquals(true, test2.isAfter(test1)); TimeOfDay test3 = new TimeOfDay(10, 20, 35, 40, GregorianChronology.getInstanceUTC()); assertEquals(false, test1.isAfter(test3)); assertEquals(true, test3.isAfter(test1)); assertEquals(false, test3.isAfter(test2)); try { new TimeOfDay(10, 20, 35, 40).isAfter(null); fail(); } catch (IllegalArgumentException ex) {} }
bbc299b6-0911-4412-8045-78a68add5488
4
private void exit() { switch (Server.getStatus()) { case Server.PLAYERS_CONNECTED: if (JOptionPane.showConfirmDialog(Main.this, "The server is running and the game is in progress.\n" + "Do you want to exit anyway?", Main.TITLE_SHORT, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) { Server.closeServer(); return; } break; case Server.RUNNING: if (JOptionPane.showConfirmDialog(Main.this, "The server is running, but\n" + "the game has not yet started.\n" + "Are you sure that you want to exit?", Main.TITLE_SHORT, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) { Server.closeServer(); return; } break; } System.exit(0); }
2a228a05-2c0c-4895-952c-39a1e0d5ca56
1
private void updateMouse() { double mouseXBefore = getMouseX(); double mouseYBefore = getMouseY(); glfwGetCursorPos(inputSource, mouseX, mouseY); if (hasBeenUpdated) { mouseDeltaX = getMouseX() - mouseXBefore; mouseDeltaY = getMouseY() - mouseYBefore; } hasBeenUpdated = true; }
1393e7fc-b8a0-4e0c-a5cb-1ca87a2aa742
8
@Override public String getColumnName(int column) { String reply = ""; switch (column) { case 0: reply = "ID"; break; case 1: reply = "Name"; break; case 2: reply = "Demand"; break; case 3: reply = "Supply"; break; case 4: reply = "Max. Buy Price/Unit"; break; case 5: reply = "Min. Sell Price/Unit"; break; case 6: reply = "Margin"; break; case 7: reply = "Link"; break; } return reply; }
7597382c-6cde-4262-9eb7-af4c0b1deaf8
9
public PacketExtension parseExtension(XmlPullParser parser) throws Exception { boolean done = false; StringBuilder buffer = null; DataForm dataForm = new DataForm(parser.getAttributeValue("", "type")); while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { if (parser.getName().equals("instructions")) { dataForm.addInstruction(parser.nextText()); } else if (parser.getName().equals("title")) { dataForm.setTitle(parser.nextText()); } else if (parser.getName().equals("field")) { dataForm.addField(parseField(parser)); } else if (parser.getName().equals("item")) { dataForm.addItem(parseItem(parser)); } else if (parser.getName().equals("reported")) { dataForm.setReportedData(parseReported(parser)); } } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals(dataForm.getElementName())) { done = true; } } } return dataForm; }
5ff0a9de-7aa9-4724-932e-edbd4a0865d6
8
void showColorForPixel(int x, int y) { if (x >= 0 && x < imageData.width && y >= 0 && y < imageData.height) { int pixel = imageData.getPixel(x, y); RGB rgb = imageData.palette.getRGB(pixel); boolean hasAlpha = false; int alphaValue = 0; if (imageData.alphaData != null && imageData.alphaData.length > 0) { hasAlpha = true; alphaValue = imageData.getAlpha(x, y); } String rgbMessageFormat = bundle.getString(hasAlpha ? "RGBA" : "RGB"); Object[] rgbArgs = { Integer.toString(rgb.red), Integer.toString(rgb.green), Integer.toString(rgb.blue), Integer.toString(alphaValue) }; Object[] rgbHexArgs = { Integer.toHexString(rgb.red), Integer.toHexString(rgb.green), Integer.toHexString(rgb.blue), Integer.toHexString(alphaValue) }; Object[] args = { new Integer(x), new Integer(y), new Integer(pixel), Integer.toHexString(pixel), createMsg(rgbMessageFormat, rgbArgs), createMsg(rgbMessageFormat, rgbHexArgs), (pixel == imageData.transparentPixel) ? bundle.getString("Color_at_transparent") : ""}; statusLabel.setText(createMsg(bundle.getString("Color_at"), args)); } else { statusLabel.setText(""); } }
c015ccb6-11bb-4cc5-9ecc-7d5e93b59204
5
public static ArrayList<Achievement> updateAchievement(User user) { ArrayList<Achievement> records = AchievementRecord.getAchievementsByUserID(user.userID, QUIZ_CREATED_TYPE); ArrayList<Achievement> newAchievements = new ArrayList<Achievement>(); int totalCreatedQuiz = QuizCreatedRecord.getCreatedQuizByUserID(user.userID).size(); // TODO can be simplified using COUNT in database for (int i = 0; i < getAllAchievements().size(); i++) { Achievement achievement = getAllAchievements().get(i); boolean found = false; for (int j = 0; j < records.size(); j++) if (records.get(j).name.equals(achievement.name)) { found = true; break; } if (found) continue; if (totalCreatedQuiz >= achievement.threshold) { AchievementRecord record = new AchievementRecord(user, achievement); record.addRecordToDB(); newAchievements.add(achievement); } } return newAchievements; }
56cae5af-01f6-470a-9fec-5eeebbdd9927
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Principal().setVisible(true); } }); }
da056690-f942-45d0-b847-bd70e351abcd
4
@Override public void triggered( CapabilityName<?>... allowHandlersFor ) { if( triggeredSite == null ){ triggeredSite = this; for(CapabilityName<?> allowHandlerFor : allowHandlersFor ){ handlersAllowed.add( allowHandlerFor ); } updateAllEnabled(); } }
a04de488-1ab7-4c3e-843c-df72976311fc
1
protected boolean isSplitable(JobContext context, Path file) { CompressionCodec codec = new CompressionCodecFactory(context.getConfiguration()).getCodec(file); if (null == codec) { return true; } return codec instanceof SplittableCompressionCodec; }
a51802d2-7559-484f-803d-4c62d8f6e460
7
protected void done() { double max = Double.NaN; try { max = Double.parseDouble( maxXField.getText()); } catch (NumberFormatException nfe) { } double min = Double.NaN; try { min = Double.parseDouble( minXField.getText()); } catch (NumberFormatException nfe) { } double tickSpacing = 0; try { tickSpacing = Double.parseDouble(tickXField.getText()); } catch (NumberFormatException nfe) { } if (max <= min) { JOptionPane.showMessageDialog(this, "Maximum value must be greater than minimum"); return; } //Adjust tick spacing so there are always a few ticks showing if (tickSpacing > (max-min)) { tickSpacing = (max-min)/4.0; } Integer fontSize = 12; try { fontSize = (Integer)fontSizeSpinner.getValue(); } catch (Exception ex) { //Probably will never happen } AxesOptions ops = new AxesOptions(min, max, tickSpacing, gridLinesBox.isSelected(), fontSize ); if (changingXAxis) currentAxes.setXAxisOptions(ops); else currentAxes.setYAxisOptions(ops); setVisible(false); currentAxes = null; }
2c9cd26f-4d81-4881-be00-c644f5eecc54
4
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } SwingUtilities.invokeLater(new Runnable() { public void run() { new Test().setVisible(true); } }); }
4000a1ba-95dd-4811-81b7-20fe14b54497
5
public void autoFit() { // KSC: make more betta :) double w = 0; CellHandle[] cxt = getCells(); for( CellHandle aCxt : cxt ) { String s = aCxt.getFormattedStringVal(); //StringVal(); FormatHandle fh = aCxt.getFormatHandle(); Font ef = fh.getFont(); int style = java.awt.Font.PLAIN; if( ef.getBold() ) { style |= java.awt.Font.BOLD; } if( ef.getItalic() ) { style |= java.awt.Font.ITALIC; } int h = (int) ef.getFontHeightInPoints(); java.awt.Font f = new java.awt.Font( ef.getFontName(), style, h ); double newW = 0; if( !aCxt.getFormatHandle().getWrapText() ) // normal case, no wrap { newW = StringTool.getApproximateStringWidth( f, s ); } else // wrap - use current column width????? { newW = getWidth() / COL_UNITS_TO_PIXELS; } w = Math.max( w, newW ); /* int strlen = cstr.length(); int csz = strlen *= cxt[t].getFontSize(); int factor= 28; // KSC: was 50 + added factor to guard below if((csz*factor)>lastsz) this.setWidth(csz*factor); */ } if( w == 0 ) { return; // keep original width ... that's what Excel does for blank columns ... } // convert pixels to excel column units basically ExtenXLS.COLUNITSTOPIXELS in double form setWidth( (int) Math.floor( (w / DEFAULT_ZERO_CHAR_WIDTH) * 256.0 ) ); }
eea7f530-acbf-41b1-b888-3686a4a2244d
4
public void addDiffFeature(){ HashMap<String, Double> difference = new HashMap<String, Double>(); for(Business b: businesses){ double truescore = b.stars; //difference.put(b.id, b.stars); for(Review r:reviews){ if(r.b_id.equals(b.id)){ difference.put(b.id, r.stars-truescore); } } } double total = 0; double abstotal = 0; for(String bid:difference.keySet()){ total+=difference.get(bid); abstotal += Math.abs(difference.get(bid)); } features.add(total); features.add(abstotal); }
46a80f45-e015-4da8-a9f5-c07cea18c133
4
@Override public int hashCode() { int result = sessionId != null ? sessionId.hashCode() : 0; result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0); result = 31 * result + (userAgent != null ? userAgent.hashCode() : 0); result = 31 * result + lastActivity; result = 31 * result + (userData != null ? userData.hashCode() : 0); return result; }
035c8003-0d58-4371-b992-8f70e34b458f
1
public static boolean isMurder(int s) { if(s==32961) return true; return false; }
62d81013-83e7-4979-96b8-91be10b9490e
4
private void add() { Integer option; String s; UI.printHeader(); System.out.println("Selecciona un agente a continuaciรณn:"); System.out.println("1) Snmp"); System.out.println(""); System.out.println("0) Atrรกs"); System.out.println(""); System.out.print("Introduce una opciรณn: "); try { BufferedReader bufferRead = new BufferedReader( new InputStreamReader(System.in)); s = bufferRead.readLine(); option = Integer.parseInt(s); switch (option) { case 0: break; case 1: snmpUI.add(); break; default: UI.setError("Opciรณn no vรกlida"); break; } } catch (NumberFormatException e) { UI.setError("Opciรณn no vรกlida"); } catch (IOException e) { e.printStackTrace(); } }
3178c75c-64b9-4954-b125-deacf745a5a5
6
public static void ZipPutLongIntoBuf(ByteBuffer _buff, long _num) { if(_num > Byte.MIN_VALUE && _num < Byte.MAX_VALUE) { //put the length _buff.put((byte)1); //put the value _buff.put((byte)_num); return ; } else if(_num > Short.MIN_VALUE && _num < Short.MAX_VALUE) { //put the length _buff.put((byte)2); //put the value _buff.putShort((short)_num); return ; } else if(_num > Integer.MIN_VALUE && _num < Integer.MAX_VALUE) { //put the length _buff.put((byte)4); //put the value _buff.putInt((int)_num); return ; } //put the length _buff.put((byte)8); //put the value _buff.putLong(_num); }
68d07b5d-30ca-4bf4-abab-574522091c36
5
public Map.Entry<Long, E> getClosestEqual(Long timestamp) { Map.Entry<Long, E> lower = getFrameEqualLower(timestamp); Map.Entry<Long, E> higher = getFrameEqualHigher(timestamp); if(lower == null && higher == null) { return null; } else if(lower == null) { return higher; } else if(higher == null) { return lower; } else { long lowerDiff = timestamp - lower.getKey(); long higherDiff = higher.getKey() - timestamp; return (lowerDiff < higherDiff) ? lower : higher; } }
d9e9807a-20b5-431f-8391-8d61cb7c00be
1
@Override public Iterable<? extends Position<T>> children(Position<T> pos) { return castPositionToNode(pos).getDirectChilren(); }
aa1477ca-155d-4026-bf66-d6e349b3c33c
6
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(BuscarLaboratorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(BuscarLaboratorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(BuscarLaboratorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(BuscarLaboratorio.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { final BuscarLaboratorio laboratorio = new BuscarLaboratorio(); laboratorio.setVisible(true); laboratorio.setLocationRelativeTo(null); } }); }
410b5aab-f53b-4536-9674-5c23dc3a076d
0
public void addSearchedSites(String url){ /* List<SqlParameter> sqlParamList = new LinkedList<SqlParameter>(); sqlParamList.add(new SqlParameter(Types.VARCHAR, url)); sqlParamList.add(new SqlParameter(Types.TIMESTAMP, new java.sql.Timestamp(new Date().getTime()))); final StringBuilder sql = new StringBuilder(); sql.append("INSERT INTO SEACHED_URL_WIKI (URL, UPDATE_TIME) VALUES (?, ?)"); this.sqlUpdater.executeSql(sql.toString(), sqlParamList); */ this.sqlUpdater.executeSql("INSERT INTO SEACHED_URL_WIKI (URL) VALUES ('"+url+"')"); }
44886b0e-07d4-43d2-9a93-627dccfc9dcd
6
@Override public void run() { String [] hosts = execHosts.split(","); int numHosts = hosts.length; int currentHost = 0; sgeExecHostsExampleScrollPane.setVisible(false); validatingHostsLabel.setVisible(true); sif.setNextEnabled(false); sif.setBackEnabled(false); List<String> checkedHosts = new LinkedList<String>(); for ( String host : hosts ) { host = host.trim(); if ( checkedHosts.contains(host) ) { finished("The host " + host + " has been entered more than\n" + "once. Each entry line has to be unique.\n", "Duplicate execution hosts found"); return; } if ( host.equals(hostname)) { checkedHosts.add(host); continue; } validatingHostsLabel.setText("Validating hosts..." + (currentHost * 100 / numHosts) + "%"); Process p = null; try { p = Runtime.getRuntime().exec("install_files/checkHost.sh " + host); p.waitFor(); if ( p.exitValue() != 0 ) { finished("Please make sure that the host " + host + "\n" + " - exists AND\n" + " - accepts ssh connections AND\n" + " - allows this host to log in without specifying password.", "Invalid host found " + host); return; } } catch ( Exception ex ) { ex.printStackTrace(); } finally{ if ( p != null ) NativeCalls.releaseProcess(p); } checkedHosts.add(host); currentHost++; validatingHostsLabel.setText("Validating hosts..." + (currentHost * 100 / numHosts) + "%"); } sgeExecHostsExampleScrollPane.setVisible(true); validatingHostsLabel.setText(""); validatingHostsLabel.setVisible(false); sif.setNextEnabled(true); sif.setBackEnabled(true); hostValidationPassed = true; sif.nextButtonAction(); }
1d877fb3-7059-4766-afd4-1ceffce85f39
8
@Override public List<ExpertiseDefinition> myListableExpertises(MOB mob) { ExpertiseDefinition D=null; final List<ExpertiseDefinition> V=new Vector<ExpertiseDefinition>(); for(final Enumeration<ExpertiseDefinition> e=definitions();e.hasMoreElements();) { D=e.nextElement(); if((D.compiledListMask()==null)||(CMLib.masking().maskCheck(D.compiledListMask(),mob,true))) V.add(D); } final PlayerStats pStats = mob.playerStats(); if(pStats != null) { for(final ExpertiseDefinition def : pStats.getExtraQualifiedExpertises().values()) { if((def.compiledListMask()==null)||(CMLib.masking().maskCheck(def.compiledListMask(),mob,true))) { D = completeEduMap.get(def.ID()); if(D!=null) V.remove(D); V.add(def); } } } return V; }
a134b805-e9fa-497f-8085-218251b57bcd
6
private void substitute() { ArrayList< Substitution> textAcc = new ArrayList<>(); text.add(new Substitution(original, original)); for (SubstitutionRule rule : rules) { for (Substitution s : text) { // there should be no substitutions in text already with subcitution if (s.isSubstitution() && rule.substitute(s.getSubstitute())) { throw new UnsupportedOperationException( "cannot have several rules that modify the same part of the string"); } if (s.isSubstitution()) { textAcc.add(s); } else { rule.substitute(s.getOriginal()); for (Substitution sForRule: rule) { textAcc.add(sForRule); } } } text.clear(); text.addAll(textAcc); textAcc.clear(); } }
1489b2c5-3616-4783-990c-ec28d85b77e6
5
public boolean login(String user, String pass) { if (!player.isRegistered()) { response = "login.error.registered"; return false; } else if (player.isAuthenticated()) { response = "login.error.authenticated"; return false; } else if (!plugin.getPwdHndlr().checkPassword(player.getAccountId(), pass)) { int strikes = plugin.getStrkMngr().getRecord(player.getIPAddress()).addStrike(player.getPlayerName()); if (strikes >= plugin.getConfig().getInt("strikes.amount")) plugin.getStrkMngr().strikeout(player.getPlayer()); response = "login.error.password"; return false; } else if (!plugin.getPlyrMngr().isActive(player.getAccountId())) { response = "login.error.active"; return false; } return true; }
773b119b-936b-46ce-a046-28142a910783
3
protected synchronized GeneralPath getOutlineFromCMaps (char val, float width) { // find the cmaps CmapTable cmap = (CmapTable) font.getTable ("cmap"); if (cmap == null) { return null; } // try maps in required order of (3, 1), (1, 0) CMap map = cmap.getCMap ((short) 3, (short) 1); if (map == null) { map = cmap.getCMap ((short) 1, (short) 0); } int idx = map.map (val); if (idx != 0) { return getOutline (idx, width); } return null; }
9d3ee05e-3126-4077-b864-d777616a86fe
0
@Override public Iterator<Feature> iterator() { return features.iterator(); }
ea6fbdff-2f95-4309-a7c2-ef6939f04bca
6
private final synchronized Properties loadPropertyFile(final String file) { // TODO optimize exception handling File propertyFile = new File(file); if(!propertyFile.exists()) { URL fileURL = this.getClass().getResource(file); if(fileURL != null) { propertyFile = loadFileFromURL(fileURL); } } if(!propertyFile.exists()) { URL fileURL = this.getClass().getClassLoader().getResource(file); if(fileURL != null) { propertyFile = loadFileFromURL(fileURL); } } if(!propertyFile.exists()) { throw new RuntimeException("cannot read file: " + file); } Properties props = new Properties(); try { props.load(new FileInputStream(propertyFile)); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("cannot read file: " + file); } return props; }
40dc1231-8a1e-4433-a4be-670e73949217
7
public void infoDisplay(final LocalExpr expr) { final UseInformation UI = (UseInformation) useInfoMap.get(expr); final DefInformation DI = (DefInformation) defInfoMap.get(expr); System.err.println(expr.toString()); System.err.println(expr.parent().toString() + "-" + expr.parent().parent().toString()); if ((expr.parent().parent().parent() != null) && (expr.parent().parent().parent().parent() != null)) { System.err.println(expr.parent().parent().parent().toString() + "-" + expr.parent().parent().parent().parent().toString()); } if (DI == null) { System.err.println("not a definition"); if (expr.def() == null) { System.err.println("has no definition (is parameter?)"); } else { System.err.println("has definition " + expr.def()); } } else { System.err.println("a definition with " + DI.type1s + " type1s total"); System.err.println("uses: " + DI.uses); System.err.println("uses found: " + DI.usesFound); if (shouldStore(expr)) { System.err.println("should store"); } } if (UI == null) { System.err.println("No use information entry. trouble"); } else { if (DI == null) { System.err.println("type on stack: " + UI.type); } System.err.println("type0s for this instance: " + UI.type0s); System.err.println("of above, number of x1s: " + UI.type0_x1s); System.err.println("of above, number of x2s: " + UI.type0_x2s); System.err.println("type1s for this instance: " + UI.type1s); System.err.println("of above, number of x1s: " + UI.type1_x1s); System.err.println("of above, number of x2s: " + UI.type1_x2s); } }
5bc181e4-fea8-4bc0-9a00-2a7c17bea00c
8
public void run() { _debug.fine( "UpdateRunnable wird gestartet fรผr " + _responseAspect + " " + _responseAtg + " Nachrichtentyp: DynamischeMengeAktualisierung/ObjektAktualisierung" ); while(true) { try { Data data = _unboundedQueue.take(); if(data == null) { _debug.fine("UpdateRunnable wird gestoppt " + _responseAspect + " " + _responseAtg); return; } // Prรผfen, was benachrichtigt werden muss final String messageType = data.getTextValue("nachrichtenTyp").getValueText(); if("DynamischeMengeAktualisierung".equals(messageType)) { actualizeMutableSet(data); } else if("Objektaktualisierung".equals(messageType)) { actualizeObject(data); } else if("DynamischeKollektionAktualisierung".equals(messageType)) { actualizeMutableCollection(data); } else if("KommunikationszustandAktualisierung".equals(messageType)) { actualizeConfigurationCommunicationState(data); } else { throw new IllegalArgumentException("Unbekannten Auftrag empfangen"); } } catch(InterruptedException ex) { _debug.error( "UpdateThread im RemoteRequestManager wurde unterbrochen " + _responseAspect + " " + _responseAtg + " Nachrichtentyp: DynamischeMengeAktualisierung", ex ); } catch(RuntimeException ignore) { _debug.warning("Unerwarteter Fehler bei der Verarbeitung von asynchronen Konfiguationsantworten", ignore); } } }
0a93d81c-ec74-47d7-af7c-ec93f27b4370
9
private boolean getsToLive(Cell cell) { int x = cell.getX(); int y = cell.getY(); int liveNeighbours = 0; liveNeighbours += isAlive(x - 1, y - 1); liveNeighbours += isAlive(x - 1, y); liveNeighbours += isAlive(x - 1, y + 1); liveNeighbours += isAlive(x, y - 1); liveNeighbours += isAlive(x, y + 1); liveNeighbours += isAlive(x + 1, y - 1); liveNeighbours += isAlive(x + 1, y); liveNeighbours += isAlive(x + 1, y + 1); // 1. Any live cell with fewer than two live neighbours dies, as if caused by under-population: if (cell.isAlive() && liveNeighbours < 2) return false; // 2. Any live cell with two or three live neighbours lives on to the next generation. if (cell.isAlive() && (liveNeighbours == 2 || liveNeighbours == 3)) return true; // 3. Any live cell with more than three live neighbours dies, as if by overcrowding. if (cell.isAlive() && liveNeighbours > 3) return false; // 4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. if (!cell.isAlive() && liveNeighbours == 3) return true; return false; }
435a9273-2446-4e47-be54-aea682754f13
8
private boolean initKeyExchange() { if (type == CLIENT) { try { // get p p = readBytes(); // ack p sendBytes(p); // get g g = readBytes(); // ack g sendBytes(g); // calc A crypto = new UMSM_Main_Crypto(p); BigInteger A = crypto.calcA(g); // send A sendBytes(A.toByteArray()); // ack A readBytes(); // get B byte[] B = readBytes(); // ack B sendBytes(B); // create AES Key crypto.createAESKey(B); return true; } catch (Exception e) { e.printStackTrace(); } } else if (type == SERVER) { // create p p = new byte[190]; (new Random()).nextBytes(p); while ((new BigInteger(p)).signum() <= 0) { (new Random()).nextBytes(p); } try { // send p to partner sendBytes(p); System.out.println("Send p"); // acknowledge receiving p if (new BigInteger(readBytes()).compareTo(new BigInteger(p)) != 0) throw new Exception("ACK p failed"); System.out.println("ACK p"); // create Crypto Class and g crypto = new UMSM_Main_Crypto(p); g = crypto.nextRandomBigInteger(new BigInteger(p)) .toByteArray(); // send g to partner sendBytes(g); System.out.println("Send g"); // acknowledge receiving g if (new BigInteger(readBytes()).compareTo(new BigInteger(g)) != 0) throw new Exception("ACK g failed"); System.out.println("ACK g"); // get B B = readBytes(); // ack B sendBytes(B); // create A and send A BigInteger A = crypto.calcA(g); sendBytes(A.toByteArray()); // acknowledge receiving A if (new BigInteger(readBytes()).compareTo(A) != 0) throw new Exception("ACK A failed"); System.out.println("ACK A"); crypto.createAESKey(B); } catch (Exception e) { e.printStackTrace(); } } return false; }
0646284d-feac-4543-9a1a-fc979cdabb29
8
public static void main(String[] args) throws Throwable{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuffer sb = new StringBuffer(); for (String ln; !(ln = in.readLine().trim()).equals("0");) { StringTokenizer st = new StringTokenizer(ln); TreeSet<Integer> arbol = new TreeSet<Integer>(); int cont = 0, max = -1; int[] arr = new int[100000]; while (st.hasMoreTokens()){ int n = parseInt(st.nextToken()); max = Math.max(max, n); if(arbol.contains(n)) arr[cont++]=n; else arbol.add(n); } if(max >= arbol.size() + cont)sb.append("Message hacked by the Martians!!!\n"); else{ Arrays.sort(arr, 0, cont); for (int i = 0, j = 0; i < cont + arbol.size(); i++) if(arbol.contains(i))sb.append(i + (i < cont + arbol.size() - 1?" ":"")); else sb.append(arr[j++] + (i < cont + arbol.size() - 1?" ":"")); sb.append("\n"); } } System.out.print(new String(sb)); }
2d4ea8db-0503-431e-b56c-f8c09e3a703f
3
@Override public void execute(VGDLSprite sprite1, VGDLSprite sprite2, Game game) { // Stop just in front of the wall, removing that velocity component, but possibly sliding along it. //Keep in the list, for the current cycle, the sprites that have triggered this event. int currentGameTime = game.getGameTick(); if(currentGameTime > lastGameTime) { spritesThisCycle.clear(); lastGameTime = currentGameTime; } //the event gets triggered only once per time-step on each sprite. if(spritesThisCycle.contains(sprite1)) return; sprite1.setRect(sprite1.lastrect); double centerXDiff = Math.abs(sprite1.rect.getCenterX() - sprite2.rect.getCenterX()); double centerYDiff = Math.abs(sprite1.rect.getCenterY() - sprite2.rect.getCenterY()); Vector2d v; if(centerXDiff > centerYDiff) { //sprite1.orientation = new Direction(0, sprite1.orientation.y() * (1.0 - friction)); v = new Vector2d(0, sprite1.orientation.y() * (1.0 - friction)); }else { //sprite1.orientation = new Direction(sprite1.orientation.x() * (1.0 - friction), 0); v = new Vector2d(0, sprite1.orientation.y() * (1.0 - friction)); } double mag = v.mag(); v.normalise(); sprite1.orientation = new Direction(v.x, v.y); sprite1.speed = mag * sprite1.speed; }
0ab30035-4859-4a64-8b91-80df3912975e
1
@Override public boolean removeAll(Collection<?> c) { // TODO Auto-generated method stub return false; }
7f1b4d5d-9294-457f-bdb7-de97f3426837
7
public void delete(int data){ //to delete first node if(head.getData() == data){ head = head.getNext(); } else{ Node ptr = head.getNext(); Node preptr = head; while(ptr.getNext() != null){ if(ptr.getData() == data) break; ptr = ptr.getNext(); preptr = preptr.getNext(); } //if it is last node if(ptr.getData() == data && ptr.getNext() == null){ ptr = null; preptr.setNext(null); } // if it is any middle node else if(ptr.getData() == data && ptr.getNext() != null){ preptr.setNext(ptr.getNext()); ptr = null; } else{ System.out.println("could not delete node with data"+data); } } }
a49c6775-7e60-4fc5-a0ac-0f6e3824e093
5
@Override protected void bindToModelModifications() { dicSystemModel.addPropertyChangeListener( dicSystemModel.getPropertyName(), new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!lock) paramsDicos.loadDicos((TagAndURISubModel[]) evt .getNewValue()); } }); dicProfileModel.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!lock) switch (evt.getPropertyName()) { case DictionaryProfileModel.AUTOMATICALLY_ENHANCED_PROPERTY: paramsDicos.setAutomaticalyEhanced((boolean) evt .getNewValue()); break; case DictionaryProfileModel.INTEGRATED_NEW_WORDS_PROPERTY: paramsDicos.setIntegratedWords((boolean) evt .getNewValue()); break; case DictionaryProfileModel.USED_DICTIONARY_PROPERTY: System.out.println("USED DICTIONARY CHANGE"); paramsDicos.setUsedDictionary(VitipiTools .normalizeName((String) evt.getNewValue())); break; } } }); }
74699b04-e2e2-42ab-95df-720b2d8b3d1b
3
public void init(int startHappinessLevel) { currentHappinessLevel = startHappinessLevel; yPos = -32 + GamePanel.HEIGHT/2; xPos = GamePanel.WIDTH/4; yVel = 0; try { heartset = ImageIO.read(getClass().getResourceAsStream("/Heart/HeartSheet.png")); for (int i = 0; i < numberHeartFrames; i++) { heartFrames[i] = heartset.getSubimage(64*i, 0, 64, 64); } faceset = ImageIO.read(getClass().getResourceAsStream("/Heart/FaceSheet.png")); for (int i = 0; i < numberFaceFrames; i++) { faceFrames[i] = faceset.getSubimage(64*i, 0, 64, 64); } } catch(IOException e) { System.out.println("Erorr loading heart"); e.printStackTrace(); } }
7f145af2-53ce-41a7-9e22-a22d96b1a8d7
4
public void removeServerFromLinkedList(Server server) { logMessage(LOGLEVEL_DEBUG, "Removing server from linked list."); if (servers == null || servers.isEmpty()) return; ListIterator<Server> it = servers.listIterator(); while (it.hasNext()) { // Check if they refer to the exact same object via reference, if so then we want to remove that if (it.next() == server) { it.remove(); return; } } }
13dcc039-4d6f-4c8c-b439-d8b430f35b1d
9
private JToolBar createUpperToolBar() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); final JButton start = new JButton("Inizio"); start.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { started = !started; if (started) { start.setText("Stop"); new Worker().start(); } else start.setText("Inizio"); } }); toolBar.add(start); final JButton step = new JButton("Avanti"); step.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!started) { game.new NextGeneration(numOfThreads); graphicGrid.repaint(); } } }); toolBar.add(step); toolBar.addSeparator(); final JButton reset = new JButton("Azzera"); reset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { game = new Game(graphicGrid.getWidth() / (cellSize + 1), graphicGrid.getHeight() / (cellSize + 1)); if (!started) graphicGrid.repaint(); } }); toolBar.add(reset); toolBar.addSeparator(); final JComboBox zoomSelector = new JComboBox(new String[]{"Piccolo", "Medio", "Grande"}); zoomSelector.setSelectedIndex(1); zoomSelector.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final int selectedIndex = zoomSelector.getSelectedIndex(); switch(selectedIndex) { case 0: cellSize = 8; break; case 1: cellSize = 10; break; case 2: cellSize = 12; break; default: ; } synchronized (game) { game.resize(graphicGrid.getWidth() / (cellSize + 1), graphicGrid.getHeight() / (cellSize + 1)); } if(!started) graphicGrid.repaint(); } }); toolBar.add(zoomSelector); toolBar.addSeparator(); final JComboBox numThreadSelector = new JComboBox(new String[]{"1 thread", "2 thread", "3 thread", "4 thread", "5 thread"}); numThreadSelector.setSelectedIndex(1); numThreadSelector.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { synchronized (game) { numOfThreads = numThreadSelector.getSelectedIndex() + 1; } } }); toolBar.add(numThreadSelector); toolBar.addSeparator(); final String[] shapeNames = new String[shapes.length + 1]; shapeNames[0] = "Scegli una forma e clicca sulla griglia per inserirla"; int i = 1; for(Shape s : shapes) shapeNames[i++] = s.getName(); final JComboBox shapeSelector = new JComboBox(shapeNames); shapeSelector.setSelectedIndex(0); shapeSelector.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final int selectedIndex = shapeSelector.getSelectedIndex(); if(selectedIndex != 0) graphicGrid.selectedShape = shapes[selectedIndex - 1]; } }); toolBar.add(shapeSelector); return toolBar; }
f054150e-5aef-4735-9417-c29c8421d7b3
9
private boolean isIndirectlyPowered(World par1World, int par2, int par3, int par4) { int var5 = par1World.getBlockMetadata(par2, par3, par4); return var5 == 5 && par1World.isBlockIndirectlyProvidingPowerTo(par2, par3 - 1, par4, 0) ? true : (var5 == 3 && par1World.isBlockIndirectlyProvidingPowerTo(par2, par3, par4 - 1, 2) ? true : (var5 == 4 && par1World.isBlockIndirectlyProvidingPowerTo(par2, par3, par4 + 1, 3) ? true : (var5 == 1 && par1World.isBlockIndirectlyProvidingPowerTo(par2 - 1, par3, par4, 4) ? true : var5 == 2 && par1World.isBlockIndirectlyProvidingPowerTo(par2 + 1, par3, par4, 5)))); }
f3fe60a9-eeca-4914-b2f0-f006d6a4cb39
2
private boolean workAll(boolean undo) { boolean result = true; for (String taskId : taskIds) { result = result && workOne(taskId, undo); } return result; }
0d448a90-0004-4246-9428-58cfc1cea38e
5
public Map(){ if (Empous.Gov.getStat("census")<=50000) mapimg = Empous.LoadImage("/main/resources/images/map1.png"); else if (Empous.Gov.getStat("census")<=1000000) mapimg = Empous.LoadImage("/main/resources/images/map2.png"); else if (Empous.Gov.getStat("census")<=300000000) mapimg = Empous.LoadImage("/main/resources/images/map3.png"); else if (Empous.Gov.getStat("census")<=6000000000D) mapimg = Empous.LoadImage("/main/resources/images/map4.png"); else if (Empous.Gov.getStat("census")<=100000000000D) mapimg = Empous.LoadImage("/main/resources/images/map5.png"); else mapimg = Empous.LoadImage("/main/resources/images/map6.png"); }
b5f547b1-c8dc-4488-8532-6103ee8b3477
5
@Override public void move(Excel start, Excel finish) { for(int i=0;i<allex.size();i++) { if (start.getX() == allex.get(i).getX() && start.getY() == allex.get(i).getY()) { allex.remove(i); allex.add(i, finish); setColoredExes(); break; } } for(Excel ex: coloredEx) { if (ex.equals(start)) { System.out.println("yes"); dragg(start,finish); break; } } }
eb882fad-2e64-4893-9904-3c447fa55bb2
4
public synchronized void shutdown(){ if(!shutdown) shutdown = true; //Poll the queue and release all objects left in the queue. while(true){ Reference<?> ref = queue.poll(); if(ref != null){ Resource res = refs.get(ref);//Get the resource by the reference. refs.remove(ref);//Remove the object referred to by "ref" because it is retrieved from the queue. res.release(); ref.clear(); } else//No objects in the queue. break; } }
45330084-7329-4ff9-a2b4-a7a6fe39c106
2
public void testGet_DateTimeFieldType() { LocalTime test = new LocalTime(10, 20, 30, 40); assertEquals(10, test.get(DateTimeFieldType.hourOfDay())); assertEquals(20, test.get(DateTimeFieldType.minuteOfHour())); assertEquals(30, test.get(DateTimeFieldType.secondOfMinute())); assertEquals(40, test.get(DateTimeFieldType.millisOfSecond())); assertEquals(TEST_TIME_NOW / 60000 , test.get(DateTimeFieldType.minuteOfDay())); assertEquals(TEST_TIME_NOW / 1000 , test.get(DateTimeFieldType.secondOfDay())); assertEquals(TEST_TIME_NOW , test.get(DateTimeFieldType.millisOfDay())); assertEquals(10, test.get(DateTimeFieldType.hourOfHalfday())); assertEquals(DateTimeConstants.AM, test.get(DateTimeFieldType.halfdayOfDay())); test = new LocalTime(12, 30); assertEquals(0, test.get(DateTimeFieldType.hourOfHalfday())); assertEquals(12, test.get(DateTimeFieldType.clockhourOfHalfday())); assertEquals(12, test.get(DateTimeFieldType.clockhourOfDay())); assertEquals(DateTimeConstants.PM, test.get(DateTimeFieldType.halfdayOfDay())); test = new LocalTime(14, 30); assertEquals(2, test.get(DateTimeFieldType.hourOfHalfday())); assertEquals(2, test.get(DateTimeFieldType.clockhourOfHalfday())); assertEquals(14, test.get(DateTimeFieldType.clockhourOfDay())); assertEquals(DateTimeConstants.PM, test.get(DateTimeFieldType.halfdayOfDay())); test = new LocalTime(0, 30); assertEquals(0, test.get(DateTimeFieldType.hourOfHalfday())); assertEquals(12, test.get(DateTimeFieldType.clockhourOfHalfday())); assertEquals(24, test.get(DateTimeFieldType.clockhourOfDay())); assertEquals(DateTimeConstants.AM, test.get(DateTimeFieldType.halfdayOfDay())); try { test.get(null); fail(); } catch (IllegalArgumentException ex) {} try { test.get(DateTimeFieldType.dayOfMonth()); fail(); } catch (IllegalArgumentException ex) {} }
84d4b502-4efb-4d83-8b58-a364f9f1a622
9
public ParseNode getParseNode() { if (null == parseNode) { Item lParentItem = getParent(); ParseNode lParentParseNode = null; if (null == lParentItem) { lParentParseNode = Processor.get().getPTree().getDocRoot(); } else if (lParentItem instanceof MNode) { lParentParseNode = ((MNode) lParentItem).getParseNode(); } else { Severity.DEATH.report(this.toString(), "parsing rule structure formation", "unexpected structure", "can't be parented by " + lParentItem); } @SuppressWarnings("rawtypes") Class lParserClass = getParserClass(); try { ParseNode lParseNode = (ParseNode) lParserClass.getConstructors()[0].newInstance(getLID().getName()); lParentParseNode.addChild(lParseNode); TreeMap<String,MNodeProp> lNodeProps = new TreeMap<String,MNodeProp>(); getProps(lNodeProps); for (MNodeProp lNodeProp : lNodeProps.values()) { lParseNode.addProp( new ParseNodeProp(lNodeProp.getLID().getName(),lNodeProp.getType(),false)); } // CHECK IF THERE'S QUALIFIER, THERE HAS TO BE NAME { MNodeProp lQualProp = lNodeProps.get(Strings.QUAL); if (null != lQualProp && !lNodeProps.containsKey(Strings.NAME)) { lParseNode.addProp( new ParseNodeProp(Strings.NAME, ParseNodePropType.QUAL,false)); } } // CHECK IF THERE'S NAME, THERE HAS TO BE QUALIFIER { MNodeProp lNameProp = lNodeProps.get(Strings.NAME); if (null != lNameProp && !lNodeProps.containsKey(Strings.QUAL)) { lParseNode.addProp( new ParseNodeProp(Strings.QUAL, ParseNodePropType.QUAL,false)); } } parseNode = lParseNode; } catch (Throwable lE) { Severity.DEATH.report(this.toString(),"parsing rule structure formation", "can't invoke constructor for: " + parserClassName, lE); } //Severity.INFO.report(toString(),"parser load", "rule loaded", "parser node: " + parseNode); } return parseNode; }
601d7275-3898-4384-9f12-adc0fe6dbf3b
7
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Option other = (Option) obj; if (optionNr != other.optionNr) return false; if (value == null) { if (other.value != null) return false; } else if (!Arrays.equals(this.getRawValue(),other.getRawValue())) return false; return true; }
da7e2a86-7cab-4888-af43-4d1d4903a36c
5
private Point chooseRandomLocation() { Point randomLocation; ArrayList<Point> listOfEmptyLocations = new ArrayList<>(); Player[][] locations = this.board.getBoardLocations(); for (int row = 0; row < locations.length; row++) { Player[] rowLocations = locations[row]; for (int col = 0; col < rowLocations.length; col++) { Player location = rowLocations[col]; if (location == null) { listOfEmptyLocations.add(new Point(row, col)); } } } int noOfEmptyLocations = listOfEmptyLocations.size(); if (noOfEmptyLocations == 0) { return null; } else if (listOfEmptyLocations.size() == 1) { randomLocation = listOfEmptyLocations.get(0); return randomLocation; } else { int randomNumber = new Random().nextInt(noOfEmptyLocations); randomLocation = listOfEmptyLocations.get(randomNumber); return randomLocation; } }
3dac7aee-75fc-488d-b497-d7fca701cb06
9
public int[] searchRange(int[] A, int target) { int l = A == null ? 0 : A.length; int[] bound = new int[2]; //search left half int start = 0, end = l - 1; while (start + 1 < end) { int mid = start + (end - start) / 2; if (A[mid] < target) { start = mid; } else { end = mid; } } if (A[start] == target) { bound[0] = start; } else if (A[end] == target) { bound[0] = end; } else { bound[0] = bound[1] = -1; return bound; } //search right half; start = bound[0]; end = l - 1; while (start + 1 < end) { int mid = start + (end - start) / 2; if (A[mid] > target) { end = mid; } else { start = mid; } } if (A[end] == target) { bound[1] = end; } else if (A[start] == target) { bound[1] = start; } else { bound[0] = bound[1] = -1; } return bound; }
7aba3d77-dbb9-4aa1-aae0-03116be9a41a
1
public void enqueue(Object value, int priority) { QueueElement current = new QueueElement(value, priority); if (count == 0) { head = current; } else { tail.connectNext(current); } tail = current; count++; }
ac7083a6-8a94-40cd-96ba-dff16afbc20b
6
public void die() { Item[] equipItems = player.getEquipment().getItems().getItems(); for (int slot = 0; slot < equipItems.length; slot++) { if (equipItems[slot] != null && degradeCompletly(equipItems[slot])) player.getEquipment().getItems().set(slot, null); } Item[] invItems = player.getInventory().getItems().getItems(); for (int slot = 0; slot < invItems.length; slot++) { if (invItems[slot] != null && degradeCompletly(invItems[slot])) player.getInventory().getItems().set(slot, null); } }
22a865d7-546e-49cb-bfc1-ee8504250d54
5
public void init(final boolean flag) { int i; int a, b, c, d, e, f, g, h; a = b = c = d = e = f = g = h = RATIO; for (i = 0; i < 4; ++i) { a ^= b << 11; d += a; b += c; b ^= c >>> 2; e += b; c += d; c ^= d << 8; f += c; d += e; d ^= e >>> 16; g += d; e += f; e ^= f << 10; h += e; f += g; f ^= g >>> 4; a += f; g += h; g ^= h << 8; b += g; h += a; h ^= a >>> 9; c += h; a += b; } for (i = 0; i < SIZE; i += 8) { if (flag) { a += results[i]; b += results[i + 1]; c += results[i + 2]; d += results[i + 3]; e += results[i + 4]; f += results[i + 5]; g += results[i + 6]; h += results[i + 7]; } a ^= b << 11; d += a; b += c; b ^= c >>> 2; e += b; c += d; c ^= d << 8; f += c; d += e; d ^= e >>> 16; g += d; e += f; e ^= f << 10; h += e; f += g; f ^= g >>> 4; a += f; g += h; g ^= h << 8; b += g; h += a; h ^= a >>> 9; c += h; a += b; memory[i] = a; memory[i + 1] = b; memory[i + 2] = c; memory[i + 3] = d; memory[i + 4] = e; memory[i + 5] = f; memory[i + 6] = g; memory[i + 7] = h; } if (flag) for (i = 0; i < SIZE; i += 8) { a += memory[i]; b += memory[i + 1]; c += memory[i + 2]; d += memory[i + 3]; e += memory[i + 4]; f += memory[i + 5]; g += memory[i + 6]; h += memory[i + 7]; a ^= b << 11; d += a; b += c; b ^= c >>> 2; e += b; c += d; c ^= d << 8; f += c; d += e; d ^= e >>> 16; g += d; e += f; e ^= f << 10; h += e; f += g; f ^= g >>> 4; a += f; g += h; g ^= h << 8; b += g; h += a; h ^= a >>> 9; c += h; a += b; memory[i] = a; memory[i + 1] = b; memory[i + 2] = c; memory[i + 3] = d; memory[i + 4] = e; memory[i + 5] = f; memory[i + 6] = g; memory[i + 7] = h; } isaac(); count = SIZE; }
654612d8-b8f4-4e0b-a526-6760008fd218
0
public Boolean getSex() { return this.sex; }
fc6dfd91-d919-4bc2-994d-91e4bc0f92ab
7
@Override public void receive(Object obj) { Helper.log("GSCONNECTIONTOCLIENT: RECEIVING"); Event event = (Event) obj; Helper.log("RECEIVED EVENT:\n" + event); event.player = player; switch(event.type) { case "key event": Helper.log("GSCONNECTION: RECEIEVED KEY EVENT"); gameServer.engine.eventQ.add(event); break; case "chat": ChatObject chat = (ChatObject)event.data; if (chat.to.equals("all")) { gameServer.broadcast(event); } else if (chat.to.equals("team")) { gameServer.teamBroadcast(chat.from.team, event); } else { gameServer.sendTo(chat.to, event); } break; case "set username": this.player.setUsername((String)event.data); if (gameServer.engine.gameState.inGame) { gameServer.broadcast(new Event("new player", this.player.username)); } else if (gameServer.engine.gameState.ready()) { gameServer.broadcast(new Event("player list", gameServer.engine.gameState.players)); gameServer.engine.start(); } break; default: Helper.log("COULD NOT RECOGNIZE EVENT: " + event); } }
c25a5188-16d3-4cab-ace7-70440737bbe2
1
public void show(T[] a, int[] perm) { // Print the array, on a // single line. for (int i = 0; i < a.length; i++) System.out.print(a[perm[i]] + " "); System.out.println(); }
502a51d8-6667-4d61-a601-c3d6357d0f8b
5
public boolean readVersion(InStream is) { done = false; if (verStrPos >= 12) return false; verStr = new StringBuilder(13); while (is.checkNoWait(1) && verStrPos < 12) { verStr.insert(verStrPos++, (char)is.readU8()); } if (verStrPos < 12) { done = false; return true; } done = true; verStr.insert(12, '0'); verStrPos = 0; if (verStr.toString().matches("RFB \\d{3}\\.\\d{3}\\n0")) { majorVersion = Integer.parseInt(verStr.substring(4, 7)); minorVersion = Integer.parseInt(verStr.substring(8, 11)); return true; } return false; }
57d547da-2602-4c5b-b642-79d08e3e69de
3
String normalizeForResourceLocation(String contextLocation){ boolean hasResource = contextLocation.startsWith("file") || contextLocation.startsWith("classpath") || contextLocation.startsWith("url"); if (!hasResource){ return String.format("%s:%s", DEFAULT_RESOURCE_TYPE, contextLocation); } return contextLocation; }
bc9935a0-d921-495b-abd2-7ceee40cd82a
0
@After public void tearDown() throws Exception { // File datei1 = new File("/var/www/uploads/3.txt"); // File datei2 = new File("/var/www/uploads/4.txt"); // File datei3 = new File("/var/www/uploads/5.txt"); // File datei4 = new File("/var/www/uploads/6.txt"); // File datei5 = new File("/var/www/uploads/7.txt"); // File datei6 = new File("/var/www/uploads/8.txt"); // datei1.delete(); // datei2.delete(); // datei3.delete(); // datei4.delete(); // datei5.delete(); // datei6.delete(); }