rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
sb.append( " <DESCRIPTION>"+getDescription()+"</DESCRIPTION>\n" );
sb.append( " <DESCRIPTION>"+SBStringUtils.subEntities(getDescription())+"</DESCRIPTION>\n" );
public String toXML(){ StringBuffer sb = new StringBuffer(); sb.append( " <ITEM>\n" ); sb.append( " <MALT>"+getName()+"</MALT>\n" ); sb.append( " <AMOUNT>"+getAmountAs(getUnits())+"</AMOUNT>\n" ); sb.append( " <UNITS>"+getUnitsAbrv()+"</UNITS>\n" ); sb.append( " <POINTS>"+pppg+"</POINTS>\n" ); sb.append( " <LOV>"+lov+"</LOV>\n" ); sb.append( " <MASHED>"+mashed+"</MASHED>\n" ); sb.append( " <STEEPED>"+steeped+"</STEEPED>\n" ); sb.append( " <COSTLB>"+getCostPerU()+"</COSTLB>\n" ); sb.append( " <DESCRIPTION>"+getDescription()+"</DESCRIPTION>\n" ); sb.append( " </ITEM>\n" ); return sb.toString(); }
public BasicTimeConfig(DataSetSeismogram[] seismos){ add(seismos); }
public BasicTimeConfig(){}
public BasicTimeConfig(DataSetSeismogram[] seismos){ add(seismos); }
public ConfigEvent(DataSetSeismogram[] seismos, TimeEvent time, AmpEvent amp){ this.seismos = seismos; this.time = time; this.amp = amp;
public ConfigEvent(DataSetSeismogram[] seismos, MicroSecondTimeRange[] times, UnitRangeImpl[] amps){ this(seismos, new TimeEvent(seismos, times), new AmpEvent(seismos, amps));
public ConfigEvent(DataSetSeismogram[] seismos, TimeEvent time, AmpEvent amp){ this.seismos = seismos; this.time = time; this.amp = amp; }
dayCache.remove(ChannelIdUtil.toString(channel_id));
dayCache.remove(key);
get_for_day(edu.iris.Fissures.IfNetwork.ChannelId channel_id, int year, int jday, edu.iris.Fissures.Dimension pixel_size) throws PlottableNotAvailable, UnsupportedDimension { SoftReference ref; Plottable[] plottableArray; String key = ChannelIdUtil.toString(channel_id)+"."+Integer.toString(year)+"."+Integer.toString(jday); ref = (SoftReference)dayCache.get(key); if(ref != null) { plottableArray = (Plottable[])ref.get(); if(plottableArray != null) { return plottableArray; } else { dayCache.remove(ChannelIdUtil.toString(channel_id)); } } plottableArray = plottableDC.get_for_day(channel_id, year, jday, pixel_size); dayCache.put(key, new SoftReference(plottableArray)); return plottableArray; }
this.verifyPassword = "";
public void setPasswordDirty(boolean passwordDirty) { this.verifyPassword = ""; this.passwordDirty = passwordDirty; }
this.passwordDirty = true;
public void setVerifyPassword(String verifyPassword) { this.verifyPassword = verifyPassword; }
public String createFileName(DataSet dataset) {
public static String createFileName(DataSet dataset) {
public String createFileName(DataSet dataset) { String filename = dataset.getName()+".dsml"; filename = filename.replaceAll(" ","_"); filename = filename.replaceAll(",","_"); filename = filename.replaceAll("/","_"); filename = filename.replaceAll(":","_"); // filename = filename.replaceAll("\\","_"); return filename; }
String childDirName = childDataSets[i].replace(' ','_');
String childDirName = createFileName(dataset.getDataSet(childDataSets[i]));
public void insertInto(Element element, DataSet dataset, File directory) throws IOException, ParserConfigurationException, MalformedURLException { Document doc = element.getOwnerDocument(); element.setAttribute("datasetid", dataset.getId()); element.appendChild(XMLUtil.createTextElement(doc, "name", dataset.getName())); element.appendChild(XMLUtil.createTextElement(doc, "owner", dataset.getOwner())); String[] childDataSets = dataset.getDataSetNames(); for (int i = 0; i < childDataSets.length; i++) { String childDirName = childDataSets[i].replace(' ','_'); File childDirectory = new File(directory, childDirName); if ( ! childDirectory.exists()) { childDirectory.mkdirs(); } if (useDataSetRef) { insertRef(element, dataset.getDataSet(childDataSets[i]), childDirectory); } else { insert(element, dataset.getDataSet(childDataSets[i]), childDirectory); } } String[] childDSS = dataset.getDataSetSeismogramNames(); File dataDir = new File(directory, "data"); dataDir.mkdirs(); for (int i = 0; i < childDSS.length; i++) { DataSetSeismogram dss = dataset.getDataSetSeismogram(childDSS[i]); URLDataSetSeismogram urlDSS; if (saveLocally || ! (dss instanceof URLDataSetSeismogram)) { urlDSS = URLDataSetSeismogram.localize(dss, dataDir); } else { urlDSS = (URLDataSetSeismogram)dss; } insert(element, urlDSS, directory.toURI().toURL()); } String[] paramNames = dataset.getParameterNames(); for (int i = 0; i < paramNames.length; i++) { insert(element, paramNames[i], dataset.getParameter(paramNames[i])); } }
return insertRef(element, dsFile.toURI().toURL().toString(), dataset.getName());
return insertRef(element, directory.getName()+"/"+dsFile.getName(), dataset.getName());
public Element insertRef(Element element, DataSet dataset, File directory) throws IOException, ParserConfigurationException, MalformedURLException { File dsFile = save(dataset, directory); return insertRef(element, dsFile.toURI().toURL().toString(), dataset.getName()); }
if(config == null) return null;
if(config == null) return new String("");
public static String getText(Element config) { if(config == null) return null; NodeList children = config.getChildNodes(); Node node; for (int i=0; i<children.getLength(); i++) { node = children.item(i); if (node instanceof Text) { return node.getNodeValue(); } } //nothing found, return null return null; }
return null;
return new String("");
public static String getText(Element config) { if(config == null) return null; NodeList children = config.getChildNodes(); Node node; for (int i=0; i<children.getLength(); i++) { node = children.item(i); if (node instanceof Text) { return node.getNodeValue(); } } //nothing found, return null return null; }
while(datasetSeismogramNames.contains(dss.getName())) {
while(datasetSeismogramNames.contains(tmpName)) {
public void addDataSetSeismogram(DataSetSeismogram dss, AuditInfo[] audit) { if (datasetSeismogramNames.contains(dss.getName())) { int n = 1; String tmpName = dss.getName(); while(datasetSeismogramNames.contains(dss.getName())) { n++; tmpName = dss.getName()+"."+n; } // found a num that isn't used dss.setName(tmpName); } dss.setDataSet(this); datasetSeismograms.put(dss.getName(), dss); datasetSeismogramNames.add(dss.getName()); }
invokeQueryMoreGWebCachesRequest( false );
public void run() { try { // no gwebcache actions if we have no auto connect and are // not connected to any host NetworkHostsContainer networkHostsCont = HostManager.getInstance().getNetworkHostsContainer(); if ( NetworkManager.getInstance().isConnected() || networkHostsCont.getTotalConnectionCount() > 0 ) { invokeQueryMoreGWebCachesRequest( false ); invokeQueryMoreHostsRequest( true ); } } catch ( Throwable th) { NLogger.error( NLoggerNames.GWEBCACHE, th, th ); } }
invokeQueryMoreGWebCachesRequest( false );
public void run() { // no gwebcache actions if we have no auto connect and are // not connected to any host NetworkHostsContainer networkHostsCont = HostManager.getInstance().getNetworkHostsContainer(); NetworkManager networkMgr = NetworkManager.getInstance(); if ( networkMgr.isConnected() || networkHostsCont.getTotalConnectionCount() > 0 ) { DestAddress localAddress = null; if ( networkMgr.hasConnectedIncoming() ) { localAddress = networkMgr.getLocalAddress(); IpAddress localIp = localAddress.getIpAddress(); if ( localIp != null && localIp.isSiteLocalIP() ) { localAddress = null; } } // even when localAddress is null update a GWebCache with // a new GWebCache URL. invokeUpdateRemoteGWebCache( localAddress, true ); } }
assert !gWebCache.isPhexCache() && gWebCache.equals( connection.getGWebCache() )
assert !gWebCache.isPhexCache() && !gWebCache.equals( connection.getGWebCache() )
public boolean updateRemoteGWebCache( DestAddress myHostAddress, boolean preferPhex ) { String fullHostName = null; if ( myHostAddress != null ) { fullHostName = myHostAddress.getFullHostName(); } int retrys = 0; boolean succ = false; do { retrys ++; GWebCacheConnection connection = getRandomGWebCacheConnection( preferPhex ); // continue if no connection... if ( connection == null ) { continue; } GWebCache gWebCache = getGWebCacheForUpdate( connection.getGWebCache() ); assert !gWebCache.isPhexCache() && gWebCache.equals( connection.getGWebCache() ) : "isPhexCache: " + gWebCache.isPhexCache() + ",equals " + gWebCache.getUrl() + " - " + connection.getGWebCache().getUrl(); String urlString = null; if ( gWebCache != null ) { urlString = gWebCache.getUrl().toExternalForm(); } if ( fullHostName == null && urlString == null ) { // no data to update... try again to determine random GWebCache in loop continue; } succ = connection.updateRequest( fullHostName, urlString ); // continue if cache is bad or not successful... if ( !verifyGWebCache( connection ) || !succ ) { continue; } } // do this max 5 times or until we where successful while ( !succ && retrys < 5 ); return succ; }
OP_DOT = new XOperator(o.getDot(),XOperator.BINARY+XOperator.RIGHT); OP_CROSS = new XOperator(o.getCross(),XOperator.BINARY+XOperator.RIGHT);
OP_DOT = new XOperator(o.getDot(),XOperator.BINARY+XOperator.LEFT); OP_CROSS = new XOperator(o.getCross(),XOperator.BINARY+XOperator.LEFT);
private void annotateOperators(OperatorSet o) { OP_GT = new XOperator(o.getGT(),XOperator.BINARY+XOperator.LEFT+XOperator.TRANSITIVE); OP_LT = new XOperator(o.getLT(),XOperator.BINARY+XOperator.LEFT+XOperator.TRANSITIVE); OP_EQ = new XOperator(o.getEQ(),XOperator.BINARY+XOperator.LEFT+XOperator.EQUIVILENCE); OP_LE = new XOperator(o.getLE(),XOperator.BINARY+XOperator.LEFT+XOperator.REFLEXIVE+XOperator.TRANSITIVE); OP_GE = new XOperator(o.getGE(),XOperator.BINARY+XOperator.LEFT+XOperator.REFLEXIVE+XOperator.TRANSITIVE); OP_NE = new XOperator(o.getNE(),XOperator.BINARY+XOperator.LEFT+XOperator.SYMMETRIC); OP_AND = new XOperator(o.getAnd(),XOperator.BINARY+XOperator.LEFT+XOperator.COMMUTATIVE+XOperator.ASSOCIATIVE+XOperator.USE_BINDING_FOR_PRINT); OP_OR = new XOperator(o.getOr(),XOperator.BINARY+XOperator.LEFT+XOperator.COMMUTATIVE+XOperator.ASSOCIATIVE); OP_NOT = new XOperator(o.getNot(),XOperator.UNARY+XOperator.RIGHT+XOperator.PREFIX+XOperator.SELF_INVERSE); OP_ADD = new XOperator(o.getAdd(),XOperator.BINARY+XOperator.LEFT+XOperator.COMMUTATIVE+XOperator.ASSOCIATIVE); OP_SUBTRACT = new XOperator(o.getSubtract(),XOperator.BINARY+XOperator.LEFT+XOperator.COMPOSITE+XOperator.USE_BINDING_FOR_PRINT); OP_UMINUS = new XOperator(o.getUMinus(),XOperator.UNARY+XOperator.RIGHT+XOperator.PREFIX+XOperator.SELF_INVERSE); OP_MULTIPLY = new XOperator(o.getMultiply(),XOperator.BINARY+XOperator.LEFT+XOperator.COMMUTATIVE+XOperator.ASSOCIATIVE); OP_DIVIDE = new XOperator(o.getDivide(),XOperator.BINARY+XOperator.LEFT+XOperator.COMPOSITE); OP_MOD = new XOperator(o.getMod(),XOperator.BINARY+XOperator.LEFT); /** unary division i.e. 1/x or x^(-1) **/ OP_UDIVIDE = new XOperator("UDivide","^-1",null,XOperator.UNARY+XOperator.RIGHT+XOperator.PREFIX+XOperator.SELF_INVERSE); OP_POWER = new XOperator(o.getPower(),XOperator.BINARY+XOperator.LEFT); OP_ASSIGN = new XOperator("=",new XAssign(),XOperator.BINARY+XOperator.RIGHT); // OP_DOT = new XOperator(o.getDot(),XOperator.BINARY+XOperator.RIGHT); // OP_CROSS = new XOperator(o.getCross(),XOperator.BINARY+XOperator.RIGHT); // OP_LIST = new XOperator(o.getList(),XOperator.NARY+XOperator.RIGHT); // setPrecedenceTable(new Operator[][] { {OP_UMINUS}, {OP_NOT}, {OP_POWER}, {OP_MULTIPLY,OP_DIVIDE,OP_MOD,OP_DOT,OP_CROSS}, {OP_ADD,OP_SUBTRACT}, {OP_LT,OP_LE}, {OP_GT,OP_GE}, {OP_EQ}, {OP_NE}, {OP_AND}, {OP_OR}, {OP_ASSIGN}, }); //printOperators(); // ((XOperator) OP_ADD).setInverseOp(OP_UMINUS); ((XOperator) OP_ADD).setBinaryInverseOp(OP_SUBTRACT); ((XOperator) OP_SUBTRACT).setRootOp(OP_ADD); ((XOperator) OP_SUBTRACT).setInverseOp(OP_UMINUS); ((XOperator) OP_UMINUS).setRootOp(OP_ADD); ((XOperator) OP_UMINUS).setBinaryInverseOp(OP_SUBTRACT); ((XOperator) OP_MULTIPLY).setInverseOp(OP_UDIVIDE); ((XOperator) OP_MULTIPLY).setBinaryInverseOp(OP_DIVIDE); ((XOperator) OP_DIVIDE).setRootOp(OP_MULTIPLY); ((XOperator) OP_DIVIDE).setInverseOp(OP_UDIVIDE); ((XOperator) OP_UDIVIDE).setRootOp(OP_MULTIPLY); ((XOperator) OP_UDIVIDE).setBinaryInverseOp(OP_DIVIDE); // Set distribuative over ((XOperator) OP_UMINUS).setDistributiveOver(OP_ADD); // -(a+b) -> (-a) + (-b) ((XOperator) OP_UMINUS).setDistributiveOver(OP_SUBTRACT); // -(a-b) -> (-a) - (-b) ((XOperator) OP_MULTIPLY).setDistributiveOver(OP_ADD); // a*(b+c) -> a*b + a*c ((XOperator) OP_MULTIPLY).setDistributiveOver(OP_SUBTRACT); // a*(b-c) -> a*b - a*c ((XOperator) OP_MULTIPLY).setDistributiveOver(OP_UMINUS); // a*(-b) -> -(a*b) }
String name; name = dss.getName(); if ( name == null || name.length == 0) { name = ChannelIdUtil.toStringNoDates(dss.getRequestFilter().channel_id); } name = getUniqueName(getDataSetSeismogramNames(), name); if ( ! name.equals(dss.getName()) ) { dss.setName(name); } dssNames.add(name); dataSetSeismograms.put(name, dss);
String name; name = dss.getName(); if ( name == null || name.length() == 0) { name = ChannelIdUtil.toStringNoDates(dss.getRequestFilter().channel_id); } name = getUniqueName(getDataSetSeismogramNames(), name); if ( ! name.equals(dss.getName()) ) { dss.setName(name); } dssNames.add(name); dataSetSeismograms.put(name, dss);
public void addDataSetSeismogram(DataSetSeismogram dss) { String name; name = dss.getName(); if ( name == null || name.length == 0) { name = ChannelIdUtil.toStringNoDates(dss.getRequestFilter().channel_id); } // end of if () name = getUniqueName(getDataSetSeismogramNames(), name); if ( ! name.equals(dss.getName()) ) { dss.setName(name); } // end of if () dssNames.add(name); dataSetSeismograms.put(name, dss); }
public abstract ChangeLogSet parse(Build build, File changelogFile) throws IOException, SAXException;
public abstract ChangeLogSet<? extends Entry> parse(Build build, File changelogFile) throws IOException, SAXException;
public abstract ChangeLogSet parse(Build build, File changelogFile) throws IOException, SAXException;
if(!isPassed()) {
if(!isPassed() && failedSince==0) {
public void freeze(SuiteResult parent) { this.parent = parent; if(!isPassed()) { CaseResult prev = getPreviousResult(); if(prev!=null && !prev.isPassed()) this.failedSince = prev.failedSince; else this.failedSince = getOwner().getNumber(); } }
testOpSetBug();
public void runTest() { String fileName = "JEPTestExpressions.txt"; testWithFile(fileName); testGetValue(); testGetComplexValue(); }
if(value == null) return Double.NaN; if(value instanceof Complex) { Complex c = (Complex) value; if( c.im() != 0.0) return Double.NaN; return c.re(); }
public double getValue() { Object value = getValueAsObject(); if (value != null && value instanceof Number) { return ((Number)value).doubleValue(); } return Double.NaN; }
this.node = node;
if(node instanceof Slave) this.nodeName = node.getNodeName(); else this.nodeName = null;
/*package*/ void setNode(Node node) { assert node!=null; this.node = node; setNumExecutors(node.getNumExecutors()); }
public static DataSetSeismogram[][] getComponents(DataSetSeismogram[] dss, String suffix){ List names = new ArrayList(); List north = new ArrayList(); List east = new ArrayList(); List z = new ArrayList(); for(int i = 0; i < dss.length; i++){ if(!names.contains(dss[i].getSeismogram().getName())){ LocalSeismogramImpl seis = dss[i].getSeismogram(); XMLDataSet dataSet = (XMLDataSet)dss[i].getDataSet(); ChannelId[] channelGroup = DataSetChannelGrouper.retrieveGrouping(dataSet, seis.getChannelID()); for(int counter = 0; counter < channelGroup.length; counter++) { LocalSeismogram[] newSeismograms = DisplayUtils.getSeismogram(channelGroup[counter], dataSet, new TimeRange(seis.getBeginTime().getFissuresTime(), seis.getEndTime().getFissuresTime())); for(int j = 0; j < newSeismograms.length; j++){ DataSetSeismogram current = new DataSetSeismogram((LocalSeismogramImpl)newSeismograms[j], dataSet, ((LocalSeismogramImpl)newSeismograms[i]).getName()+ suffix); if(DisplayUtils.getOrientationName(channelGroup[counter].channel_code).equals("North")){ north.add(current); }else if(DisplayUtils.getOrientationName(channelGroup[counter].channel_code).equals("East")){ east.add(current); }else{ z.add(current); } names.add(current.getSeismogram().getName()); } } } } DataSetSeismogram[][] sortedSeismos = new DataSetSeismogram[3][]; sortedSeismos[0] = ((DataSetSeismogram[])north.toArray(new DataSetSeismogram[north.size()])); sortedSeismos[1] = ((DataSetSeismogram[])east.toArray(new DataSetSeismogram[east.size()])); sortedSeismos[2] = ((DataSetSeismogram[])z.toArray(new DataSetSeismogram[z.size()])); return sortedSeismos;
public static DataSetSeismogram[][] getComponents(DataSetSeismogram[] dss){ return getComponents(dss, "");
public static DataSetSeismogram[][] getComponents(DataSetSeismogram[] dss, String suffix){ List names = new ArrayList(); List north = new ArrayList(); List east = new ArrayList(); List z = new ArrayList(); for(int i = 0; i < dss.length; i++){ if(!names.contains(dss[i].getSeismogram().getName())){ LocalSeismogramImpl seis = dss[i].getSeismogram(); XMLDataSet dataSet = (XMLDataSet)dss[i].getDataSet(); ChannelId[] channelGroup = DataSetChannelGrouper.retrieveGrouping(dataSet, seis.getChannelID()); for(int counter = 0; counter < channelGroup.length; counter++) { LocalSeismogram[] newSeismograms = DisplayUtils.getSeismogram(channelGroup[counter], dataSet, new TimeRange(seis.getBeginTime().getFissuresTime(), seis.getEndTime().getFissuresTime())); for(int j = 0; j < newSeismograms.length; j++){ DataSetSeismogram current = new DataSetSeismogram((LocalSeismogramImpl)newSeismograms[j], dataSet, ((LocalSeismogramImpl)newSeismograms[i]).getName()+ suffix); if(DisplayUtils.getOrientationName(channelGroup[counter].channel_code).equals("North")){ north.add(current); }else if(DisplayUtils.getOrientationName(channelGroup[counter].channel_code).equals("East")){ east.add(current); }else{ z.add(current); } names.add(current.getSeismogram().getName()); } } } } DataSetSeismogram[][] sortedSeismos = new DataSetSeismogram[3][]; sortedSeismos[0] = ((DataSetSeismogram[])north.toArray(new DataSetSeismogram[north.size()])); sortedSeismos[1] = ((DataSetSeismogram[])east.toArray(new DataSetSeismogram[east.size()])); sortedSeismos[2] = ((DataSetSeismogram[])z.toArray(new DataSetSeismogram[z.size()])); return sortedSeismos; }
partialFile = swDownloadFile.getIncompleteFile(); long startOffset = requestedRange.getStartOffset( fileSize ); long endOffset = Math.min( requestedRange.getEndOffset( fileSize ), availableRange.getEndOffset( fileSize ) ); requestedRange.update( startOffset, endOffset ); fileStartOffset = startOffset; return;
try { partialFile = swDownloadFile.getIncompleteDownloadFile().getFile(); long startOffset = requestedRange.getStartOffset( fileSize ); long endOffset = Math.min( requestedRange.getEndOffset( fileSize ), availableRange.getEndOffset( fileSize ) ); requestedRange.update( startOffset, endOffset ); fileStartOffset = startOffset; return; } catch ( ManagedFileException exp ) { NLogger.error( PartialShareFile.class, exp ); } catch ( FileHandlingException exp ) { NLogger.error( PartialShareFile.class, exp ); }
public void findFittingPartForRange( Range requestedRange ) { Range availableRange; Iterator iterator = availableRangeSet.getIterator(); long fileSize = getFileSize(); while ( iterator.hasNext() ) { availableRange = (Range)iterator.next(); if ( availableRange.isRangeSatisfiable( requestedRange, fileSize ) ) { partialFile = swDownloadFile.getIncompleteFile(); long startOffset = requestedRange.getStartOffset( fileSize ); long endOffset = Math.min( requestedRange.getEndOffset( fileSize ), availableRange.getEndOffset( fileSize ) ); requestedRange.update( startOffset, endOffset ); fileStartOffset = startOffset; return; } } }
numberOfParameters = 2;
super.numberOfParameters = 2;
public Diff() { super(); numberOfParameters = 2; }
logger.warn("Caught exception, retrying "+count+" of "+retry, t);
logger.warn("Caught exception, retrying "+ ++count +" of "+retry, t);
public NetworkAttr get_attributes() { int count = 0; RuntimeException lastException = null; while (count < retry) { try { return net.get_attributes(); } catch (RuntimeException t) { lastException = t; logger.warn("Caught exception, retrying "+count+" of "+retry, t); } count++; } throw lastException; }
count++;
public NetworkAttr get_attributes() { int count = 0; RuntimeException lastException = null; while (count < retry) { try { return net.get_attributes(); } catch (RuntimeException t) { lastException = t; logger.warn("Caught exception, retrying "+count+" of "+retry, t); } count++; } throw lastException; }
public void mul(PNodeI term,PNodeI power) throws ParseException
public void mul(PConstant c) throws ParseException
public void mul(PNodeI term,PNodeI power) throws ParseException { for(int i=0;i<length;++i) { if(terms[i].equals(term)) { powers[i] = powers[i].add(power); return; } } // insert in correct posn PNodeI newTerms[] = new PNodeI[length+1]; PNodeI newPowers[] = new PNodeI[length+1]; int pos=0; boolean done = false; for(int i=0;i<length;++i) { if(!done && terms[i].compareTo(term) > 0) { newTerms[pos] = term; newPowers[pos] = power; ++pos; done = true; } newTerms[pos] = terms[i]; newPowers[pos] = powers[i]; ++pos; } if(!done) { newTerms[pos] = term; newPowers[pos] = power; ++pos; } length = length+1; terms = newTerms; powers = newPowers; }
for(int i=0;i<length;++i) { if(terms[i].equals(term)) { powers[i] = powers[i].add(power); return; } } PNodeI newTerms[] = new PNodeI[length+1]; PNodeI newPowers[] = new PNodeI[length+1]; int pos=0; boolean done = false; for(int i=0;i<length;++i) { if(!done && terms[i].compareTo(term) > 0) { newTerms[pos] = term; newPowers[pos] = power; ++pos; done = true; } newTerms[pos] = terms[i]; newPowers[pos] = powers[i]; ++pos; } if(!done) { newTerms[pos] = term; newPowers[pos] = power; ++pos; } length = length+1; terms = newTerms; powers = newPowers;
coeff = (PConstant) coeff.mul(c);
public void mul(PNodeI term,PNodeI power) throws ParseException { for(int i=0;i<length;++i) { if(terms[i].equals(term)) { powers[i] = powers[i].add(power); return; } } // insert in correct posn PNodeI newTerms[] = new PNodeI[length+1]; PNodeI newPowers[] = new PNodeI[length+1]; int pos=0; boolean done = false; for(int i=0;i<length;++i) { if(!done && terms[i].compareTo(term) > 0) { newTerms[pos] = term; newPowers[pos] = power; ++pos; done = true; } newTerms[pos] = terms[i]; newPowers[pos] = powers[i]; ++pos; } if(!done) { newTerms[pos] = term; newPowers[pos] = power; ++pos; } length = length+1; terms = newTerms; powers = newPowers; }
coeff = (PConstant) c.pow(c);
coeff = (PConstant) coeff.pow(c);
void power(PConstant c) throws ParseException { coeff = (PConstant) c.pow(c); for(int i=0;i<length;++i) powers[i] = powers[i].mul(c); }
public Process(Entity entity, String docCode) { super(entity, docCode);
public Process() {
public Process(Entity entity, String docCode) { super(entity, docCode); }
if ( selectionPaths.length == 0 )
if ( selectionPaths == null || selectionPaths.length == 0 )
public RemoteFile[] getSelectedRemoteFiles( boolean singleForAll ) { ISearchDataModel searchDataModel = searchTreeTableModel.getDisplayedResultsData(); if (searchDataModel == null) { return EMPTY_REMOTE_FILE_ARRAY; } TreePath[] selectionPaths = searchTreeTable.getTreeSelectionModel().getSelectionPaths(); if ( selectionPaths.length == 0 ) { return EMPTY_REMOTE_FILE_ARRAY; } HashSet remoteFileSet = new HashSet(); for ( int i = 0; i < selectionPaths.length; i++ ) { if ( selectionPaths[i].getPathCount() == 3 ) { if ( singleForAll ) { SearchResultElement element = (SearchResultElement)selectionPaths[i].getPathComponent( 1 ); RemoteFile[] files = element.getRemoteFiles(); remoteFileSet.addAll( Arrays.asList( files ) ); } else { RemoteFile remoteFile = (RemoteFile)selectionPaths[i].getPathComponent( 2 ); remoteFileSet.add( remoteFile ); } } else { SearchResultElement element = (SearchResultElement)selectionPaths[i].getPathComponent( 1 ); RemoteFile[] files = element.getRemoteFiles(); remoteFileSet.addAll( Arrays.asList( files ) ); } } RemoteFile[] result = new RemoteFile[ remoteFileSet.size() ]; remoteFileSet.toArray( result ); return result; }
public SWDownloadFile getDownloadFile( long fileSize, URN matchURN )
public SWDownloadFile getDownloadFile( int index )
public SWDownloadFile getDownloadFile( long fileSize, URN matchURN ) { synchronized( downloadList ) { SWDownloadFile file = getDownloadFileByURN( matchURN ); if ( file != null && file.getTotalDataSize() == fileSize ) { return file; } return null; } }
SWDownloadFile file = getDownloadFileByURN( matchURN ); if ( file != null && file.getTotalDataSize() == fileSize )
if ( index < 0 || index >= downloadList.size() )
public SWDownloadFile getDownloadFile( long fileSize, URN matchURN ) { synchronized( downloadList ) { SWDownloadFile file = getDownloadFileByURN( matchURN ); if ( file != null && file.getTotalDataSize() == fileSize ) { return file; } return null; } }
return file;
return null;
public SWDownloadFile getDownloadFile( long fileSize, URN matchURN ) { synchronized( downloadList ) { SWDownloadFile file = getDownloadFileByURN( matchURN ); if ( file != null && file.getTotalDataSize() == fileSize ) { return file; } return null; } }
return null;
return downloadList.get( index );
public SWDownloadFile getDownloadFile( long fileSize, URN matchURN ) { synchronized( downloadList ) { SWDownloadFile file = getDownloadFileByURN( matchURN ); if ( file != null && file.getTotalDataSize() == fileSize ) { return file; } return null; } }
JButton backBtn = new JButton( Localizer.getString( "WizardDialog_Back" ) );
backBtn = new JButton( Localizer.getString( "WizardDialog_Back" ) );
private void prepareComponent() { CloseEventHandler closeEventHandler = new CloseEventHandler(); addWindowListener( closeEventHandler ); Container contentPane = getContentPane(); contentPane.setLayout( new BorderLayout() ); JPanel contentPanel = new JPanel(); //JPanel contentPanel = new FormDebugPanel(); contentPane.add(contentPanel, BorderLayout.CENTER); CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout("4dlu, fill:d:grow, 4dlu", // columns "4dlu, fill:p:grow, 12dlu, fill:p:grow, 8dlu," + // rows "p, 2dlu, p 4dlu" ); //btn rows PanelBuilder contentPB = new PanelBuilder(layout, contentPanel); int columnCount = layout.getColumnCount(); int rowCount = layout.getRowCount(); ruleEditPanel = new JPanel(); ruleEditPanel.setLayout(new BorderLayout()); contentPB.add( ruleEditPanel, cc.xywh( 2, 2, 1, 1 ) ); ruleDescPanel = new RuleDescriptionPanel( this ); contentPB.add( ruleDescPanel, cc.xywh( 2, 4, 1, 1 ) ); // button bar contentPB.add( new JSeparator(), cc.xywh( 1, rowCount - 3, columnCount, 1 ) ); JButton backBtn = new JButton( Localizer.getString( "WizardDialog_Back" ) ); backBtn.addActionListener( new BackBtnListener()); nextBtn = new JButton( Localizer.getString( "WizardDialog_Next" ) ); nextBtn.setDefaultCapable( true ); nextBtn.setRequestFocusEnabled( true ); nextBtn.addActionListener( new NextBtnListener()); finishBtn = new JButton( Localizer.getString( "WizardDialog_Finish" ) ); finishBtn.addActionListener( new FinishBtnListener()); JButton cancelBtn = new JButton( Localizer.getString( "WizardDialog_Cancel" ) ); cancelBtn.addActionListener( closeEventHandler ); JPanel btnPanel = ButtonBarFactory.buildWizardBar(backBtn, nextBtn, finishBtn, cancelBtn); contentPB.add( btnPanel, cc.xywh( 2, rowCount - 1, columnCount - 2, 1 ) ); setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE ); getRootPane().setDefaultButton( nextBtn ); // set first panel to show... updatePage(); pack(); int height = getHeight(); setSize( height*5/4, height ); setLocationRelativeTo( getParent() ); }
if ( editRule != null && editRule.isDefaultRule() ) { backBtn.setEnabled(false); } else { backBtn.setEnabled(true); }
private void updatePage() { ruleEditPanel.removeAll(); JPanel newPage = null; switch ( currentPage ) { case CONDITION_PAGE: if ( conditionPanel == null ) { conditionPanel = new ConditionPanel(this); } newPage = conditionPanel; nextBtn.setEnabled(true); break; case CONSEQUENCE_PAGE: if ( consequencePanel == null ) { consequencePanel = new ConsequencePanel(this); } newPage = consequencePanel; nextBtn.setEnabled(true); break; case EXCEPTION_PAGE: if ( exceptionPanel == null ) { exceptionPanel = new ExceptionPanel(this); } newPage = exceptionPanel; nextBtn.setEnabled(true); break; case RULE_PROPERTIES_PAGE: if ( rulePropertiesPanel == null ) { rulePropertiesPanel = new RulePropertiesPanel(this); } newPage = rulePropertiesPanel; nextBtn.setEnabled(false); break; } ruleEditPanel.add(newPage, BorderLayout.CENTER); updateRuleData(); ruleEditPanel.doLayout(); ruleEditPanel.revalidate(); ruleEditPanel.repaint(); // here we adjust the size of the dialog if necessary Dimension prefSize = getPreferredSize(); Dimension currSize = getSize(); if ( prefSize.height > currSize.height ) { int height = Math.max( prefSize.height, currSize.height ); setSize( height*5/4, height ); doLayout(); } }
public UserRole findUserRoleByNaturalId(User user, Service service, String serviceExtension);
public UserRole findUserRoleByNaturalId(UserGroup userGroup, Service service, String serviceExtension);
public UserRole findUserRoleByNaturalId(User user, Service service, String serviceExtension);
if(diff>100*60)
if(abs>100*60)
public String getClockDifferenceString() { try { long diff = getClockDifference(); if(-1000<diff && diff <1000) return "In sync"; // clock is in sync long abs = Math.abs(diff); String s = Util.getTimeSpanString(abs); if(diff<0) s += " ahead"; else s += " behind"; if(diff>100*60) // more than a minute difference s = "<span class='error'>"+s+"</span>"; return s; } catch (IOException e) { return "<span class='error'>Unable to check</span>"; } }
return entityDao.findDefaultEntity().getDefaultEntity().getEntity();
return entityDao.findDefaultEntity();
public Entity findDefaultEntity() { return entityDao.findDefaultEntity().getDefaultEntity().getEntity(); }
otherMagType = new String(fourBytes);
otherMagType = new String(PSNDataFile.chopToLength(fourBytes));
public PSNEventInfo(DataInputStream data) throws IOException{ dis = data; time = new PSNDateTime(dis); //System.out.println(time.toString()); lat = SacTimeSeries.swapBytes(dis.readDouble()); lon = SacTimeSeries.swapBytes(dis.readDouble()); depthKM = SacTimeSeries.swapBytes(dis.readDouble()); magnitudes = new double[6]; for (int i = 0; i < magnitudes.length; i++) { magnitudes[i] = (double)SacTimeSeries.swapBytes(dis.readShort())/100.0; } dis.readFully(fourBytes); otherMagType = new String(fourBytes); eventType = dis.readByte(); locationQuality = dis.readByte(); flags = SacTimeSeries.swapBytes((short)dis.readUnsignedShort()); dis.readFully(sixBytes); reportingAgency = new String(sixBytes); }
reportingAgency = new String(sixBytes);
reportingAgency = new String(PSNDataFile.chopToLength(sixBytes));
public PSNEventInfo(DataInputStream data) throws IOException{ dis = data; time = new PSNDateTime(dis); //System.out.println(time.toString()); lat = SacTimeSeries.swapBytes(dis.readDouble()); lon = SacTimeSeries.swapBytes(dis.readDouble()); depthKM = SacTimeSeries.swapBytes(dis.readDouble()); magnitudes = new double[6]; for (int i = 0; i < magnitudes.length; i++) { magnitudes[i] = (double)SacTimeSeries.swapBytes(dis.readShort())/100.0; } dis.readFully(fourBytes); otherMagType = new String(fourBytes); eventType = dis.readByte(); locationQuality = dis.readByte(); flags = SacTimeSeries.swapBytes((short)dis.readUnsignedShort()); dis.readFully(sixBytes); reportingAgency = new String(sixBytes); }
for (int j = 0; j < containedSeis.length && !found; j++) { if(containedSeis == it.next()){ found = true; }
Object o = it.next(); if(containedSeis[i] == o){ found = true;
public void run(){ LocalSeismogramImpl[] containedSeis = container.getSeismograms(); List alreadyFiltered = new ArrayList(); Iterator it = data.iterator(); boolean found = false; while(it.hasNext()){ SoftReference currentRef = (SoftReference)it.next(); LocalSeismogramImpl current = (LocalSeismogramImpl)currentRef.get(); if(current == null){ it.remove(); break; } for (int i = 0; i < containedSeis.length && !found; i++){ if(current.getEndTime().equals(containedSeis[i].getEndTime()) && current.getBeginTime().equals(containedSeis[i].getBeginTime())){ found = true; alreadyFiltered.add(containedSeis[i]); } } if(!found){ it.remove(); } } for (int i = 0; i < containedSeis.length; i++){ it = alreadyFiltered.iterator(); found = false; while(it.hasNext()){ for (int j = 0; j < containedSeis.length && !found; j++) { if(containedSeis == it.next()){ found = true; } } } if(!found){ data.add(new SoftReference(filterData(containedSeis[i], filter))); } } if((containedSeis.length - alreadyFiltered.size()) > 0){ pushData(getFilteredSeismograms(), null); } }
public FilteredDataSetSeismogram(DataSetSeismogram dss, ColoredFilter filter){
private FilteredDataSetSeismogram(DataSetSeismogram dss, ColoredFilter filter){
public FilteredDataSetSeismogram(DataSetSeismogram dss, ColoredFilter filter){ super(dss.getDataSet(), filter.getName()); this.filter = filter; wrappedDSS = dss; container = new SeismogramContainer(this, wrappedDSS); }
container.getSeismograms();
public FilteredDataSetSeismogram(DataSetSeismogram dss, ColoredFilter filter){ super(dss.getDataSet(), filter.getName()); this.filter = filter; wrappedDSS = dss; container = new SeismogramContainer(this, wrappedDSS); }
public edu.iris.Fissures.Time getBeginTime() {
public Time getBeginTime() {
public edu.iris.Fissures.Time getBeginTime() { return wrappedDSS.getBeginTime(); }
public edu.iris.Fissures.Time getEndTime() {
public Time getEndTime() {
public edu.iris.Fissures.Time getEndTime() { return wrappedDSS.getEndTime(); }
public void setBeginTime(edu.iris.Fissures.Time time) {
public void setBeginTime(Time time) {
public void setBeginTime(edu.iris.Fissures.Time time) { throw new UnsupportedOperationException("Cannot set begin time on filtered seismogram. It is entirely reliant on the wrapped dss time"); }
public void setEndTime(edu.iris.Fissures.Time time) {
public void setEndTime(Time time) {
public void setEndTime(edu.iris.Fissures.Time time) { throw new UnsupportedOperationException("Cannot set end time on filtered seismogram. It is entirely reliant on the wrapped dss time"); }
Node processed = j.commandv.process(node,j);
Node processed = j.preprocess(node);
public void simplifyTestString(String expr,String expected) throws ParseException { Node node = j.parse(expr); Node processed = j.commandv.process(node,j); Node simp = j.simplify(processed); String res = j.pv.toString(simp); if(!expected.equals(res)) System.out.println("Error: Value of \""+expr+"\" is \""+res+"\" should be \""+expected+"\""); assertEquals("<"+expr+">",expected,res); System.out.println("Sucess: Value of \""+expr+"\" is \""+res+"\""); // System.out.print("Full Brackets:\t");// j.pv.setFullBrackets(true);// j.pv.println(simp);// j.pv.setFullBrackets(false); }
String res = j.pv.toString(simp);
String res = j.toString(simp);
public void simplifyTestString(String expr,String expected) throws ParseException { Node node = j.parse(expr); Node processed = j.commandv.process(node,j); Node simp = j.simplify(processed); String res = j.pv.toString(simp); if(!expected.equals(res)) System.out.println("Error: Value of \""+expr+"\" is \""+res+"\" should be \""+expected+"\""); assertEquals("<"+expr+">",expected,res); System.out.println("Sucess: Value of \""+expr+"\" is \""+res+"\""); // System.out.print("Full Brackets:\t");// j.pv.setFullBrackets(true);// j.pv.println(simp);// j.pv.setFullBrackets(false); }
Node processed = j.commandv.process(node,j);
Node processed = j.preprocess(node);
public void simplifyTest(String expr,String expected) throws ParseException { Node node = j.parse(expr); Node processed = j.commandv.process(node,j); Node simp = j.simplify(processed); String res = j.pv.toString(simp); Node node2 = j.parse(expected); Node processed2 = j.commandv.process(node2,j); Node simp2 = j.simplify(processed2); String res2 = j.pv.toString(simp2); if(!res2.equals(res)) System.out.println("Error: Value of \""+expr+"\" is \""+res+"\" should be \""+res2+"\""); assertEquals("<"+expr+">",res2,res); System.out.println("Sucess: Value of \""+expr+"\" is \""+res+"\""); // System.out.print("Full Brackets:\t");// j.pv.setFullBrackets(true);// j.pv.println(simp);// j.pv.setFullBrackets(false); }
String res = j.pv.toString(simp);
String res = j.toString(simp);
public void simplifyTest(String expr,String expected) throws ParseException { Node node = j.parse(expr); Node processed = j.commandv.process(node,j); Node simp = j.simplify(processed); String res = j.pv.toString(simp); Node node2 = j.parse(expected); Node processed2 = j.commandv.process(node2,j); Node simp2 = j.simplify(processed2); String res2 = j.pv.toString(simp2); if(!res2.equals(res)) System.out.println("Error: Value of \""+expr+"\" is \""+res+"\" should be \""+res2+"\""); assertEquals("<"+expr+">",res2,res); System.out.println("Sucess: Value of \""+expr+"\" is \""+res+"\""); // System.out.print("Full Brackets:\t");// j.pv.setFullBrackets(true);// j.pv.println(simp);// j.pv.setFullBrackets(false); }
Node processed2 = j.commandv.process(node2,j);
Node processed2 = j.preprocess(node2);
public void simplifyTest(String expr,String expected) throws ParseException { Node node = j.parse(expr); Node processed = j.commandv.process(node,j); Node simp = j.simplify(processed); String res = j.pv.toString(simp); Node node2 = j.parse(expected); Node processed2 = j.commandv.process(node2,j); Node simp2 = j.simplify(processed2); String res2 = j.pv.toString(simp2); if(!res2.equals(res)) System.out.println("Error: Value of \""+expr+"\" is \""+res+"\" should be \""+res2+"\""); assertEquals("<"+expr+">",res2,res); System.out.println("Sucess: Value of \""+expr+"\" is \""+res+"\""); // System.out.print("Full Brackets:\t");// j.pv.setFullBrackets(true);// j.pv.println(simp);// j.pv.setFullBrackets(false); }
String res2 = j.pv.toString(simp2);
String res2 = j.toString(simp2);
public void simplifyTest(String expr,String expected) throws ParseException { Node node = j.parse(expr); Node processed = j.commandv.process(node,j); Node simp = j.simplify(processed); String res = j.pv.toString(simp); Node node2 = j.parse(expected); Node processed2 = j.commandv.process(node2,j); Node simp2 = j.simplify(processed2); String res2 = j.pv.toString(simp2); if(!res2.equals(res)) System.out.println("Error: Value of \""+expr+"\" is \""+res+"\" should be \""+res2+"\""); assertEquals("<"+expr+">",res2,res); System.out.println("Sucess: Value of \""+expr+"\" is \""+res+"\""); // System.out.print("Full Brackets:\t");// j.pv.setFullBrackets(true);// j.pv.println(simp);// j.pv.setFullBrackets(false); }
public StatRecord(String description, String unit, int value) { this.description = description; this.unit = unit; intValue = value;
public StatRecord(StatisticType type, long value) { this.type = type; longValue = value; this.description = type.getDescription(); this.unit = type.getUnit();
public StatRecord(String description, String unit, int value) { this.description = description; this.unit = unit; intValue = value; this.value = "" + value; }
for (File child : file.listFiles()) {
File[] files = file.listFiles(); if(files==null) return; for (File child : files) {
public static void deleteContentsRecursive(File file) throws IOException { for (File child : file.listFiles()) { if (child.isDirectory()) deleteContentsRecursive(child); if (!child.delete()) throw new IOException("Unable to delete " + child.getPath()); } }
static public int binom(int n,int i)
static public int binom(int n,int i) throws ArrayIndexOutOfBoundsException
static public int binom(int n,int i) { expand(n); return coeffs[n][i]; }
return new AssertionImpl(new SimplePrincipal("test"), new HashMap());
return new AssertionImpl(new SimplePrincipal("test"), new HashMap(), new ProxyRetriever() { public String getProxyTicketIdFor(String proxyGrantingTicketId, Service targetService) { return "test"; } }, "proxyTicketId");
public void testAuthenticateWithProxy() throws Exception { this.context = new CasSecurityContext(new TicketValidator() { public Assertion validate(String ticketId, Service service) throws ValidationException { return new AssertionImpl(new SimplePrincipal("test"), new HashMap()); } }, new SimpleService("test")); this.context.getOpaqueCredentialsInstance().setCredentials("ticket"); this.context.authenticate(); assertEquals("test", this.context.getProxyTicket(new SimpleService("test"))); }
return new AssertionImpl(new SimplePrincipal("test"), new HashMap());
return new AssertionImpl(new SimplePrincipal("test"), new HashMap(), new ProxyRetriever() { public String getProxyTicketIdFor(String proxyGrantingTicketId, Service targetService) { return "test"; } }, "proxyTicketId");
public Assertion validate(String ticketId, Service service) throws ValidationException { return new AssertionImpl(new SimplePrincipal("test"), new HashMap()); }
if(node instanceof PVariable) { if(this.equalsIgnoreConstant(node)) { return valueOf((PConstant)coeff.add(pc.oneConstant), vars,powers); } }
public PNodeI add(PNodeI node) throws ParseException { if(node instanceof Monomial) { Monomial mon = (Monomial) node; if(this.equalsIgnoreConstant(mon)) { return valueOf((PConstant)coeff.add(mon.coeff), vars,powers); } } return super.add(node); }
if(node instanceof PVariable) { if(this.equalsIgnoreConstant(node)) { return valueOf((PConstant)coeff.sub(pc.oneConstant), vars,powers); } }
public PNodeI sub(PNodeI node) throws ParseException { if(node instanceof Monomial) { Monomial mon = (Monomial) node; if(this.equalsIgnoreConstant(mon)) { return valueOf((PConstant)coeff.sub(mon.coeff), vars,powers); } } return super.sub(node); }
public AbstractPNode(PolynomialCreator pc) { this.pc = pc; }
private AbstractPNode() {}
public AbstractPNode(PolynomialCreator pc) { this.pc = pc; }
else return new Polynomial(pc,new PNodeI[]{node,this});
return new Polynomial(pc,new PNodeI[]{node,this});
public PNodeI add(PNodeI node) throws ParseException { if(node.isZero()) return this; if(this.isZero()) return node; if(this.equals(node)) return new Monomial(pc,pc.twoConstant,this); if(node instanceof Polynomial) return node.add(this); if(this.compareTo(node) < 0) return new Polynomial(pc,new PNodeI[]{this,node}); // x+y else return new Polynomial(pc,new PNodeI[]{node,this}); // x+y }
else return new Monomial(pc, pc.oneConstant, new PNodeI[]{node,this}, new PNodeI[]{pc.oneConstant,pc.oneConstant});
return new Monomial(pc, pc.oneConstant, new PNodeI[]{node,this}, new PNodeI[]{pc.oneConstant,pc.oneConstant});
public PNodeI mul(PNodeI node) throws ParseException { if(node.isZero()) return pc.zeroConstant; if(node.isOne()) return this; if(this.equals(node)) return new Monomial(pc,pc.oneConstant,this,pc.twoConstant); if(node instanceof Constant) return new Monomial(pc,(Constant) node,this); if(node instanceof Monomial) return ((Monomial) node).mul(this); if(this instanceof Constant) {// if(node instanceof Polynomial)// return ((Polynomial) node).mul((Constant) this); return new Monomial(pc,(Constant) this,node); } if(this.compareTo(node) < 0) return new Monomial(pc, pc.oneConstant, new PNodeI[]{this,node}, new PNodeI[]{pc.oneConstant,pc.oneConstant}); else return new Monomial(pc, pc.oneConstant, new PNodeI[]{node,this}, new PNodeI[]{pc.oneConstant,pc.oneConstant}); }
return ((Double) value).compareTo(pc.zero) < 0;
return ((Double) value).compareTo((Double) pc.zero) < 0;
public boolean isNegative() { try { return ((Double) value).compareTo(pc.zero) < 0; } catch(Exception e) { return false; } }
public FilteredSeismogramShape(ColoredFilter filter, DataSetSeismogram seismogram, JComponent parent){ super(parent, seismogram); this.seismogram = seismogram; this.filter = filter;
public FilteredSeismogramShape(ColoredFilter filter, DataSetSeismogram seismogram, JComponent parent){ super(parent, seismogram); this.seismogram = seismogram; filteredSeis = (DataSetSeismogram)seismogram.clone(); filteredSeis.setName(filter.getName()); this.filter = filter;
public FilteredSeismogramShape(ColoredFilter filter, DataSetSeismogram seismogram, JComponent parent){ super(parent, seismogram); this.seismogram = seismogram; this.filter = filter; }
this.builds = new RunMap<PromotedBuild>();
protected void onLoad(Hudson root, String name) throws IOException { this.builds.load(this,new Constructor<PromotedBuild>() { public PromotedBuild create(File dir) throws IOException { return new PromotedBuild(PromotedJob.this,dir); } }); }
throws IOException {
throws IOException, SeedFormatException {
public static Blockette parseBlockette(int type, byte[] bytes) throws IOException { try { //System.out.println(" Class.forName Blockette"+type); Class blocketteClass = Class.forName("edu.sc.seis.fissuresUtil.mseed.Blockette"+type); //System.out.println(" Class.forName suceeded"); Class[] argTypes = new Class[1]; // argTypes[0] = Class.forName("byte[]"); argTypes[0] = byte[].class; Constructor read = blocketteClass.getConstructor(argTypes); // blockette needs 4 bytes for type and next offset values, even // though their values are not used directly byte[] fullBytes = new byte[4+bytes.length]; System.arraycopy(Utility.intToByteArray(type), 2, fullBytes, 0, 2); System.arraycopy(bytes, 0, fullBytes, 4, bytes.length); Object[] arguments = new Object[1]; arguments[0] = fullBytes; //System.out.println("Constructor suceeded"); Blockette blockette = (Blockette)read.newInstance(arguments); //System.out.println("read suceeded"); return blockette; } catch (ClassNotFoundException e) { // must not be installed, read an unknownblockette System.out.println(" Class.forName failed: "+type); Blockette blockette = new BlocketteUnknown(bytes, type); return blockette; } catch ( NoSuchMethodException e) { // must not be installed, skip this blockette return null; } catch (InstantiationException e) { // must not be installed, skip this blockette return null; } catch (IllegalAccessException e) { // must not be installed, skip this blockette return null; } catch (InvocationTargetException e) { // must not be installed, skip this blockette return null; } }
byte[] fullBytes = new byte[4+bytes.length]; System.arraycopy(Utility.intToByteArray(type), 2, fullBytes, 0, 2); System.arraycopy(bytes, 0, fullBytes, 4, bytes.length);
public static Blockette parseBlockette(int type, byte[] bytes) throws IOException { try { //System.out.println(" Class.forName Blockette"+type); Class blocketteClass = Class.forName("edu.sc.seis.fissuresUtil.mseed.Blockette"+type); //System.out.println(" Class.forName suceeded"); Class[] argTypes = new Class[1]; // argTypes[0] = Class.forName("byte[]"); argTypes[0] = byte[].class; Constructor read = blocketteClass.getConstructor(argTypes); // blockette needs 4 bytes for type and next offset values, even // though their values are not used directly byte[] fullBytes = new byte[4+bytes.length]; System.arraycopy(Utility.intToByteArray(type), 2, fullBytes, 0, 2); System.arraycopy(bytes, 0, fullBytes, 4, bytes.length); Object[] arguments = new Object[1]; arguments[0] = fullBytes; //System.out.println("Constructor suceeded"); Blockette blockette = (Blockette)read.newInstance(arguments); //System.out.println("read suceeded"); return blockette; } catch (ClassNotFoundException e) { // must not be installed, read an unknownblockette System.out.println(" Class.forName failed: "+type); Blockette blockette = new BlocketteUnknown(bytes, type); return blockette; } catch ( NoSuchMethodException e) { // must not be installed, skip this blockette return null; } catch (InstantiationException e) { // must not be installed, skip this blockette return null; } catch (IllegalAccessException e) { // must not be installed, skip this blockette return null; } catch (InvocationTargetException e) { // must not be installed, skip this blockette return null; } }
arguments[0] = fullBytes;
arguments[0] = bytes;
public static Blockette parseBlockette(int type, byte[] bytes) throws IOException { try { //System.out.println(" Class.forName Blockette"+type); Class blocketteClass = Class.forName("edu.sc.seis.fissuresUtil.mseed.Blockette"+type); //System.out.println(" Class.forName suceeded"); Class[] argTypes = new Class[1]; // argTypes[0] = Class.forName("byte[]"); argTypes[0] = byte[].class; Constructor read = blocketteClass.getConstructor(argTypes); // blockette needs 4 bytes for type and next offset values, even // though their values are not used directly byte[] fullBytes = new byte[4+bytes.length]; System.arraycopy(Utility.intToByteArray(type), 2, fullBytes, 0, 2); System.arraycopy(bytes, 0, fullBytes, 4, bytes.length); Object[] arguments = new Object[1]; arguments[0] = fullBytes; //System.out.println("Constructor suceeded"); Blockette blockette = (Blockette)read.newInstance(arguments); //System.out.println("read suceeded"); return blockette; } catch (ClassNotFoundException e) { // must not be installed, read an unknownblockette System.out.println(" Class.forName failed: "+type); Blockette blockette = new BlocketteUnknown(bytes, type); return blockette; } catch ( NoSuchMethodException e) { // must not be installed, skip this blockette return null; } catch (InstantiationException e) { // must not be installed, skip this blockette return null; } catch (IllegalAccessException e) { // must not be installed, skip this blockette return null; } catch (InvocationTargetException e) { // must not be installed, skip this blockette return null; } }
return null;
throw new SeedFormatException("Can't load blockette for type="+type, e);
public static Blockette parseBlockette(int type, byte[] bytes) throws IOException { try { //System.out.println(" Class.forName Blockette"+type); Class blocketteClass = Class.forName("edu.sc.seis.fissuresUtil.mseed.Blockette"+type); //System.out.println(" Class.forName suceeded"); Class[] argTypes = new Class[1]; // argTypes[0] = Class.forName("byte[]"); argTypes[0] = byte[].class; Constructor read = blocketteClass.getConstructor(argTypes); // blockette needs 4 bytes for type and next offset values, even // though their values are not used directly byte[] fullBytes = new byte[4+bytes.length]; System.arraycopy(Utility.intToByteArray(type), 2, fullBytes, 0, 2); System.arraycopy(bytes, 0, fullBytes, 4, bytes.length); Object[] arguments = new Object[1]; arguments[0] = fullBytes; //System.out.println("Constructor suceeded"); Blockette blockette = (Blockette)read.newInstance(arguments); //System.out.println("read suceeded"); return blockette; } catch (ClassNotFoundException e) { // must not be installed, read an unknownblockette System.out.println(" Class.forName failed: "+type); Blockette blockette = new BlocketteUnknown(bytes, type); return blockette; } catch ( NoSuchMethodException e) { // must not be installed, skip this blockette return null; } catch (InstantiationException e) { // must not be installed, skip this blockette return null; } catch (IllegalAccessException e) { // must not be installed, skip this blockette return null; } catch (InvocationTargetException e) { // must not be installed, skip this blockette return null; } }
String s = new BufferedReader(new FileReader(file)).readLine(); if(s==null) return false; return s.trim().equals(contents.trim());
Reader r = new FileReader(file); try { String s = new BufferedReader(r).readLine(); if (s == null) return false; return s.trim().equals(contents.trim()); } finally { r.close(); }
private boolean checkContents(File file, String contents) { try { String s = new BufferedReader(new FileReader(file)).readLine(); if(s==null) return false; return s.trim().equals(contents.trim()); } catch (IOException e) { return false; } }
throws SeedFormatException, IOException { ControlHeader header = ControlHeader.read(inStream); if (header instanceof DataHeader) { return readDataRecord((DataHeader)header); } else { throw new SeedFormatException("Found a control record in miniseed");
throws SeedFormatException, IOException { ControlHeader header = ControlHeader.read(inStream); if (header instanceof DataHeader) { return readDataRecord((DataHeader)header); } else { throw new SeedFormatException("Found a control record in miniseed"); }
public SeedRecord getNextRecord() throws SeedFormatException, IOException { ControlHeader header = ControlHeader.read(inStream); if (header instanceof DataHeader) { return readDataRecord((DataHeader)header); } else {throw new SeedFormatException("Found a control record in miniseed");// return readControlRecord(header); } }
}
public SeedRecord getNextRecord() throws SeedFormatException, IOException { ControlHeader header = ControlHeader.read(inStream); if (header instanceof DataHeader) { return readDataRecord((DataHeader)header); } else {throw new SeedFormatException("Found a control record in miniseed");// return readControlRecord(header); } }
Blockette b = Blockette.parseBlockette(type,
byte[] fullBytes = new byte[4+blocketteBytes.length]; System.arraycopy(Utility.intToByteArray(type), 2, fullBytes, 0, 2); System.arraycopy(blocketteBytes, 0, fullBytes, 4, blocketteBytes.length); Blockette b = Blockette.parseBlockette(type,
protected DataRecord readDataRecord(DataHeader header) throws IOException, SeedFormatException { Assert.isTrue(header.getDataBlocketteOffset()>= header.getSize(), "Offset to first blockette must be larger than the header size"); byte[] garbage = new byte[header.getDataBlocketteOffset()- header.getSize()]; DataRecord dataRec = new DataRecord(header); if (garbage.length != 0) { inStream.readFully(garbage); } byte[] blocketteBytes; int currOffset = header.getDataBlocketteOffset(); int type, nextOffset; for (int i=0; i< header.getNumBlockettes() ; i++) { //get blockette type (first 2 bytes) byte hibyte = inStream.readByte(); byte lowbyte = inStream.readByte(); type = Utility.uBytesToInt(hibyte, lowbyte, false); // System.out.println("Blockette type "+type); hibyte = inStream.readByte(); lowbyte = inStream.readByte(); nextOffset = Utility.uBytesToInt(hibyte, lowbyte, false); // account for the 4 bytes above currOffset += 4; if (nextOffset != 0) { blocketteBytes = new byte[nextOffset - currOffset]; } else if (header.getDataOffset() > currOffset) { blocketteBytes = new byte[header.getDataOffset()- currOffset]; } else { blocketteBytes = new byte[0]; } inStream.readFully(blocketteBytes); if (nextOffset != 0) { currOffset = nextOffset; } else { currOffset += blocketteBytes.length; } Blockette b = Blockette.parseBlockette(type, blocketteBytes); dataRec.addBlockette(b); if (nextOffset == 0) { break; } } Blockette[] allBs = dataRec.getBlockettes(1000); if (allBs.length == 0) { // no data throw new SeedFormatException("no blockette 1000"); } else if (allBs.length > 1) { throw new SeedFormatException( "Multiple blockette 1000s in the volume. "+ allBs.length); } // System.out.println("allBs.length="+allBs.length); Blockette1000 b1000 = (Blockette1000)allBs[0]; // System.out.println(b1000); byte[] timeseries; if (header.getDataOffset() == 0) { // data record with no data, so gobble up the rest of the record timeseries = new byte[b1000.getDataRecordLength() - currOffset]; } else { timeseries = new byte[ b1000.getDataRecordLength() - header.getDataOffset() ]; } // System.out.println("getDataRecordLength() = "+ b1000.getDataRecordLength()); inStream.readFully(timeseries); dataRec.setData(timeseries); return dataRec; }
dataRec.addBlockette(b); if (nextOffset == 0) { break;
dataRec.addBlockette(b); if (nextOffset == 0) { break; }
protected DataRecord readDataRecord(DataHeader header) throws IOException, SeedFormatException { Assert.isTrue(header.getDataBlocketteOffset()>= header.getSize(), "Offset to first blockette must be larger than the header size"); byte[] garbage = new byte[header.getDataBlocketteOffset()- header.getSize()]; DataRecord dataRec = new DataRecord(header); if (garbage.length != 0) { inStream.readFully(garbage); } byte[] blocketteBytes; int currOffset = header.getDataBlocketteOffset(); int type, nextOffset; for (int i=0; i< header.getNumBlockettes() ; i++) { //get blockette type (first 2 bytes) byte hibyte = inStream.readByte(); byte lowbyte = inStream.readByte(); type = Utility.uBytesToInt(hibyte, lowbyte, false); // System.out.println("Blockette type "+type); hibyte = inStream.readByte(); lowbyte = inStream.readByte(); nextOffset = Utility.uBytesToInt(hibyte, lowbyte, false); // account for the 4 bytes above currOffset += 4; if (nextOffset != 0) { blocketteBytes = new byte[nextOffset - currOffset]; } else if (header.getDataOffset() > currOffset) { blocketteBytes = new byte[header.getDataOffset()- currOffset]; } else { blocketteBytes = new byte[0]; } inStream.readFully(blocketteBytes); if (nextOffset != 0) { currOffset = nextOffset; } else { currOffset += blocketteBytes.length; } Blockette b = Blockette.parseBlockette(type, blocketteBytes); dataRec.addBlockette(b); if (nextOffset == 0) { break; } } Blockette[] allBs = dataRec.getBlockettes(1000); if (allBs.length == 0) { // no data throw new SeedFormatException("no blockette 1000"); } else if (allBs.length > 1) { throw new SeedFormatException( "Multiple blockette 1000s in the volume. "+ allBs.length); } // System.out.println("allBs.length="+allBs.length); Blockette1000 b1000 = (Blockette1000)allBs[0]; // System.out.println(b1000); byte[] timeseries; if (header.getDataOffset() == 0) { // data record with no data, so gobble up the rest of the record timeseries = new byte[b1000.getDataRecordLength() - currOffset]; } else { timeseries = new byte[ b1000.getDataRecordLength() - header.getDataOffset() ]; } // System.out.println("getDataRecordLength() = "+ b1000.getDataRecordLength()); inStream.readFully(timeseries); dataRec.setData(timeseries); return dataRec; }
} Blockette[] allBs = dataRec.getBlockettes(1000); if (allBs.length == 0) { throw new SeedFormatException("no blockette 1000"); } else if (allBs.length > 1) { throw new SeedFormatException( "Multiple blockette 1000s in the volume. "+ allBs.length); }
Blockette[] allBs = dataRec.getBlockettes(1000); if (allBs.length == 0) { throw new SeedFormatException("no blockette 1000"); } else if (allBs.length > 1) { throw new SeedFormatException( "Multiple blockette 1000s in the volume. "+ allBs.length); }
protected DataRecord readDataRecord(DataHeader header) throws IOException, SeedFormatException { Assert.isTrue(header.getDataBlocketteOffset()>= header.getSize(), "Offset to first blockette must be larger than the header size"); byte[] garbage = new byte[header.getDataBlocketteOffset()- header.getSize()]; DataRecord dataRec = new DataRecord(header); if (garbage.length != 0) { inStream.readFully(garbage); } byte[] blocketteBytes; int currOffset = header.getDataBlocketteOffset(); int type, nextOffset; for (int i=0; i< header.getNumBlockettes() ; i++) { //get blockette type (first 2 bytes) byte hibyte = inStream.readByte(); byte lowbyte = inStream.readByte(); type = Utility.uBytesToInt(hibyte, lowbyte, false); // System.out.println("Blockette type "+type); hibyte = inStream.readByte(); lowbyte = inStream.readByte(); nextOffset = Utility.uBytesToInt(hibyte, lowbyte, false); // account for the 4 bytes above currOffset += 4; if (nextOffset != 0) { blocketteBytes = new byte[nextOffset - currOffset]; } else if (header.getDataOffset() > currOffset) { blocketteBytes = new byte[header.getDataOffset()- currOffset]; } else { blocketteBytes = new byte[0]; } inStream.readFully(blocketteBytes); if (nextOffset != 0) { currOffset = nextOffset; } else { currOffset += blocketteBytes.length; } Blockette b = Blockette.parseBlockette(type, blocketteBytes); dataRec.addBlockette(b); if (nextOffset == 0) { break; } } Blockette[] allBs = dataRec.getBlockettes(1000); if (allBs.length == 0) { // no data throw new SeedFormatException("no blockette 1000"); } else if (allBs.length > 1) { throw new SeedFormatException( "Multiple blockette 1000s in the volume. "+ allBs.length); } // System.out.println("allBs.length="+allBs.length); Blockette1000 b1000 = (Blockette1000)allBs[0]; // System.out.println(b1000); byte[] timeseries; if (header.getDataOffset() == 0) { // data record with no data, so gobble up the rest of the record timeseries = new byte[b1000.getDataRecordLength() - currOffset]; } else { timeseries = new byte[ b1000.getDataRecordLength() - header.getDataOffset() ]; } // System.out.println("getDataRecordLength() = "+ b1000.getDataRecordLength()); inStream.readFully(timeseries); dataRec.setData(timeseries); return dataRec; }
public SeedFormatException(String s) { super(s); }
public SeedFormatException() { super(); }
public SeedFormatException(String s) { super(s); }
if (b == null) { throw new IllegalArgumentException("Blockette cannot be null"); }
public void addBlockette(Blockette b) throws SeedFormatException { if (b instanceof DataBlockette) { super.addBlockette(b); getHeader().setNumBlockettes((byte)(getHeader().getNumBlockettes()+1)); } else if (b instanceof BlocketteUnknown) { System.out.println("BlockettUnknown added: "+b.getType()); } else { throw new SeedFormatException( "Cannot add non-data blockettes to a DataRecord "+ b.getType()); } recheckDataOffset(); }
assert( shareFile.getURN() != null ); urnToFileMap.put( shareFile.getURN(), shareFile ); addTimeToFile( shareFile );
rwLock.writeLock(); try { assert( shareFile.getURN() != null ); urnToFileMap.put( shareFile.getURN(), shareFile ); addTimeToFile( shareFile ); } finally { try{ rwLock.writeUnlock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } }
public void addUrn2FileMapping( ShareFile shareFile ) { assert( shareFile.getURN() != null ); urnToFileMap.put( shareFile.getURN(), shareFile ); // only add time once we have a valid URN... // it makes no sense to return whats new files without urn. addTimeToFile( shareFile ); }
colour = (lov * 2.65) - 1.2;
colour = 1.4922 * Math.pow(lov, 0.6859); colour = (colour * 2.65) - 1.2;
private double calcColour(double lov) { double colour = 0; if (colourMethod.equals("EBC")){ // From Greg Noonan's article at http://brewingtechniques.com/bmg/noonan.html colour = (lov * 2.65) - 1.2; } else { // calculates SRM based on MCU (degrees LOV) if (lov > 0) colour = 1.4922 * Math.pow(lov, 0.6859); else colour = 0; } return colour; }
double og = 0; double fg = 0; double lov = 0;
public void calcMaltTotals() { double og = 0; double fg = 0; double lov = 0; double maltPoints = 0; double mcu = 0; totalMaltLbs = 0; totalMaltCost = 0; totalMashLbs = 0; // first figure out the total we're dealing with for (int i = 0; i < fermentables.size(); i++) { Fermentable m = ((Fermentable) fermentables.get(i)); totalMaltLbs += (m.getAmountAs("lb")); if (m.getMashed()){ // apply efficiency and add to mash weight maltPoints += (m.getPppg() - 1) * m.getAmountAs("lb") * efficiency / postBoilVol.getValueAs("gal"); totalMashLbs += (m.getAmountAs("lb")); } else maltPoints += (m.getPppg() - 1) * m.getAmountAs("lb") * 100 / postBoilVol.getValueAs("gal"); mcu += m.getLov() * m.getAmountAs("lb") / postBoilVol.getValueAs("gal"); totalMaltCost += m.getCostPerU() * m.getAmountAs("lb"); } // now set the malt % by weight: for (int i = 0; i < fermentables.size(); i++) { Fermentable m = ((Fermentable) fermentables.get(i)); m.setPercent((m.getAmountAs("lb")/totalMaltLbs * 100)); } // set the fields in the object estOg = (maltPoints / 100) + 1; estFg = 1 + ((estOg - 1) * ((100 - attenuation) / 100)); srm = calcColour(mcu); mash.setMaltWeight(totalMashLbs); calcAlcohol("Volume"); }
DecimalFormat df1 = new DecimalFormat("0.0"); DecimalFormat df2 = new DecimalFormat("0.00");
public String toText(){ DecimalFormat df1 = new DecimalFormat("0.0"); DecimalFormat df2 = new DecimalFormat("0.00"); 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: " + 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(" "+df2.format(f.getAmountAs(f.getUnits())), 6, ' '), f.getUnits(), new Double(f.getPppg()), padRight(" "+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(" "+df2.format(h.getAmountAs(h.getUnits())), 6, ' '), h.getUnits(), padRight(" "+h.getAlpha(), 5, ' '), padRight(" "+df1.format(h.getMinutes()), 6, ' '), padRight(" "+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(); }
rwLock.writeLock(); try
try{ rwLock.assertWriteLock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get( time ); if ( shareFileSet == null )
private void addTimeToFile( ShareFile shareFile ) { rwLock.writeLock(); try { Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get( time ); if ( shareFileSet == null ) { shareFileSet = new HashSet(); timeToFileMap.put(time, shareFileSet); } shareFileSet.add( shareFile ); } finally { try{ rwLock.writeUnlock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } } }
Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get( time ); if ( shareFileSet == null ) { shareFileSet = new HashSet(); timeToFileMap.put(time, shareFileSet); } shareFileSet.add( shareFile );
shareFileSet = new HashSet(); timeToFileMap.put(time, shareFileSet);
private void addTimeToFile( ShareFile shareFile ) { rwLock.writeLock(); try { Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get( time ); if ( shareFileSet == null ) { shareFileSet = new HashSet(); timeToFileMap.put(time, shareFileSet); } shareFileSet.add( shareFile ); } finally { try{ rwLock.writeUnlock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } } }
finally { try{ rwLock.writeUnlock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } }
shareFileSet.add( shareFile );
private void addTimeToFile( ShareFile shareFile ) { rwLock.writeLock(); try { Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get( time ); if ( shareFileSet == null ) { shareFileSet = new HashSet(); timeToFileMap.put(time, shareFileSet); } shareFileSet.add( shareFile ); } finally { try{ rwLock.writeUnlock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } } }
rwLock.writeLock(); try
try{ rwLock.assertWriteLock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get(time); if ( shareFileSet == null )
private void removeTimeToFile( ShareFile shareFile ) { rwLock.writeLock(); try { Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get(time); if ( shareFileSet == null ) { return; } shareFileSet.remove(shareFile); if ( shareFileSet.size() == 0 ) { timeToFileMap.remove(time); } } finally { try{ rwLock.writeUnlock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } } }
Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get(time); if ( shareFileSet == null ) { return; } shareFileSet.remove(shareFile); if ( shareFileSet.size() == 0 ) { timeToFileMap.remove(time); }
return;
private void removeTimeToFile( ShareFile shareFile ) { rwLock.writeLock(); try { Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get(time); if ( shareFileSet == null ) { return; } shareFileSet.remove(shareFile); if ( shareFileSet.size() == 0 ) { timeToFileMap.remove(time); } } finally { try{ rwLock.writeUnlock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } } }
finally
shareFileSet.remove(shareFile); if ( shareFileSet.size() == 0 )
private void removeTimeToFile( ShareFile shareFile ) { rwLock.writeLock(); try { Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get(time); if ( shareFileSet == null ) { return; } shareFileSet.remove(shareFile); if ( shareFileSet.size() == 0 ) { timeToFileMap.remove(time); } } finally { try{ rwLock.writeUnlock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } } }
try{ rwLock.writeUnlock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); }
timeToFileMap.remove(time);
private void removeTimeToFile( ShareFile shareFile ) { rwLock.writeLock(); try { Long time = shareFile.getNetworkCreateTime(); Set shareFileSet = (Set) timeToFileMap.get(time); if ( shareFileSet == null ) { return; } shareFileSet.remove(shareFile); if ( shareFileSet.size() == 0 ) { timeToFileMap.remove(time); } } finally { try{ rwLock.writeUnlock(); } catch (IllegalAccessException exp ) { NLogger.error( NLoggerNames.Sharing, exp, exp ); } } }
j.addFunction("zap2",new MacroFunction("zap",4,"x1+x2+x3+x4",(XJep) j)); valueTest("zap2(5,5,3,6)",19);
public void testMacroFun() throws Exception { j.addFunction("zap",new MacroFunction("zap",1,"x*(x-1)/2",(XJep) j)); valueTest("zap(10)",45); }
public void valueTest(String expr,String expected) throws Exception
public void valueTest(String expr,Object expected) throws Exception
public void valueTest(String expr,String expected) throws Exception { Object res = calcValue(expr); myAssertEquals(expr,expected,res.toString()); }
myAssertEquals(expr,expected,res.toString());
myAssertEquals(expr,expected,res);
public void valueTest(String expr,String expected) throws Exception { Object res = calcValue(expr); myAssertEquals(expr,expected,res.toString()); }
public BaseFormat(int base,String prefix) {
private BaseFormat() {
public BaseFormat(int base,String prefix) { super(); this.base = base; tb = new ToBase(base,prefix); fb = new FromBase(base,prefix); }
this.base = base; tb = new ToBase(base,prefix); fb = new FromBase(base,prefix);
tb = new ToBase(); fb = new FromBase();
public BaseFormat(int base,String prefix) { super(); this.base = base; tb = new ToBase(base,prefix); fb = new FromBase(base,prefix); }
public Comparator getColumnComparator( int column )
public Comparator<?> getColumnComparator( int column )
public Comparator getColumnComparator( int column ) { switch( column ) { case HOST_MODEL_INDEX: return new DestAddressComparator(); case PROGRESS_MODEL_INDEX: return ComparableComparator.getInstance(); case ETA_MODEL_INDEX: return new ETAComparator(); // for all other columns use default comparator default: return null; } }
return "";
return null;
public Object getComparableValueAt( int row, int column ) { SWDownloadCandidate candidate = downloadFile.getTransferCandidate( row ); if ( candidate == null ) { return ""; } SWDownloadSegment segment; switch( column ) { case FROM_MODEL_INDEX: segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getStart() ); case TO_MODEL_INDEX: segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getEnd() ); case SIZE_MODEL_INDEX: segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getTotalDataSize() ); case PROGRESS_MODEL_INDEX: { DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { return null; } return new Long( availableScopeList.getAggregatedLength() ); } case STATUS_MODEL_INDEX: CandidateStatus status = candidate.getStatus(); if ( status == CandidateStatus.REMOTLY_QUEUED ) { int queuePosition = candidate.getXQueueParameters().getPosition().intValue(); Double doubObj = new Double( status.ordinal() + 1.0 - Math.min( (double)queuePosition, (double)10000 ) / 10000.0 ); return doubObj; } else { long timeLeft = candidate.getStatusTimeLeft(); return new Double( status.ordinal() + (double)timeLeft / 1000000.0 ); } case RATE_MODEL_INDEX: { segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getTransferSpeed() ); } case ETA_MODEL_INDEX: { segment = candidate.getDownloadSegment(); return segment; } } return getValueAt( row, column ); }
(double)timeLeft / 1000000.0 );
timeLeft / 1000000.0 );
public Object getComparableValueAt( int row, int column ) { SWDownloadCandidate candidate = downloadFile.getTransferCandidate( row ); if ( candidate == null ) { return ""; } SWDownloadSegment segment; switch( column ) { case FROM_MODEL_INDEX: segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getStart() ); case TO_MODEL_INDEX: segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getEnd() ); case SIZE_MODEL_INDEX: segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getTotalDataSize() ); case PROGRESS_MODEL_INDEX: { DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { return null; } return new Long( availableScopeList.getAggregatedLength() ); } case STATUS_MODEL_INDEX: CandidateStatus status = candidate.getStatus(); if ( status == CandidateStatus.REMOTLY_QUEUED ) { int queuePosition = candidate.getXQueueParameters().getPosition().intValue(); Double doubObj = new Double( status.ordinal() + 1.0 - Math.min( (double)queuePosition, (double)10000 ) / 10000.0 ); return doubObj; } else { long timeLeft = candidate.getStatusTimeLeft(); return new Double( status.ordinal() + (double)timeLeft / 1000000.0 ); } case RATE_MODEL_INDEX: { segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getTransferSpeed() ); } case ETA_MODEL_INDEX: { segment = candidate.getDownloadSegment(); return segment; } } return getValueAt( row, column ); }