rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
else return pc.zeroConstant; | return pc.zeroConstant; | public PNodeI div(PNodeI c) throws ParseException { if(this.isZero()) { if(c.isZero()) return pc.nanConstant; else return pc.zeroConstant; } if(c.isZero()) return pc.infConstant; if(c.isOne()) return this; if(c instanceof Constant) return new Constant(pc,pc.div(value,((Constant) c).value)); return super.div(c); } |
else return false; | return false; | public boolean equals(PNodeI node) { if(node instanceof Constant) return value.equals(((Constant)node).value); else return false; } |
else return pc.zeroConstant; | return pc.zeroConstant; | public PNodeI pow(PNodeI c) throws ParseException { if(this.isZero()){ if(c.isZero()) return pc.nanConstant; else return pc.zeroConstant; } if(this.isOne()) return pc.oneConstant; if(c.isZero()) return pc.oneConstant; if(c instanceof Constant) return new Constant(pc,pc.raise(value,((Constant) c).value)); return super.pow(c); } |
simplifyTest("2*x+x","3*x"); simplifyTest("2*x+3*x","5*x"); simplifyTest("5*x-3*x","2*x"); simplifyTest("3*x-5*x","-2*x"); simplifyTest("3*x-x","2*x"); | public void testSimp() throws ParseException { simplifyTest("2+3","5"); simplifyTest("2*3","6"); simplifyTest("2^3","8"); simplifyTest("3/2","1.5"); simplifyTest("2*3+4","10"); simplifyTest("2*(3+4)","14"); simplifyTest("0+x","x"); simplifyTest("x+0","x"); simplifyTest("0-x","0-x"); simplifyTest("x-0","x"); simplifyTest("0*x","0"); simplifyTest("x*0","0"); simplifyTest("1*x","x"); simplifyTest("x*1","x"); simplifyTest("-1*x","-x"); simplifyTest("x*-1","-x"); simplifyTest("-(-x)","x"); simplifyTest("-(-(-x))","-x"); simplifyTest("(-1)*(-1)*x","x"); simplifyTest("(-1)*(-1)*(-1)*x","-x"); simplifyTest("0/x","0"); simplifyTest("x/0","1/0"); simplifyTest("x^0","1"); simplifyTest("x^1","x"); simplifyTest("0^x","0"); simplifyTest("1^x","1"); // (a+b)+c simplifyTest("(2+3)+x","5+x"); simplifyTest("(2+x)+3","5+x"); simplifyTest("(x+2)+3","5+x"); // a+(b+c) simplifyTest("x+(2+3)","5+x"); simplifyTest("2+(x+3)","5+x"); simplifyTest("2+(3+x)","5+x"); // (a+b)-c simplifyTest("(2+3)-x","5-x"); simplifyTest("(2+x)-3","x-1"); simplifyTest("(x+2)-3","x-1"); // (a-b)+c simplifyTest("(2-3)+x","-1+x"); simplifyTest("(2-x)+3","5-x"); simplifyTest("(x-2)+3","1+x"); // a-(b+c) simplifyTest("x-(2+3)","x-5"); simplifyTest("2-(x+3)","-1-x"); simplifyTest("2-(3+x)","-1-x"); // a+(b-c) simplifyTest("x+(2-3)","x-1"); simplifyTest("2+(x-3)","-1+x"); simplifyTest("2+(3-x)","5-x"); // a-(b-c) simplifyTest("x-(2-3)","1+x"); simplifyTest("2-(x-3)","5-x"); simplifyTest("2-(3-x)","-1+x"); // (a-b)-c simplifyTest("(2-3)-x","-1-x"); simplifyTest("(2-x)-3","-1-x"); simplifyTest("(x-2)-3","x-5"); // (a*b)*c simplifyTest("(2*3)*x","6*x"); simplifyTest("(2*x)*3","6*x"); simplifyTest("(x*2)*3","6*x"); // a+(b+c) simplifyTest("x*(2*3)","6*x"); simplifyTest("2*(x*3)","6*x"); simplifyTest("2*(3*x)","6*x"); // (a+b)-c simplifyTest("(2*3)/x","6/x"); simplifyTest("(3*x)/2","1.5*x"); simplifyTest("(x*3)/2","1.5*x"); // (a-b)+c simplifyTest("(3/2)*x","1.5*x"); simplifyTest("(3/x)*2","6/x"); simplifyTest("(x/2)*3","1.5*x"); // a-(b+c) simplifyTest("x/(2*3)","x/6"); simplifyTest("3/(x*2)","1.5/x"); simplifyTest("3/(2*x)","1.5/x"); // a+(b-c) simplifyTest("x*(3/2)","1.5*x"); simplifyTest("3*(x/2)","1.5*x"); simplifyTest("3*(2/x)","6/x"); // a-(b-c) simplifyTest("x/(3/2)","x/1.5"); simplifyTest("2/(x/3)","6/x"); simplifyTest("3/(2/x)","1.5*x"); // (a-b)-c simplifyTest("(3/2)/x","1.5/x"); simplifyTest("(3/x)/2","1.5/x"); simplifyTest("(x/3)/2","x/6"); simplifyTest("x*(3+2)","5*x");// simplifyTest("3*(x+2)","6+3*x");// simplifyTest("3*(2+x)","6+3*x");// simplifyTest("(3+2)*x","5*x");// simplifyTest("(3+x)*2","6+2*x");// simplifyTest("(x+3)*2","6+x*2"); simplifyTest("x*(3-2)","x");// simplifyTest("3*(x-2)","-6+3*x");// simplifyTest("3*(2-x)","6-3*x"); simplifyTest("(3-2)*x","x");// simplifyTest("(3-x)*2","6-2*x");// simplifyTest("(x-3)*2","-6+2*x");// simplifyTest("3+(x/4)","3+x/4");// simplifyTest("2*(x/4)","0.5*x");// simplifyTest("(2*(3+(x/4)))","6+0.5*x");// simplifyTest("1+(2*(3+(x/4)))","7+0.5*x");// simplifyTest("((3+(x/4))*2)+1","7+0.5*x"); simplifyTest("x*x","x^2"); simplifyTest("x*x*x","x^3"); simplifyTest("(x^3)*(x^4)","x^7"); simplifyTest("(x^4)/(x^3)","x"); simplifyTest("(x^3)/(x^4)","1/x"); simplifyTest("(x^2)/(x^4)","1/x^2"); simplifyTestString("1/x","1/x"); simplifyTestString("-1/x","-1/x"); simplifyTestString("2/x","2/x"); simplifyTestString("-2/x","-2/x"); simplifyTestString("(1+x)*(1+x)","(1+x)^2"); simplifyTestString("(1+x)/(1+x)","1"); } |
|
if (method == "Volume") | if (method.equalsIgnoreCase("Volume")) | private void calcAlcohol(String method) { double oPlato = sGToPlato(estOg); double fPlato = sGToPlato(estFg); double q = 0.22 + 0.001 * oPlato; double re = (q * oPlato + fPlato) / (1.0 + q); // calculate by weight: alcohol = (oPlato - re) / (2.0665 - 0.010665 * oPlato); if (method == "Volume") // convert to by volume alcohol = alcohol * estFg / 0.794; } |
mf = new MessageFormat("OG: {0,number,0.000},\tFG:{1,number,0.000}, \tALC:{2,number,0.0}\n"); Object[] objs = {new Double(estOg), new Double(estFg), new Double(alcohol) }; | mf = new MessageFormat("OG: {0,number,0.000},\tFG:{1,number,0.000}, \tAlc:{2,number,0.0}, \tIBU:{3,number,0.0}\n"); Object[] objs = {new Double(estOg), new Double(estFg), new Double(alcohol), new Double(ibu) }; | public String toText(){ MessageFormat mf; StringBuffer sb = new StringBuffer(); sb.append("StrangeBrew J1.0 recipe text output\n\n"); sb.append("Details:\n"); sb.append("Name: " + name + "\n"); sb.append("Brewer: " + brewer + "\n"); sb.append("Size: " + SBStringUtils.df1.format(postBoilVol.getValue()) + " " + postBoilVol.getUnits()+"\n"); sb.append("Style: " + style.getName() + "\n"); mf = new MessageFormat("OG: {0,number,0.000},\tFG:{1,number,0.000}, \tALC:{2,number,0.0}\n"); Object[] objs = {new Double(estOg), new Double(estFg), new Double(alcohol) }; sb.append(mf.format( objs )); sb.append("Fermentables:\n"); sb.append(padLeft("Name ", 30, ' ') + " amount units pppg lov %\n"); mf = new MessageFormat("{0} {1} {2} {3,number,0.000} {4} {5,number, 0.0}%\n"); for (int i=0; i<fermentables.size(); i++){ Fermentable f = (Fermentable)fermentables.get(i); Object[] objf = {padLeft(f.getName(), 30, ' '), padRight(" "+SBStringUtils.df2.format(f.getAmountAs(f.getUnits())), 6, ' '), f.getUnits(), new Double(f.getPppg()), padRight(" "+SBStringUtils.df1.format(f.getLov()), 6, ' '), new Double(f.getPercent())}; sb.append(mf.format(objf)); } sb.append("Hops:\n"); sb.append(padLeft("Name ", 20, ' ') + " amount units Alpha Min IBU\n"); mf = new MessageFormat("{0} {1} {2} {3} {4} {5}\n"); for (int i=0; i<hops.size(); i++){ Hop h = (Hop)hops.get(i); Object[] objh = {padLeft(h.getName(), 20, ' '), padRight(" "+SBStringUtils.df2.format(h.getAmountAs(h.getUnits())), 6, ' '), h.getUnits(), padRight(" "+h.getAlpha(), 5, ' '), padRight(" "+SBStringUtils.df1.format(h.getMinutes()), 6, ' '), padRight(" "+SBStringUtils.df1.format(h.getIBU()), 5, ' ')}; sb.append(mf.format(objh)); } sb.append("Mash:\n"); sb.append(padLeft("Step ", 10, ' ') + " Temp End Ramp Min\n"); mf = new MessageFormat("{0} {1} {2} {3} {4}\n"); for (int i=0; i<mash.getStepSize(); i++){ Object[] objm = {padLeft(mash.getStepType(i), 10, ' '), padRight(" " + mash.getStepStartTemp(i), 6, ' '), padRight(" " + mash.getStepEndTemp(i), 6, ' '), padRight(" "+mash.getStepRampMin(i), 4, ' '), padRight(" "+mash.getStepMin(i), 6, ' ')}; sb.append(mf.format(objm)); } return sb.toString(); } |
sb.append("<!-- This is a SBJava export. StrangeBrew 1.8 will not import it. -->\n"); | public String toXML() { StringBuffer sb = new StringBuffer(); sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"); sb.append("<STRANGEBREWRECIPE version = \"J1.0\">\n"); sb.append(" <DETAILS>\n"); sb.append(" <NAME>" + SBStringUtils.subEntities(name) + "</NAME>\n"); sb.append(" <BREWER>" + SBStringUtils.subEntities(brewer) + "</BREWER>\n"); sb.append(" <NOTES>" + SBStringUtils.subEntities(comments) + "</NOTES>\n"); sb.append(" <EFFICIENCY>" + efficiency + "</EFFICIENCY>\n"); sb.append(" <OG>" + SBStringUtils.df3.format(estOg) + "</OG>\n"); sb.append(" <FG>" + SBStringUtils.df3.format(estFg) + "</FG>\n"); sb.append(" <STYLE>" + style.getName() + "</STYLE>\n"); sb.append(" <MASH>" + mashed + "</MASH>\n"); sb.append(" <LOV>" + SBStringUtils.df1.format(srm) + "</LOV>\n"); sb.append(" <IBU>" + SBStringUtils.df1.format(ibu) + "</IBU>\n"); sb.append(" <ALC>" + SBStringUtils.df1.format(alcohol) + "</ALC>\n"); sb.append(" <BOIL_TIME>" + boilMinutes + "</BOIL_TIME>\n"); sb.append(" <PRESIZE>" + preBoilVol.getValue() + "</PRESIZE>\n"); sb.append(" <SIZE>" + postBoilVol.getValue() + "</SIZE>\n"); sb.append(" <SIZE_UNITS>" + postBoilVol.getUnits() + "</SIZE_UNITS>\n"); sb.append(" <MALT_UNITS>" + maltUnits + "</MALT_UNITS>\n"); sb.append(" <HOPS_UNITS>" + hopUnits + "</HOPS_UNITS>\n"); sb.append(" <YEAST>" + yeast.getName() + "</YEAST>\n"); SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy"); sb.append(" <RECIPE_DATE>" + df.format(created.getTime()) + "</RECIPE_DATE>\n"); sb.append(" <ATTENUATION>" + attenuation + "</ATTENUATION>\n"); sb.append(" <!-- SBJ1.0 Extensions: -->\n"); sb.append(" <ALC_METHOD>" + alcMethod + "</ALC_METHOD>\n"); sb.append(" <IBU_METHOD>" + ibuCalcMethod + "</IBU_METHOD>\n"); sb.append(" <COLOUR_METHOD>" + colourMethod + "</COLOUR_METHOD>\n"); sb.append(" <EVAP>" + evap + "</EVAP>\n"); sb.append(" <EVAP_METHOD>" + evapMethod + "</EVAP_METHOD>\n"); sb.append(" <KETTLE_LOSS>" + kettleLoss + "</KETTLE_LOSS>\n"); sb.append(" <TRUB_LOSS>" + trubLoss + "</TRUB_LOSS>\n"); sb.append(" <MISC_LOSS>" + miscLoss + "</MISC_LOSS>\n"); sb.append(" <PELLET_HOP_PCT>" + pelletHopPct + "</PELLET_HOP_PCT>\n"); sb.append(" <!-- END SBJ1.0 Extensions -->\n"); sb.append(" </DETAILS>\n"); // fermentables list: sb.append(" <FERMENTABLES>\n"); for (int i = 0; i < fermentables.size(); i++) { Fermentable m = (Fermentable) fermentables.get(i); sb.append(m.toXML()); } sb.append(" </FERMENTABLES>\n"); // hops list: sb.append(" <HOPS>\n"); for (int i = 0; i < hops.size(); i++) { Hop h = (Hop) hops.get(i); sb.append(h.toXML()); } sb.append(" </HOPS>\n"); // misc ingredients list: sb.append(" <MISC>\n"); for (int i = 0; i < misc.size(); i++) { Misc mi = (Misc) misc.get(i); sb.append(mi.toXML()); } sb.append(" </MISC>\n"); sb.append(mash.toXml()); // notes list: sb.append(" <NOTES>\n"); for (int i = 0; i < notes.size(); i++) { sb.append(((Note) notes.get(i)).toXML()); } sb.append(" </NOTES>\n"); sb.append("</STRANGEBREWRECIPE>"); return sb.toString(); } |
|
UnitRangeImpl range, double value) { return (int)Math.round(linearInterp(range.getMinValue(), 0, range.getMaxValue(), totalPixels, value)); | MicroSecondDate begin, MicroSecondDate end, MicroSecondDate value) { return (int)Math.round(linearInterp(begin.getMicroSecondTime(), 0, end.getMicroSecondTime(), totalPixels, value.getMicroSecondTime())); | public static final int getPixel(int totalPixels, UnitRangeImpl range, double value) { return (int)Math.round(linearInterp(range.getMinValue(), 0, range.getMaxValue(), totalPixels, value)); } |
public int compare(Object obj1, Object obj2) | public int compare( SearchResultElement sr1, SearchResultElement sr2 ) | public int compare(Object obj1, Object obj2) { if( obj1 == obj2 || obj1.equals( obj2 ) ) { return 0; } SearchResultElement sr1 = (SearchResultElement)obj1; SearchResultElement sr2 = (SearchResultElement)obj2; long diff; switch ( sortField ) { case SORT_BY_SIZE: diff = sr1.getSingleRemoteFile().getFileSize() - sr2.getSingleRemoteFile().getFileSize(); break; case SORT_BY_FILE: diff = sr1.getSingleRemoteFile().getFilename().compareTo( sr2.getSingleRemoteFile().getFilename() ); break; case SORT_BY_EXTENSION: diff = sr1.getSingleRemoteFile().getFileExt().compareTo( sr2.getSingleRemoteFile().getFileExt() ); break; case SORT_BY_SHA1: diff = sr1.getSingleRemoteFile().getSHA1().compareTo( sr2.getSingleRemoteFile().getSHA1() ); break; case SORT_BY_HOST: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = destAddressComparator.compare( sr1.getSingleRemoteFile().getHostAddress(), sr2.getSingleRemoteFile().getHostAddress() ); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_META_DATA: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { String meta1 = sr1.getSingleRemoteFile().getMetaData(); String meta2 = sr2.getSingleRemoteFile().getMetaData(); diff = (meta1 == null || meta2 == null) ? -1 : meta1.compareTo( meta2 ); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_VENDOR: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { String v1 = sr1.getSingleRemoteFile().getQueryHitHost().getVendor(); String v2 = sr2.getSingleRemoteFile().getQueryHitHost().getVendor(); diff = (v1 == null || v2 == null) ? -1 : v1.compareTo( v2 ); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_SPEED: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = sr1.getSingleRemoteFile().getQueryHitHost().getHostSpeed() - sr2.getSingleRemoteFile().getQueryHitHost().getHostSpeed(); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_RATING: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = sr1.getSingleRemoteFile().getQueryHitHost().getHostRating() - sr2.getSingleRemoteFile().getQueryHitHost().getHostRating(); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_SCORE: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = sr1.getSingleRemoteFile().getScore().shortValue() - sr2.getSingleRemoteFile().getScore().shortValue(); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; default: diff = 1; } if ( diff == 0 ) { // diff is 0 we need to determine a difference value that stays unique on // consequitive calls. Using a hashCode sounds reasonable though it might // still result to 0... diff = sr1.hashCode() - sr2.hashCode(); } diff = isSortedAscending ? diff : -diff; if ( diff < 0 ) { return -1; } else if ( diff > 0 ) { return 1; } else { return 1; } } |
if( obj1 == obj2 || obj1.equals( obj2 ) ) | if( sr1 == sr2 || sr1.equals( sr2 ) ) | public int compare(Object obj1, Object obj2) { if( obj1 == obj2 || obj1.equals( obj2 ) ) { return 0; } SearchResultElement sr1 = (SearchResultElement)obj1; SearchResultElement sr2 = (SearchResultElement)obj2; long diff; switch ( sortField ) { case SORT_BY_SIZE: diff = sr1.getSingleRemoteFile().getFileSize() - sr2.getSingleRemoteFile().getFileSize(); break; case SORT_BY_FILE: diff = sr1.getSingleRemoteFile().getFilename().compareTo( sr2.getSingleRemoteFile().getFilename() ); break; case SORT_BY_EXTENSION: diff = sr1.getSingleRemoteFile().getFileExt().compareTo( sr2.getSingleRemoteFile().getFileExt() ); break; case SORT_BY_SHA1: diff = sr1.getSingleRemoteFile().getSHA1().compareTo( sr2.getSingleRemoteFile().getSHA1() ); break; case SORT_BY_HOST: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = destAddressComparator.compare( sr1.getSingleRemoteFile().getHostAddress(), sr2.getSingleRemoteFile().getHostAddress() ); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_META_DATA: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { String meta1 = sr1.getSingleRemoteFile().getMetaData(); String meta2 = sr2.getSingleRemoteFile().getMetaData(); diff = (meta1 == null || meta2 == null) ? -1 : meta1.compareTo( meta2 ); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_VENDOR: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { String v1 = sr1.getSingleRemoteFile().getQueryHitHost().getVendor(); String v2 = sr2.getSingleRemoteFile().getQueryHitHost().getVendor(); diff = (v1 == null || v2 == null) ? -1 : v1.compareTo( v2 ); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_SPEED: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = sr1.getSingleRemoteFile().getQueryHitHost().getHostSpeed() - sr2.getSingleRemoteFile().getQueryHitHost().getHostSpeed(); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_RATING: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = sr1.getSingleRemoteFile().getQueryHitHost().getHostRating() - sr2.getSingleRemoteFile().getQueryHitHost().getHostRating(); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_SCORE: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = sr1.getSingleRemoteFile().getScore().shortValue() - sr2.getSingleRemoteFile().getScore().shortValue(); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; default: diff = 1; } if ( diff == 0 ) { // diff is 0 we need to determine a difference value that stays unique on // consequitive calls. Using a hashCode sounds reasonable though it might // still result to 0... diff = sr1.hashCode() - sr2.hashCode(); } diff = isSortedAscending ? diff : -diff; if ( diff < 0 ) { return -1; } else if ( diff > 0 ) { return 1; } else { return 1; } } |
SearchResultElement sr1 = (SearchResultElement)obj1; SearchResultElement sr2 = (SearchResultElement)obj2; | public int compare(Object obj1, Object obj2) { if( obj1 == obj2 || obj1.equals( obj2 ) ) { return 0; } SearchResultElement sr1 = (SearchResultElement)obj1; SearchResultElement sr2 = (SearchResultElement)obj2; long diff; switch ( sortField ) { case SORT_BY_SIZE: diff = sr1.getSingleRemoteFile().getFileSize() - sr2.getSingleRemoteFile().getFileSize(); break; case SORT_BY_FILE: diff = sr1.getSingleRemoteFile().getFilename().compareTo( sr2.getSingleRemoteFile().getFilename() ); break; case SORT_BY_EXTENSION: diff = sr1.getSingleRemoteFile().getFileExt().compareTo( sr2.getSingleRemoteFile().getFileExt() ); break; case SORT_BY_SHA1: diff = sr1.getSingleRemoteFile().getSHA1().compareTo( sr2.getSingleRemoteFile().getSHA1() ); break; case SORT_BY_HOST: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = destAddressComparator.compare( sr1.getSingleRemoteFile().getHostAddress(), sr2.getSingleRemoteFile().getHostAddress() ); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_META_DATA: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { String meta1 = sr1.getSingleRemoteFile().getMetaData(); String meta2 = sr2.getSingleRemoteFile().getMetaData(); diff = (meta1 == null || meta2 == null) ? -1 : meta1.compareTo( meta2 ); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_VENDOR: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { String v1 = sr1.getSingleRemoteFile().getQueryHitHost().getVendor(); String v2 = sr2.getSingleRemoteFile().getQueryHitHost().getVendor(); diff = (v1 == null || v2 == null) ? -1 : v1.compareTo( v2 ); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_SPEED: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = sr1.getSingleRemoteFile().getQueryHitHost().getHostSpeed() - sr2.getSingleRemoteFile().getQueryHitHost().getHostSpeed(); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_RATING: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = sr1.getSingleRemoteFile().getQueryHitHost().getHostRating() - sr2.getSingleRemoteFile().getQueryHitHost().getHostRating(); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; case SORT_BY_SCORE: if ( sr1.getRemoteFileListCount() == 0 && sr2.getRemoteFileListCount() == 0 ) { diff = sr1.getSingleRemoteFile().getScore().shortValue() - sr2.getSingleRemoteFile().getScore().shortValue(); } else { diff = sr1.getRemoteFileListCount() - sr2.getRemoteFileListCount(); } break; default: diff = 1; } if ( diff == 0 ) { // diff is 0 we need to determine a difference value that stays unique on // consequitive calls. Using a hashCode sounds reasonable though it might // still result to 0... diff = sr1.hashCode() - sr2.hashCode(); } diff = isSortedAscending ? diff : -diff; if ( diff < 0 ) { return -1; } else if ( diff > 0 ) { return 1; } else { return 1; } } |
|
assertSame(childUserRole, roles.toArray()[0]); assertSame(parentUserRole, roles.toArray()[1]); | assertTrue(roles.contains(childUserRole)); assertTrue(roles.contains(parentUserRole)); | public void testDefaultAuthorityResolution() { UserRole childUserRole = new UserRole(), parentUserRole = new UserRole(); childUserRole.setServiceExtension("1"); parentUserRole.setServiceExtension("2"); User user = userDetailsAdapter.getUser(); user.setParent(new UserGroup()); user.getRoles().add(childUserRole); user.getParent().getRoles().add(parentUserRole); Set<UserRole> roles = authorityResolutionStrategy.resolveUserRoles(); assertEquals(2, roles.size()); assertSame(childUserRole, roles.toArray()[0]); assertSame(parentUserRole, roles.toArray()[1]); } |
assertSame(childUserRole, roles.toArray()[0]); assertSame(parentUserRole, roles.toArray()[1]); | assertTrue(roles.contains(childUserRole)); assertTrue(roles.contains(parentUserRole)); | public void testDuplicateDefaultAuthorityResolution() { UserRole childUserRole = new UserRole(), parentUserRole = new UserRole(); childUserRole.setServiceExtension("1"); parentUserRole.setServiceExtension("2"); User user = userDetailsAdapter.getUser(); user.setParent(new UserGroup()); user.getRoles().add(childUserRole); user.getParent().getRoles().add(parentUserRole); user.getParent().getRoles().add(childUserRole); //too Set<UserRole> roles = authorityResolutionStrategy.resolveUserRoles(); assertEquals(2, roles.size()); assertSame(childUserRole, roles.toArray()[0]); assertSame(parentUserRole, roles.toArray()[1]); } |
shareMgr = ShareManager.getInstance(); queryHistory = QueryManager.getInstance().getQueryHistoryMonitor(); | public ConnectionEngine( Host connectedHost ) { this.connectedHost = connectedHost; connection = connectedHost.getConnection(); shareMgr = ShareManager.getInstance(); queryHistory = QueryManager.getInstance().getQueryHistoryMonitor(); messageMgr = MsgManager.getInstance(); hostMgr = HostManager.getInstance(); networkMgr = NetworkManager.getInstance(); securityManager = PhexSecurityManager.getInstance(); } |
|
msgDispatcher = messageMgr.getMessageDispatcher(); | public ConnectionEngine( Host connectedHost ) { this.connectedHost = connectedHost; connection = connectedHost.getConnection(); shareMgr = ShareManager.getInstance(); queryHistory = QueryManager.getInstance().getQueryHistoryMonitor(); messageMgr = MsgManager.getInstance(); hostMgr = HostManager.getInstance(); networkMgr = NetworkManager.getInstance(); securityManager = PhexSecurityManager.getInstance(); } |
|
handlePing( (PingMsg)message ); | msgDispatcher.handlePing((PingMsg)message, connectedHost ); | public void processIncomingData() throws IOException { headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; try { while ( true ) { MsgHeader header = readHeader(); byte[] body = MessageProcessor.readMessageBody( connection, header.getDataLength() ); connectedHost.incReceivedCount(); int ttl = header.getTTL(); int hops = header.getHopsTaken(); // verify valid ttl and hops data if ( ttl < 0 || hops < 0 ) { dropMessage( header, body, "TTL or hops below 0" ); continue; } // if message traveled too far already... drop it. if ( hops > ServiceManager.sCfg.maxNetworkTTL ) { dropMessage( header, body, "Hops larger then maxNetworkTTL" ); continue; } // limit TTL if too high! if ( ttl >= ServiceManager.sCfg.maxNetworkTTL ) { header.setTTL( (byte)(ServiceManager.sCfg.maxNetworkTTL - hops) ); } Message message; try { message = MessageProcessor.createMessageFromBody( header, body ); if ( message == null ) { // unknown message type... dropMessage( header, body, "Unknown message type" ); continue; } } catch ( InvalidMessageException exp ) { dropMessage( header, body, "Invalid message: " + exp.getMessage() ); NLogger.warn(NLoggerNames.IncomingMessages, exp, exp ); continue; } // count the hop and decrement ttl... header.countHop(); //Logger.logMessage( Logger.FINEST, Logger.NETWORK, // "Received Header function: " + header.getPayload() ); switch ( header.getPayload() ) { case MsgHeader.PING_PAYLOAD: handlePing( (PingMsg)message ); break; case MsgHeader.PONG_PAYLOAD: handlePong( (PongMsg)message ); break; case MsgHeader.PUSH_PAYLOAD: handlePushRequest( (PushRequestMsg) message ); break; case MsgHeader.QUERY_PAYLOAD: handleQuery( (QueryMsg) message ); break; case MsgHeader.QUERY_HIT_PAYLOAD: handleQueryResponse( (QueryResponseMsg) message ); break; case MsgHeader.ROUTE_TABLE_UPDATE_PAYLOAD: handleRouteTableUpdate( (RouteTableUpdateMsg) message ); break; case MsgHeader.VENDOR_MESSAGE_PAYLOAD: case MsgHeader.STANDARD_VENDOR_MESSAGE_PAYLOAD: handleVendorMessage( (VendorMsg) message ); break; } } } catch ( IOException exp ) { NLogger.debug( ConnectionEngine.class, exp, exp ); if ( connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw exp; } catch ( Exception exp ) { NLogger.warn( ConnectionEngine.class, exp, exp ); if (connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw new IOException( "Exception occured: " + exp.getMessage() ); } } |
handlePong( (PongMsg)message ); | msgDispatcher.handlePong( (PongMsg)message, connectedHost ); | public void processIncomingData() throws IOException { headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; try { while ( true ) { MsgHeader header = readHeader(); byte[] body = MessageProcessor.readMessageBody( connection, header.getDataLength() ); connectedHost.incReceivedCount(); int ttl = header.getTTL(); int hops = header.getHopsTaken(); // verify valid ttl and hops data if ( ttl < 0 || hops < 0 ) { dropMessage( header, body, "TTL or hops below 0" ); continue; } // if message traveled too far already... drop it. if ( hops > ServiceManager.sCfg.maxNetworkTTL ) { dropMessage( header, body, "Hops larger then maxNetworkTTL" ); continue; } // limit TTL if too high! if ( ttl >= ServiceManager.sCfg.maxNetworkTTL ) { header.setTTL( (byte)(ServiceManager.sCfg.maxNetworkTTL - hops) ); } Message message; try { message = MessageProcessor.createMessageFromBody( header, body ); if ( message == null ) { // unknown message type... dropMessage( header, body, "Unknown message type" ); continue; } } catch ( InvalidMessageException exp ) { dropMessage( header, body, "Invalid message: " + exp.getMessage() ); NLogger.warn(NLoggerNames.IncomingMessages, exp, exp ); continue; } // count the hop and decrement ttl... header.countHop(); //Logger.logMessage( Logger.FINEST, Logger.NETWORK, // "Received Header function: " + header.getPayload() ); switch ( header.getPayload() ) { case MsgHeader.PING_PAYLOAD: handlePing( (PingMsg)message ); break; case MsgHeader.PONG_PAYLOAD: handlePong( (PongMsg)message ); break; case MsgHeader.PUSH_PAYLOAD: handlePushRequest( (PushRequestMsg) message ); break; case MsgHeader.QUERY_PAYLOAD: handleQuery( (QueryMsg) message ); break; case MsgHeader.QUERY_HIT_PAYLOAD: handleQueryResponse( (QueryResponseMsg) message ); break; case MsgHeader.ROUTE_TABLE_UPDATE_PAYLOAD: handleRouteTableUpdate( (RouteTableUpdateMsg) message ); break; case MsgHeader.VENDOR_MESSAGE_PAYLOAD: case MsgHeader.STANDARD_VENDOR_MESSAGE_PAYLOAD: handleVendorMessage( (VendorMsg) message ); break; } } } catch ( IOException exp ) { NLogger.debug( ConnectionEngine.class, exp, exp ); if ( connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw exp; } catch ( Exception exp ) { NLogger.warn( ConnectionEngine.class, exp, exp ); if (connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw new IOException( "Exception occured: " + exp.getMessage() ); } } |
handlePushRequest( (PushRequestMsg) message ); | msgDispatcher.handlePushRequest( (PushRequestMsg) message, connectedHost ); | public void processIncomingData() throws IOException { headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; try { while ( true ) { MsgHeader header = readHeader(); byte[] body = MessageProcessor.readMessageBody( connection, header.getDataLength() ); connectedHost.incReceivedCount(); int ttl = header.getTTL(); int hops = header.getHopsTaken(); // verify valid ttl and hops data if ( ttl < 0 || hops < 0 ) { dropMessage( header, body, "TTL or hops below 0" ); continue; } // if message traveled too far already... drop it. if ( hops > ServiceManager.sCfg.maxNetworkTTL ) { dropMessage( header, body, "Hops larger then maxNetworkTTL" ); continue; } // limit TTL if too high! if ( ttl >= ServiceManager.sCfg.maxNetworkTTL ) { header.setTTL( (byte)(ServiceManager.sCfg.maxNetworkTTL - hops) ); } Message message; try { message = MessageProcessor.createMessageFromBody( header, body ); if ( message == null ) { // unknown message type... dropMessage( header, body, "Unknown message type" ); continue; } } catch ( InvalidMessageException exp ) { dropMessage( header, body, "Invalid message: " + exp.getMessage() ); NLogger.warn(NLoggerNames.IncomingMessages, exp, exp ); continue; } // count the hop and decrement ttl... header.countHop(); //Logger.logMessage( Logger.FINEST, Logger.NETWORK, // "Received Header function: " + header.getPayload() ); switch ( header.getPayload() ) { case MsgHeader.PING_PAYLOAD: handlePing( (PingMsg)message ); break; case MsgHeader.PONG_PAYLOAD: handlePong( (PongMsg)message ); break; case MsgHeader.PUSH_PAYLOAD: handlePushRequest( (PushRequestMsg) message ); break; case MsgHeader.QUERY_PAYLOAD: handleQuery( (QueryMsg) message ); break; case MsgHeader.QUERY_HIT_PAYLOAD: handleQueryResponse( (QueryResponseMsg) message ); break; case MsgHeader.ROUTE_TABLE_UPDATE_PAYLOAD: handleRouteTableUpdate( (RouteTableUpdateMsg) message ); break; case MsgHeader.VENDOR_MESSAGE_PAYLOAD: case MsgHeader.STANDARD_VENDOR_MESSAGE_PAYLOAD: handleVendorMessage( (VendorMsg) message ); break; } } } catch ( IOException exp ) { NLogger.debug( ConnectionEngine.class, exp, exp ); if ( connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw exp; } catch ( Exception exp ) { NLogger.warn( ConnectionEngine.class, exp, exp ); if (connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw new IOException( "Exception occured: " + exp.getMessage() ); } } |
handleQuery( (QueryMsg) message ); | msgDispatcher.handleQuery( (QueryMsg) message, connectedHost ); | public void processIncomingData() throws IOException { headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; try { while ( true ) { MsgHeader header = readHeader(); byte[] body = MessageProcessor.readMessageBody( connection, header.getDataLength() ); connectedHost.incReceivedCount(); int ttl = header.getTTL(); int hops = header.getHopsTaken(); // verify valid ttl and hops data if ( ttl < 0 || hops < 0 ) { dropMessage( header, body, "TTL or hops below 0" ); continue; } // if message traveled too far already... drop it. if ( hops > ServiceManager.sCfg.maxNetworkTTL ) { dropMessage( header, body, "Hops larger then maxNetworkTTL" ); continue; } // limit TTL if too high! if ( ttl >= ServiceManager.sCfg.maxNetworkTTL ) { header.setTTL( (byte)(ServiceManager.sCfg.maxNetworkTTL - hops) ); } Message message; try { message = MessageProcessor.createMessageFromBody( header, body ); if ( message == null ) { // unknown message type... dropMessage( header, body, "Unknown message type" ); continue; } } catch ( InvalidMessageException exp ) { dropMessage( header, body, "Invalid message: " + exp.getMessage() ); NLogger.warn(NLoggerNames.IncomingMessages, exp, exp ); continue; } // count the hop and decrement ttl... header.countHop(); //Logger.logMessage( Logger.FINEST, Logger.NETWORK, // "Received Header function: " + header.getPayload() ); switch ( header.getPayload() ) { case MsgHeader.PING_PAYLOAD: handlePing( (PingMsg)message ); break; case MsgHeader.PONG_PAYLOAD: handlePong( (PongMsg)message ); break; case MsgHeader.PUSH_PAYLOAD: handlePushRequest( (PushRequestMsg) message ); break; case MsgHeader.QUERY_PAYLOAD: handleQuery( (QueryMsg) message ); break; case MsgHeader.QUERY_HIT_PAYLOAD: handleQueryResponse( (QueryResponseMsg) message ); break; case MsgHeader.ROUTE_TABLE_UPDATE_PAYLOAD: handleRouteTableUpdate( (RouteTableUpdateMsg) message ); break; case MsgHeader.VENDOR_MESSAGE_PAYLOAD: case MsgHeader.STANDARD_VENDOR_MESSAGE_PAYLOAD: handleVendorMessage( (VendorMsg) message ); break; } } } catch ( IOException exp ) { NLogger.debug( ConnectionEngine.class, exp, exp ); if ( connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw exp; } catch ( Exception exp ) { NLogger.warn( ConnectionEngine.class, exp, exp ); if (connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw new IOException( "Exception occured: " + exp.getMessage() ); } } |
handleQueryResponse( (QueryResponseMsg) message ); | msgDispatcher.handleQueryResponse( (QueryResponseMsg) message, connectedHost ); | public void processIncomingData() throws IOException { headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; try { while ( true ) { MsgHeader header = readHeader(); byte[] body = MessageProcessor.readMessageBody( connection, header.getDataLength() ); connectedHost.incReceivedCount(); int ttl = header.getTTL(); int hops = header.getHopsTaken(); // verify valid ttl and hops data if ( ttl < 0 || hops < 0 ) { dropMessage( header, body, "TTL or hops below 0" ); continue; } // if message traveled too far already... drop it. if ( hops > ServiceManager.sCfg.maxNetworkTTL ) { dropMessage( header, body, "Hops larger then maxNetworkTTL" ); continue; } // limit TTL if too high! if ( ttl >= ServiceManager.sCfg.maxNetworkTTL ) { header.setTTL( (byte)(ServiceManager.sCfg.maxNetworkTTL - hops) ); } Message message; try { message = MessageProcessor.createMessageFromBody( header, body ); if ( message == null ) { // unknown message type... dropMessage( header, body, "Unknown message type" ); continue; } } catch ( InvalidMessageException exp ) { dropMessage( header, body, "Invalid message: " + exp.getMessage() ); NLogger.warn(NLoggerNames.IncomingMessages, exp, exp ); continue; } // count the hop and decrement ttl... header.countHop(); //Logger.logMessage( Logger.FINEST, Logger.NETWORK, // "Received Header function: " + header.getPayload() ); switch ( header.getPayload() ) { case MsgHeader.PING_PAYLOAD: handlePing( (PingMsg)message ); break; case MsgHeader.PONG_PAYLOAD: handlePong( (PongMsg)message ); break; case MsgHeader.PUSH_PAYLOAD: handlePushRequest( (PushRequestMsg) message ); break; case MsgHeader.QUERY_PAYLOAD: handleQuery( (QueryMsg) message ); break; case MsgHeader.QUERY_HIT_PAYLOAD: handleQueryResponse( (QueryResponseMsg) message ); break; case MsgHeader.ROUTE_TABLE_UPDATE_PAYLOAD: handleRouteTableUpdate( (RouteTableUpdateMsg) message ); break; case MsgHeader.VENDOR_MESSAGE_PAYLOAD: case MsgHeader.STANDARD_VENDOR_MESSAGE_PAYLOAD: handleVendorMessage( (VendorMsg) message ); break; } } } catch ( IOException exp ) { NLogger.debug( ConnectionEngine.class, exp, exp ); if ( connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw exp; } catch ( Exception exp ) { NLogger.warn( ConnectionEngine.class, exp, exp ); if (connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw new IOException( "Exception occured: " + exp.getMessage() ); } } |
handleRouteTableUpdate( (RouteTableUpdateMsg) message ); | msgDispatcher.handleRouteTableUpdate( (RouteTableUpdateMsg) message, connectedHost ); | public void processIncomingData() throws IOException { headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; try { while ( true ) { MsgHeader header = readHeader(); byte[] body = MessageProcessor.readMessageBody( connection, header.getDataLength() ); connectedHost.incReceivedCount(); int ttl = header.getTTL(); int hops = header.getHopsTaken(); // verify valid ttl and hops data if ( ttl < 0 || hops < 0 ) { dropMessage( header, body, "TTL or hops below 0" ); continue; } // if message traveled too far already... drop it. if ( hops > ServiceManager.sCfg.maxNetworkTTL ) { dropMessage( header, body, "Hops larger then maxNetworkTTL" ); continue; } // limit TTL if too high! if ( ttl >= ServiceManager.sCfg.maxNetworkTTL ) { header.setTTL( (byte)(ServiceManager.sCfg.maxNetworkTTL - hops) ); } Message message; try { message = MessageProcessor.createMessageFromBody( header, body ); if ( message == null ) { // unknown message type... dropMessage( header, body, "Unknown message type" ); continue; } } catch ( InvalidMessageException exp ) { dropMessage( header, body, "Invalid message: " + exp.getMessage() ); NLogger.warn(NLoggerNames.IncomingMessages, exp, exp ); continue; } // count the hop and decrement ttl... header.countHop(); //Logger.logMessage( Logger.FINEST, Logger.NETWORK, // "Received Header function: " + header.getPayload() ); switch ( header.getPayload() ) { case MsgHeader.PING_PAYLOAD: handlePing( (PingMsg)message ); break; case MsgHeader.PONG_PAYLOAD: handlePong( (PongMsg)message ); break; case MsgHeader.PUSH_PAYLOAD: handlePushRequest( (PushRequestMsg) message ); break; case MsgHeader.QUERY_PAYLOAD: handleQuery( (QueryMsg) message ); break; case MsgHeader.QUERY_HIT_PAYLOAD: handleQueryResponse( (QueryResponseMsg) message ); break; case MsgHeader.ROUTE_TABLE_UPDATE_PAYLOAD: handleRouteTableUpdate( (RouteTableUpdateMsg) message ); break; case MsgHeader.VENDOR_MESSAGE_PAYLOAD: case MsgHeader.STANDARD_VENDOR_MESSAGE_PAYLOAD: handleVendorMessage( (VendorMsg) message ); break; } } } catch ( IOException exp ) { NLogger.debug( ConnectionEngine.class, exp, exp ); if ( connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw exp; } catch ( Exception exp ) { NLogger.warn( ConnectionEngine.class, exp, exp ); if (connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw new IOException( "Exception occured: " + exp.getMessage() ); } } |
handleVendorMessage( (VendorMsg) message ); | msgDispatcher.handleVendorMessage( (VendorMsg) message, connectedHost ); | public void processIncomingData() throws IOException { headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; try { while ( true ) { MsgHeader header = readHeader(); byte[] body = MessageProcessor.readMessageBody( connection, header.getDataLength() ); connectedHost.incReceivedCount(); int ttl = header.getTTL(); int hops = header.getHopsTaken(); // verify valid ttl and hops data if ( ttl < 0 || hops < 0 ) { dropMessage( header, body, "TTL or hops below 0" ); continue; } // if message traveled too far already... drop it. if ( hops > ServiceManager.sCfg.maxNetworkTTL ) { dropMessage( header, body, "Hops larger then maxNetworkTTL" ); continue; } // limit TTL if too high! if ( ttl >= ServiceManager.sCfg.maxNetworkTTL ) { header.setTTL( (byte)(ServiceManager.sCfg.maxNetworkTTL - hops) ); } Message message; try { message = MessageProcessor.createMessageFromBody( header, body ); if ( message == null ) { // unknown message type... dropMessage( header, body, "Unknown message type" ); continue; } } catch ( InvalidMessageException exp ) { dropMessage( header, body, "Invalid message: " + exp.getMessage() ); NLogger.warn(NLoggerNames.IncomingMessages, exp, exp ); continue; } // count the hop and decrement ttl... header.countHop(); //Logger.logMessage( Logger.FINEST, Logger.NETWORK, // "Received Header function: " + header.getPayload() ); switch ( header.getPayload() ) { case MsgHeader.PING_PAYLOAD: handlePing( (PingMsg)message ); break; case MsgHeader.PONG_PAYLOAD: handlePong( (PongMsg)message ); break; case MsgHeader.PUSH_PAYLOAD: handlePushRequest( (PushRequestMsg) message ); break; case MsgHeader.QUERY_PAYLOAD: handleQuery( (QueryMsg) message ); break; case MsgHeader.QUERY_HIT_PAYLOAD: handleQueryResponse( (QueryResponseMsg) message ); break; case MsgHeader.ROUTE_TABLE_UPDATE_PAYLOAD: handleRouteTableUpdate( (RouteTableUpdateMsg) message ); break; case MsgHeader.VENDOR_MESSAGE_PAYLOAD: case MsgHeader.STANDARD_VENDOR_MESSAGE_PAYLOAD: handleVendorMessage( (VendorMsg) message ); break; } } } catch ( IOException exp ) { NLogger.debug( ConnectionEngine.class, exp, exp ); if ( connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw exp; } catch ( Exception exp ) { NLogger.warn( ConnectionEngine.class, exp, exp ); if (connectedHost.isConnected() ) { connectedHost.setStatus( HostStatus.ERROR, exp.getMessage()); hostMgr.disconnectHost( connectedHost ); } throw new IOException( "Exception occured: " + exp.getMessage() ); } } |
req.setCharacterEncoding("UTF-8"); | public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { try { if(!Hudson.adminCheck(req,rsp)) return; int scmidx = Integer.parseInt(req.getParameter("scm")); scm = SCMManager.getSupportedSCMs()[scmidx].newInstance(req); disabled = req.getParameter("disable")!=null; jdk = req.getParameter("jdk"); if(req.getParameter("hasCustomQuietPeriod")!=null) { quietPeriod = Integer.parseInt(req.getParameter("quiet_period")); } else { quietPeriod = null; } if(req.getParameter("hasSlaveAffinity")!=null) { canRoam = false; assignedNode = req.getParameter("slave"); if(assignedNode !=null) { if(Hudson.getInstance().getSlave(assignedNode)==null) { assignedNode = null; // no such slave } } } else { canRoam = true; assignedNode = null; } buildDescribable(req, BuildStep.BUILDERS, builders, "builder"); buildDescribable(req, BuildStep.PUBLISHERS, publishers, "publisher"); for (Trigger t : triggers) t.stop(); buildDescribable(req, Trigger.TRIGGERS, triggers, "trigger"); for (Trigger t : triggers) t.start(this); super.doConfigSubmit(req,rsp); } catch (InstantiationException e) { sendError(e,req,rsp); } } |
|
allRemoteFiles = new ArrayList(); allSearchResultSHA1Set = new HashSet(); | allRemoteFiles = new ArrayList<RemoteFile>(); allSearchResultSHA1Set = new HashSet<String>(); | private SearchResultsDataModel( Search search ) { this.search = search; allRemoteFiles = new ArrayList(); allSearchResultSHA1Set = new HashSet(); allSearchResultCount = 0; displayedSearchResults = new ArrayList(); displayedSearchResultSHA1Map = new HashMap(); searchElementCountObj = new IntObj(); filteredElementCountObj = new IntObj(); comparator = new SearchResultElementComparator(); searchFilterRuleSet = new HashSet(); SearchFilterRules filterRules = QueryManager.getInstance().getSearchFilterRules(); searchFilterRuleSet.addAll( filterRules.getPermanentList() ); search.addSearchChangeListener( this ); PhexSecurityManager.getInstance().addSecurityRuleChangeListener( this ); } |
displayedSearchResults = new ArrayList(); displayedSearchResultSHA1Map = new HashMap(); | displayedSearchResults = new ArrayList<SearchResultElement>(); displayedSearchResultSHA1Map = new HashMap<String, SearchResultElement>(); | private SearchResultsDataModel( Search search ) { this.search = search; allRemoteFiles = new ArrayList(); allSearchResultSHA1Set = new HashSet(); allSearchResultCount = 0; displayedSearchResults = new ArrayList(); displayedSearchResultSHA1Map = new HashMap(); searchElementCountObj = new IntObj(); filteredElementCountObj = new IntObj(); comparator = new SearchResultElementComparator(); searchFilterRuleSet = new HashSet(); SearchFilterRules filterRules = QueryManager.getInstance().getSearchFilterRules(); searchFilterRuleSet.addAll( filterRules.getPermanentList() ); search.addSearchChangeListener( this ); PhexSecurityManager.getInstance().addSecurityRuleChangeListener( this ); } |
searchFilterRuleSet = new HashSet(); | searchFilterRuleSet = new HashSet<Rule>(); | private SearchResultsDataModel( Search search ) { this.search = search; allRemoteFiles = new ArrayList(); allSearchResultSHA1Set = new HashSet(); allSearchResultCount = 0; displayedSearchResults = new ArrayList(); displayedSearchResultSHA1Map = new HashMap(); searchElementCountObj = new IntObj(); filteredElementCountObj = new IntObj(); comparator = new SearchResultElementComparator(); searchFilterRuleSet = new HashSet(); SearchFilterRules filterRules = QueryManager.getInstance().getSearchFilterRules(); searchFilterRuleSet.addAll( filterRules.getPermanentList() ); search.addSearchChangeListener( this ); PhexSecurityManager.getInstance().addSecurityRuleChangeListener( this ); } |
resultElement = (SearchResultElement)displayedSearchResultSHA1Map.get( sha1 ); | resultElement = displayedSearchResultSHA1Map.get( sha1 ); | private void addSearchResultForDisplay(RemoteFile remoteFile) { SearchResultElement resultElement = null; String sha1 = remoteFile.getSHA1(); if ( sha1 != null ) { resultElement = (SearchResultElement)displayedSearchResultSHA1Map.get( sha1 ); } if ( resultElement != null ) { resultElement.addRemoteFile( remoteFile ); // TODO in here is the problem of bug 1288776 // http://sourceforge.net/tracker/index.php?func=detail&aid=1288776&group_id=27021&atid=388892 // The main cause is that we are having a sorted list to which we // add child elements, the number of child elements changes the order // of the parent element in the displayedSearchResults. // I tried removing the resultElement and readd it at its updated // position, but this is not working right. Often the expected position // of the resultElement could not be determined right.... fireSearchResultAdded(remoteFile, resultElement); } else { resultElement = new SearchResultElement( remoteFile ); // search for the right position to add this search result. int index = Collections.binarySearch( displayedSearchResults, resultElement, comparator ); if (index <= 0) { if ( sha1 != null && sha1.length() > 0 ) { displayedSearchResultSHA1Map.put( sha1, resultElement ); } displayedSearchResults.add(-index-1, resultElement); fireNewSearchResultAdded(resultElement, -index-1); } } } |
return (SearchResultElement)displayedSearchResults.get( index ); | return displayedSearchResults.get( index ); | public SearchResultElement getSearchElementAt( int index ) { if ( index < 0 || index >= displayedSearchResults.size() ) { return null; } return (SearchResultElement)displayedSearchResults.get( index ); } |
Iterator iterator = searchFilterRuleSet.iterator(); while( iterator.hasNext() ) | for ( Rule rule : searchFilterRuleSet ) | private void processFilterRules( RemoteFile[] remoteFiles ) { if ( searchFilterRuleSet == null ) { return; } if ( quickFilterRule != null ) { quickFilterRule.process(search, remoteFiles); } Iterator iterator = searchFilterRuleSet.iterator(); while( iterator.hasNext() ) { Rule rule = (Rule) iterator.next(); rule.process(search, remoteFiles); } } |
Rule rule = (Rule) iterator.next(); | private void processFilterRules( RemoteFile[] remoteFiles ) { if ( searchFilterRuleSet == null ) { return; } if ( quickFilterRule != null ) { quickFilterRule.process(search, remoteFiles); } Iterator iterator = searchFilterRuleSet.iterator(); while( iterator.hasNext() ) { Rule rule = (Rule) iterator.next(); rule.process(search, remoteFiles); } } |
|
List remoteFilesList = new ArrayList( allRemoteFiles ); | List<RemoteFile> remoteFilesList = new ArrayList<RemoteFile>( allRemoteFiles ); | private void updateSecurityFilteredQueryList( IPAccessRule rule ) { // the code is basically the same as updateFilteredQueryList // except that is using a list for better performance. synchronized( allRemoteFiles ) { synchronized( displayedSearchResults ) { // create a copy of all List remoteFilesList = new ArrayList( allRemoteFiles ); // clear all and displayed allSearchResultCount = 0; allRemoteFiles.clear(); allSearchResultSHA1Set.clear(); displayedSearchResultSHA1Map.clear(); displayedSearchResults.clear(); fireAllSearchResultsChanged(); // reset filter flags ListIterator iterator = remoteFilesList.listIterator(); while( iterator.hasNext() ) { RemoteFile remoteFile = (RemoteFile) iterator.next(); DestAddress address = remoteFile.getHostAddress(); IpAddress ipAddress = address.getIpAddress(); if ( ipAddress != null && !rule.isHostIPAllowed( ipAddress.getHostIP() ) ) { iterator.remove(); continue; } remoteFile.clearFilterFlags(); } // add all search results (will trigger filtering) RemoteFile[] remoteFiles = new RemoteFile[ remoteFilesList.size() ]; remoteFilesList.toArray(remoteFiles); addSearchResults( remoteFiles ); // update search workaround to update search count... search.fireSearchChanged(); } } } |
ListIterator iterator = remoteFilesList.listIterator(); | ListIterator<RemoteFile> iterator = remoteFilesList.listIterator(); | private void updateSecurityFilteredQueryList( IPAccessRule rule ) { // the code is basically the same as updateFilteredQueryList // except that is using a list for better performance. synchronized( allRemoteFiles ) { synchronized( displayedSearchResults ) { // create a copy of all List remoteFilesList = new ArrayList( allRemoteFiles ); // clear all and displayed allSearchResultCount = 0; allRemoteFiles.clear(); allSearchResultSHA1Set.clear(); displayedSearchResultSHA1Map.clear(); displayedSearchResults.clear(); fireAllSearchResultsChanged(); // reset filter flags ListIterator iterator = remoteFilesList.listIterator(); while( iterator.hasNext() ) { RemoteFile remoteFile = (RemoteFile) iterator.next(); DestAddress address = remoteFile.getHostAddress(); IpAddress ipAddress = address.getIpAddress(); if ( ipAddress != null && !rule.isHostIPAllowed( ipAddress.getHostIP() ) ) { iterator.remove(); continue; } remoteFile.clearFilterFlags(); } // add all search results (will trigger filtering) RemoteFile[] remoteFiles = new RemoteFile[ remoteFilesList.size() ]; remoteFilesList.toArray(remoteFiles); addSearchResults( remoteFiles ); // update search workaround to update search count... search.fireSearchChanged(); } } } |
RemoteFile remoteFile = (RemoteFile) iterator.next(); | RemoteFile remoteFile = iterator.next(); | private void updateSecurityFilteredQueryList( IPAccessRule rule ) { // the code is basically the same as updateFilteredQueryList // except that is using a list for better performance. synchronized( allRemoteFiles ) { synchronized( displayedSearchResults ) { // create a copy of all List remoteFilesList = new ArrayList( allRemoteFiles ); // clear all and displayed allSearchResultCount = 0; allRemoteFiles.clear(); allSearchResultSHA1Set.clear(); displayedSearchResultSHA1Map.clear(); displayedSearchResults.clear(); fireAllSearchResultsChanged(); // reset filter flags ListIterator iterator = remoteFilesList.listIterator(); while( iterator.hasNext() ) { RemoteFile remoteFile = (RemoteFile) iterator.next(); DestAddress address = remoteFile.getHostAddress(); IpAddress ipAddress = address.getIpAddress(); if ( ipAddress != null && !rule.isHostIPAllowed( ipAddress.getHostIP() ) ) { iterator.remove(); continue; } remoteFile.clearFilterFlags(); } // add all search results (will trigger filtering) RemoteFile[] remoteFiles = new RemoteFile[ remoteFilesList.size() ]; remoteFilesList.toArray(remoteFiles); addSearchResults( remoteFiles ); // update search workaround to update search count... search.fireSearchChanged(); } } } |
if (param1 instanceof Number) { if (param2 instanceof Number) { | if (param1 instanceof Complex) { if (param2 instanceof Complex) return power((Complex)param1, (Complex)param2); else if (param2 instanceof Number) return power((Complex)param1, (Number)param2); } else if (param1 instanceof Number) { if (param2 instanceof Complex) return power((Number)param1, (Complex)param2); else if (param2 instanceof Number) | public Object power(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) { return power((Number)param1, (Number)param2); } else if (param2 instanceof Complex) { return power((Number)param1, (Complex)param2); } } else if (param1 instanceof Complex) { if (param2 instanceof Number) { return power((Complex)param1, (Number)param2); } else if (param2 instanceof Complex) { return power((Complex)param1, (Complex)param2); } } throw new ParseException("Invalid parameter type"); } |
} else if (param2 instanceof Complex) { return power((Number)param1, (Complex)param2); } } else if (param1 instanceof Complex) { if (param2 instanceof Number) { return power((Complex)param1, (Number)param2); } else if (param2 instanceof Complex) { return power((Complex)param1, (Complex)param2); } | public Object power(Object param1, Object param2) throws ParseException { if (param1 instanceof Number) { if (param2 instanceof Number) { return power((Number)param1, (Number)param2); } else if (param2 instanceof Complex) { return power((Number)param1, (Complex)param2); } } else if (param1 instanceof Complex) { if (param2 instanceof Number) { return power((Complex)param1, (Number)param2); } else if (param2 instanceof Complex) { return power((Complex)param1, (Complex)param2); } } throw new ParseException("Invalid parameter type"); } |
|
setAsText(id, ExternalDocument.class); | if (logger.isDebugEnabled()) { logger.debug("Loaded ExternalDocument property editor"); } try { Object value = getHibernateTemplate().load(ExternalDocument.class, Long.parseLong(id)); super.setValue(value); if (logger.isDebugEnabled()) { logger.debug("Loaded property: "+value); } } catch (Exception e) { super.setValue(null); } | public void setAsText(String id) throws IllegalArgumentException { setAsText(id, ExternalDocument.class); } |
PropertyEditor documentPropertyEditor = new DocumentPropertyEditor(getHibernateTemplate()); if (logger.isDebugEnabled()) { logger.debug("Registering custom editor "+documentPropertyEditor); } registry.registerCustomEditor(Document.class, documentPropertyEditor); | public void registerCustomEditors(PropertyEditorRegistry registry) { PropertyEditor externalDocumentPropertyEditor = new ExternalDocumentPropertyEditor(getHibernateTemplate()); if (logger.isDebugEnabled()) { logger.debug("Registering custom editor "+externalDocumentPropertyEditor); } registry.registerCustomEditor(ExternalDocument.class, externalDocumentPropertyEditor); } |
|
public int getDownloadFileCount( int status ) | public int getDownloadFileCount() | public int getDownloadFileCount( int status ) { int count = 0; synchronized( downloadList ) { for ( SWDownloadFile file : downloadList ) { if ( file.getStatus() == status ) { count ++; } } } return count; } |
int count = 0; synchronized( downloadList ) { for ( SWDownloadFile file : downloadList ) { if ( file.getStatus() == status ) { count ++; } } } return count; | return downloadList.size(); | public int getDownloadFileCount( int status ) { int count = 0; synchronized( downloadList ) { for ( SWDownloadFile file : downloadList ) { if ( file.getStatus() == status ) { count ++; } } } return count; } |
timeRefType = new String(threeBytes); | timeRefType = new String(PSNDataFile.chopToLength(threeBytes)); | private void readHeader() throws IOException{ /**Variable Header Length**/ //varHeadLength = dis.readInt(); varHeadLength = SacTimeSeries.swapBytes(dis.readInt()); //System.out.println("varHeadLength = " + Integer.toHexString(varHeadLength) + " or " + varHeadLength); dateTime = new PSNDateTime(dis); /**StartTime offset**/ startTimeOffset = SacTimeSeries.swapBytes(dis.readDouble()); /**SampleRate**/ sampleRate = SacTimeSeries.swapBytes(dis.readDouble()); /**SampleCount**/ sampleCount = SacTimeSeries.swapBytes(dis.readInt()); /**Flags**/ flags = SacTimeSeries.swapBytes(dis.readInt()); /**Timing Ref Type**/ dis.readFully(threeBytes); timeRefType = new String(threeBytes); /**Timing Ref Status**/ timeRefStatus = dis.readByte(); /**Sample Data Type**/ sampleDataType = dis.readByte(); /**Sample Compression**/ sampleCompression = dis.readByte(); /**Component Incident**/ compIncident = SacTimeSeries.swapBytes(dis.readDouble()); /**Component Azimuth**/ compAz = SacTimeSeries.swapBytes(dis.readDouble()); /**Component Orientation**/ compOrientation = dis.readByte(); /**Sensor Type**/ sensorType = dis.readByte(); /**Sensor Latitude**/ sensorLat = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Longitude**/ sensorLong = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Elevation**/ sensorElevation = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Name**/ dis.readFully(sixBytes); sensorName = new String(sixBytes); /**ChannelID**/ dis.readFully(fourBytes); channelId = new String(fourBytes); /**Sensor Network**/ dis.readFully(sixBytes); sensorNetwork = new String(sixBytes); /**Sensitivity**/ sensitivity = SacTimeSeries.swapBytes(dis.readDouble()); /**Magnitude Correction**/ magCorrect = SacTimeSeries.swapBytes(dis.readDouble()); /**A/D Bit Resolution**/ adBitRes = SacTimeSeries.swapBytes(dis.readShort()); /**Sample Minimum**/ sampleMin = SacTimeSeries.swapBytes(dis.readDouble()); /**Sample Maximum**/ sampleMax = SacTimeSeries.swapBytes(dis.readDouble()); /**Sample Mean**/ sampleMean = SacTimeSeries.swapBytes(dis.readDouble()); } |
sensorName = new String(sixBytes); | sensorName = new String(PSNDataFile.chopToLength(sixBytes)); | private void readHeader() throws IOException{ /**Variable Header Length**/ //varHeadLength = dis.readInt(); varHeadLength = SacTimeSeries.swapBytes(dis.readInt()); //System.out.println("varHeadLength = " + Integer.toHexString(varHeadLength) + " or " + varHeadLength); dateTime = new PSNDateTime(dis); /**StartTime offset**/ startTimeOffset = SacTimeSeries.swapBytes(dis.readDouble()); /**SampleRate**/ sampleRate = SacTimeSeries.swapBytes(dis.readDouble()); /**SampleCount**/ sampleCount = SacTimeSeries.swapBytes(dis.readInt()); /**Flags**/ flags = SacTimeSeries.swapBytes(dis.readInt()); /**Timing Ref Type**/ dis.readFully(threeBytes); timeRefType = new String(threeBytes); /**Timing Ref Status**/ timeRefStatus = dis.readByte(); /**Sample Data Type**/ sampleDataType = dis.readByte(); /**Sample Compression**/ sampleCompression = dis.readByte(); /**Component Incident**/ compIncident = SacTimeSeries.swapBytes(dis.readDouble()); /**Component Azimuth**/ compAz = SacTimeSeries.swapBytes(dis.readDouble()); /**Component Orientation**/ compOrientation = dis.readByte(); /**Sensor Type**/ sensorType = dis.readByte(); /**Sensor Latitude**/ sensorLat = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Longitude**/ sensorLong = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Elevation**/ sensorElevation = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Name**/ dis.readFully(sixBytes); sensorName = new String(sixBytes); /**ChannelID**/ dis.readFully(fourBytes); channelId = new String(fourBytes); /**Sensor Network**/ dis.readFully(sixBytes); sensorNetwork = new String(sixBytes); /**Sensitivity**/ sensitivity = SacTimeSeries.swapBytes(dis.readDouble()); /**Magnitude Correction**/ magCorrect = SacTimeSeries.swapBytes(dis.readDouble()); /**A/D Bit Resolution**/ adBitRes = SacTimeSeries.swapBytes(dis.readShort()); /**Sample Minimum**/ sampleMin = SacTimeSeries.swapBytes(dis.readDouble()); /**Sample Maximum**/ sampleMax = SacTimeSeries.swapBytes(dis.readDouble()); /**Sample Mean**/ sampleMean = SacTimeSeries.swapBytes(dis.readDouble()); } |
channelId = new String(fourBytes); | channelId = new String(PSNDataFile.chopToLength(fourBytes)); | private void readHeader() throws IOException{ /**Variable Header Length**/ //varHeadLength = dis.readInt(); varHeadLength = SacTimeSeries.swapBytes(dis.readInt()); //System.out.println("varHeadLength = " + Integer.toHexString(varHeadLength) + " or " + varHeadLength); dateTime = new PSNDateTime(dis); /**StartTime offset**/ startTimeOffset = SacTimeSeries.swapBytes(dis.readDouble()); /**SampleRate**/ sampleRate = SacTimeSeries.swapBytes(dis.readDouble()); /**SampleCount**/ sampleCount = SacTimeSeries.swapBytes(dis.readInt()); /**Flags**/ flags = SacTimeSeries.swapBytes(dis.readInt()); /**Timing Ref Type**/ dis.readFully(threeBytes); timeRefType = new String(threeBytes); /**Timing Ref Status**/ timeRefStatus = dis.readByte(); /**Sample Data Type**/ sampleDataType = dis.readByte(); /**Sample Compression**/ sampleCompression = dis.readByte(); /**Component Incident**/ compIncident = SacTimeSeries.swapBytes(dis.readDouble()); /**Component Azimuth**/ compAz = SacTimeSeries.swapBytes(dis.readDouble()); /**Component Orientation**/ compOrientation = dis.readByte(); /**Sensor Type**/ sensorType = dis.readByte(); /**Sensor Latitude**/ sensorLat = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Longitude**/ sensorLong = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Elevation**/ sensorElevation = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Name**/ dis.readFully(sixBytes); sensorName = new String(sixBytes); /**ChannelID**/ dis.readFully(fourBytes); channelId = new String(fourBytes); /**Sensor Network**/ dis.readFully(sixBytes); sensorNetwork = new String(sixBytes); /**Sensitivity**/ sensitivity = SacTimeSeries.swapBytes(dis.readDouble()); /**Magnitude Correction**/ magCorrect = SacTimeSeries.swapBytes(dis.readDouble()); /**A/D Bit Resolution**/ adBitRes = SacTimeSeries.swapBytes(dis.readShort()); /**Sample Minimum**/ sampleMin = SacTimeSeries.swapBytes(dis.readDouble()); /**Sample Maximum**/ sampleMax = SacTimeSeries.swapBytes(dis.readDouble()); /**Sample Mean**/ sampleMean = SacTimeSeries.swapBytes(dis.readDouble()); } |
sensorNetwork = new String(sixBytes); | sensorNetwork = new String(PSNDataFile.chopToLength(sixBytes)); | private void readHeader() throws IOException{ /**Variable Header Length**/ //varHeadLength = dis.readInt(); varHeadLength = SacTimeSeries.swapBytes(dis.readInt()); //System.out.println("varHeadLength = " + Integer.toHexString(varHeadLength) + " or " + varHeadLength); dateTime = new PSNDateTime(dis); /**StartTime offset**/ startTimeOffset = SacTimeSeries.swapBytes(dis.readDouble()); /**SampleRate**/ sampleRate = SacTimeSeries.swapBytes(dis.readDouble()); /**SampleCount**/ sampleCount = SacTimeSeries.swapBytes(dis.readInt()); /**Flags**/ flags = SacTimeSeries.swapBytes(dis.readInt()); /**Timing Ref Type**/ dis.readFully(threeBytes); timeRefType = new String(threeBytes); /**Timing Ref Status**/ timeRefStatus = dis.readByte(); /**Sample Data Type**/ sampleDataType = dis.readByte(); /**Sample Compression**/ sampleCompression = dis.readByte(); /**Component Incident**/ compIncident = SacTimeSeries.swapBytes(dis.readDouble()); /**Component Azimuth**/ compAz = SacTimeSeries.swapBytes(dis.readDouble()); /**Component Orientation**/ compOrientation = dis.readByte(); /**Sensor Type**/ sensorType = dis.readByte(); /**Sensor Latitude**/ sensorLat = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Longitude**/ sensorLong = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Elevation**/ sensorElevation = SacTimeSeries.swapBytes(dis.readDouble()); /**Sensor Name**/ dis.readFully(sixBytes); sensorName = new String(sixBytes); /**ChannelID**/ dis.readFully(fourBytes); channelId = new String(fourBytes); /**Sensor Network**/ dis.readFully(sixBytes); sensorNetwork = new String(sixBytes); /**Sensitivity**/ sensitivity = SacTimeSeries.swapBytes(dis.readDouble()); /**Magnitude Correction**/ magCorrect = SacTimeSeries.swapBytes(dis.readDouble()); /**A/D Bit Resolution**/ adBitRes = SacTimeSeries.swapBytes(dis.readShort()); /**Sample Minimum**/ sampleMin = SacTimeSeries.swapBytes(dis.readDouble()); /**Sample Maximum**/ sampleMax = SacTimeSeries.swapBytes(dis.readDouble()); /**Sample Mean**/ sampleMean = SacTimeSeries.swapBytes(dis.readDouble()); } |
MutiableMonomial toMutiableMonomial() throws ParseException | MutiableMonomial toMutiableMonomial() | MutiableMonomial toMutiableMonomial() throws ParseException { PNodeI newTerms[] = new PNodeI[vars.length]; PNodeI newPows[] = new PNodeI[vars.length]; for(int i=0;i<vars.length;++i){ newTerms[i] = vars[i]; newPows[i] = powers[i]; } return new MutiableMonomial(pc,coeff,newTerms,newPows); } |
PNodeI valueOf(Constant coeff,PNodeI terms[],PNodeI pows[]) throws ParseException | PNodeI valueOf(Constant coefficient,PNodeI terms[],PNodeI pows[]) | PNodeI valueOf(Constant coeff,PNodeI terms[],PNodeI pows[]) throws ParseException { if(coeff.isZero()) return pc.zeroConstant; if(terms.length ==0) return coeff; return new Monomial(pc,coeff,terms,pows); } |
if(coeff.isZero()) return pc.zeroConstant; if(terms.length ==0) return coeff; return new Monomial(pc,coeff,terms,pows); | if(coefficient.isZero()) return pc.zeroConstant; if(terms.length ==0) return coefficient; return new Monomial(pc,coefficient,terms,pows); | PNodeI valueOf(Constant coeff,PNodeI terms[],PNodeI pows[]) throws ParseException { if(coeff.isZero()) return pc.zeroConstant; if(terms.length ==0) return coeff; return new Monomial(pc,coeff,terms,pows); } |
System.out.println(query); | private StationId[] extractAll(PreparedStatement query) throws SQLException { System.out.println(query); ResultSet rs = query.executeQuery(); List aList = new ArrayList(); try { while(rs.next()) aList.add(extractId(rs, netTable, time)); } catch(NotFound e) { return new StationId[] {}; } return (StationId[])aList.toArray(new StationId[aList.size()]); } |
|
for( Executor e : executors ) e.interrupt(); | synchronized(this) { for( Executor e : executors ) if(e.getCurrentBuild()==null) e.interrupt(); | public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException { useSecurity = req.getParameter("use_security")!=null; numExecutors = Integer.parseInt(req.getParameter("numExecutors")); for( Executor e : executors ) e.interrupt(); while(executors.size()<numExecutors) executors.add(new Executor(this)); boolean result = true; for( BuildStepDescriptor d : BuildStep.BUILDERS ) result &= d.configure(req); for( SCMDescriptor scmd : SCMManager.getSupportedSCMs() ) result &= scmd.configure(req); save(); if(result) rsp.sendRedirect("."); // go to the top page else rsp.sendRedirect("configure"); // back to config } |
while(executors.size()<numExecutors) executors.add(new Executor(this)); | while(executors.size()<numExecutors) executors.add(new Executor(this)); } | public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException { useSecurity = req.getParameter("use_security")!=null; numExecutors = Integer.parseInt(req.getParameter("numExecutors")); for( Executor e : executors ) e.interrupt(); while(executors.size()<numExecutors) executors.add(new Executor(this)); boolean result = true; for( BuildStepDescriptor d : BuildStep.BUILDERS ) result &= d.configure(req); for( SCMDescriptor scmd : SCMManager.getSupportedSCMs() ) result &= scmd.configure(req); save(); if(result) rsp.sendRedirect("."); // go to the top page else rsp.sendRedirect("configure"); // back to config } |
for( int i=0; i<subdirs.length; i++ ) { | for (final File subdir : subdirs) { | private void load() throws IOException { if(getConfigFile().exists()) { Reader r = new InputStreamReader(new FileInputStream(getConfigFile()),"UTF-8"); createConfiguredStream().unmarshal(new XppReader(r),this); r.close(); } File projectsDir = new File(root,"jobs"); projectsDir.mkdirs(); File[] subdirs = projectsDir.listFiles(new FileFilter() { public boolean accept(File child) { return child.isDirectory(); } }); jobs.clear(); for( int i=0; i<subdirs.length; i++ ) { try { Job p = Job.load(this,subdirs[i]); jobs.put(p.getName(),p); } catch( IOException e ) { e.printStackTrace(); // TODO: logging } } } |
Job p = Job.load(this,subdirs[i]); jobs.put(p.getName(),p); } catch( IOException e ) { | Job p = Job.load(this,subdir); jobs.put(p.getName(), p); } catch (IOException e) { | private void load() throws IOException { if(getConfigFile().exists()) { Reader r = new InputStreamReader(new FileInputStream(getConfigFile()),"UTF-8"); createConfiguredStream().unmarshal(new XppReader(r),this); r.close(); } File projectsDir = new File(root,"jobs"); projectsDir.mkdirs(); File[] subdirs = projectsDir.listFiles(new FileFilter() { public boolean accept(File child) { return child.isDirectory(); } }); jobs.clear(); for( int i=0; i<subdirs.length; i++ ) { try { Job p = Job.load(this,subdirs[i]); jobs.put(p.getName(),p); } catch( IOException e ) { e.printStackTrace(); // TODO: logging } } } |
if (param instanceof Number) | if (param instanceof Complex) { return ((Complex)param).cosh(); } else if (param instanceof Number) | public Object cosh(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); return new Double((Math.exp(value) + Math.exp(-value))/2); } else if (param instanceof Complex) { return ((Complex)param).cosh(); } throw new ParseException("Invalid parameter type"); } |
else if (param instanceof Complex) { return ((Complex)param).cosh(); } | public Object cosh(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); return new Double((Math.exp(value) + Math.exp(-value))/2); } else if (param instanceof Complex) { return ((Complex)param).cosh(); } throw new ParseException("Invalid parameter type"); } |
|
if ( !ggepBlock.isExtensionAvailable( GGEPBlock.ULTRAPEER_ID ) ) | if ( ggepBlock == null || !ggepBlock.isExtensionAvailable( GGEPBlock.ULTRAPEER_ID ) ) | public boolean hasFreeLeafSlots() { if ( !ggepBlock.isExtensionAvailable( GGEPBlock.ULTRAPEER_ID ) ) { return false; } byte[] data = ggepBlock.getExtensionData( GGEPBlock.ULTRAPEER_ID ); if ( data != null ) { if( data.length >= 3 ) { if( data[1] > 0 ) { return true; } } } return false; } |
if ( !ggepBlock.isExtensionAvailable( GGEPBlock.ULTRAPEER_ID ) ) | if ( ggepBlock == null || !ggepBlock.isExtensionAvailable( GGEPBlock.ULTRAPEER_ID ) ) | public boolean hasFreeUPSlots() { if ( !ggepBlock.isExtensionAvailable( GGEPBlock.ULTRAPEER_ID ) ) { return false; } byte[] data = ggepBlock.getExtensionData( GGEPBlock.ULTRAPEER_ID ); if ( data != null ) { if( data.length >= 3 ) { if( data[2] > 0 ) { return true; } } } return false; } |
rsp.sendRedirect(req.getContextPath()+"/images/48x48/"+getBuildStatusUrl()); | rsp.sendRedirect(req.getContextPath()+"/nocacheImages/48x48/"+getBuildStatusUrl()); | public void doBuildStatus( StaplerRequest req, StaplerResponse rsp ) throws IOException { rsp.sendRedirect(req.getContextPath()+"/images/48x48/"+getBuildStatusUrl()); } |
req.setCharacterEncoding("UTF-8"); | public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException { if(!Hudson.adminCheck(req,rsp)) return; useSecurity = req.getParameter("use_security")!=null; numExecutors = Integer.parseInt(req.getParameter("numExecutors")); quietPeriod = Integer.parseInt(req.getParameter("quiet_period")); systemMessage = Util.nullify(req.getParameter("system_message")); {// update slave list slaves.clear(); String[] names = req.getParameterValues("slave_name"); String[] descriptions = req.getParameterValues("slave_description"); String[] executors = req.getParameterValues("slave_executors"); String[] cmds = req.getParameterValues("slave_command"); String[] rfs = req.getParameterValues("slave_remoteFS"); String[] lfs = req.getParameterValues("slave_localFS"); String[] mode = req.getParameterValues("slave_mode"); if(names!=null && descriptions!=null && executors!=null && cmds!=null && rfs!=null && lfs!=null && mode!=null) { int len = Util.min(names.length,descriptions.length,executors.length,cmds.length,rfs.length, lfs.length, mode.length); for(int i=0;i<len;i++) { int n = 2; try { n = Integer.parseInt(executors[i].trim()); } catch(NumberFormatException e) { // ignore } slaves.add(new Slave(names[i],descriptions[i],cmds[i],rfs[i],new File(lfs[i]),n,Node.Mode.valueOf(mode[i]))); } } updateComputerList(); } {// update JDK installations jdks.clear(); String[] names = req.getParameterValues("jdk_name"); String[] homes = req.getParameterValues("jdk_home"); if(names!=null && homes!=null) { int len = Math.min(names.length,homes.length); for(int i=0;i<len;i++) { jdks.add(new JDK(names[i],homes[i])); } } } boolean result = true; for( Descriptor<BuildStep> d : BuildStep.BUILDERS ) result &= d.configure(req); for( Descriptor<BuildStep> d : BuildStep.PUBLISHERS ) result &= d.configure(req); for( Descriptor<SCM> scmd : SCMManager.getSupportedSCMs() ) result &= scmd.configure(req); save(); if(result) rsp.sendRedirect("."); // go to the top page else rsp.sendRedirect("configure"); // back to config } |
|
req.setCharacterEncoding("UTF-8"); | public synchronized Job doCreateJob( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { if(!Hudson.adminCheck(req,rsp)) return null; String name = req.getParameter("name").trim(); String className = req.getParameter("type"); String mode = req.getParameter("mode"); try { checkGoodName(name); } catch (ParseException e) { sendError(e,req,rsp); return null; } if(getJob(name)!=null) { sendError("A job already exists with the name '"+name+"'",req,rsp); return null; } if(mode==null) { rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return null; } Job result; if(mode.equals("newJob")) { if(className==null) { // request forged? rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return null; } try { Class type = Class.forName(className); // redirect to the project config screen result = createProject(type, name); } catch (ClassNotFoundException e) { e.printStackTrace(); rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return null; } } else { Job src = getJob(req.getParameter("from")); if(src==null) { rsp.sendError(HttpServletResponse.SC_BAD_REQUEST); return null; } result = createProject(src.getClass(),name); // copy config Copy cp = new Copy(); cp.setProject(new org.apache.tools.ant.Project()); cp.setTofile(result.getConfigFile()); cp.setFile(src.getConfigFile()); cp.setOverwrite(true); cp.execute(); // reload from the new config result = Job.load(this,result.root); result.nextBuildNumber = 1; // reset the next build number jobs.put(name,result); } rsp.sendRedirect2(req.getContextPath()+'/'+result.getUrl()+"configure"); return result; } |
|
req.setCharacterEncoding("UTF-8"); | public synchronized void doCreateView( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { if(!Hudson.adminCheck(req,rsp)) return; String name = req.getParameter("name"); try { checkGoodName(name); } catch (ParseException e) { sendError(e, req, rsp); return; } View v = new View(this, name); if(views==null) views = new Vector<View>(); views.add(v); save(); // redirect to the config screen rsp.sendRedirect2("./"+v.getUrl()+"configure"); } |
|
for( BuildStepDescriptor d : BuildStep.PUBLISHERS ) result &= d.configure(req); | public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException { useSecurity = req.getParameter("use_security")!=null; numExecutors = Integer.parseInt(req.getParameter("numExecutors")); synchronized(this) { for( Executor e : executors ) if(e.getCurrentBuild()==null) e.interrupt(); while(executors.size()<numExecutors) executors.add(new Executor(this)); } boolean result = true; for( BuildStepDescriptor d : BuildStep.BUILDERS ) result &= d.configure(req); for( SCMDescriptor scmd : SCMManager.getSupportedSCMs() ) result &= scmd.configure(req); save(); if(result) rsp.sendRedirect("."); // go to the top page else rsp.sendRedirect("configure"); // back to config } |
|
public Node deepCopy(Node node,XJep xjep) throws ParseException | public Node deepCopy(Node node,XJep xj) throws ParseException | public Node deepCopy(Node node,XJep xjep) throws ParseException { this.xjep = xjep; Node res = (Node) node.jjtAccept(this,null); return res; } |
this.xjep = xjep; | this.xjep = xj; | public Node deepCopy(Node node,XJep xjep) throws ParseException { this.xjep = xjep; Node res = (Node) node.jjtAccept(this,null); return res; } |
|| qName.equalsIgnoreCase("NOTES")) { | || (qName.equalsIgnoreCase("NOTES") && !currentList.equalsIgnoreCase("DETAILS")) ) { | public void endElement(String namespaceURI, String sName, // simple name String qName // qualified name ) throws SAXException { if (importType == "STRANGEBREW") { if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("FERMENTABLES")) { r.addMalt(m); m = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("HOPS")) { h.setDescription(descrBuf); descrBuf = ""; r.addHop(h); h = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("MISC")) { misc.setDescription(descrBuf); descrBuf = ""; r.addMisc(misc); misc = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("NOTES")) { r.addNote(note); note = null; } else if (qName.equalsIgnoreCase("ITEM") && currentList.equalsIgnoreCase("MASH")) { r.mash.addStep(type, startTemp, endTemp, "F", method, minutes, rampMin); } else if (qName.equalsIgnoreCase("FERMENTABLS") || qName.equalsIgnoreCase("HOPS") || qName.equalsIgnoreCase("DETAILS") || qName.equalsIgnoreCase("MISC") || qName.equalsIgnoreCase("NOTES")) { currentList = ""; } } else if (importType == "QBREW"){ if (qName.equalsIgnoreCase("GRAIN")){ r.addMalt(m); m = null; } else if (qName.equalsIgnoreCase("HOP")){ r.addHop(h); h = null; } else if (qName.equalsIgnoreCase("title")){ r.setName(buffer); buffer = ""; } } } |
} else if (eName.equalsIgnoreCase("NOTES")) { | } else if (eName.equalsIgnoreCase("NOTES") && !currentList.equals("DETAILS")) { | void sbStartElement(String eName) { if (eName.equalsIgnoreCase("DETAILS")) { currentList = "DETAILS"; } else if (eName.equalsIgnoreCase("FERMENTABLES")) { currentList = "FERMENTABLES"; } else if (eName.equalsIgnoreCase("HOPS")) { currentList = "HOPS"; } else if (eName.equalsIgnoreCase("MASH") && currentList.equals("")) { currentList = "MASH"; } else if (eName.equalsIgnoreCase("MISC")) { currentList = "MISC"; } else if (eName.equalsIgnoreCase("NOTES")) { currentList = "NOTES"; } else if (eName.equalsIgnoreCase("ITEM")) { // this is an item in a // list if (currentList.equals("FERMENTABLES")) { m = new Fermentable(); } else if (currentList.equals("HOPS")) { h = new Hop(); } else if (currentList.equals("MISC")) { misc = new Misc(); } else if (currentList.equals("NOTES")) { note = new Note(); } } } |
public Object locateService(String name) { | public Object locateService(Object bindObject, String name) { | public Object locateService(String name) { Reference ref = config.getReference(name); return ref.getService(); } |
return ref.getService(); | return ref.getService(bindObject); | public Object locateService(String name) { Reference ref = config.getReference(name); return ref.getService(); } |
public Object[] locateServices(String name) { | public Object[] locateServices(Object bindObject, String name) { | public Object[] locateServices(String name) { Reference ref = config.getReference(name); return ref.getServiceReferences(); } |
return ref.getServiceReferences(); | ServiceReference[] refs = ref.getServiceReferences(); Object[] ret = new Object[refs.length]; for (int i = 0; i < refs.length; i++) { ret[i] = ref.getService(bindObject, refs[i]); } return ret; | public Object[] locateServices(String name) { Reference ref = config.getReference(name); return ref.getServiceReferences(); } |
disable(); | public void dispose() { unregisterService(); deactivate(); } |
|
config.bindReferences(instance, this.usingBundle); | config.bindReferences(instance, getDuplexObject()); | public synchronized void activate() { // this method is described on page 297 r4 // Synchronized because the service is registered before activation, // enabling another thread to get the service and thereby trigger a // second activate() call. if (!config.isEnabled() || !config.isSatisfied()) return; if (isActivated()) return; // 1. get class Class klass = config.getImplementationClass(); try { // 2. create ComponentContext and ComponentInstance instance = klass.newInstance(); componentInstance = new ComponentInstanceImpl(); componentContext = new ComponentContextImpl(componentInstance); } catch (IllegalAccessException e) { if (Activator.log.doError()) Activator.log.error("Could not access constructor of class " + config.getImplementation()); return; } catch (InstantiationException e) { if (Activator.log.doError()) Activator.log .error("Could not create instance of " + config.getImplementation() + " isn't a proper class."); return; } catch (ExceptionInInitializerError e) { if (Activator.log.doError()) Activator.log.error("Constructor for " + config.getImplementation() + " threw exception.", e); return; } catch (SecurityException e) { if (Activator.log.doError()) Activator.log.error( "Did not have permissions to create an instance of " + config.getImplementation(), e); return; } // 3. Bind the services. This should be sent to all the references. config.bindReferences(instance, this.usingBundle); try { Method method = klass.getDeclaredMethod("activate", new Class[] { ComponentContext.class }); method.setAccessible(true); method.invoke(instance, new Object[] { componentContext }); } catch (NoSuchMethodException e) { // this instance does not have an activate method, (which is ok) if (Activator.log.doDebug()) { Activator.log .debug("this instance does not have an activate method, (which is ok)"); } } catch (IllegalAccessException e) { Activator.log.error( "Declarative Services could not invoke \"deactivate\"" + " method in component \"" + config.getName() + "\". Got exception", e); return; } catch (InvocationTargetException e) { // the method threw an exception. Activator.log.error( "Declarative Services got exception when invoking " + "\"activate\" in component " + config.getName(), e); // if this happens the component should not be activatated config.unbindReferences(instance); instance = null; componentContext = null; return; } active = true; } |
config.unbindReferences(instance); | config.unbindReferences(instance, getDuplexObject()); | public synchronized void activate() { // this method is described on page 297 r4 // Synchronized because the service is registered before activation, // enabling another thread to get the service and thereby trigger a // second activate() call. if (!config.isEnabled() || !config.isSatisfied()) return; if (isActivated()) return; // 1. get class Class klass = config.getImplementationClass(); try { // 2. create ComponentContext and ComponentInstance instance = klass.newInstance(); componentInstance = new ComponentInstanceImpl(); componentContext = new ComponentContextImpl(componentInstance); } catch (IllegalAccessException e) { if (Activator.log.doError()) Activator.log.error("Could not access constructor of class " + config.getImplementation()); return; } catch (InstantiationException e) { if (Activator.log.doError()) Activator.log .error("Could not create instance of " + config.getImplementation() + " isn't a proper class."); return; } catch (ExceptionInInitializerError e) { if (Activator.log.doError()) Activator.log.error("Constructor for " + config.getImplementation() + " threw exception.", e); return; } catch (SecurityException e) { if (Activator.log.doError()) Activator.log.error( "Did not have permissions to create an instance of " + config.getImplementation(), e); return; } // 3. Bind the services. This should be sent to all the references. config.bindReferences(instance, this.usingBundle); try { Method method = klass.getDeclaredMethod("activate", new Class[] { ComponentContext.class }); method.setAccessible(true); method.invoke(instance, new Object[] { componentContext }); } catch (NoSuchMethodException e) { // this instance does not have an activate method, (which is ok) if (Activator.log.doDebug()) { Activator.log .debug("this instance does not have an activate method, (which is ok)"); } } catch (IllegalAccessException e) { Activator.log.error( "Declarative Services could not invoke \"deactivate\"" + " method in component \"" + config.getName() + "\". Got exception", e); return; } catch (InvocationTargetException e) { // the method threw an exception. Activator.log.error( "Declarative Services got exception when invoking " + "\"activate\" in component " + config.getName(), e); // if this happens the component should not be activatated config.unbindReferences(instance); instance = null; componentContext = null; return; } active = true; } |
config.unbindReferences(instance); | config.unbindReferences(instance, getDuplexObject()); | public synchronized void deactivate() { // this method is described on page 432 r4 if (!isActivated()) return; try { Class klass = instance.getClass(); Method method = klass.getDeclaredMethod("deactivate", new Class[] { ComponentContext.class }); method.setAccessible(true); method.invoke(instance, new Object[] { componentContext }); } catch (NoSuchMethodException e) { // this instance does not have a deactivate method, (which is ok) if (Activator.log.doDebug()) { Activator.log .debug("this instance does not have a deactivate method, (which is ok)"); } } catch (IllegalAccessException e) { Activator.log.error( "Declarative Services could not invoke \"deactivate\"" + " method in component \"" + config.getName() + "\". Got exception", e); } catch (InvocationTargetException e) { // the method threw an exception. Activator.log .error( "Declarative Services got exception when invoking " + "\"deactivate\" in component " + config.getName(), e); } config.unbindReferences(instance); instance = null; componentContext = null; componentInstance = null; active = false; } |
ArrayList<DuplexReference> duplexRef = this.config .getDuplexReferences(); if (duplexRef != null && duplexRef.size() != 0) effectiveProperties.put(Constants.DUPLEX_REFERENCE, duplexRef); | public void registerService() { if (Activator.log.doDebug()) { Activator.log.debug("registerService() got BundleContext: " + bundleContext); } if (!config.getShouldRegisterService()) return; String[] interfaces = config.getServices(); if (interfaces == null) { return; } ArrayList<DuplexReference> duplexRef = this.config .getDuplexReferences(); if (duplexRef != null && duplexRef.size() != 0) effectiveProperties.put(Constants.DUPLEX_REFERENCE, duplexRef); serviceRegistration = bundleContext.registerService(interfaces, this, effectiveProperties); } |
|
public void bindReferences(Object instance, Bundle bundle) { | public void bindReferences(Object instance, Object duplexObject) { | public void bindReferences(Object instance, Bundle bundle) { for (int i = 0; i < references.size(); i++) { ((Reference) references.get(i)).bind(instance); } for (DuplexReference ref : this.duplexReferences) { ref.bind(instance, bundle); } } |
ref.bind(instance, bundle); | ref.bind(instance, duplexObject); | public void bindReferences(Object instance, Bundle bundle) { for (int i = 0; i < references.size(); i++) { ((Reference) references.get(i)).bind(instance); } for (DuplexReference ref : this.duplexReferences) { ref.bind(instance, bundle); } } |
public void unbindReferences(Object instance) { | public void unbindReferences(Object instance, Object duplexObject) { for (int i = this.duplexReferences.size() - 1; i >= 0; i--) { this.duplexReferences.get(i).unbind(instance, duplexObject); } | public void unbindReferences(Object instance) { for (int i = references.size() - 1; i >= 0; i--) { ((Reference) references.get(i)).unbind(instance); } for (DuplexReference ref : this.duplexReferences) { ref.unbind(instance); } } |
for (DuplexReference ref : this.duplexReferences) { ref.unbind(instance); } | public void unbindReferences(Object instance) { for (int i = references.size() - 1; i >= 0; i--) { ((Reference) references.get(i)).unbind(instance); } for (DuplexReference ref : this.duplexReferences) { ref.unbind(instance); } } |
|
int idx1 = key1.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val1Str = key1.substring( idx1 ); | int idx1 = key1.lastIndexOf( LIST_DESER_POSTFIX ) + LIST_DESER_POSTFIX.length(); int idx1E = key1.indexOf( ']', idx1 ); String val1Str = key1.substring( idx1, idx1E ); | public int compare( String key1, String key2 ) { if ( key1 == key2 || key1.equals( key2 ) ) { return 0; } int idx1 = key1.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val1Str = key1.substring( idx1 ); int val1; try { val1 = Integer.parseInt( val1Str ); } catch ( NumberFormatException exp ) { val1 = Integer.MAX_VALUE; } int idx2 = key2.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val2Str = key1.substring( idx1 ); int val2; try { val2 = Integer.parseInt( val1Str ); } catch ( NumberFormatException exp ) { val2 = Integer.MAX_VALUE; } if ( val1 == val2 ) { return key2.hashCode() - key1.hashCode(); } return val2 - val1; } |
int idx2 = key2.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val2Str = key1.substring( idx1 ); | int idx2 = key2.lastIndexOf( LIST_DESER_POSTFIX ) + LIST_DESER_POSTFIX.length(); int idx2E = key2.indexOf( ']', idx2 ); String val2Str = key1.substring( idx2, idx2E ); | public int compare( String key1, String key2 ) { if ( key1 == key2 || key1.equals( key2 ) ) { return 0; } int idx1 = key1.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val1Str = key1.substring( idx1 ); int val1; try { val1 = Integer.parseInt( val1Str ); } catch ( NumberFormatException exp ) { val1 = Integer.MAX_VALUE; } int idx2 = key2.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val2Str = key1.substring( idx1 ); int val2; try { val2 = Integer.parseInt( val1Str ); } catch ( NumberFormatException exp ) { val2 = Integer.MAX_VALUE; } if ( val1 == val2 ) { return key2.hashCode() - key1.hashCode(); } return val2 - val1; } |
val2 = Integer.parseInt( val1Str ); | val2 = Integer.parseInt( val2Str ); | public int compare( String key1, String key2 ) { if ( key1 == key2 || key1.equals( key2 ) ) { return 0; } int idx1 = key1.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val1Str = key1.substring( idx1 ); int val1; try { val1 = Integer.parseInt( val1Str ); } catch ( NumberFormatException exp ) { val1 = Integer.MAX_VALUE; } int idx2 = key2.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val2Str = key1.substring( idx1 ); int val2; try { val2 = Integer.parseInt( val1Str ); } catch ( NumberFormatException exp ) { val2 = Integer.MAX_VALUE; } if ( val1 == val2 ) { return key2.hashCode() - key1.hashCode(); } return val2 - val1; } |
return key2.hashCode() - key1.hashCode(); | return key1.hashCode() - key2.hashCode(); | public int compare( String key1, String key2 ) { if ( key1 == key2 || key1.equals( key2 ) ) { return 0; } int idx1 = key1.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val1Str = key1.substring( idx1 ); int val1; try { val1 = Integer.parseInt( val1Str ); } catch ( NumberFormatException exp ) { val1 = Integer.MAX_VALUE; } int idx2 = key2.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val2Str = key1.substring( idx1 ); int val2; try { val2 = Integer.parseInt( val1Str ); } catch ( NumberFormatException exp ) { val2 = Integer.MAX_VALUE; } if ( val1 == val2 ) { return key2.hashCode() - key1.hashCode(); } return val2 - val1; } |
return val2 - val1; | return val1 - val2; | public int compare( String key1, String key2 ) { if ( key1 == key2 || key1.equals( key2 ) ) { return 0; } int idx1 = key1.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val1Str = key1.substring( idx1 ); int val1; try { val1 = Integer.parseInt( val1Str ); } catch ( NumberFormatException exp ) { val1 = Integer.MAX_VALUE; } int idx2 = key2.lastIndexOf( LIST_POSTFIX ) + LIST_POSTFIX.length(); String val2Str = key1.substring( idx1 ); int val2; try { val2 = Integer.parseInt( val1Str ); } catch ( NumberFormatException exp ) { val2 = Integer.MAX_VALUE; } if ( val1 == val2 ) { return key2.hashCode() - key1.hashCode(); } return val2 - val1; } |
List<String> names = preferences.getPrefixedPropertyNames( name + LIST_POSTFIX ); | List<String> names = preferences.getPrefixedPropertyNames( name + LIST_DESER_POSTFIX ); | private static List<String> deserializeList( String name, Preferences preferences ) { List<String> list = new ArrayList<String>(); List<String> names = preferences.getPrefixedPropertyNames( name + LIST_POSTFIX ); Collections.sort( names, new ListPostfixKeyComparator() ); for ( String key : names ) { String value = preferences.getLoadedProperty( key ); if ( !StringUtils.isEmpty( value ) ) { list.add( value ); } } return list; } |
String prefix = new String ( name + SET_POSTFIX ); | String prefix = new String ( name + SET_DESER_POSTFIX ); | private static Set<String> deserializeSet( String name, Preferences preferences ) { Set<String> set = new HashSet<String>(); String prefix = new String ( name + SET_POSTFIX ); List<String> names = preferences.getPrefixedPropertyNames( prefix ); for ( String key : names ) { String value = preferences.getLoadedProperty( key ); if ( !StringUtils.isEmpty( value ) ) { set.add( value ); } } return set; } |
String setName = name + SET_POSTFIX; | public static void serializeSetting( Setting setting, Properties properties ) { String name = setting.getName(); Object value = setting.get(); if ( value instanceof String ) { properties.setProperty( name, (String)value ); } else if ( value instanceof Number ) { properties.setProperty( name, ((Number)value).toString() ); } else if ( value instanceof Boolean ) { properties.setProperty( name, ((Boolean)value).toString() ); } else if ( value instanceof Set ) { String setName = name + SET_POSTFIX; Set<String> setValue = (Set<String>)value; for( String elem : setValue ) { properties.setProperty( setName, elem ); } } else if ( value instanceof List ) { String listName = name + LIST_POSTFIX; List<String> listValue = (List<String>)value; int listSize = listValue.size(); for ( int i=0; i < listSize; i++ ) { properties.setProperty( listName + String.valueOf( i ), listValue.get( i ) ); } } else { NLogger.error( PreferencesFactory.class, "Unknwon settings value type: " + value.getClass() ); } } |
|
properties.setProperty( setName, elem ); | properties.setProperty( name + String.format( SET_SER_POSTFIX, new Integer( pos++ ) ), elem ); | public static void serializeSetting( Setting setting, Properties properties ) { String name = setting.getName(); Object value = setting.get(); if ( value instanceof String ) { properties.setProperty( name, (String)value ); } else if ( value instanceof Number ) { properties.setProperty( name, ((Number)value).toString() ); } else if ( value instanceof Boolean ) { properties.setProperty( name, ((Boolean)value).toString() ); } else if ( value instanceof Set ) { String setName = name + SET_POSTFIX; Set<String> setValue = (Set<String>)value; for( String elem : setValue ) { properties.setProperty( setName, elem ); } } else if ( value instanceof List ) { String listName = name + LIST_POSTFIX; List<String> listValue = (List<String>)value; int listSize = listValue.size(); for ( int i=0; i < listSize; i++ ) { properties.setProperty( listName + String.valueOf( i ), listValue.get( i ) ); } } else { NLogger.error( PreferencesFactory.class, "Unknwon settings value type: " + value.getClass() ); } } |
String listName = name + LIST_POSTFIX; | public static void serializeSetting( Setting setting, Properties properties ) { String name = setting.getName(); Object value = setting.get(); if ( value instanceof String ) { properties.setProperty( name, (String)value ); } else if ( value instanceof Number ) { properties.setProperty( name, ((Number)value).toString() ); } else if ( value instanceof Boolean ) { properties.setProperty( name, ((Boolean)value).toString() ); } else if ( value instanceof Set ) { String setName = name + SET_POSTFIX; Set<String> setValue = (Set<String>)value; for( String elem : setValue ) { properties.setProperty( setName, elem ); } } else if ( value instanceof List ) { String listName = name + LIST_POSTFIX; List<String> listValue = (List<String>)value; int listSize = listValue.size(); for ( int i=0; i < listSize; i++ ) { properties.setProperty( listName + String.valueOf( i ), listValue.get( i ) ); } } else { NLogger.error( PreferencesFactory.class, "Unknwon settings value type: " + value.getClass() ); } } |
|
properties.setProperty( listName + String.valueOf( i ), | properties.setProperty( name + String.format( LIST_SER_POSTFIX, new Integer( i ) ), | public static void serializeSetting( Setting setting, Properties properties ) { String name = setting.getName(); Object value = setting.get(); if ( value instanceof String ) { properties.setProperty( name, (String)value ); } else if ( value instanceof Number ) { properties.setProperty( name, ((Number)value).toString() ); } else if ( value instanceof Boolean ) { properties.setProperty( name, ((Boolean)value).toString() ); } else if ( value instanceof Set ) { String setName = name + SET_POSTFIX; Set<String> setValue = (Set<String>)value; for( String elem : setValue ) { properties.setProperty( setName, elem ); } } else if ( value instanceof List ) { String listName = name + LIST_POSTFIX; List<String> listValue = (List<String>)value; int listSize = listValue.size(); for ( int i=0; i < listSize; i++ ) { properties.setProperty( listName + String.valueOf( i ), listValue.get( i ) ); } } else { NLogger.error( PreferencesFactory.class, "Unknwon settings value type: " + value.getClass() ); } } |
public Rational(BigInteger num) { numerator = num; denominator = BigInteger.ONE; } | private Rational() { } | public Rational(BigInteger num) { numerator = num; denominator = BigInteger.ONE; } |
else return numerator.toString() +"/" + denominator.toString(); | return numerator.toString() +"/" + denominator.toString(); | public String toString() { if(denominator.equals(BigInteger.ONE)) return numerator.toString(); else return numerator.toString() +"/" + denominator.toString(); } |
else return new Rational( | return new Rational( | public static Number valueOf(String s) { int pos = s.indexOf('/'); if(pos==-1) return new Rational(new BigInteger(s)); else return new Rational( new BigInteger(s.substring(pos-1)), new BigInteger(s.substring(pos+1,-1))); } |
FileInputStream log = new FileInputStream(changelogFile); try { Util.copyStream(log,listener.getLogger()); } finally { log.close(); } | private boolean calcChangeLog(Build build, File changelogFile, Launcher launcher, BuildListener listener) throws IOException { if(build.getPreviousBuild()==null) { // nothing to compare against return createEmptyChangeLog(changelogFile, listener, "log"); } PrintStream logger = listener.getLogger(); Map<String,Integer> previousRevisions = parseRevisionFile(build.getPreviousBuild()); Map env = createEnvVarMap(true); for( String module : getModuleDirNames() ) { Integer prevRev = previousRevisions.get(module); if(prevRev==null) { logger.println("no revision recorded for "+module+" in the previous build"); continue; } String cmd = DESCRIPTOR.getSvnExe()+" log -v --xml --non-interactive -r "+(prevRev+1)+":BASE "+module; OutputStream os = new BufferedOutputStream(new FileOutputStream(changelogFile)); try { int r = launcher.launch(cmd,env,os,build.getProject().getWorkspace()).join(); if(r!=0) { listener.fatalError("revision check failed"); return false; } } finally { os.close(); } } return true; } |
|
private String checkFileType(File f){ String suff = f.getPath().substring(f.getPath().length()-3, f.getPath().length()); Debug.print(suff); if (suff.equalsIgnoreCase(".rec")) | private String checkFileType(File f) { if (f.getPath().endsWith(".rec")) | private String checkFileType(File f){ String suff = f.getPath().substring(f.getPath().length()-3, f.getPath().length()); Debug.print(suff); if (suff.equalsIgnoreCase(".rec")) return "promash"; // let's open it up and have a peek // we'll only read 10 lines try { FileReader in = new FileReader(f); BufferedReader inb = new BufferedReader(in); String c; int i = 0; while ((c = inb.readLine()) != null && i<10){ if (c.indexOf("BeerXML Format") > -1) return "beerxml"; if (c.indexOf("STRANGEBREWRECIPE") > -1) return "sb"; if (c.indexOf("generator=\"qbrew\"") > -1) return "qbrew"; i++; } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; } |
try { FileReader in = new FileReader(f); BufferedReader inb = new BufferedReader(in); String c; int i = 0; while ((c = inb.readLine()) != null && i<10){ if (c.indexOf("BeerXML Format") > -1) return "beerxml"; if (c.indexOf("STRANGEBREWRECIPE") > -1) return "sb"; if (c.indexOf("generator=\"qbrew\"") > -1) return "qbrew"; i++; | if (f.getPath().endsWith(".qbrew") || (f.getPath().endsWith(".xml"))) { try { FileReader in = new FileReader(f); BufferedReader inb = new BufferedReader(in); String c; int i = 0; while ((c = inb.readLine()) != null && i < 10) { if (c.indexOf("BeerXML Format") > -1) return "beerxml"; if (c.indexOf("STRANGEBREWRECIPE") > -1) return "sb"; if (c.indexOf("generator=\"qbrew\"") > -1) return "qbrew"; i++; } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); | private String checkFileType(File f){ String suff = f.getPath().substring(f.getPath().length()-3, f.getPath().length()); Debug.print(suff); if (suff.equalsIgnoreCase(".rec")) return "promash"; // let's open it up and have a peek // we'll only read 10 lines try { FileReader in = new FileReader(f); BufferedReader inb = new BufferedReader(in); String c; int i = 0; while ((c = inb.readLine()) != null && i<10){ if (c.indexOf("BeerXML Format") > -1) return "beerxml"; if (c.indexOf("STRANGEBREWRECIPE") > -1) return "sb"; if (c.indexOf("generator=\"qbrew\"") > -1) return "qbrew"; i++; } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; } |
} catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } | } | private String checkFileType(File f){ String suff = f.getPath().substring(f.getPath().length()-3, f.getPath().length()); Debug.print(suff); if (suff.equalsIgnoreCase(".rec")) return "promash"; // let's open it up and have a peek // we'll only read 10 lines try { FileReader in = new FileReader(f); BufferedReader inb = new BufferedReader(in); String c; int i = 0; while ((c = inb.readLine()) != null && i<10){ if (c.indexOf("BeerXML Format") > -1) return "beerxml"; if (c.indexOf("STRANGEBREWRECIPE") > -1) return "sb"; if (c.indexOf("generator=\"qbrew\"") > -1) return "qbrew"; i++; } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; } |
public Recipe openFile(File f){ String type = checkFileType(f); Debug.print("File type: " + type); if (type.equalsIgnoreCase("")){ Debug.print("Unrecognized file"); JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); myRecipe = new Recipe(); } if (type.equals("promash")){ PromashImport imp = new PromashImport(); | public Recipe openFile(File f) { fileType = checkFileType(f); Debug.print("File type: " + fileType); if (fileType.equals("promash")) { PromashImport imp = new PromashImport(); | public Recipe openFile(File f){ String type = checkFileType(f); Debug.print("File type: " + type); if (type.equalsIgnoreCase("")){ Debug.print("Unrecognized file"); JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); myRecipe = new Recipe(); } if (type.equals("promash")){ PromashImport imp = new PromashImport(); myRecipe = imp.readRecipe(f); } if (type.equals("sb") || type.equals("qbrew")){ ImportXml imp = new ImportXml(f.toString(), "recipe"); myRecipe = imp.handler.getRecipe(); } if (type.equals("beerxml")){ ImportXml imp = new ImportXml(f.toString(), "beerXML"); myRecipe = imp.beerXmlHandler.getRecipe(); } return myRecipe; } |
} if (type.equals("sb") || type.equals("qbrew")){ | } else if (fileType.equals("sb") || fileType.equals("qbrew")) { | public Recipe openFile(File f){ String type = checkFileType(f); Debug.print("File type: " + type); if (type.equalsIgnoreCase("")){ Debug.print("Unrecognized file"); JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); myRecipe = new Recipe(); } if (type.equals("promash")){ PromashImport imp = new PromashImport(); myRecipe = imp.readRecipe(f); } if (type.equals("sb") || type.equals("qbrew")){ ImportXml imp = new ImportXml(f.toString(), "recipe"); myRecipe = imp.handler.getRecipe(); } if (type.equals("beerxml")){ ImportXml imp = new ImportXml(f.toString(), "beerXML"); myRecipe = imp.beerXmlHandler.getRecipe(); } return myRecipe; } |
} if (type.equals("beerxml")){ | } else if (fileType.equals("beerxml")) { | public Recipe openFile(File f){ String type = checkFileType(f); Debug.print("File type: " + type); if (type.equalsIgnoreCase("")){ Debug.print("Unrecognized file"); JOptionPane.showMessageDialog( null, "The file you've tried to open isn't a recognized format. \n" + "You can open: \n" + "StrangeBrew 1.x and Java files (.xml)\n" + "QBrew files (.qbrew)\n" + "BeerXML files (.xml)\n" + "Promash files (.rec)", "Unrecognized Format!", JOptionPane.INFORMATION_MESSAGE); myRecipe = new Recipe(); } if (type.equals("promash")){ PromashImport imp = new PromashImport(); myRecipe = imp.readRecipe(f); } if (type.equals("sb") || type.equals("qbrew")){ ImportXml imp = new ImportXml(f.toString(), "recipe"); myRecipe = imp.handler.getRecipe(); } if (type.equals("beerxml")){ ImportXml imp = new ImportXml(f.toString(), "beerXML"); myRecipe = imp.beerXmlHandler.getRecipe(); } return myRecipe; } |
if(names!=null && cmds!=null && rfs!=null && lfs!=null) { int len = Math.min( Math.min(names.length,cmds.length), Math.min(rfs.length, lfs.length) ); | if(names!=null && descriptions!=null && cmds!=null && rfs!=null && lfs!=null) { int len = Util.min(names.length,descriptions.length,cmds.length,rfs.length, lfs.length); | public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException { if(!Hudson.adminCheck(req,rsp)) return; useSecurity = req.getParameter("use_security")!=null; numExecutors = Integer.parseInt(req.getParameter("numExecutors")); quietPeriod = Integer.parseInt(req.getParameter("quiet_period")); {// update slave list slaves.clear(); String [] names = req.getParameterValues("slave_name"); String [] cmds = req.getParameterValues("slave_command"); String [] rfs = req.getParameterValues("slave_remoteFS"); String [] lfs = req.getParameterValues("slave_localFS"); if(names!=null && cmds!=null && rfs!=null && lfs!=null) { int len = Math.min( Math.min(names.length,cmds.length), Math.min(rfs.length, lfs.length) ); for(int i=0;i<len;i++) { slaves.add(new Slave(names[i],cmds[i],rfs[i],new File(lfs[i]))); } } } {// update JDK installations jdks.clear(); String[] names = req.getParameterValues("jdk_name"); String[] homes = req.getParameterValues("jdk_home"); if(names!=null && homes!=null) { int len = Math.min(names.length,homes.length); for(int i=0;i<len;i++) { jdks.add(new JDK(names[i],homes[i])); } } } for( Executor e : executors ) if(e.getCurrentBuild()==null) e.interrupt(); while(executors.size()<numExecutors) executors.add(new Executor(this)); boolean result = true; for( BuildStepDescriptor d : BuildStep.BUILDERS ) result &= d.configure(req); for( BuildStepDescriptor d : BuildStep.PUBLISHERS ) result &= d.configure(req); for( SCMDescriptor scmd : SCMManager.getSupportedSCMs() ) result &= scmd.configure(req); save(); if(result) rsp.sendRedirect("."); // go to the top page else rsp.sendRedirect("configure"); // back to config } |
slaves.add(new Slave(names[i],cmds[i],rfs[i],new File(lfs[i]))); | slaves.add(new Slave(names[i],descriptions[i],cmds[i],rfs[i],new File(lfs[i]))); | public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException { if(!Hudson.adminCheck(req,rsp)) return; useSecurity = req.getParameter("use_security")!=null; numExecutors = Integer.parseInt(req.getParameter("numExecutors")); quietPeriod = Integer.parseInt(req.getParameter("quiet_period")); {// update slave list slaves.clear(); String [] names = req.getParameterValues("slave_name"); String [] cmds = req.getParameterValues("slave_command"); String [] rfs = req.getParameterValues("slave_remoteFS"); String [] lfs = req.getParameterValues("slave_localFS"); if(names!=null && cmds!=null && rfs!=null && lfs!=null) { int len = Math.min( Math.min(names.length,cmds.length), Math.min(rfs.length, lfs.length) ); for(int i=0;i<len;i++) { slaves.add(new Slave(names[i],cmds[i],rfs[i],new File(lfs[i]))); } } } {// update JDK installations jdks.clear(); String[] names = req.getParameterValues("jdk_name"); String[] homes = req.getParameterValues("jdk_home"); if(names!=null && homes!=null) { int len = Math.min(names.length,homes.length); for(int i=0;i<len;i++) { jdks.add(new JDK(names[i],homes[i])); } } } for( Executor e : executors ) if(e.getCurrentBuild()==null) e.interrupt(); while(executors.size()<numExecutors) executors.add(new Executor(this)); boolean result = true; for( BuildStepDescriptor d : BuildStep.BUILDERS ) result &= d.configure(req); for( BuildStepDescriptor d : BuildStep.PUBLISHERS ) result &= d.configure(req); for( SCMDescriptor scmd : SCMManager.getSupportedSCMs() ) result &= scmd.configure(req); save(); if(result) rsp.sendRedirect("."); // go to the top page else rsp.sendRedirect("configure"); // back to config } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.