bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
public UserLog findLastUserLog(String principal) { try { // two different queries to grant compatibility with all databases Date lastLogin = (Date) findUnique(LASTUSERLOGDATE_QUERY, principal); List<UserLog> userLogList = (ArrayList<UserLog>) find(LASTUSERLOG_QUERY, principal, lastLogin ); if (logger.isDebugEnabled()) { for (UserLog ul: userLogList) { logger.debug("Found UserLog(s) with principal "+principal+"[" +ul.getUser().getIdentity().getPrincipal()+"]: "+ul.getUser()+" - "+ul.getLastLogin()); } } if (userLogList.size()>0) { return userLogList.get(0); } return null; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Exception "+e.toString()); } throw new DataRetrievalFailureException("Unable to find UserLogs for principal: "+principal); } }
public UserLog findLastUserLog(String principal) { try { // two different queries to grant compatibility with all databases Date lastLogin = findLastIdentityLogDate(principal); List<UserLog> userLogList = (ArrayList<UserLog>) find(LASTUSERLOG_QUERY, principal, lastLogin ); if (logger.isDebugEnabled()) { for (UserLog ul: userLogList) { logger.debug("Found UserLog(s) with principal "+principal+"[" +ul.getUser().getIdentity().getPrincipal()+"]: "+ul.getUser()+" - "+ul.getLastLogin()); } } if (userLogList.size()>0) { return userLogList.get(0); } return null; } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug("Exception "+e.toString()); } throw new DataRetrievalFailureException("Unable to find UserLogs for principal: "+principal); } }
1,116,282
public Object exp(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.exp(((Number)param).doubleValue())); } else if (param instanceof Complex) { Complex z = (Complex) param; double x = z.re(); double y = z.im(); double mod = Math.exp(x); return new Complex(mod*Math.cos(y),mod*Math.sin(y)); } throw new ParseException("Invalid parameter type"); }
public Object exp(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.exp(((Number)param).doubleValue())); } else if (param instanceof Complex) { Complex z = (Complex) param; double x = z.re(); double y = z.im(); double mod = Math.exp(x); return new Complex(mod*Math.cos(y),mod*Math.sin(y)); } throw new ParseException("Invalid parameter type"); }
1,116,283
public synchronized void doLoginEntry( StaplerRequest req, StaplerResponse rsp ) throws IOException { rsp.sendRedirect(req.getContextPath()); }
public synchronized void doLoginEntry( StaplerRequest req, StaplerResponse rsp ) throws IOException { rsp.sendRedirect(req.getContextPath()+"/"); }
1,116,285
public synchronized void doLogout( StaplerRequest req, StaplerResponse rsp ) throws IOException { HttpSession session = req.getSession(false); if(session!=null) session.invalidate(); rsp.sendRedirect(req.getContextPath()); }
public synchronized void doLogout( StaplerRequest req, StaplerResponse rsp ) throws IOException { HttpSession session = req.getSession(false); if(session!=null) session.invalidate(); rsp.sendRedirect(req.getContextPath()+"/"); }
1,116,286
public synchronized void doReload( StaplerRequest req, StaplerResponse rsp ) throws IOException { if(!Hudson.adminCheck(req,rsp)) return; load(); rsp.sendRedirect(req.getContextPath()); }
public synchronized void doReload( StaplerRequest req, StaplerResponse rsp ) throws IOException { if(!Hudson.adminCheck(req,rsp)) return; load(); rsp.sendRedirect(req.getContextPath()+"/"); }
1,116,287
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI param1,MatrixValueI param2) throws ParseException {// Number num = (Number) rhs.getEle(0);// res.setEle(0,lhs.getEle(num.intValue()-1)); if(param1 instanceof MVector) { if(param2 instanceof Scaler) { int index = ((Double) param2.getEle(0)).intValue()-1; Object val = ((MVector) param1).getEle(index); res.setEle(0,val); } else throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); res.setEle(0,val); } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } else throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); return res; }
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI param1,MatrixValueI param2) throws ParseException {// Number num = (Number) rhs.getEle(0);// res.setEle(0,lhs.getEle(num.intValue()-1)); if(param1 instanceof MVector) { if(param2 instanceof Scaler) { int index = ((Number) param2.getEle(0)).intValue()-1; Object val = ((MVector) param1).getEle(index); res.setEle(0,val); } else throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); res.setEle(0,val); } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } else throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); return res; }
1,116,288
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI param1,MatrixValueI param2) throws ParseException {// Number num = (Number) rhs.getEle(0);// res.setEle(0,lhs.getEle(num.intValue()-1)); if(param1 instanceof MVector) { if(param2 instanceof Scaler) { int index = ((Double) param2.getEle(0)).intValue()-1; Object val = ((MVector) param1).getEle(index); res.setEle(0,val); } else throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); res.setEle(0,val); } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } else throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); return res; }
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI param1,MatrixValueI param2) throws ParseException {// Number num = (Number) rhs.getEle(0);// res.setEle(0,lhs.getEle(num.intValue()-1)); if(param1 instanceof MVector) { if(param2 instanceof Scaler) { int index = ((Double) param2.getEle(0)).intValue()-1; Object val = ((MVector) param1).getEle(index); res.setEle(0,val); } else throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); res.setEle(0,val); } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } else throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); return res; }
1,116,289
public void run(Stack stack) throws ParseException { checkStack(stack); // check the stack Object param1,param2; // get the parameter from the stack param2 = stack.pop(); param1 = stack.pop(); if(param1 instanceof MVector) { if(param2 instanceof Double) { Object val = ((MVector) param1).getEle(((Double) param2).intValue()-1); stack.push(val); return; } throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); stack.push(val); return; } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); }
public void run(Stack stack) throws ParseException { checkStack(stack); // check the stack Object param1,param2; // get the parameter from the stack param2 = stack.pop(); param1 = stack.pop(); if(param1 instanceof MVector) { if(param2 instanceof Number) { Object val = ((MVector) param1).getEle(((Double) param2).intValue()-1); stack.push(val); return; } throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); stack.push(val); return; } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); }
1,116,290
public void run(Stack stack) throws ParseException { checkStack(stack); // check the stack Object param1,param2; // get the parameter from the stack param2 = stack.pop(); param1 = stack.pop(); if(param1 instanceof MVector) { if(param2 instanceof Double) { Object val = ((MVector) param1).getEle(((Double) param2).intValue()-1); stack.push(val); return; } throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); stack.push(val); return; } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); }
public void run(Stack stack) throws ParseException { checkStack(stack); // check the stack Object param1,param2; // get the parameter from the stack param2 = stack.pop(); param1 = stack.pop(); if(param1 instanceof MVector) { if(param2 instanceof Double) { Object val = ((MVector) param1).getEle(((Number) param2).intValue()-1); stack.push(val); return; } throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); stack.push(val); return; } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); }
1,116,291
public void run(Stack stack) throws ParseException { checkStack(stack); // check the stack Object param1,param2; // get the parameter from the stack param2 = stack.pop(); param1 = stack.pop(); if(param1 instanceof MVector) { if(param2 instanceof Double) { Object val = ((MVector) param1).getEle(((Double) param2).intValue()-1); stack.push(val); return; } throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); stack.push(val); return; } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); }
public void run(Stack stack) throws ParseException { checkStack(stack); // check the stack Object param1,param2; // get the parameter from the stack param2 = stack.pop(); param1 = stack.pop(); if(param1 instanceof MVector) { if(param2 instanceof Double) { Object val = ((MVector) param1).getEle(((Double) param2).intValue()-1); stack.push(val); return; } throw new ParseException("Bad second argument to ele, expecting a double "+param2.toString()); } else if(param1 instanceof Matrix) { if(param2 instanceof MVector) { MVector vec = (MVector) param2; if(vec.getDim().equals(Dimensions.TWO)) { Double d1 = (Double) vec.getEle(0); Double d2 = (Double) vec.getEle(1); Object val = ((Matrix) param1).getEle(d1.intValue()-1,d2.intValue()-1); stack.push(val); return; } } else throw new ParseException("Bad second argument to ele, expecting [i,j] "+param2.toString()); } else if(param1 instanceof Tensor) { throw new ParseException("Sorry don't know how to find elements for a tensor"); } throw new ParseException("ele requires a vector matrix or tensor for first argument it has "+param1.toString()); }
1,116,292
private void loadProperties() { try { String path = getPath(); File inputFile = new File(path + getSep() + type + ".ini"); if (inputFile.exists()){ props.load(new FileInputStream(inputFile)); Debug.print(type + ".ini file read: " + inputFile.getAbsolutePath() +". Contents:"); } } catch (Exception e) { System.out.println(e); } }
private void loadProperties() { try { String path = getPath(); File inputFile = new File(path + getSep() + type + ".ini"); if (inputFile.exists()){ props.load(new FileInputStream(inputFile)); Debug.print(type + ".ini file read: " + inputFile.getAbsolutePath() +". Contents:"); } } catch (Exception e) { System.out.println(e); } }
1,116,293
public void saveProperties() { try{ String path = getPath(); Debug.print("Storing props: " + path); FileOutputStream out = new FileOutputStream(path + "\\" + type +".ini"); props.store(out, "/* properties updated */"); } catch (Exception e) { System.out.println(e); } }
public void saveProperties() { try{ String path = getPath(); Debug.print("Storing props: " + path); FileOutputStream out = new FileOutputStream(path + "\\" + type +".ini"); props.store(out, "/* properties updated */"); } catch (Exception e) { System.out.println(e); } }
1,116,294
public AdvancedFilterAction() { super( Localizer.getString( "AdvancedSearchFilter" ), IconFactory.EMPTY_IMAGE_16, Localizer.getString( "TTTAdvancedSearchFilter" ) ); refreshActionState(); }
public AdvancedFilterAction() { super( Localizer.getString( "AdvancedSearchFilter" ), IconFactory.EMPTY_IMAGE_16, Localizer.getString( "TTTAdvancedSearchFilter" ) ); refreshActionState(); }
1,116,295
public boolean equals(PNodeI node) { if(!(node instanceof POperator)) return false; POperator op = (POperator) node; if(!this.op.equals(op)) return false; if(args.length != op.args.length) return false; for(int i=0;i<args.length;++i) if(!args[i].equals(op.args[i])) return false; return true; }
public boolean equals(PNodeI node) { if(!(node instanceof POperator)) return false; POperator op = (POperator) node; if(!this.op.equals(op)) return false; if(args.length != op.args.length) return false; for(int i=0;i<args.length;++i) if(!args[i].equals(op.args[i])) return false; return true; }
1,116,296
public boolean equals(PNodeI node) { if(!(node instanceof POperator)) return false; POperator op = (POperator) node; if(!this.op.equals(op)) return false; if(args.length != op.args.length) return false; for(int i=0;i<args.length;++i) if(!args[i].equals(op.args[i])) return false; return true; }
public boolean equals(PNodeI node) { if(!(node instanceof POperator)) return false; POperator op = (POperator) node; if(!this.op.equals(op)) return false; if(args.length != op.args.length) return false; for(int i=0;i<args.length;++i) if(!args[i].equals(nodeOp.args[i])) return false; return true; }
1,116,297
private String checkFileType(File f) { if (f.getPath().endsWith(".rec")) return "promash"; // let's open it up and have a peek // we'll only read 10 lines 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) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return ""; }
private String checkFileType(File f) { if (f.getPath().endsWith(".rec")) return "promash"; // let's open it up and have a peek // we'll only read 10 lines 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 (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return ""; }
1,116,298
private String checkFileType(File f) { if (f.getPath().endsWith(".rec")) return "promash"; // let's open it up and have a peek // we'll only read 10 lines 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) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return ""; }
private String checkFileType(File f) { if (f.getPath().endsWith(".rec")) return "promash"; // let's open it up and have a peek // we'll only read 10 lines 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) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return ""; }
1,116,299
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); }
public PNodeI div(PNodeI c) throws ParseException { if(this.isZero()) { if(c.isZero()) return pc.nanConstant; 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); }
1,116,300
public boolean equals(PNodeI node) { if(node instanceof Constant) return value.equals(((Constant)node).value); else return false; }
public boolean equals(PNodeI node) { if(node instanceof Constant) return value.equals(((Constant)node).value); else return false; }
1,116,301
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); }
public PNodeI pow(PNodeI c) throws ParseException { if(this.isZero()){ if(c.isZero()) return pc.nanConstant; 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); }
1,116,302
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; }
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.equalsIgnoreCase("Volume")) // convert to by volume alcohol = alcohol * estFg / 0.794; }
1,116,304
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(); }
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(); }
1,116,305
public static final int getPixel(int totalPixels, UnitRangeImpl range, double value) { return (int)Math.round(linearInterp(range.getMinValue(), 0, range.getMaxValue(), totalPixels, value)); }
public static final int getPixel(int totalPixels, UnitRangeImpl range, double value) { return (int)Math.round(linearInterp(range.getMinValue(), 0, range.getMaxValue(), totalPixels, value)); }
1,116,307
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; } }
public int compare( SearchResultElement sr1, SearchResultElement sr2 ) { 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; } }
1,116,308
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; } }
public int compare(Object obj1, Object obj2) { if( sr1 == sr2 || sr1.equals( sr2 ) ) { 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; } }
1,116,309
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; } }
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; } }
1,116,310
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]); }
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]); }
1,116,311
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]); }
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]); }
1,116,312
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(); }
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(); }
1,116,313
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() ); } }
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: msgDispatcher.handlePing((PingMsg)message, connectedHost ); 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() ); } }
1,116,315
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() ); } }
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: msgDispatcher.handlePong( (PongMsg)message, connectedHost ); 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() ); } }
1,116,316
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() ); } }
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: msgDispatcher.handlePushRequest( (PushRequestMsg) message, connectedHost ); 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() ); } }
1,116,317
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() ); } }
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: msgDispatcher.handleQuery( (QueryMsg) message, connectedHost ); 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() ); } }
1,116,318
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() ); } }
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: msgDispatcher.handleQueryResponse( (QueryResponseMsg) message, connectedHost ); 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() ); } }
1,116,319
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() ); } }
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: msgDispatcher.handleRouteTableUpdate( (RouteTableUpdateMsg) message, connectedHost ); 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() ); } }
1,116,320
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() ); } }
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: msgDispatcher.handleVendorMessage( (VendorMsg) message, connectedHost ); 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() ); } }
1,116,321
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 ); }
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 ); }
1,116,323
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 ); }
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 ); }
1,116,324
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 ); }
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<Rule>(); SearchFilterRules filterRules = QueryManager.getInstance().getSearchFilterRules(); searchFilterRuleSet.addAll( filterRules.getPermanentList() ); search.addSearchChangeListener( this ); PhexSecurityManager.getInstance().addSecurityRuleChangeListener( this ); }
1,116,325
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); } } }
private void addSearchResultForDisplay(RemoteFile remoteFile) { SearchResultElement resultElement = null; String sha1 = remoteFile.getSHA1(); if ( sha1 != null ) { resultElement = 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); } } }
1,116,326
public SearchResultElement getSearchElementAt( int index ) { if ( index < 0 || index >= displayedSearchResults.size() ) { return null; } return (SearchResultElement)displayedSearchResults.get( index ); }
public SearchResultElement getSearchElementAt( int index ) { if ( index < 0 || index >= displayedSearchResults.size() ) { return null; } return displayedSearchResults.get( index ); }
1,116,327
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); } }
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); } }
1,116,328
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); } }
private void processFilterRules( RemoteFile[] remoteFiles ) { if ( searchFilterRuleSet == null ) { return; } if ( quickFilterRule != null ) { quickFilterRule.process(search, remoteFiles); } Iterator iterator = searchFilterRuleSet.iterator(); while( iterator.hasNext() ) { rule.process(search, remoteFiles); } }
1,116,329
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(); } } }
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<RemoteFile> remoteFilesList = new ArrayList<RemoteFile>( 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(); } } }
1,116,330
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(); } } }
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<RemoteFile> 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(); } } }
1,116,331
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(); } } }
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 = 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(); } } }
1,116,332
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"); }
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"); }
1,116,333
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"); }
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"); }
1,116,334
public void setAsText(String id) throws IllegalArgumentException { setAsText(id, ExternalDocument.class); }
public void setAsText(String id) throws IllegalArgumentException { 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); } }
1,116,335
public int getDownloadFileCount( int status ) { int count = 0; synchronized( downloadList ) { for ( SWDownloadFile file : downloadList ) { if ( file.getStatus() == status ) { count ++; } } } return count; }
public int getDownloadFileCount() { int count = 0; synchronized( downloadList ) { for ( SWDownloadFile file : downloadList ) { if ( file.getStatus() == status ) { count ++; } } } return count; }
1,116,337
public int getDownloadFileCount( int status ) { int count = 0; synchronized( downloadList ) { for ( SWDownloadFile file : downloadList ) { if ( file.getStatus() == status ) { count ++; } } } return count; }
public int getDownloadFileCount( int status ) { int count = 0; synchronized( downloadList ) { for ( SWDownloadFile file : downloadList ) { if ( file.getStatus() == status ) { count ++; } } } return count; }
1,116,338
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()); }
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(PSNDataFile.chopToLength(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()); }
1,116,339
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()); }
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(PSNDataFile.chopToLength(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()); }
1,116,340
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()); }
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(PSNDataFile.chopToLength(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()); }
1,116,341
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()); }
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(PSNDataFile.chopToLength(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()); }
1,116,342
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); }
MutiableMonomial toMutiableMonomial() { 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); }
1,116,343
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); }
PNodeI valueOf(Constant coefficient,PNodeI terms[],PNodeI pows[]) { if(coeff.isZero()) return pc.zeroConstant; if(terms.length ==0) return coeff; return new Monomial(pc,coeff,terms,pows); }
1,116,344
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); }
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); }
1,116,345
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()]); }
private StationId[] extractAll(PreparedStatement query) throws SQLException { 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()]); }
1,116,346
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 }
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 }
1,116,347
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 }
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 }
1,116,348
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 } } }
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 (final File subdir : subdirs) { try { Job p = Job.load(this,subdirs[i]); jobs.put(p.getName(),p); } catch( IOException e ) { e.printStackTrace(); // TODO: logging } } }
1,116,349
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 } } }
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 } } }
1,116,350
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"); }
public Object cosh(Object param) throws ParseException { if (param instanceof Complex) { return ((Complex)param).cosh(); } else 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"); }
1,116,351
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"); }
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"); }
1,116,352
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; }
public boolean hasFreeLeafSlots() { if ( ggepBlock == null || !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; }
1,116,353
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; }
public boolean hasFreeUPSlots() { if ( ggepBlock == null || !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; }
1,116,354
public void doBuildStatus( StaplerRequest req, StaplerResponse rsp ) throws IOException { rsp.sendRedirect(req.getContextPath()+"/images/48x48/"+getBuildStatusUrl()); }
public void doBuildStatus( StaplerRequest req, StaplerResponse rsp ) throws IOException { rsp.sendRedirect(req.getContextPath()+"/nocacheImages/48x48/"+getBuildStatusUrl()); }
1,116,355
public Node deepCopy(Node node,XJep xjep) throws ParseException { this.xjep = xjep; Node res = (Node) node.jjtAccept(this,null); return res; }
public Node deepCopy(Node node,XJep xj) throws ParseException { this.xjep = xjep; Node res = (Node) node.jjtAccept(this,null); return res; }
1,116,360
public Node deepCopy(Node node,XJep xjep) throws ParseException { this.xjep = xjep; Node res = (Node) node.jjtAccept(this,null); return res; }
public Node deepCopy(Node node,XJep xjep) throws ParseException { this.xjep = xj; Node res = (Node) node.jjtAccept(this,null); return res; }
1,116,361
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 = ""; } } }
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.equalsIgnoreCase("DETAILS")) ) { 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 = ""; } } }
1,116,362
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(); } } }
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.equals("DETAILS")) { 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(); } } }
1,116,363
public Object locateService(String name) { Reference ref = config.getReference(name); return ref.getService(); }
public Object locateService(Object bindObject, String name) { Reference ref = config.getReference(name); return ref.getService(); }
1,116,364
public Object locateService(String name) { Reference ref = config.getReference(name); return ref.getService(); }
public Object locateService(String name) { Reference ref = config.getReference(name); return ref.getService(bindObject); }
1,116,365
public Object[] locateServices(String name) { Reference ref = config.getReference(name); return ref.getServiceReferences(); }
public Object[] locateServices(Object bindObject, String name) { Reference ref = config.getReference(name); return ref.getServiceReferences(); }
1,116,366
public Object[] locateServices(String name) { Reference ref = config.getReference(name); return ref.getServiceReferences(); }
public Object[] locateServices(String name) { Reference ref = config.getReference(name); 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; }
1,116,367
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; }
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, getDuplexObject()); 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; }
1,116,369
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; }
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, getDuplexObject()); instance = null; componentContext = null; return; } active = true; }
1,116,370
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; }
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, getDuplexObject()); instance = null; componentContext = null; componentInstance = null; active = false; }
1,116,371
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 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); }
1,116,372
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 bindReferences(Object instance, Object duplexObject) { for (int i = 0; i < references.size(); i++) { ((Reference) references.get(i)).bind(instance); } for (DuplexReference ref : this.duplexReferences) { ref.bind(instance, bundle); } }
1,116,373
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 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, duplexObject); } }
1,116,374
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); } }
public void unbindReferences(Object instance, Object duplexObject) { for (int i = this.duplexReferences.size() - 1; i >= 0; i--) { this.duplexReferences.get(i).unbind(instance, duplexObject); } for (int i = references.size() - 1; i >= 0; i--) { ((Reference) references.get(i)).unbind(instance); } for (DuplexReference ref : this.duplexReferences) { ref.unbind(instance); } }
1,116,375
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); } }
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); } }
1,116,376
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; }
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; }
1,116,377
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; }
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; }
1,116,378
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; }
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( val2Str ); } catch ( NumberFormatException exp ) { val2 = Integer.MAX_VALUE; } if ( val1 == val2 ) { return key2.hashCode() - key1.hashCode(); } return val2 - val1; }
1,116,379
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; }
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 key1.hashCode() - key2.hashCode(); } return val2 - val1; }
1,116,380
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; }
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 val1 - val2; }
1,116,381
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; }
private static List<String> deserializeList( String name, Preferences preferences ) { List<String> list = new ArrayList<String>(); List<String> names = preferences.getPrefixedPropertyNames( name + LIST_DESER_POSTFIX ); Collections.sort( names, new ListPostfixKeyComparator() ); for ( String key : names ) { String value = preferences.getLoadedProperty( key ); if ( !StringUtils.isEmpty( value ) ) { list.add( value ); } } return list; }
1,116,382
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; }
private static Set<String> deserializeSet( String name, Preferences preferences ) { Set<String> set = new HashSet<String>(); String prefix = new String ( name + SET_DESER_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; }
1,116,383
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 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 ) { 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() ); } }
1,116,384
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 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( name + String.format( SET_SER_POSTFIX, new Integer( pos++ ) ), 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() ); } }
1,116,385
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 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 ) { 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() ); } }
1,116,386
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 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( name + String.format( LIST_SER_POSTFIX, new Integer( i ) ), listValue.get( i ) ); } } else { NLogger.error( PreferencesFactory.class, "Unknwon settings value type: " + value.getClass() ); } }
1,116,387
public Rational(BigInteger num) { numerator = num; denominator = BigInteger.ONE; }
public Rational(BigInteger num) { numerator = num; denominator = BigInteger.ONE; }
1,116,388
public String toString() { if(denominator.equals(BigInteger.ONE)) return numerator.toString(); else return numerator.toString() +"/" + denominator.toString(); }
public String toString() { if(denominator.equals(BigInteger.ONE)) return numerator.toString(); else return numerator.toString() +"/" + denominator.toString(); }
1,116,389
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))); }
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))); }
1,116,390
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 ""; }
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 ""; }
1,116,392
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 ""; }
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 ""; }
1,116,393