bugged
stringlengths
6
599k
fixed
stringlengths
10
599k
__index_level_0__
int64
0
1.13M
public static CVSChangeLogSet parse( java.io.File f ) throws IOException, SAXException { Digester digester = new Digester(); ArrayList<CVSChangeLog> r = new ArrayList<CVSChangeLog>(); digester.push(r); digester.addObjectCreate("*/entry",CVSChangeLog.class); digester.addBeanPropertySetter("*/entry/date"); digester.addBeanPropertySetter("*/entry/time"); digester.addBeanPropertySetter("*/entry/author"); digester.addBeanPropertySetter("*/entry/msg"); digester.addSetNext("*/entry","add"); digester.addObjectCreate("*/entry/file",File.class); digester.addBeanPropertySetter("*/entry/file/name"); digester.addBeanPropertySetter("*/entry/file/revision"); digester.addBeanPropertySetter("*/entry/file/prevrevision"); digester.addCallMethod("*/entry/file/dead","setDead"); digester.addSetNext("*/entry/file","addFile"); digester.parse(f); // merge duplicate entries. Ant task somehow seems to report duplicate entries. for(int i=r.size()-1; i>=0; i--) { CVSChangeLog log = r.get(i); boolean merged = false; for(int j=0;j<i;j++) { CVSChangeLog c = r.get(j); if(c.canBeMergedWith(log)) { c.merge(log); merged = true; break; } } if(merged) r.remove(log); } return new CVSChangeLogSet(r); }
public static CVSChangeLogSet parse( java.io.File f ) throws IOException, SAXException { Digester digester = new Digester(); ArrayList<CVSChangeLog> r = new ArrayList<CVSChangeLog>(); digester.push(r); digester.addObjectCreate("*/entry",CVSChangeLog.class); digester.addBeanPropertySetter("*/entry/date"); digester.addBeanPropertySetter("*/entry/time"); digester.addBeanPropertySetter("*/entry/author","user"); digester.addBeanPropertySetter("*/entry/msg"); digester.addSetNext("*/entry","add"); digester.addObjectCreate("*/entry/file",File.class); digester.addBeanPropertySetter("*/entry/file/name"); digester.addBeanPropertySetter("*/entry/file/revision"); digester.addBeanPropertySetter("*/entry/file/prevrevision"); digester.addCallMethod("*/entry/file/dead","setDead"); digester.addSetNext("*/entry/file","addFile"); digester.parse(f); // merge duplicate entries. Ant task somehow seems to report duplicate entries. for(int i=r.size()-1; i>=0; i--) { CVSChangeLog log = r.get(i); boolean merged = false; for(int j=0;j<i;j++) { CVSChangeLog c = r.get(j); if(c.canBeMergedWith(log)) { c.merge(log); merged = true; break; } } if(merged) r.remove(log); } return new CVSChangeLogSet(r); }
1,116,047
private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } }
private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } }
1,116,048
private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } }
private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } }; task.setProject(new org.apache.tools.ant.Project()); File baseDir = build.getProject().getWorkspace().getLocal(); task.setDir(baseDir); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } }
1,116,049
private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } }
private boolean calcChangeLog(Build build, List<String> changedFiles, File changelogFile, final BuildListener listener) { if(build.getPreviousBuild()==null || (changedFiles!=null && changedFiles.isEmpty())) { // nothing to compare against, or no changes // (note that changedFiles==null means fallback, so we have to run cvs log. listener.getLogger().println("$ no changes detected"); return createEmptyChangeLog(changelogFile,listener, "changelog"); } listener.getLogger().println("$ computing changelog"); ChangeLogTask task = new ChangeLogTask() { public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); } }; task.setProject(new org.apache.tools.ant.Project()); task.setDir(build.getProject().getWorkspace().getLocal()); if(DESCRIPTOR.getCvspassFile().length()!=0) task.setPassfile(new File(DESCRIPTOR.getCvspassFile())); task.setCvsRoot(cvsroot); task.setCvsRsh(cvsRsh); task.setFailOnError(true); task.setDestfile(changelogFile); task.setStart(build.getPreviousBuild().getTimestamp().getTime()); task.setEnd(build.getTimestamp().getTime()); if(changedFiles!=null) task.setFile(changedFiles); else { // fallback if(!flatten) task.setPackage(module); } try { task.execute(); return true; } catch( BuildException e ) { e.printStackTrace(listener.error(e.getMessage())); return false; } catch( RuntimeException e ) { // an user reported a NPE inside the changeLog task. // we don't want a bug in Ant to prevent a build. e.printStackTrace(listener.error(e.getMessage())); return true; // so record the message but continue } }
1,116,050
public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); }
public void log(String msg, int msgLevel) { // send error to listener. This seems like the route in which the changelog task // sends output if(msgLevel==org.apache.tools.ant.Project.MSG_ERR) listener.error(msg); }
1,116,052
public int compare( Object obj1, Object obj2 ) { if ( obj1 == obj2 || obj1.equals(obj2) ) { return 0; } SWDownloadCandidate candidate1 = (SWDownloadCandidate)obj1; SWDownloadCandidate candidate2 = (SWDownloadCandidate)obj2; long diff = candidate1.getLastConnectionTime() - candidate2.getLastConnectionTime(); if ( diff < 0 ) { return 1; } else if ( diff > 0 ) { return -1; } else { return candidate1.hashCode() - candidate2.hashCode(); } }
public int compare( SWDownloadCandidate candidate1, SWDownloadCandidate candidate2 ) { if ( obj1 == obj2 || obj1.equals(obj2) ) { return 0; } SWDownloadCandidate candidate1 = (SWDownloadCandidate)obj1; SWDownloadCandidate candidate2 = (SWDownloadCandidate)obj2; long diff = candidate1.getLastConnectionTime() - candidate2.getLastConnectionTime(); if ( diff < 0 ) { return 1; } else if ( diff > 0 ) { return -1; } else { return candidate1.hashCode() - candidate2.hashCode(); } }
1,116,053
public int compare( Object obj1, Object obj2 ) { if ( obj1 == obj2 || obj1.equals(obj2) ) { return 0; } SWDownloadCandidate candidate1 = (SWDownloadCandidate)obj1; SWDownloadCandidate candidate2 = (SWDownloadCandidate)obj2; long diff = candidate1.getLastConnectionTime() - candidate2.getLastConnectionTime(); if ( diff < 0 ) { return 1; } else if ( diff > 0 ) { return -1; } else { return candidate1.hashCode() - candidate2.hashCode(); } }
public int compare( Object obj1, Object obj2 ) { if ( candidate1 == candidate2 || candidate1.equals(candidate2) ) { return 0; } SWDownloadCandidate candidate1 = (SWDownloadCandidate)obj1; SWDownloadCandidate candidate2 = (SWDownloadCandidate)obj2; long diff = candidate1.getLastConnectionTime() - candidate2.getLastConnectionTime(); if ( diff < 0 ) { return 1; } else if ( diff > 0 ) { return -1; } else { return candidate1.hashCode() - candidate2.hashCode(); } }
1,116,054
public int compare( Object obj1, Object obj2 ) { if ( obj1 == obj2 || obj1.equals(obj2) ) { return 0; } SWDownloadCandidate candidate1 = (SWDownloadCandidate)obj1; SWDownloadCandidate candidate2 = (SWDownloadCandidate)obj2; long diff = candidate1.getLastConnectionTime() - candidate2.getLastConnectionTime(); if ( diff < 0 ) { return 1; } else if ( diff > 0 ) { return -1; } else { return candidate1.hashCode() - candidate2.hashCode(); } }
public int compare( Object obj1, Object obj2 ) { if ( obj1 == obj2 || obj1.equals(obj2) ) { return 0; } SWDownloadCandidate candidate1 = (SWDownloadCandidate)obj1; SWDownloadCandidate candidate2 = (SWDownloadCandidate)obj2; long diff = candidate1.getLastConnectionTime() - candidate2.getLastConnectionTime(); if ( diff < 0 ) { return 1; } else if ( diff > 0 ) { return -1; } else { return candidate1.hashCode() - candidate2.hashCode(); } }
1,116,055
public boolean addAndValidateQueuedCandidate( SWDownloadCandidate candidate ) { int maxWorkers = Math.min( ServiceManager.sCfg.maxTotalDownloadWorker, ServiceManager.sCfg.maxWorkerPerDownload ); int maxQueuedWorkers = (int)Math.max( Math.floor( maxWorkers - (maxWorkers*0.2) ), 1 ); synchronized ( candidatesLock ) { int queuedCount = queuedCandidatesSet.size(); if ( queuedCount < maxQueuedWorkers ) { candidate.addToCandidateLog("Accept queued candidate (" + queuedCount +"/"+maxQueuedWorkers + ")"); queuedCandidatesSet.add(candidate); return true; } if ( queuedCandidatesSet.contains(candidate) ) { return true; } // find a bad slot to drop... SWDownloadCandidate highestCandidate = null; int highestPos = -1; Iterator iterator = queuedCandidatesSet.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate altCandidate = (SWDownloadCandidate) iterator.next(); int altPos = altCandidate.getXQueueParameters().getPosition().intValue(); if ( altPos > highestPos ) { highestCandidate = altCandidate; highestPos = altPos; } } int candidatePos = candidate.getXQueueParameters().getPosition().intValue(); if ( highestCandidate != null && highestPos > candidatePos ) { // TODO1 use a higher timeout to honor queue pos highestCandidate.addToCandidateLog( "Drop queued candidate - new alternative: " + highestPos +" - " + candidatePos + ")"); highestCandidate.setStatus( CandidateStatus.BUSY, -1 ); SWDownloadWorker worker = (SWDownloadWorker)allocatedCandidateWorkerMap.get( highestCandidate); if ( worker != null ) { worker.stopWorker(); } queuedCandidatesSet.add(candidate); return true; } else { // TODO1 use a higher timeout to honor queue pos candidate.addToCandidateLog( "Drop queued candidate - existing alternative: " + candidatePos +" - " + highestPos ); candidate.setStatus( CandidateStatus.BUSY, -1 ); return false; } } }
public boolean addAndValidateQueuedCandidate( SWDownloadCandidate candidate ) { int maxWorkers = Math.min( ServiceManager.sCfg.maxTotalDownloadWorker, ServiceManager.sCfg.maxWorkerPerDownload ); int maxQueuedWorkers = (int)Math.max( Math.floor( maxWorkers - (maxWorkers*0.2) ), 1 ); synchronized ( candidatesLock ) { int queuedCount = queuedCandidatesSet.size(); if ( queuedCount < maxQueuedWorkers ) { candidate.addToCandidateLog("Accept queued candidate (" + queuedCount +"/"+maxQueuedWorkers + ")"); queuedCandidatesSet.add(candidate); return true; } if ( queuedCandidatesSet.contains(candidate) ) { return true; } // find a bad slot to drop... SWDownloadCandidate highestCandidate = null; int highestPos = -1; Iterator iterator = queuedCandidatesSet.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate altCandidate = (SWDownloadCandidate) iterator.next(); int altPos = altCandidate.getXQueueParameters().getPosition().intValue(); if ( altPos > highestPos ) { highestCandidate = altCandidate; highestPos = altPos; } } int candidatePos = candidate.getXQueueParameters().getPosition().intValue(); if ( highestCandidate != null && highestPos > candidatePos ) { // TODO1 use a higher timeout to honor queue pos highestCandidate.addToCandidateLog( "Drop queued candidate - new alternative: " + highestPos +" - " + candidatePos + ")"); highestCandidate.setStatus( CandidateStatus.BUSY, -1 ); SWDownloadWorker worker = (SWDownloadWorker)allocatedCandidateWorkerMap.get( highestCandidate); if ( worker != null ) { worker.stopWorker(); } queuedCandidatesSet.add(candidate); return true; } else { // TODO1 use a higher timeout to honor queue pos candidate.addToCandidateLog( "Drop queued candidate - existing alternative: " + candidatePos +" - " + highestPos ); candidate.setStatus( CandidateStatus.BUSY, -1 ); return false; } } }
1,116,056
public boolean addAndValidateQueuedCandidate( SWDownloadCandidate candidate ) { int maxWorkers = Math.min( ServiceManager.sCfg.maxTotalDownloadWorker, ServiceManager.sCfg.maxWorkerPerDownload ); int maxQueuedWorkers = (int)Math.max( Math.floor( maxWorkers - (maxWorkers*0.2) ), 1 ); synchronized ( candidatesLock ) { int queuedCount = queuedCandidatesSet.size(); if ( queuedCount < maxQueuedWorkers ) { candidate.addToCandidateLog("Accept queued candidate (" + queuedCount +"/"+maxQueuedWorkers + ")"); queuedCandidatesSet.add(candidate); return true; } if ( queuedCandidatesSet.contains(candidate) ) { return true; } // find a bad slot to drop... SWDownloadCandidate highestCandidate = null; int highestPos = -1; Iterator iterator = queuedCandidatesSet.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate altCandidate = (SWDownloadCandidate) iterator.next(); int altPos = altCandidate.getXQueueParameters().getPosition().intValue(); if ( altPos > highestPos ) { highestCandidate = altCandidate; highestPos = altPos; } } int candidatePos = candidate.getXQueueParameters().getPosition().intValue(); if ( highestCandidate != null && highestPos > candidatePos ) { // TODO1 use a higher timeout to honor queue pos highestCandidate.addToCandidateLog( "Drop queued candidate - new alternative: " + highestPos +" - " + candidatePos + ")"); highestCandidate.setStatus( CandidateStatus.BUSY, -1 ); SWDownloadWorker worker = (SWDownloadWorker)allocatedCandidateWorkerMap.get( highestCandidate); if ( worker != null ) { worker.stopWorker(); } queuedCandidatesSet.add(candidate); return true; } else { // TODO1 use a higher timeout to honor queue pos candidate.addToCandidateLog( "Drop queued candidate - existing alternative: " + candidatePos +" - " + highestPos ); candidate.setStatus( CandidateStatus.BUSY, -1 ); return false; } } }
public boolean addAndValidateQueuedCandidate( SWDownloadCandidate candidate ) { int maxWorkers = Math.min( ServiceManager.sCfg.maxTotalDownloadWorker, ServiceManager.sCfg.maxWorkerPerDownload ); int maxQueuedWorkers = (int)Math.max( Math.floor( maxWorkers - (maxWorkers*0.2) ), 1 ); synchronized ( candidatesLock ) { int queuedCount = queuedCandidatesSet.size(); if ( queuedCount < maxQueuedWorkers ) { candidate.addToCandidateLog("Accept queued candidate (" + queuedCount +"/"+maxQueuedWorkers + ")"); queuedCandidatesSet.add(candidate); return true; } if ( queuedCandidatesSet.contains(candidate) ) { return true; } // find a bad slot to drop... SWDownloadCandidate highestCandidate = null; int highestPos = -1; Iterator iterator = queuedCandidatesSet.iterator(); while ( iterator.hasNext() ) { int altPos = altCandidate.getXQueueParameters().getPosition().intValue(); if ( altPos > highestPos ) { highestCandidate = altCandidate; highestPos = altPos; } } int candidatePos = candidate.getXQueueParameters().getPosition().intValue(); if ( highestCandidate != null && highestPos > candidatePos ) { // TODO1 use a higher timeout to honor queue pos highestCandidate.addToCandidateLog( "Drop queued candidate - new alternative: " + highestPos +" - " + candidatePos + ")"); highestCandidate.setStatus( CandidateStatus.BUSY, -1 ); SWDownloadWorker worker = (SWDownloadWorker)allocatedCandidateWorkerMap.get( highestCandidate); if ( worker != null ) { worker.stopWorker(); } queuedCandidatesSet.add(candidate); return true; } else { // TODO1 use a higher timeout to honor queue pos candidate.addToCandidateLog( "Drop queued candidate - existing alternative: " + candidatePos +" - " + highestPos ); candidate.setStatus( CandidateStatus.BUSY, -1 ); return false; } } }
1,116,057
private SWDownloadCandidate allocateBadCandidate( SWDownloadWorker worker ) { SWDownloadCandidate candidate = null; synchronized( candidatesLock ) { int numCandidates = badCandidatesList.size(); // return quickly if there are no candidates if ( numCandidates == 0 ) { return null; } // sanity check on persistent index, because since the last call to this method, // the number of candidates may have decreased, leaving the persistent index // out of range. if ( badCandidatePosition >= numCandidates ) { badCandidatePosition = 0; } // Iterate over candidates to find the next available for (int i=0; i < numCandidates; i++) { // currentIndex holds the index of the candidate that will be // checked for availability int currentIndex = i + badCandidatePosition; if (currentIndex >= numCandidates) { currentIndex -= numCandidates; } candidate = (SWDownloadCandidate)badCandidatesList.get(currentIndex); if ( candidate.isAbleToBeAllocated() && !allocatedCandidateWorkerMap.containsKey( candidate ) ) { NLogger.debug( NLoggerNames.Download_Candidate_Allocate, "Allocating bad candidate " + candidate + " from " + worker ); candidate.addToCandidateLog("Allocating as bad candidate."); // Sets the segment to be allocated by a worker. allocatedCandidateWorkerMap.put( candidate, worker ); badCandidatePosition = currentIndex + 1; return candidate; } } } // No valid candidate found // Don't bother updating the persistent index, because it probably // doesn't matter where we begin the search from on the next call. return null; }
private SWDownloadCandidate allocateBadCandidate( SWDownloadWorker worker ) { SWDownloadCandidate candidate = null; synchronized( candidatesLock ) { int numCandidates = badCandidatesList.size(); // return quickly if there are no candidates if ( numCandidates == 0 ) { return null; } // sanity check on persistent index, because since the last call to this method, // the number of candidates may have decreased, leaving the persistent index // out of range. if ( badCandidatePosition >= numCandidates ) { badCandidatePosition = 0; } // Iterate over candidates to find the next available for (int i=0; i < numCandidates; i++) { // currentIndex holds the index of the candidate that will be // checked for availability int currentIndex = i + badCandidatePosition; if (currentIndex >= numCandidates) { currentIndex -= numCandidates; } candidate = badCandidatesList.get(currentIndex); if ( candidate.isAbleToBeAllocated() && !allocatedCandidateWorkerMap.containsKey( candidate ) ) { NLogger.debug( NLoggerNames.Download_Candidate_Allocate, "Allocating bad candidate " + candidate + " from " + worker ); candidate.addToCandidateLog("Allocating as bad candidate."); // Sets the segment to be allocated by a worker. allocatedCandidateWorkerMap.put( candidate, worker ); badCandidatePosition = currentIndex + 1; return candidate; } } } // No valid candidate found // Don't bother updating the persistent index, because it probably // doesn't matter where we begin the search from on the next call. return null; }
1,116,058
private DownloadScope allocateSegmentForRangeSet( DownloadScopeList candidateScopeList, long preferredSize) { assert fileSize != UNKNOWN_FILE_SIZE : "Cant allocate segment for range set with unknown end."; NLogger.debug( NLoggerNames.Download_Segment_Allocate, "allocateSegmentForRangeSet() size: " + preferredSize); if( candidateScopeList == null ) { // create scope covering the whole file. candidateScopeList = new DownloadScopeList(); candidateScopeList.add( new DownloadScope( 0, fileSize - 1 ) ); } return memoryFile.allocateMissingScopeForCandidate( this, candidateScopeList, preferredSize ); }
private DownloadScope allocateSegmentForRangeSet( DownloadScopeList candidateScopeList, long preferredSize) { assert fileSize != UNKNOWN_FILE_SIZE : "Cant allocate segment for range set with unknown end."; NLogger.debug( NLoggerNames.Download_Segment_Allocate, "allocateSegmentForRangeSet() size: " + preferredSize); if( candidateScopeList == null ) { // create scope covering the whole file. candidateScopeList = new DownloadScopeList(); candidateScopeList.add( new DownloadScope( 0, fileSize - 1 ) ); } return memoryFile.allocateMissingScopeForCandidate( candidateScopeList, preferredSize ); }
1,116,059
public XJBSWDownloadFile createXJBSWDownloadFile() throws JAXBException { ObjectFactory objFactory = new ObjectFactory(); XJBSWDownloadFile xjbFile = objFactory.createXJBSWDownloadFile(); xjbFile.setLocalFileName( destinationFile.getName() ); xjbFile.setIncompleteFileName( incompleteFile.getAbsolutePath() ); xjbFile.setFileSize( fileSize ); xjbFile.setSearchTerm( researchSetting.getSearchTerm() ); xjbFile.setCreatedTime( createdDate.getTime() ); xjbFile.setModifiedTime( modifiedDate.getTime() ); if ( fileURN != null ) { xjbFile.setFileURN( fileURN.getAsString() ); } xjbFile.setStatus( status ); synchronized ( candidatesLock ) { List list = xjbFile.getCandidateList(); Iterator iterator = goodCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); XJBSWDownloadCandidate xjbCandidate = candidate.createXJBSWDownloadCandidate(); list.add( xjbCandidate ); } iterator = mediumCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); XJBSWDownloadCandidate xjbCandidate = candidate.createXJBSWDownloadCandidate(); list.add( xjbCandidate ); } iterator = badCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); if ( candidate.getStatus() == CandidateStatus.IGNORED ) { continue; } XJBSWDownloadCandidate xjbCandidate = candidate.createXJBSWDownloadCandidate(); list.add( xjbCandidate ); } } memoryFile.createXJBFinishedScopes(xjbFile); return xjbFile; }
public XJBSWDownloadFile createXJBSWDownloadFile() throws JAXBException { ObjectFactory objFactory = new ObjectFactory(); XJBSWDownloadFile xjbFile = objFactory.createXJBSWDownloadFile(); xjbFile.setLocalFileName( destinationFile.getName() ); if ( incompleteFile != null ) { xjbFile.setIncompleteFileName( incompleteFile.getAbsolutePath() ); } xjbFile.setFileSize( fileSize ); xjbFile.setSearchTerm( researchSetting.getSearchTerm() ); xjbFile.setCreatedTime( createdDate.getTime() ); xjbFile.setModifiedTime( modifiedDate.getTime() ); if ( fileURN != null ) { xjbFile.setFileURN( fileURN.getAsString() ); } xjbFile.setStatus( status ); synchronized ( candidatesLock ) { List list = xjbFile.getCandidateList(); Iterator iterator = goodCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); XJBSWDownloadCandidate xjbCandidate = candidate.createXJBSWDownloadCandidate(); list.add( xjbCandidate ); } iterator = mediumCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); XJBSWDownloadCandidate xjbCandidate = candidate.createXJBSWDownloadCandidate(); list.add( xjbCandidate ); } iterator = badCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); if ( candidate.getStatus() == CandidateStatus.IGNORED ) { continue; } XJBSWDownloadCandidate xjbCandidate = candidate.createXJBSWDownloadCandidate(); list.add( xjbCandidate ); } } memoryFile.createXJBFinishedScopes(xjbFile); return xjbFile; }
1,116,060
public SWDownloadCandidate getCandidate( int index ) { if ( index < 0 || index >= allCandidatesList.size() ) { return null; } return (SWDownloadCandidate) allCandidatesList.get( index ); }
public SWDownloadCandidate getCandidate( int index ) { if ( index < 0 || index >= allCandidatesList.size() ) { return null; } return allCandidatesList.get( index ); }
1,116,061
public RatedDownloadScopeList getRatedScopeList() { return memoryFile.getRatedScopeList( this ); }
public RatedDownloadScopeList getRatedScopeList() { return memoryFile.getRatedScopeList( ); }
1,116,062
public SWDownloadCandidate getTransferCandidate( int index ) { if ( index < 0 || index >= transferCandidatesList.size() ) { return null; } return (SWDownloadCandidate)transferCandidatesList.get( index ); }
public SWDownloadCandidate getTransferCandidate( int index ) { if ( index < 0 || index >= transferCandidatesList.size() ) { return null; } return transferCandidatesList.get( index ); }
1,116,063
public void rateDownloadScopeList( RatedDownloadScopeList ratedScopeList) { long oldestConnectTime = System.currentTimeMillis() - BAD_CANDIDATE_STATUS_TIMEOUT; synchronized( candidatesLock ) { Iterator iterator = goodCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); if ( candidate.getLastConnectionTime() == 0 || candidate.getLastConnectionTime() < oldestConnectTime ) { continue; } DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { availableScopeList = new DownloadScopeList(); availableScopeList.add( new DownloadScope( 0, fileSize - 1) ); } ratedScopeList.rateDownloadScopeList( availableScopeList, candidate.getSpeed() ); } } }
public void rateDownloadScopeList( RatedDownloadScopeList ratedScopeList) { long oldestConnectTime = System.currentTimeMillis() - BAD_CANDIDATE_STATUS_TIMEOUT; synchronized( candidatesLock ) { Iterator iterator = goodCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); if ( candidate.getLastConnectionTime() == 0 || candidate.getLastConnectionTime() < oldestConnectTime ) { continue; } DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { availableScopeList = new DownloadScopeList(); availableScopeList.add( new DownloadScope( 0, fileSize - 1) ); } ratedScopeList.rateDownloadScopeList( availableScopeList, candidate.getSpeed() ); } } }
1,116,064
public void rateDownloadScopeList( RatedDownloadScopeList ratedScopeList) { long oldestConnectTime = System.currentTimeMillis() - BAD_CANDIDATE_STATUS_TIMEOUT; synchronized( candidatesLock ) { Iterator iterator = goodCandidatesList.iterator(); while( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate)iterator.next(); if ( candidate.getLastConnectionTime() == 0 || candidate.getLastConnectionTime() < oldestConnectTime ) { continue; } DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { availableScopeList = new DownloadScopeList(); availableScopeList.add( new DownloadScope( 0, fileSize - 1) ); } ratedScopeList.rateDownloadScopeList( availableScopeList, candidate.getSpeed() ); } } }
public void rateDownloadScopeList( RatedDownloadScopeList ratedScopeList) { long oldestConnectTime = System.currentTimeMillis() - BAD_CANDIDATE_STATUS_TIMEOUT; synchronized( candidatesLock ) { Iterator iterator = goodCandidatesList.iterator(); while( iterator.hasNext() ) { if ( candidate.getLastConnectionTime() == 0 || candidate.getLastConnectionTime() < oldestConnectTime ) { continue; } DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { availableScopeList = new DownloadScopeList(); availableScopeList.add( new DownloadScope( 0, fileSize - 1) ); } ratedScopeList.rateDownloadScopeList( availableScopeList, candidate.getSpeed() ); } } }
1,116,065
private void updateCandidateWorkerCounts() { // to save performance search in transfer list for // downloading candidates. synchronized( candidatesLock ) { long now = System.currentTimeMillis(); if ( lastCandidateWorkerCountUpdate + CANDIDATE_WORKER_COUNT_TIMEOUT > now ) { return; } int downloadingCount = 0; int queuedCount = 0; int connectingCount = 0; Iterator iterator = transferCandidatesList.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate) iterator.next(); CandidateStatus status = candidate.getStatus(); switch ( status ) { case DOWNLOADING: downloadingCount ++; break; case REMOTLY_QUEUED: queuedCount ++; break; case CONNECTING: connectingCount ++; break; } } queuedCandidateCount = queuedCount; downloadingCandidateCount = downloadingCount; connectingCandidateCount = connectingCount; // calculation could take a while.. therefor we dont use cached // time. lastCandidateWorkerCountUpdate = System.currentTimeMillis(); } }
private void updateCandidateWorkerCounts() { // to save performance search in transfer list for // downloading candidates. synchronized( candidatesLock ) { long now = System.currentTimeMillis(); if ( lastCandidateWorkerCountUpdate + CANDIDATE_WORKER_COUNT_TIMEOUT > now ) { return; } int downloadingCount = 0; int queuedCount = 0; int connectingCount = 0; Iterator iterator = transferCandidatesList.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate) iterator.next(); CandidateStatus status = candidate.getStatus(); switch ( status ) { case DOWNLOADING: downloadingCount ++; break; case REMOTLY_QUEUED: queuedCount ++; break; case CONNECTING: connectingCount ++; break; } } queuedCandidateCount = queuedCount; downloadingCandidateCount = downloadingCount; connectingCandidateCount = connectingCount; // calculation could take a while.. therefor we dont use cached // time. lastCandidateWorkerCountUpdate = System.currentTimeMillis(); } }
1,116,066
private void updateCandidateWorkerCounts() { // to save performance search in transfer list for // downloading candidates. synchronized( candidatesLock ) { long now = System.currentTimeMillis(); if ( lastCandidateWorkerCountUpdate + CANDIDATE_WORKER_COUNT_TIMEOUT > now ) { return; } int downloadingCount = 0; int queuedCount = 0; int connectingCount = 0; Iterator iterator = transferCandidatesList.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate) iterator.next(); CandidateStatus status = candidate.getStatus(); switch ( status ) { case DOWNLOADING: downloadingCount ++; break; case REMOTLY_QUEUED: queuedCount ++; break; case CONNECTING: connectingCount ++; break; } } queuedCandidateCount = queuedCount; downloadingCandidateCount = downloadingCount; connectingCandidateCount = connectingCount; // calculation could take a while.. therefor we dont use cached // time. lastCandidateWorkerCountUpdate = System.currentTimeMillis(); } }
private void updateCandidateWorkerCounts() { // to save performance search in transfer list for // downloading candidates. synchronized( candidatesLock ) { long now = System.currentTimeMillis(); if ( lastCandidateWorkerCountUpdate + CANDIDATE_WORKER_COUNT_TIMEOUT > now ) { return; } int downloadingCount = 0; int queuedCount = 0; int connectingCount = 0; Iterator iterator = transferCandidatesList.iterator(); while ( iterator.hasNext() ) { SWDownloadCandidate candidate = (SWDownloadCandidate) iterator.next(); CandidateStatus status = candidate.getStatus(); switch ( status ) { case DOWNLOADING: downloadingCount ++; break; case REMOTLY_QUEUED: queuedCount ++; break; case CONNECTING: connectingCount ++; break; } } queuedCandidateCount = queuedCount; downloadingCandidateCount = downloadingCount; connectingCandidateCount = connectingCount; // calculation could take a while.. therefor we dont use cached // time. lastCandidateWorkerCountUpdate = System.currentTimeMillis(); } }
1,116,067
public void verifyStatus() { forceCollectionOfTransferData(); synchronized( candidatesLock ) { if ( !isFileCompletedOrMoved() && memoryFile.getFinishedBufferedLength() == getTotalDataSize() ) { // trigger data write down to disk... // this will also adjust the status in case file really turns // out to be complete memoryFile.writeBuffersToDisk(); return; } SWDownloadCandidate candidate; Iterator iterator = allocatedCandidateWorkerMap.keySet().iterator(); CandidateStatus highestStatus = CandidateStatus.WAITING; while ( iterator.hasNext() && highestStatus != CandidateStatus.DOWNLOADING) { candidate = (SWDownloadCandidate)iterator.next(); switch ( candidate.getStatus() ) { case DOWNLOADING: { highestStatus = CandidateStatus.DOWNLOADING; break; } case REMOTLY_QUEUED: { highestStatus = CandidateStatus.REMOTLY_QUEUED; break; } } } // when we are here no download is running... // we dont need to set status if file is stopped or completed if ( !isDownloadStopped() && !isFileCompletedOrMoved() ) { switch ( highestStatus ) { case REMOTLY_QUEUED: setStatus( STATUS_FILE_QUEUED ); break; case DOWNLOADING: setStatus( STATUS_FILE_DOWNLOADING ); break; default: setStatus( STATUS_FILE_WAITING ); break; } } } }
public void verifyStatus() { forceCollectionOfTransferData(); synchronized( candidatesLock ) { if ( !isFileCompletedOrMoved() && memoryFile.getFinishedBufferedLength() == getTotalDataSize() ) { // trigger data write down to disk... // this will also adjust the status in case file really turns // out to be complete memoryFile.requestBufferWriting(); return; } SWDownloadCandidate candidate; Iterator iterator = allocatedCandidateWorkerMap.keySet().iterator(); CandidateStatus highestStatus = CandidateStatus.WAITING; while ( iterator.hasNext() && highestStatus != CandidateStatus.DOWNLOADING) { candidate = (SWDownloadCandidate)iterator.next(); switch ( candidate.getStatus() ) { case DOWNLOADING: { highestStatus = CandidateStatus.DOWNLOADING; break; } case REMOTLY_QUEUED: { highestStatus = CandidateStatus.REMOTLY_QUEUED; break; } } } // when we are here no download is running... // we dont need to set status if file is stopped or completed if ( !isDownloadStopped() && !isFileCompletedOrMoved() ) { switch ( highestStatus ) { case REMOTLY_QUEUED: setStatus( STATUS_FILE_QUEUED ); break; case DOWNLOADING: setStatus( STATUS_FILE_DOWNLOADING ); break; default: setStatus( STATUS_FILE_WAITING ); break; } } } }
1,116,068
public DownloadScope allocateMissingScopeForCandidate( SWDownloadFile downloadFile, DownloadScopeList candidateScopeList, long preferredSize ) { synchronized( missingScopeList ) { DownloadScopeList wantedScopeList = (DownloadScopeList)missingScopeList.clone(); wantedScopeList.addAll( missingScopeList ); wantedScopeList.retainAll( candidateScopeList ); if ( wantedScopeList.size() == 0 ) { return null; } DownloadScope scope = scopeSelectionStrategy.selectDownloadScope( downloadFile, wantedScopeList, preferredSize ); if ( scope == null ) { return null; } missingScopeList.remove( scope ); synchronized( blockedScopeList ) { blockedScopeList.add( scope ); } return scope; } }
public DownloadScope allocateMissingScopeForCandidate( SWDownloadFile downloadFile, DownloadScopeList candidateScopeList, long preferredSize ) { synchronized( missingScopeList ) { DownloadScopeList wantedScopeList = (DownloadScopeList)missingScopeList.clone(); wantedScopeList.addAll( missingScopeList ); wantedScopeList.retainAll( candidateScopeList ); if ( wantedScopeList.size() == 0 ) { return null; } DownloadScope scope = scopeSelectionStrategy.selectDownloadScope( downloadFile, wantedScopeList, preferredSize ); if ( scope == null ) { return null; } missingScopeList.remove( scope ); synchronized( blockedScopeList ) { blockedScopeList.add( scope ); } return scope; } }
1,116,069
public List getFinishedScopeListCopy() { return finishedScopeList.getScopeListCopy(); }
public List<DownloadScope> getFinishedScopeListCopy() { return finishedScopeList.getScopeListCopy(); }
1,116,070
public RatedDownloadScopeList getRatedScopeList( SWDownloadFile downloadFile ) { long now = System.currentTimeMillis(); if ( ratedScopeListBuildTime + SWDownloadConstants.RATED_SCOPE_LIST_TIMEOUT > now ) { return ratedScopeList; } if ( ratedScopeList == null ) { ratedScopeList = new RatedDownloadScopeList(); } else { ratedScopeList.clear(); } ratedScopeList.addAll( missingScopeList ); downloadFile.rateDownloadScopeList( ratedScopeList ); ratedScopeListBuildTime = System.currentTimeMillis(); return ratedScopeList; }
public RatedDownloadScopeList getRatedScopeList() { long now = System.currentTimeMillis(); if ( ratedScopeListBuildTime + SWDownloadConstants.RATED_SCOPE_LIST_TIMEOUT > now ) { return ratedScopeList; } if ( ratedScopeList == null ) { ratedScopeList = new RatedDownloadScopeList(); } else { ratedScopeList.clear(); } ratedScopeList.addAll( missingScopeList ); downloadFile.rateDownloadScopeList( ratedScopeList ); ratedScopeListBuildTime = System.currentTimeMillis(); return ratedScopeList; }
1,116,071
public synchronized void setThrottlingRate(long bytesPerSecond) { throttlingRate = bytesPerSecond; bytesPerWindow = (int) ((double) throttlingRate / (double) WINDOWS_PER_SECONDS); if ( NLogger.isDebugEnabled( NLoggerNames.BANDWIDTH ) ) NLogger.debug(NLoggerNames.BANDWIDTH, "["+controllerName + "] Set throttling rate to " + bytesPerSecond + "bps (" + bytesPerWindow + " per window)"); bytesRemaining = Math.min( bytesRemaining, bytesPerWindow ); }
public synchronized void setThrottlingRate(long bytesPerSecond) { throttlingRate = bytesPerSecond; bytesPerWindow = Math.max( (int) ((double) throttlingRate / (double) WINDOWS_PER_SECONDS), 1 ) ; if ( NLogger.isDebugEnabled( NLoggerNames.BANDWIDTH ) ) NLogger.debug(NLoggerNames.BANDWIDTH, "["+controllerName + "] Set throttling rate to " + bytesPerSecond + "bps (" + bytesPerWindow + " per window)"); bytesRemaining = Math.min( bytesRemaining, bytesPerWindow ); }
1,116,073
public synchronized void setThrottlingRate(long bytesPerSecond) { throttlingRate = bytesPerSecond; bytesPerWindow = (int) ((double) throttlingRate / (double) WINDOWS_PER_SECONDS); if ( NLogger.isDebugEnabled( NLoggerNames.BANDWIDTH ) ) NLogger.debug(NLoggerNames.BANDWIDTH, "["+controllerName + "] Set throttling rate to " + bytesPerSecond + "bps (" + bytesPerWindow + " per window)"); bytesRemaining = Math.min( bytesRemaining, bytesPerWindow ); }
public synchronized void setThrottlingRate(long bytesPerSecond) { throttlingRate = bytesPerSecond; bytesPerWindow = (int) ((double) throttlingRate / (double) WINDOWS_PER_SECONDS); if ( NLogger.isDebugEnabled( NLoggerNames.BANDWIDTH ) ) NLogger.debug(NLoggerNames.BANDWIDTH, "["+controllerName + "] Set throttling rate to " + bytesPerSecond + "bps (" + bytesPerWindow + " per window)"); bytesRemaining = bytesRemaining < bytesPerWindow ? Math.min( bytesRemaining, bytesPerWindow ) : bytesRemaining; }
1,116,074
public Host(DestAddress address, Connection connection) { this(); hostAddress = address; this.connection = connection; }
public Host() { this(); hostAddress = address; this.connection = connection; }
1,116,075
public Host(DestAddress address, Connection connection) { this(); hostAddress = address; this.connection = connection; }
public Host(DestAddress address, Connection connection) { this(); hostAddress = address; this.connection = connection; }
1,116,076
public Object sqrt(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); // a value less than 0 will produce a complex result if (value < 0) { return (new Complex(value).sqrt()); } else { return new Double(Math.sqrt(value)); } } else if (param instanceof Complex) { return ((Complex)param).sqrt(); } throw new ParseException("Invalid parameter type"); }
public Object sqrt(Object param) throws ParseException { if (param instanceof Complex) return ((Complex)param).sqrt(); if (param instanceof Number) { double value = ((Number)param).doubleValue(); // a value less than 0 will produce a complex result if (value < 0) { return (new Complex(value).sqrt()); } else { return new Double(Math.sqrt(value)); } } else if (param instanceof Complex) { return ((Complex)param).sqrt(); } throw new ParseException("Invalid parameter type"); }
1,116,077
public Object sqrt(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); // a value less than 0 will produce a complex result if (value < 0) { return (new Complex(value).sqrt()); } else { return new Double(Math.sqrt(value)); } } else if (param instanceof Complex) { return ((Complex)param).sqrt(); } throw new ParseException("Invalid parameter type"); }
public Object sqrt(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); // a value less than 0 will produce a complex result if (value < 0.0) { return (new Complex(value).sqrt()); } else { return new Double(Math.sqrt(value)); } } else if (param instanceof Complex) { return ((Complex)param).sqrt(); } throw new ParseException("Invalid parameter type"); }
1,116,078
public Object sqrt(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); // a value less than 0 will produce a complex result if (value < 0) { return (new Complex(value).sqrt()); } else { return new Double(Math.sqrt(value)); } } else if (param instanceof Complex) { return ((Complex)param).sqrt(); } throw new ParseException("Invalid parameter type"); }
public Object sqrt(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); // a value less than 0 will produce a complex result if (value < 0) { return (new Complex(value).sqrt()); } else { return new Double(Math.sqrt(value)); } } else if (param instanceof Complex) { return ((Complex)param).sqrt(); } throw new ParseException("Invalid parameter type"); }
1,116,079
public void println(Node node) { println(node,System.out); }
public void println(Node node,PrintStream out) { print(node,out); out.println(""); }
1,116,081
public Recipe getRecipe() {return r;}
public Recipe getRecipe() { r.setAllowRecalcs(true); return r;}
1,116,083
public ServiceFactoryComponent(Config config, Dictionary overriddenProps) { super(config, overriddenProps); services = new Hashtable(); }
public ServiceFactoryComponent(Config config, Dictionary overriddenProps) { super(config, overriddenProps); services = new Hashtable(); }
1,116,085
public synchronized Object getService(Bundle bundle, ServiceRegistration reg) { Object service = services.get(bundle); if (service == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); Component component = copy.createComponent(); component.enable(); service = component.getService(bundle, reg); services.put(bundle, service); } return service; }
public synchronized Object getService(Bundle bundle, ServiceRegistration reg) { Component component = services.get(bundle); if (service == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); Component component = copy.createComponent(); component.enable(); service = component.getService(bundle, reg); services.put(bundle, service); } return service; }
1,116,086
public synchronized Object getService(Bundle bundle, ServiceRegistration reg) { Object service = services.get(bundle); if (service == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); Component component = copy.createComponent(); component.enable(); service = component.getService(bundle, reg); services.put(bundle, service); } return service; }
public synchronized Object getService(Bundle bundle, ServiceRegistration reg) { Object service = services.get(bundle); if (service == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); Component component = copy.createComponent(); component.enable(); service = component.getService(bundle, reg); services.put(bundle, service); } return service; }
1,116,087
public synchronized Object getService(Bundle bundle, ServiceRegistration reg) { Object service = services.get(bundle); if (service == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); Component component = copy.createComponent(); component.enable(); service = component.getService(bundle, reg); services.put(bundle, service); } return service; }
public synchronized Object getService(Bundle bundle, ServiceRegistration reg) { Object service = services.get(bundle); if (service == null) { Config copy = config.copy(); copy.setServiceFactory(false); copy.setShouldRegisterService(false); Component component = copy.createComponent(); component.enable(); service = component.getService(bundle, reg); services.put(bundle, service); } return service; }
1,116,088
public void ungetService(Bundle bundle, ServiceRegistration reg, Object instance) { super.ungetService(bundle, reg, instance); services.remove(bundle); }
public void ungetService(Bundle bundle, ServiceRegistration reg, Object instance) { super.ungetService(bundle, reg, instance); services.remove(bundle); }
1,116,089
private void appendBuildUrl(Build build, StringBuffer buf) { String baseUrl = DESCRIPTOR.getUrl(); if(baseUrl!=null) { String encodedUrl = null; try { encodedUrl = URLEncoder.encode(build.getUrl(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); // UTF-8 is supported everywhere } buf.append("See ").append(baseUrl).append(encodedUrl).append("\n\n"); } }
private void appendBuildUrl(Build build, StringBuffer buf) { String baseUrl = DESCRIPTOR.getUrl(); if(baseUrl!=null) { String encodedUrl = null; try { encodedUrl = URLEncoder.encode(build.getUrl(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); // UTF-8 is supported everywhere } buf.append("See ").append(baseUrl).append(encodedUrl).append("\n\n"); } }
1,116,090
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI lhs) throws ParseException { if(!(res instanceof Scaler)) throw new ParseException("vsum: result must be a scaler"); Object val = Scaler.getInstance(lhs.getEle(0)); for(int i=1;i<lhs.getNumEles();++i) val = add.add(val,lhs.getEle(i)); res.setEle(0,val); return res; }
public MatrixValueI calcValue(MatrixValueI res, MatrixValueI lhs) throws ParseException { if(!(res instanceof Scaler)) throw new ParseException("vsum: result must be a scaler"); Object val = lhs.getEle(0); for(int i=1;i<lhs.getNumEles();++i) val = add.add(val,lhs.getEle(i)); res.setEle(0,val); return res; }
1,116,091
public Comparator getColumnComparator( int column ) { switch( column ) { case HOST_MODEL_INDEX: return new DestAddressComparator(); case PROGRESS_MODEL_INDEX: return ComparableComparator.getInstance(); // for all other columns use default comparator default: return null; } }
public Comparator<?> getColumnComparator( int column ) { switch( column ) { case HOST_MODEL_INDEX: return new DestAddressComparator(); case PROGRESS_MODEL_INDEX: return ComparableComparator.getInstance(); // for all other columns use default comparator default: return null; } }
1,116,092
public Object getComparableValueAt( int row, int column ) { SWDownloadCandidate candidate = downloadFile.getCandidate( row ); if ( candidate == null ) { return ""; } switch( column ) { case PROGRESS_MODEL_INDEX: { DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { return null; } return new Long( availableScopeList.getAggregatedLength() ); } case TOTAL_DOWNLOAD_MODEL_INDEX: return new Long( candidate.getTotalDownloadSize() ); 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(); double val; if ( timeLeft == 0 ) { val = status.ordinal(); } else {// timeLeft is not 0.. checked above.. val = status.ordinal() - 1.0 + 1 / (double)timeLeft; } return new Double( val ); } case RATE_MODEL_INDEX: { SWDownloadSegment segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getTransferSpeed() ); } } return getValueAt( row, column ); }
public Object getComparableValueAt( int row, int column ) { SWDownloadCandidate candidate = downloadFile.getCandidate( row ); if ( candidate == null ) { return null; } switch( column ) { case PROGRESS_MODEL_INDEX: { DownloadScopeList availableScopeList = candidate.getAvailableScopeList(); if ( availableScopeList == null ) { return null; } return new Long( availableScopeList.getAggregatedLength() ); } case TOTAL_DOWNLOAD_MODEL_INDEX: return new Long( candidate.getTotalDownloadSize() ); 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(); double val; if ( timeLeft == 0 ) { val = status.ordinal(); } else {// timeLeft is not 0.. checked above.. val = status.ordinal() - 1.0 + 1 / (double)timeLeft; } return new Double( val ); } case RATE_MODEL_INDEX: { SWDownloadSegment segment = candidate.getDownloadSegment(); if ( segment == null ) { return null; } return new Long( segment.getTransferSpeed() ); } } return getValueAt( row, column ); }
1,116,093
public Object abs(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.abs(((Number)param).doubleValue())); } else if (param instanceof Complex) { return new Double(((Complex)param).abs()); } throw new ParseException("Invalid parameter type"); }
public Object abs(Object param) throws ParseException { if (param instanceof Complex) { return new Double(((Complex)param).abs()); } else if (param instanceof Number) { return new Double(Math.abs(((Number)param).doubleValue())); } else if (param instanceof Complex) { return new Double(((Complex)param).abs()); } throw new ParseException("Invalid parameter type"); }
1,116,094
public Object abs(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.abs(((Number)param).doubleValue())); } else if (param instanceof Complex) { return new Double(((Complex)param).abs()); } throw new ParseException("Invalid parameter type"); }
public Object abs(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.abs(((Number)param).doubleValue())); } else if (param instanceof Complex) { return new Double(((Complex)param).abs()); } throw new ParseException("Invalid parameter type"); }
1,116,095
public void testRandThroughput() throws Exception { BandwidthController controller = BandwidthController.acquireBandwidthController( "Test2", 1000 ); long start = System.currentTimeMillis(); long totalData = 10000; while( totalData > 0 ) { int available = controller.getAvailableByteCount( true ); int toUse = Math.min( available, 1000 ); totalData -= toUse; controller.markBytesUsed(toUse); System.out.println( toUse + " - " + totalData + " - " + controller.toDebugString() ); Thread.sleep( (long)(Math.random() * 1000.0) ); } long end = System.currentTimeMillis(); System.out.println( "Throughput: " + (end-start)/1000 + " " + (10000 / (end-start)/1000)); System.out.println( controller.toDebugString() ); }
public void testRandThroughput() throws Exception { BandwidthController controller = BandwidthController.acquireBandwidthController( "Test2", 1000 ); long start = System.currentTimeMillis(); long totalData = 10000; while( totalData > 0 ) { int available = controller.getAvailableByteCount( true ); int toUse = Math.min( available, 1000 ); totalData -= toUse; controller.markBytesUsed(toUse); System.out.println( toUse + " - " + totalData + " - " + controller.toDebugString() ); Thread.sleep( (long)(Math.random() * 1000.0) ); } long end = System.currentTimeMillis(); System.out.println( "Throughput: " + (end-start)/1000 + " " + (10000 / (end-start)/1000)); System.out.println( controller.toDebugString() ); }
1,116,096
public void testThroughput2() throws Exception { BandwidthController controller = BandwidthController.acquireBandwidthController( "Test2", 1000 ); long start = System.currentTimeMillis(); long totalData = 10000; while( totalData > 0 ) { int available = controller.getAvailableByteCount( true ); int toUse = Math.min( available, 1000 ); totalData -= toUse; controller.markBytesUsed(toUse); System.out.println( toUse + " - " + totalData + " - " + controller.toDebugString() ); } long end = System.currentTimeMillis(); System.out.println( "Throughput: " + (end-start)/1000 + " " + (10000 / (end-start)/1000)); System.out.println( controller.toDebugString() ); }
public void testThroughput2() throws Exception { BandwidthController controller = BandwidthController.acquireBandwidthController( "Test2", 1000 ); long start = System.currentTimeMillis(); long totalData = 10000; while( totalData > 0 ) { int available = controller.getAvailableByteCount( true ); int toUse = Math.min( available, 1000 ); totalData -= toUse; controller.markBytesUsed(toUse); System.out.println( toUse + " - " + totalData + " - " + controller.toDebugString() ); } long end = System.currentTimeMillis(); System.out.println( "Throughput: " + (end-start)/1000 + " " + (10000 / (end-start)/1000)); System.out.println( controller.toDebugString() ); }
1,116,097
public synchronized void doArtifact( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { serveFile(req, rsp, getArtifactsDir(), "package.gif", true); }
public void doArtifact( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException { serveFile(req, rsp, getArtifactsDir(), "package.gif", true); }
1,116,098
public RecipeDetailsView getRecipeDetailsView() { TabItem details = new TabItem(myFolder, SWT.NONE); details.setText("Recipe Details"); Group group = new Group(myFolder, SWT.NONE); details.setControl(group); return new SWTRecipeDetailsView(group); }
public RecipeDetailsView getRecipeDetailsView(String title) { TabItem details = new TabItem(myFolder, SWT.NONE); details.setText("Recipe Details"); Group group = new Group(myFolder, SWT.NONE); details.setControl(group); return new SWTRecipeDetailsView(group); }
1,116,100
public RecipeDetailsView getRecipeDetailsView() { TabItem details = new TabItem(myFolder, SWT.NONE); details.setText("Recipe Details"); Group group = new Group(myFolder, SWT.NONE); details.setControl(group); return new SWTRecipeDetailsView(group); }
public RecipeDetailsView getRecipeDetailsView() { TabItem details = new TabItem(myFolder, SWT.NONE); details.setText(title); Group group = new Group(myFolder, SWT.NONE); details.setControl(group); return new SWTRecipeDetailsView(group); }
1,116,101
public void init() { myLayout = new FillLayout(); myLayout.type = SWT.VERTICAL; myShell.setLayout(myLayout); // @TODO Create a separate view/controller for the TabFolder myFolder = new TabFolder(myShell, SWT.NONE); }
public void init() { myLayout = new FillLayout(); myLayout.type = SWT.VERTICAL; myShell.setLayout(myLayout); // @TODO Create a separate view/controller for the TabFolder myFolder = new TabFolder(myShell, SWT.NONE); }
1,116,102
public SubversionChangeLogSet parse(Build build, File changelogFile) throws IOException, SAXException { // http://svn.collab.net/repos/svn/trunk/subversion/svn/schema/ Digester digester = new Digester(); ArrayList<LogEntry> r = new ArrayList<LogEntry>(); digester.push(r); digester.addObjectCreate("*/logentry", LogEntry.class); digester.addSetProperties("*/logentry"); digester.addBeanPropertySetter("*/logentry/author"); digester.addBeanPropertySetter("*/logentry/date"); digester.addBeanPropertySetter("*/logentry/msg"); digester.addSetNext("*/logentry","add"); digester.addObjectCreate("*/logentry/paths/path", Path.class); digester.addSetProperties("*/logentry/paths/path"); digester.addBeanPropertySetter("*/logentry/paths/path","value"); digester.addSetNext("*/logentry/paths/path","addPath"); digester.parse(changelogFile); return new SubversionChangeLogSet(build,r); }
public SubversionChangeLogSet parse(Build build, File changelogFile) throws IOException, SAXException { // http://svn.collab.net/repos/svn/trunk/subversion/svn/schema/ Digester digester = new Digester(); ArrayList<LogEntry> r = new ArrayList<LogEntry>(); digester.push(r); digester.addObjectCreate("*/logentry", LogEntry.class); digester.addSetProperties("*/logentry"); digester.addBeanPropertySetter("*/logentry/author","user"); digester.addBeanPropertySetter("*/logentry/date"); digester.addBeanPropertySetter("*/logentry/msg"); digester.addSetNext("*/logentry","add"); digester.addObjectCreate("*/logentry/paths/path", Path.class); digester.addSetProperties("*/logentry/paths/path"); digester.addBeanPropertySetter("*/logentry/paths/path","value"); digester.addSetNext("*/logentry/paths/path","addPath"); digester.parse(changelogFile); return new SubversionChangeLogSet(build,r); }
1,116,105
public SubversionChangeLogSet(List<LogEntry> logs) { this.logs = Collections.unmodifiableList(logs); }
SubversionChangeLogSet(Build build, List<LogEntry> logs) { this.build = build; this.logs = Collections.unmodifiableList(logs); }
1,116,106
public Node parseProcSimpEval(String expr,Object expected) throws ParseException,Exception { Node node = j.parse(expr); Node processed = j.commandv.process(node,j); Node simp = j.simplify(processed); Object res = j.evaluate(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+"\""); return simp; }
public Node parseProcSimpEval(String expr,Object expected) throws ParseException,Exception { Node node = j.parse(expr); Node processed = j.preprocess(node); Node simp = j.simplify(processed); Object res = j.evaluate(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+"\""); return simp; }
1,116,107
public Node process(Node node,XJep xjep) throws ParseException { this.xjep=xjep; Node res = (Node) node.jjtAccept(this,null); return res; }
public Node process(Node node,XJep xj) throws ParseException { this.xjep=xjep; Node res = (Node) node.jjtAccept(this,null); return res; }
1,116,108
public Node process(Node node,XJep xjep) throws ParseException { this.xjep=xjep; Node res = (Node) node.jjtAccept(this,null); return res; }
public Node process(Node node,XJep xjep) throws ParseException { this.xjep=xj; Node res = (Node) node.jjtAccept(this,null); return res; }
1,116,109
public void addSeismogram(DataSetSeismogram seis){ timeConfig.addSeismogram(seis, timeFinder.getBeginTime(seis)); seismos.put(seis, timeConfig.getTimeRange(seis)); }
public void addSeismogram(DataSetSeismogram seis){ timeConfig.addSeismogram(seis, timeFinder.getBeginTime(seis)); }
1,116,110
public boolean contains(DataSetSeismogram seis){ if(seismos.containsKey(seis)){ return true; } if(timeConfig.contains(seis)){ seismos.put(seis, timeConfig.getTimeRange(seis)); return true; } return false; }
public boolean contains(DataSetSeismogram seis){ if(seismos.containsKey(seis)){ return true; } /*if(timeConfig.contains(seis)){ seismos.put(seis, timeConfig.getTimeRange(seis)); return true; } return false; }
1,116,111
public boolean contains(DataSetSeismogram seis){ if(seismos.containsKey(seis)){ return true; } if(timeConfig.contains(seis)){ seismos.put(seis, timeConfig.getTimeRange(seis)); return true; } return false; }
public boolean contains(DataSetSeismogram seis){ if(seismos.containsKey(seis)){ return true; }*/ if(timeConfig.contains(seis)){ seismos.put(seis, timeConfig.getTimeRange(seis)); return true; }*/ return false; }*/
1,116,112
public Object tanh(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); return new Double((Math.exp(value)-Math.exp(-value))/(Math.pow(Math.E,value)+Math.pow(Math.E,-value))); } else if (param instanceof Complex) { return ((Complex)param).tanh(); } throw new ParseException("Invalid parameter type"); }
public Object tanh(Object param) throws ParseException { if (param instanceof Complex) { return ((Complex)param).tanh(); } else if (param instanceof Number) { double value = ((Number)param).doubleValue(); return new Double((Math.exp(value)-Math.exp(-value))/(Math.pow(Math.E,value)+Math.pow(Math.E,-value))); } else if (param instanceof Complex) { return ((Complex)param).tanh(); } throw new ParseException("Invalid parameter type"); }
1,116,114
public Object tanh(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); return new Double((Math.exp(value)-Math.exp(-value))/(Math.pow(Math.E,value)+Math.pow(Math.E,-value))); } else if (param instanceof Complex) { return ((Complex)param).tanh(); } throw new ParseException("Invalid parameter type"); }
public Object tanh(Object param) throws ParseException { if (param instanceof Number) { double value = ((Number)param).doubleValue(); return new Double((Math.exp(value)-Math.exp(-value))/(Math.pow(Math.E,value)+Math.pow(Math.E,-value))); } else if (param instanceof Complex) { return ((Complex)param).tanh(); } throw new ParseException("Invalid parameter type"); }
1,116,115
public Object acos(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.acos(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).acos(); } throw new ParseException("Invalid parameter type"); }
public Object acos(Object param) throws ParseException { if (param instanceof Complex) { return ((Complex)param).acos(); } else if (param instanceof Number) { return new Double(Math.acos(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).acos(); } throw new ParseException("Invalid parameter type"); }
1,116,116
public Object acos(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.acos(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).acos(); } throw new ParseException("Invalid parameter type"); }
public Object acos(Object param) throws ParseException { if (param instanceof Number) { return new Double(Math.acos(((Number)param).doubleValue())); } else if (param instanceof Complex) { return ((Complex)param).acos(); } throw new ParseException("Invalid parameter type"); }
1,116,117
public void itemStateChanged(ItemEvent ae) { if(ae.getStateChange() == ItemEvent.SELECTED) { String orientation = ((AbstractButton)ae.getItem()).getText(); view.setDisplayKey(orientation); if(orientation.equals(labelStrings[0])){ setHorizontalTitle("North-South"); setVerticalTitle("East-West"); }else if(orientation.equals(labelStrings[1])){ setHorizontalTitle("Up-Down"); setVerticalTitle("North-South"); }else{ setHorizontalTitle("Up-Down"); setVerticalTitle("East-West"); } repaint(); } repaint(); }
public void itemStateChanged(ItemEvent ae) { if(ae.getStateChange() == ItemEvent.SELECTED) { String orientation = ((AbstractButton)ae.getItem()).getText(); view.setDisplayKey(orientation); if(orientation.equals(labelStrings[0])){ setHorizontalTitle("North-South"); setVerticalTitle("East-West"); }else if(orientation.equals(labelStrings[1])){ setHorizontalTitle("Up-Down"); setVerticalTitle("North-South"); }else{ setHorizontalTitle("Up-Down"); setVerticalTitle("East-West"); } repaint(); } repaint(); }
1,116,118
public void itemStateChanged(ItemEvent ae) { if(ae.getStateChange() == ItemEvent.SELECTED) { String orientation = ((AbstractButton)ae.getItem()).getText(); view.setDisplayKey(orientation); if(orientation.equals(labelStrings[0])){ setHorizontalTitle("North-South"); setVerticalTitle("East-West"); }else if(orientation.equals(labelStrings[1])){ setHorizontalTitle("Up-Down"); setVerticalTitle("North-South"); }else{ setHorizontalTitle("Up-Down"); setVerticalTitle("East-West"); } repaint(); } repaint(); }
public void itemStateChanged(ItemEvent ae) { if(ae.getStateChange() == ItemEvent.SELECTED) { String orientation = ((AbstractButton)ae.getItem()).getText(); view.setDisplayKey(orientation); if(orientation.equals(labelStrings[0])){ setHorizontalTitle("North-South"); setVerticalTitle("East-West"); }else if(orientation.equals(labelStrings[1])){ setHorizontalTitle("Up-Down"); setVerticalTitle("North-South"); }else{ setHorizontalTitle("Up-Down"); setVerticalTitle("East-West"); } repaint(); } repaint(); }
1,116,119
public ParticleMotionDisplay(DataSetSeismogram datasetSeismogram, TimeConfig tc, Color color) { particleDisplayPanel = new JPanel(new BorderLayout()); radioPanel = new JPanel(new GridLayout(1, 0)); setLayout(new BorderLayout()); view = new ParticleMotionView(this); view.setSize(new Dimension(300, 300)); particleDisplayPanel.add(view); hAmpScaleMap = new AmpScaleMapper(50, 4); vAmpScaleMap = new AmpScaleMapper(50, 4); ScaleBorder scaleBorder = new ScaleBorder(); scaleBorder.setBottomScaleMapper(hAmpScaleMap); scaleBorder.setLeftScaleMapper(vAmpScaleMap); hTitleBorder = new BottomTitleBorder("X - axis Title"); vTitleBorder = new LeftTitleBorder("Y - axis Title"); Border titleBorder = BorderFactory.createCompoundBorder(hTitleBorder, vTitleBorder); Border bevelBorder = BorderFactory.createRaisedBevelBorder(); Border bevelTitleBorder = BorderFactory.createCompoundBorder(bevelBorder, titleBorder); Border lowBevelBorder = BorderFactory.createLoweredBevelBorder(); Border scaleBevelBorder = BorderFactory.createCompoundBorder(scaleBorder, lowBevelBorder); particleDisplayPanel.setBorder(BorderFactory.createCompoundBorder(bevelTitleBorder, scaleBevelBorder)); add(particleDisplayPanel); radioPanel.setVisible(false); addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { resize(); } public void componentShown(ComponentEvent e) { resize(); } }); ParticleMotionDisplayThread t = new ParticleMotionDisplayThread(datasetSeismogram, tc, this, color); t.execute(); formRadioSetPanel(); initialized = t.getCompletion(); if(initialized){ setInitialButton(); } add(radioPanel, BorderLayout.SOUTH); }
public ParticleMotionDisplay(DataSetSeismogram datasetSeismogram, TimeConfig tc, Color color) { particleDisplayPanel = new JPanel(new BorderLayout()); radioPanel = new JPanel(new GridLayout(1, 0)); setLayout(new BorderLayout()); view = new ParticleMotionView(this); view.setSize(new Dimension(300, 300)); particleDisplayPanel.add(view); hAmpScaleMap = new AmpScaleMapper(50, 4); vAmpScaleMap = new AmpScaleMapper(50, 4); ScaleBorder scaleBorder = new ScaleBorder(); scaleBorder.setBottomScaleMapper(hAmpScaleMap); scaleBorder.setLeftScaleMapper(vAmpScaleMap); hTitleBorder = new BottomTitleBorder("X - axis Title"); vTitleBorder = new LeftTitleBorder("Y - axis Title"); Border titleBorder = BorderFactory.createCompoundBorder(hTitleBorder, vTitleBorder); Border bevelBorder = BorderFactory.createRaisedBevelBorder(); Border bevelTitleBorder = BorderFactory.createCompoundBorder(bevelBorder, titleBorder); Border lowBevelBorder = BorderFactory.createLoweredBevelBorder(); Border scaleBevelBorder = BorderFactory.createCompoundBorder(scaleBorder, lowBevelBorder); particleDisplayPanel.setBorder(BorderFactory.createCompoundBorder(bevelTitleBorder, scaleBevelBorder)); add(particleDisplayPanel); radioPanel.setVisible(false); addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { resize(); } public void componentShown(ComponentEvent e) { resize(); } }); ParticleMotionDisplayThread t = new ParticleMotionDisplayThread(datasetSeismogram, tc, this, color); t.execute(); formRadioSetPanel(); initialized = t.getCompletion(); if(initialized){ setInitialButton(); } add(radioPanel, BorderLayout.SOUTH); }
1,116,120
public void setSize(Dimension d) { logger.debug("Setting the size"); if (d.width < d.height) { super.setSize(new Dimension(d.width, d.width)); } else { super.setSize(new Dimension(d.height, d.height)); } }
public void setSize(Dimension d) { if (d.width < d.height) { super.setSize(new Dimension(d.width, d.width)); } else { super.setSize(new Dimension(d.height, d.height)); } }
1,116,121
public MatrixNodeI preprocess( ASTFunNode node, MatrixPreprocessor visitor, MatrixJep jep, MatrixNodeFactory nf) throws ParseException { MatrixNodeI children[] = visitor.visitChildrenAsArray(node,null); Operator listOp = ((MatrixOperatorSet) jep.getOperatorSet()).getMList(); // What if we have x=[1,2]; y = [x,x]; or z=[[1,2],x]; // first check if all arguments are TENSORS boolean flag=true; for(int i=0;i<children.length;++i) { if(children[i] instanceof ASTMFunNode) { if(((ASTMFunNode) children[i]).getOperator() != listOp) { flag=false; break; } } else flag=false; break; } if(flag) { ASTMFunNode opNode1 = (ASTMFunNode) children[0]; Dimensions dim = Dimensions.valueOf(children.length,opNode1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildUnfinishedOperatorNode(listOp); int k=0; res.setDim(dim); res.jjtOpen(); for(int i=0;i<children.length;++i) { ASTMFunNode opNode = (ASTMFunNode) children[i]; for(int j=0;j<opNode.jjtGetNumChildren();++j) { Node child = opNode.jjtGetChild(j); res.jjtAddChild(child,k++); child.jjtSetParent(res); } } res.jjtClose(); return res; } else { MatrixNodeI node1 = (MatrixNodeI) children[0]; Dimensions dim = Dimensions.valueOf(children.length,node1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(listOp,children,dim); return res; } }
public MatrixNodeI preprocess( ASTFunNode node, MatrixPreprocessor visitor, MatrixJep jep, MatrixNodeFactory nf) throws ParseException { MatrixNodeI children[] = visitor.visitChildrenAsArray(node,null); Operator listOp = ((MatrixOperatorSet) jep.getOperatorSet()).getMList(); // What if we have x=[1,2]; y = [x,x]; or z=[[1,2],x]; // first check if all arguments are TENSORS boolean flag=true; for(int i=0;i<children.length;++i) { if(children[i] instanceof ASTMFunNode) { if(((ASTMFunNode) children[i]).getOperator() != listOp) { flag=false; break; } } else flag=false; break; } if(flag) { ASTMFunNode opNode1 = (ASTMFunNode) children[0]; Dimensions dim = Dimensions.valueOf(children.length,opNode1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildUnfinishedOperatorNode(listOp); int k=0; res.setDim(dim); res.jjtOpen(); for(int i=0;i<children.length;++i) { ASTMFunNode opNode = (ASTMFunNode) children[i]; for(int j=0;j<opNode.jjtGetNumChildren();++j) { Node child = opNode.jjtGetChild(j); res.jjtAddChild(child,k++); child.jjtSetParent(res); } } res.jjtClose(); return res; } else { MatrixNodeI node1 = (MatrixNodeI) children[0]; Dimensions dim = Dimensions.valueOf(children.length,node1.getDim()); ASTMFunNode res = (ASTMFunNode) nf.buildOperatorNode(listOp,children,dim); return res; } }
1,116,122
public void sendBrowseHostRequest() throws IOException, BrowseHostException { NLogger.debug(BrowseHostConnection.class, "Connection for Browse Host to " + address ); results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.CONNECTING ); SocketFacade socket; try { socket = SocketFactory.connect( address, ServiceManager.sCfg.mNetConnectionTimeout ); } catch ( IOException exp ) {// standard connection failed try push request, if we have a hostGUID if ( hostGUID == null ) { throw exp; } socket = PushHandler.requestSocketViaPush( hostGUID, // HEX for Phex 50484558 ); if ( socket == null ) { throw new IOException( "Push request failed" ); } } Connection connection = new Connection( socket, BandwidthManager.getInstance().getNetworkBandwidthController() ); HTTPRequest request = new HTTPRequest( "GET", "/", true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, address.getFullHostName() ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.ACCEPT, // "text/html, application/x-gnutella-packets" ) ); "application/x-gnutella-packets" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, "0" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "close" ) ); String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(BrowseHostConnection.class, "Sending Browse Host request: " + httpRequestStr ); connection.write( httpRequestStr.toString().getBytes() ); HTTPResponse response; try { response = HTTPProcessor.parseHTTPResponse( connection ); } catch ( HTTPMessageException exp ) { throw new BrowseHostException( "Invalid HTTP Response: " + exp.getMessage() ); } NLogger.debug(BrowseHostConnection.class, "Received Browse Host response: " + response.buildHTTPResponseString() ); if ( response.getStatusCode() < 200 || response.getStatusCode() > 299 ) { throw new BrowseHostException( "Browse host request not successfull. StatusCode: " + response.getStatusCode() + " " + response.getStatusReason() ); } HTTPHeader typeHeader = response.getHeader( HTTPHeaderNames.CONTENT_TYPE ); if ( typeHeader == null ) { throw new BrowseHostException( "Unknwon content-type." ); } if ( typeHeader.getValue().equals( "application/x-gnutella-packets" ) ) { results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.FETCHING ); MsgManager msgMgr = MsgManager.getInstance(); byte[] headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; while( true ) { MsgHeader header = MessageProcessor.parseMessageHeader( connection, headerBuffer ); if ( header == null ) { break; } if ( header.getPayload() != MsgHeader.QUERY_HIT_PAYLOAD ) { throw new BrowseHostException( "Wrong header payload. Expecting query hit." ); } QueryResponseMsg message = null; try { message = ( QueryResponseMsg )MessageProcessor.parseMessage( header, connection ); } catch ( InvalidMessageException exp ) { NLogger.debug(BrowseHostConnection.class, exp, exp); throw new IOException( "Invalid message returned: " + exp.getMessage() ); } msgMgr.getQueryResultMonitor().processResponse( message ); results.processResponse( message ); } } else { throw new BrowseHostException( "Not supported content-type. " + typeHeader.getValue() ); } }
public void sendBrowseHostRequest() throws IOException, BrowseHostException { NLogger.debug(BrowseHostConnection.class, "Connection for Browse Host to " + address ); results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.CONNECTING ); SocketFacade socket; try { socket = SocketFactory.connect( address, ServiceManager.sCfg.mNetConnectionTimeout ); } catch ( IOException exp ) {// standard connection failed try push request, if we have a hostGUID if ( hostGUID == null ) { throw exp; } socket = PushHandler.requestSocketViaPush( hostGUID, // HEX for Phex 50484558 ); if ( socket == null ) { throw new IOException( "Push request failed" ); } } Connection connection = new Connection( socket, BandwidthManager.getInstance().getNetworkBandwidthController() ); HTTPRequest request = new HTTPRequest( "GET", "/", true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, address.getFullHostName() ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.ACCEPT, // "text/html, application/x-gnutella-packets" ) ); "application/x-gnutella-packets" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, "0" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "close" ) ); String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(BrowseHostConnection.class, "Sending Browse Host request: " + httpRequestStr ); connection.write( httpRequestStr.toString().getBytes() ); HTTPResponse response; try { response = HTTPProcessor.parseHTTPResponse( connection ); } catch ( HTTPMessageException exp ) { throw new BrowseHostException( "Invalid HTTP Response: " + exp.getMessage() ); } NLogger.debug(BrowseHostConnection.class, "Received Browse Host response: " + response.buildHTTPResponseString() ); if ( response.getStatusCode() < 200 || response.getStatusCode() > 299 ) { throw new BrowseHostException( "Browse host request not successfull. StatusCode: " + response.getStatusCode() + " " + response.getStatusReason() ); } HTTPHeader typeHeader = response.getHeader( HTTPHeaderNames.CONTENT_TYPE ); if ( typeHeader == null ) { throw new BrowseHostException( "Unknwon content-type." ); } if ( typeHeader.getValue().equals( "application/x-gnutella-packets" ) ) { results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.FETCHING ); MsgManager msgMgr = MsgManager.getInstance(); byte[] headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; while( true ) { MsgHeader header = MessageProcessor.parseMessageHeader( connection, headerBuffer ); if ( header == null ) { break; } if ( header.getPayload() != MsgHeader.QUERY_HIT_PAYLOAD ) { throw new BrowseHostException( "Wrong header payload. Expecting query hit." ); } try { message = ( QueryResponseMsg )MessageProcessor.parseMessage( header, connection ); } catch ( InvalidMessageException exp ) { NLogger.debug(BrowseHostConnection.class, exp, exp); throw new IOException( "Invalid message returned: " + exp.getMessage() ); } msgMgr.getQueryResultMonitor().processResponse( message ); results.processResponse( message ); } } else { throw new BrowseHostException( "Not supported content-type. " + typeHeader.getValue() ); } }
1,116,123
public void sendBrowseHostRequest() throws IOException, BrowseHostException { NLogger.debug(BrowseHostConnection.class, "Connection for Browse Host to " + address ); results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.CONNECTING ); SocketFacade socket; try { socket = SocketFactory.connect( address, ServiceManager.sCfg.mNetConnectionTimeout ); } catch ( IOException exp ) {// standard connection failed try push request, if we have a hostGUID if ( hostGUID == null ) { throw exp; } socket = PushHandler.requestSocketViaPush( hostGUID, // HEX for Phex 50484558 ); if ( socket == null ) { throw new IOException( "Push request failed" ); } } Connection connection = new Connection( socket, BandwidthManager.getInstance().getNetworkBandwidthController() ); HTTPRequest request = new HTTPRequest( "GET", "/", true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, address.getFullHostName() ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.ACCEPT, // "text/html, application/x-gnutella-packets" ) ); "application/x-gnutella-packets" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, "0" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "close" ) ); String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(BrowseHostConnection.class, "Sending Browse Host request: " + httpRequestStr ); connection.write( httpRequestStr.toString().getBytes() ); HTTPResponse response; try { response = HTTPProcessor.parseHTTPResponse( connection ); } catch ( HTTPMessageException exp ) { throw new BrowseHostException( "Invalid HTTP Response: " + exp.getMessage() ); } NLogger.debug(BrowseHostConnection.class, "Received Browse Host response: " + response.buildHTTPResponseString() ); if ( response.getStatusCode() < 200 || response.getStatusCode() > 299 ) { throw new BrowseHostException( "Browse host request not successfull. StatusCode: " + response.getStatusCode() + " " + response.getStatusReason() ); } HTTPHeader typeHeader = response.getHeader( HTTPHeaderNames.CONTENT_TYPE ); if ( typeHeader == null ) { throw new BrowseHostException( "Unknwon content-type." ); } if ( typeHeader.getValue().equals( "application/x-gnutella-packets" ) ) { results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.FETCHING ); MsgManager msgMgr = MsgManager.getInstance(); byte[] headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; while( true ) { MsgHeader header = MessageProcessor.parseMessageHeader( connection, headerBuffer ); if ( header == null ) { break; } if ( header.getPayload() != MsgHeader.QUERY_HIT_PAYLOAD ) { throw new BrowseHostException( "Wrong header payload. Expecting query hit." ); } QueryResponseMsg message = null; try { message = ( QueryResponseMsg )MessageProcessor.parseMessage( header, connection ); } catch ( InvalidMessageException exp ) { NLogger.debug(BrowseHostConnection.class, exp, exp); throw new IOException( "Invalid message returned: " + exp.getMessage() ); } msgMgr.getQueryResultMonitor().processResponse( message ); results.processResponse( message ); } } else { throw new BrowseHostException( "Not supported content-type. " + typeHeader.getValue() ); } }
public void sendBrowseHostRequest() throws IOException, BrowseHostException { NLogger.debug(BrowseHostConnection.class, "Connection for Browse Host to " + address ); results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.CONNECTING ); SocketFacade socket; try { socket = SocketFactory.connect( address, ServiceManager.sCfg.mNetConnectionTimeout ); } catch ( IOException exp ) {// standard connection failed try push request, if we have a hostGUID if ( hostGUID == null ) { throw exp; } socket = PushHandler.requestSocketViaPush( hostGUID, // HEX for Phex 50484558 ); if ( socket == null ) { throw new IOException( "Push request failed" ); } } Connection connection = new Connection( socket, BandwidthManager.getInstance().getNetworkBandwidthController() ); HTTPRequest request = new HTTPRequest( "GET", "/", true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, address.getFullHostName() ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.ACCEPT, // "text/html, application/x-gnutella-packets" ) ); "application/x-gnutella-packets" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, "0" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "close" ) ); String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(BrowseHostConnection.class, "Sending Browse Host request: " + httpRequestStr ); connection.write( httpRequestStr.toString().getBytes() ); HTTPResponse response; try { response = HTTPProcessor.parseHTTPResponse( connection ); } catch ( HTTPMessageException exp ) { throw new BrowseHostException( "Invalid HTTP Response: " + exp.getMessage() ); } NLogger.debug(BrowseHostConnection.class, "Received Browse Host response: " + response.buildHTTPResponseString() ); if ( response.getStatusCode() < 200 || response.getStatusCode() > 299 ) { throw new BrowseHostException( "Browse host request not successfull. StatusCode: " + response.getStatusCode() + " " + response.getStatusReason() ); } HTTPHeader typeHeader = response.getHeader( HTTPHeaderNames.CONTENT_TYPE ); if ( typeHeader == null ) { throw new BrowseHostException( "Unknwon content-type." ); } if ( typeHeader.getValue().equals( "application/x-gnutella-packets" ) ) { results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.FETCHING ); MsgManager msgMgr = MsgManager.getInstance(); byte[] headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; while( true ) { MsgHeader header = MessageProcessor.parseMessageHeader( connection, headerBuffer ); if ( header == null ) { break; } if ( header.getPayload() != MsgHeader.QUERY_HIT_PAYLOAD ) { throw new BrowseHostException( "Wrong header payload. Expecting query hit." ); } QueryResponseMsg message = null; try { QueryResponseMsg message = ( QueryResponseMsg )MessageProcessor.parseMessage( header, connection ); } catch ( InvalidMessageException exp ) { NLogger.debug(BrowseHostConnection.class, exp, exp); throw new IOException( "Invalid message returned: " + exp.getMessage() ); } msgMgr.getQueryResultMonitor().processResponse( message ); results.processResponse( message ); } } else { throw new BrowseHostException( "Not supported content-type. " + typeHeader.getValue() ); } }
1,116,124
public void sendBrowseHostRequest() throws IOException, BrowseHostException { NLogger.debug(BrowseHostConnection.class, "Connection for Browse Host to " + address ); results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.CONNECTING ); SocketFacade socket; try { socket = SocketFactory.connect( address, ServiceManager.sCfg.mNetConnectionTimeout ); } catch ( IOException exp ) {// standard connection failed try push request, if we have a hostGUID if ( hostGUID == null ) { throw exp; } socket = PushHandler.requestSocketViaPush( hostGUID, // HEX for Phex 50484558 ); if ( socket == null ) { throw new IOException( "Push request failed" ); } } Connection connection = new Connection( socket, BandwidthManager.getInstance().getNetworkBandwidthController() ); HTTPRequest request = new HTTPRequest( "GET", "/", true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, address.getFullHostName() ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.ACCEPT, // "text/html, application/x-gnutella-packets" ) ); "application/x-gnutella-packets" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, "0" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "close" ) ); String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(BrowseHostConnection.class, "Sending Browse Host request: " + httpRequestStr ); connection.write( httpRequestStr.toString().getBytes() ); HTTPResponse response; try { response = HTTPProcessor.parseHTTPResponse( connection ); } catch ( HTTPMessageException exp ) { throw new BrowseHostException( "Invalid HTTP Response: " + exp.getMessage() ); } NLogger.debug(BrowseHostConnection.class, "Received Browse Host response: " + response.buildHTTPResponseString() ); if ( response.getStatusCode() < 200 || response.getStatusCode() > 299 ) { throw new BrowseHostException( "Browse host request not successfull. StatusCode: " + response.getStatusCode() + " " + response.getStatusReason() ); } HTTPHeader typeHeader = response.getHeader( HTTPHeaderNames.CONTENT_TYPE ); if ( typeHeader == null ) { throw new BrowseHostException( "Unknwon content-type." ); } if ( typeHeader.getValue().equals( "application/x-gnutella-packets" ) ) { results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.FETCHING ); MsgManager msgMgr = MsgManager.getInstance(); byte[] headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; while( true ) { MsgHeader header = MessageProcessor.parseMessageHeader( connection, headerBuffer ); if ( header == null ) { break; } if ( header.getPayload() != MsgHeader.QUERY_HIT_PAYLOAD ) { throw new BrowseHostException( "Wrong header payload. Expecting query hit." ); } QueryResponseMsg message = null; try { message = ( QueryResponseMsg )MessageProcessor.parseMessage( header, connection ); } catch ( InvalidMessageException exp ) { NLogger.debug(BrowseHostConnection.class, exp, exp); throw new IOException( "Invalid message returned: " + exp.getMessage() ); } msgMgr.getQueryResultMonitor().processResponse( message ); results.processResponse( message ); } } else { throw new BrowseHostException( "Not supported content-type. " + typeHeader.getValue() ); } }
public void sendBrowseHostRequest() throws IOException, BrowseHostException { NLogger.debug(BrowseHostConnection.class, "Connection for Browse Host to " + address ); results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.CONNECTING ); SocketFacade socket; try { socket = SocketFactory.connect( address, ServiceManager.sCfg.mNetConnectionTimeout ); } catch ( IOException exp ) {// standard connection failed try push request, if we have a hostGUID if ( hostGUID == null ) { throw exp; } socket = PushHandler.requestSocketViaPush( hostGUID, // HEX for Phex 50484558 ); if ( socket == null ) { throw new IOException( "Push request failed" ); } } Connection connection = new Connection( socket, BandwidthManager.getInstance().getNetworkBandwidthController() ); HTTPRequest request = new HTTPRequest( "GET", "/", true ); request.addHeader( new HTTPHeader( HTTPHeaderNames.HOST, address.getFullHostName() ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.ACCEPT, // "text/html, application/x-gnutella-packets" ) ); "application/x-gnutella-packets" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONTENT_LENGTH, "0" ) ); request.addHeader( new HTTPHeader( HTTPHeaderNames.CONNECTION, "close" ) ); String httpRequestStr = request.buildHTTPRequestString(); NLogger.debug(BrowseHostConnection.class, "Sending Browse Host request: " + httpRequestStr ); connection.write( httpRequestStr.toString().getBytes() ); HTTPResponse response; try { response = HTTPProcessor.parseHTTPResponse( connection ); } catch ( HTTPMessageException exp ) { throw new BrowseHostException( "Invalid HTTP Response: " + exp.getMessage() ); } NLogger.debug(BrowseHostConnection.class, "Received Browse Host response: " + response.buildHTTPResponseString() ); if ( response.getStatusCode() < 200 || response.getStatusCode() > 299 ) { throw new BrowseHostException( "Browse host request not successfull. StatusCode: " + response.getStatusCode() + " " + response.getStatusReason() ); } HTTPHeader typeHeader = response.getHeader( HTTPHeaderNames.CONTENT_TYPE ); if ( typeHeader == null ) { throw new BrowseHostException( "Unknwon content-type." ); } if ( typeHeader.getValue().equals( "application/x-gnutella-packets" ) ) { results.setBrowseHostStatus( BrowseHostResults.BrowseHostStatus.FETCHING ); MsgManager msgMgr = MsgManager.getInstance(); byte[] headerBuffer = new byte[ MsgHeader.DATA_LENGTH ]; while( true ) { MsgHeader header = MessageProcessor.parseMessageHeader( connection, headerBuffer ); if ( header == null ) { break; } if ( header.getPayload() != MsgHeader.QUERY_HIT_PAYLOAD ) { throw new BrowseHostException( "Wrong header payload. Expecting query hit." ); } QueryResponseMsg message = null; try { message = ( QueryResponseMsg )MessageProcessor.parseMessage( header, connection ); } catch ( InvalidMessageException exp ) { NLogger.debug(BrowseHostConnection.class, exp, exp); throw new IOException( "Invalid message returned: " + exp.getMessage() ); } msgMgr.getQueryResultMonitor().processResponse( message ); results.processResponse( message ); } } else { throw new BrowseHostException( "Not supported content-type. " + typeHeader.getValue() ); } }
1,116,125
public void startSearching() { isSearching = true; browseHostError = NO_ERROR; Runnable runner = new Runnable() { public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = CONNECTION_ERROR; stopSearching(); } } }; ThreadPool.getInstance().addJob( runner, "BrowseHostConnection-" + Integer.toHexString(runner.hashCode()) ); fireSearchStarted(); }
public void startSearching() { isSearching = true; Runnable runner = new Runnable() { public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = CONNECTION_ERROR; stopSearching(); } } }; ThreadPool.getInstance().addJob( runner, "BrowseHostConnection-" + Integer.toHexString(runner.hashCode()) ); fireSearchStarted(); }
1,116,127
public void startSearching() { isSearching = true; browseHostError = NO_ERROR; Runnable runner = new Runnable() { public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = CONNECTION_ERROR; stopSearching(); } } }; ThreadPool.getInstance().addJob( runner, "BrowseHostConnection-" + Integer.toHexString(runner.hashCode()) ); fireSearchStarted(); }
public void startSearching() { isSearching = true; browseHostError = NO_ERROR; Runnable runner = new Runnable() { public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostStatus = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = CONNECTION_ERROR; stopSearching(); } } }; ThreadPool.getInstance().addJob( runner, "BrowseHostConnection-" + Integer.toHexString(runner.hashCode()) ); fireSearchStarted(); }
1,116,128
public void startSearching() { isSearching = true; browseHostError = NO_ERROR; Runnable runner = new Runnable() { public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = CONNECTION_ERROR; stopSearching(); } } }; ThreadPool.getInstance().addJob( runner, "BrowseHostConnection-" + Integer.toHexString(runner.hashCode()) ); fireSearchStarted(); }
public void startSearching() { isSearching = true; browseHostError = NO_ERROR; Runnable runner = new Runnable() { public void run() { BrowseHostConnection connection = new BrowseHostConnection( destAddress, hostGUID, BrowseHostResults.this ); try { connection.sendBrowseHostRequest(); } catch ( BrowseHostException exp ) { NLogger.warn(BrowseHostResults.class, exp, exp); browseHostError = BROWSE_HOST_ERROR; stopSearching(); } catch ( IOException exp ) {// TODO integrate error handling if no results have been returned NLogger.warn(BrowseHostResults.class, exp, exp); browseHostStatus = CONNECTION_ERROR; stopSearching(); } } }; ThreadPool.getInstance().addJob( runner, "BrowseHostConnection-" + Integer.toHexString(runner.hashCode()) ); fireSearchStarted(); }
1,116,129
private RpCommand(short command){ this.command = command; this.aux1 = -1; }
RpCommand(short command){ this.command = command; this.aux1 = -1; }
1,116,131
public boolean run() throws Exception { Class.forName("org.sqlite.JDBC"); Connection conn = DriverManager.getConnection("jdbc:sqlite:"); Statement stat = conn.createStatement(); ResultSet rs; // test calling Function.create(conn, "f1", new Function() { public void xFunc() throws SQLException { val = 4; } }); stat.executeQuery("select f1();").close(); if (val != 4) { error = "f1 not called"; return false; } // test returning Function.create(conn, "f2", new Function() { public void xFunc() throws SQLException { result(4); } }); rs = stat.executeQuery("select f2();"); if (!rs.next() || rs.getInt(1) != 4) { error ="f2 bad"; return false; } rs.close(); for (int i=0; i < 20; i++) { rs = stat.executeQuery("select f2();"); if (!rs.next() || rs.getInt(1) != 4) { error ="f2 bad in loop"; return false; } rs.close(); } // test accessing arguments Function.create(conn, "f3", new Function() { public void xFunc() throws SQLException { result(value_int(0)); } }); rs = stat.executeQuery("select f3(7);"); if (!rs.next() || rs.getInt(1) != 7) { error ="f3 bad"; return false; } // test multiple arguments Function.create(conn, "f4", new Function() { public void xFunc() throws SQLException { int ret = 0; for (int i=0; i < args(); i++) ret += value_int(i); result(ret); } }); rs.close(); rs = stat.executeQuery("select f4(2, 3, 9, -5);"); if (!rs.next() || rs.getInt(1) != 9) { error ="f4 bad1"; return false; } rs.close(); rs = stat.executeQuery("select f4(2);"); if (!rs.next() || rs.getInt(1) != 2) { error ="f4 bad2"; return false; } rs.close(); rs = stat.executeQuery("select f4(-3, -4, -5);"); if (!rs.next() || rs.getInt(1)!=-12) { error ="f4 bad3"; return false; } // test different return types Function.create(conn, "f5", new Function() { public void xFunc() throws SQLException { result("Hello World"); } }); rs.close(); rs = stat.executeQuery("select f5();"); if (!rs.next() || !"Hello World".equals(rs.getString(1))) { error = "f5 bad"; return false; } Function.create(conn, "f6", new Function() { public void xFunc() throws SQLException { result(Long.MAX_VALUE); } }); rs.close(); rs = stat.executeQuery("select f6();"); if (!rs.next() || rs.getLong(1) != Long.MAX_VALUE) { error = "f6 bad"; return false; } Function.create(conn, "f7", new Function() { public void xFunc() throws SQLException {result(Double.MAX_VALUE);} }); rs.close(); rs = stat.executeQuery("select f7();"); if (!rs.next() || rs.getDouble(1) != Double.MAX_VALUE) { error = "f7 bad"; return false; } Function.create(conn, "f8", new Function() { public void xFunc() throws SQLException { result(b1); } }); rs.close(); rs = stat.executeQuery("select f8();"); if (!rs.next() || !same(b1, rs.getBytes(1))) { error = "f8 bad"; return false; } // TODO test different argument types Function.create(conn, "farg_int", new Function() { public void xFunc() throws SQLException { result(value_int(0)); } }); PreparedStatement prep; prep = conn.prepareStatement("select farg_int(?);"); prep.setInt(1, Integer.MAX_VALUE); rs = prep.executeQuery(); if (!rs.next() || Integer.MAX_VALUE != rs.getInt(1)) { error = "bad int arg"; return false; } prep.close(); Function.create(conn, "farg_long", new Function() { public void xFunc() throws SQLException { result(value_long(0)); } }); prep = conn.prepareStatement("select farg_long(?);"); prep.setLong(1, Long.MAX_VALUE); rs = prep.executeQuery(); if (!rs.next() || Long.MAX_VALUE != rs.getLong(1)) { error = "bad long arg"; return false; } prep.close(); Function.create(conn, "farg_double", new Function() { public void xFunc() throws SQLException { result(value_double(0));} }); prep = conn.prepareStatement("select farg_double(?);"); prep.setDouble(1, Double.MAX_VALUE); rs = prep.executeQuery(); if (!rs.next() || Double.MAX_VALUE != rs.getDouble(1)) { error = "bad double arg"; return false; } prep.close(); Function.create(conn, "farg_blob", new Function() { public void xFunc() throws SQLException { result(value_blob(0));} }); prep = conn.prepareStatement("select farg_blob(?);"); prep.setBytes(1, b1); rs = prep.executeQuery(); if (!rs.next() || !same(b1, rs.getBytes(1))) { error = "bad bytes arg"; return false; } prep.close(); Function.create(conn, "farg_string", new Function() { public void xFunc() throws SQLException { result(value_text(0));} }); prep = conn.prepareStatement("select farg_string(?);"); prep.setString(1, "Hello World"); rs = prep.executeQuery(); if (!rs.next() || "Hello World".equals(rs.getInt(1))) { error = "bad string arg"; return false; } prep.close(); // test errors rs.close(); Function.create(conn, "f9", new Function() { public void xFunc() throws SQLException { throw new SQLException("myErr"); } }); String msg = null; try { stat.executeQuery("select f9();"); } catch (SQLException e) { msg = e.getMessage(); } if (!"java.sql.SQLException: myErr".equals(msg)) { System.out.println(msg); error = "bad error"; return false; } // test triggers Function.create(conn, "inform", new Function() { protected void xFunc() throws SQLException { gotTrigger = value_int(0); } }); stat.executeUpdate("create table trigtest (c1);"); stat.executeUpdate( "create trigger trigt after insert on trigtest" + " begin select inform(new.c1); end;" ); stat.executeUpdate("insert into trigtest values (5);"); if (gotTrigger != 5) { error = "bad trigger"; return false; } conn.close(); return true; }
public boolean run() throws Exception { Class.forName("org.sqlite.JDBC"); Connection conn = DriverManager.getConnection("jdbc:sqlite:"); Statement stat = conn.createStatement(); ResultSet rs; // test calling Function.create(conn, "f1", new Function() { public void xFunc() throws SQLException { val = 4; } }); stat.executeQuery("select f1();").close(); if (val != 4) { error = "f1 not called"; return false; } // test returning Function.create(conn, "f2", new Function() { public void xFunc() throws SQLException { result(4); } }); rs = stat.executeQuery("select f2();"); if (!rs.next() || rs.getInt(1) != 4) { error ="f2 bad"; return false; } rs.close(); for (int i=0; i < 20; i++) { rs = stat.executeQuery("select f2();"); if (!rs.next() || rs.getInt(1) != 4) { error ="f2 bad in loop"; return false; } rs.close(); } // test accessing arguments Function.create(conn, "f3", new Function() { public void xFunc() throws SQLException { result(value_int(0)); } }); rs = stat.executeQuery("select f3(7);"); if (!rs.next() || rs.getInt(1) != 7) { error ="f3 bad"; return false; } // test multiple arguments Function.create(conn, "f4", new Function() { public void xFunc() throws SQLException { int ret = 0; for (int i=0; i < args(); i++) ret += value_int(i); result(ret); } }); rs.close(); rs = stat.executeQuery("select f4(2, 3, 9, -5);"); if (!rs.next() || rs.getInt(1) != 9) { error ="f4 bad1"; return false; } rs.close(); rs = stat.executeQuery("select f4(2);"); if (!rs.next() || rs.getInt(1) != 2) { error ="f4 bad2"; return false; } rs.close(); rs = stat.executeQuery("select f4(-3, -4, -5);"); if (!rs.next() || rs.getInt(1)!=-12) { error ="f4 bad3"; return false; } // test different return types Function.create(conn, "f5", new Function() { public void xFunc() throws SQLException { result("Hello World"); } }); rs.close(); rs = stat.executeQuery("select f5();"); if (!rs.next() || !"Hello World".equals(rs.getString(1))) { error = "f5 bad"; return false; } Function.create(conn, "f6", new Function() { public void xFunc() throws SQLException { result(Long.MAX_VALUE); } }); rs.close(); rs = stat.executeQuery("select f6();"); if (!rs.next() || rs.getLong(1) != Long.MAX_VALUE) { error = "f6 bad"; return false; } Function.create(conn, "f7", new Function() { public void xFunc() throws SQLException {result(Double.MAX_VALUE);} }); rs.close(); rs = stat.executeQuery("select f7();"); if (!rs.next() || rs.getDouble(1) != Double.MAX_VALUE) { error = "f7 bad"; return false; } Function.create(conn, "f8", new Function() { public void xFunc() throws SQLException { result(b1); } }); rs.close(); rs = stat.executeQuery("select f8();"); if (!rs.next() || !same(b1, rs.getBytes(1))) { error = "f8 bad"; return false; } // TODO test different argument types Function.create(conn, "farg_int", new Function() { public void xFunc() throws SQLException { result(value_int(0)); } }); PreparedStatement prep; prep = conn.prepareStatement("select farg_int(?);"); prep.setInt(1, Integer.MAX_VALUE); rs = prep.executeQuery(); if (!rs.next() || Integer.MAX_VALUE != rs.getInt(1)) { error = "bad int arg"; return false; } prep.close(); Function.create(conn, "farg_long", new Function() { public void xFunc() throws SQLException { result(value_long(0)); } }); prep = conn.prepareStatement("select farg_long(?);"); prep.setLong(1, Long.MAX_VALUE); rs = prep.executeQuery(); if (!rs.next() || Long.MAX_VALUE != rs.getLong(1)) { error = "bad long arg"; return false; } prep.close(); Function.create(conn, "farg_double", new Function() { public void xFunc() throws SQLException { result(value_double(0));} }); prep = conn.prepareStatement("select farg_double(?);"); prep.setDouble(1, Double.MAX_VALUE); rs = prep.executeQuery(); if (!rs.next() || Double.MAX_VALUE != rs.getDouble(1)) { error = "bad double arg"; return false; } prep.close(); Function.create(conn, "farg_blob", new Function() { public void xFunc() throws SQLException { result(value_blob(0));} }); prep = conn.prepareStatement("select farg_blob(?);"); prep.setBytes(1, b1); rs = prep.executeQuery(); if (!rs.next() || !same(b1, rs.getBytes(1))) { error = "bad bytes arg"; return false; } prep.close(); Function.create(conn, "farg_string", new Function() { public void xFunc() throws SQLException { result(value_text(0));} }); prep = conn.prepareStatement("select farg_string(?);"); prep.setString(1, "Hello World"); rs = prep.executeQuery(); if (!rs.next() || !"Hello World".equals(rs.getString(1))) { error = "bad string arg"; return false; } prep.close(); // test errors rs.close(); Function.create(conn, "f9", new Function() { public void xFunc() throws SQLException { throw new SQLException("myErr"); } }); String msg = null; try { stat.executeQuery("select f9();"); } catch (SQLException e) { msg = e.getMessage(); } if (!"java.sql.SQLException: myErr".equals(msg)) { System.out.println(msg); error = "bad error"; return false; } // test triggers Function.create(conn, "inform", new Function() { protected void xFunc() throws SQLException { gotTrigger = value_int(0); } }); stat.executeUpdate("create table trigtest (c1);"); stat.executeUpdate( "create trigger trigt after insert on trigtest" + " begin select inform(new.c1); end;" ); stat.executeUpdate("insert into trigtest values (5);"); if (gotTrigger != 5) { error = "bad trigger"; return false; } conn.close(); return true; }
1,116,132
public Node apply(ASTFunNode node, Node[] children) throws ParseException { OperatorSet opSet = xj.getOperatorSet(); TreeUtils tu = xj.getTreeUtils(); Operator lhsOp = tu.getOperator(children[0]); int n = tu.intValue(children[1]); Node sub1 = children[0].jjtGetChild(0); Node sub2 = children[0].jjtGetChild(1); if(lhsOp == opSet.getAdd() || lhsOp == opSet.getSubtract()) { /* (a+b)^n --> (a^n+nC1 a^(n-1) b + ....) */ if(n == 0) return nf.buildConstantNode(new Double(1)); if(n == 1) return children[0]; Node vals[] = new Node[(int) n+1]; /* a^n */ vals[0] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n)) ); if(n==2) { vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(2)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), xj.deepCopy(sub2))); } else { /* n * a^(n-1) * b */ vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-1))), xj.deepCopy(sub2))); } /* n * a * b^(n-1) */ if(n>=3) { vals[n-1] = nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n-1))))); } /* a^n */ vals[n] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n)) ); for(int i=2;i<n-1;++i) { /* (n,i) * a^(n-i) * b^i */ vals[i]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(XMath.binomial(n,i))), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-i))), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(i))))); }// for(int i=0;i<=n;++i)// {// System.out.print("val["+i+"] ");// xj.println(vals[i]);// } Node sums[] = new Node[n+1]; sums[n]=vals[n]; for(int i=n-1;i>=0;--i) { sums[i] = nf.buildOperatorNode( lhsOp, vals[i], sums[i+1]); }// xj.println(sums[0]); return sums[0]; } throw new ParseException("ExpandBrackets at least one child must be + or -"); }
public Node apply(ASTFunNode node, Node[] children) throws ParseException { OperatorSet opSet = xj.getOperatorSet(); TreeUtils tu = xj.getTreeUtils(); Operator lhsOp = tu.getOperator(children[0]); int n = tu.intValue(children[1]); Node sub1 = children[0].jjtGetChild(0); Node sub2 = children[0].jjtGetChild(1); if(lhsOp == opSet.getAdd() || lhsOp == opSet.getSubtract()) { /* (a+b)^n --> (a^n+nC1 a^(n-1) b + ....) */ if(n == 0) return nf.buildConstantNode(new Double(1)); if(n == 1) return children[0]; Node vals[] = new Node[(int) n+1]; /* a^n */ vals[0] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n)) ); if(n==2) { vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(2)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), xj.deepCopy(sub2))); } else { /* n * a^(n-1) * b */ vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-1))), xj.deepCopy(sub2))); } /* n * a * b^(n-1) */ if(n>=3) { vals[n-1] = nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n-1))))); } /* a^n */ vals[n] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n)) ); for(int i=2;i<n-1;++i) { /* (n,i) * a^(n-i) * b^i */ vals[i]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(XMath.binomial(n,i))), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-i))), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(i))))); }// for(int i=0;i<=n;++i)// {// System.out.print("val["+i+"] ");// xj.println(vals[i]);// } Node sums[] = new Node[n+1]; sums[n]=vals[n]; for(int i=n-1;i>=0;--i) { sums[i] = nf.buildOperatorNode( lhsOp, vals[i], sums[i+1]); }// xj.println(sums[0]); return sums[0]; } throw new ParseException("ExpandBrackets at least one child must be + or -"); }
1,116,133
public Node apply(ASTFunNode node, Node[] children) throws ParseException { OperatorSet opSet = xj.getOperatorSet(); TreeUtils tu = xj.getTreeUtils(); Operator lhsOp = tu.getOperator(children[0]); int n = tu.intValue(children[1]); Node sub1 = children[0].jjtGetChild(0); Node sub2 = children[0].jjtGetChild(1); if(lhsOp == opSet.getAdd() || lhsOp == opSet.getSubtract()) { /* (a+b)^n --> (a^n+nC1 a^(n-1) b + ....) */ if(n == 0) return nf.buildConstantNode(new Double(1)); if(n == 1) return children[0]; Node vals[] = new Node[(int) n+1]; /* a^n */ vals[0] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n)) ); if(n==2) { vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(2)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), xj.deepCopy(sub2))); } else { /* n * a^(n-1) * b */ vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-1))), xj.deepCopy(sub2))); } /* n * a * b^(n-1) */ if(n>=3) { vals[n-1] = nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n-1))))); } /* a^n */ vals[n] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n)) ); for(int i=2;i<n-1;++i) { /* (n,i) * a^(n-i) * b^i */ vals[i]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(XMath.binomial(n,i))), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-i))), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(i))))); }// for(int i=0;i<=n;++i)// {// System.out.print("val["+i+"] ");// xj.println(vals[i]);// } Node sums[] = new Node[n+1]; sums[n]=vals[n]; for(int i=n-1;i>=0;--i) { sums[i] = nf.buildOperatorNode( lhsOp, vals[i], sums[i+1]); }// xj.println(sums[0]); return sums[0]; } throw new ParseException("ExpandBrackets at least one child must be + or -"); }
public Node apply(ASTFunNode node, Node[] children) throws ParseException { OperatorSet opSet = xj.getOperatorSet(); TreeUtils tu = xj.getTreeUtils(); Operator lhsOp = tu.getOperator(children[0]); int n = tu.intValue(children[1]); Node sub1 = children[0].jjtGetChild(0); Node sub2 = children[0].jjtGetChild(1); if(lhsOp == opSet.getAdd() || lhsOp == opSet.getSubtract()) { /* (a+b)^n --> (a^n+nC1 a^(n-1) b + ....) */ if(n == 0) return nf.buildConstantNode(new Double(1)); if(n == 1) return children[0]; Node vals[] = new Node[n+1]; /* a^n */ vals[0] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n)) ); if(n==2) { vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(2)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), xj.deepCopy(sub2))); } else { /* n * a^(n-1) * b */ vals[1]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-1))), xj.deepCopy(sub2))); } /* n * a * b^(n-1) */ if(n>=3) { vals[n-1] = nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(n)), nf.buildOperatorNode( opSet.getMultiply(), xj.deepCopy(sub1), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n-1))))); } /* a^n */ vals[n] = nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(n)) ); for(int i=2;i<n-1;++i) { /* (n,i) * a^(n-i) * b^i */ vals[i]=nf.buildOperatorNode( opSet.getMultiply(), nf.buildConstantNode(new Double(XMath.binomial(n,i))), nf.buildOperatorNode( opSet.getMultiply(), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub1), nf.buildConstantNode(new Double(n-i))), nf.buildOperatorNode( opSet.getPower(), xj.deepCopy(sub2), nf.buildConstantNode(new Double(i))))); }// for(int i=0;i<=n;++i)// {// System.out.print("val["+i+"] ");// xj.println(vals[i]);// } Node sums[] = new Node[n+1]; sums[n]=vals[n]; for(int i=n-1;i>=0;--i) { sums[i] = nf.buildOperatorNode( lhsOp, vals[i], sums[i+1]); }// xj.println(sums[0]); return sums[0]; } throw new ParseException("ExpandBrackets at least one child must be + or -"); }
1,116,134
public Operator getOperator(Node node) { if(isOperator(node)) return ((ASTFunNode) node).getOperator(); else return null; }
public Operator getOperator(Node node) { if(isOperator(node)) return ((ASTFunNode) node).getOperator(); return null; }
1,116,135
public boolean isInteger(Node node) { if(isReal(node)) { Number val = (Number) ((ASTConstant) node).getValue(); double x = val.doubleValue(); double xInt = Math.rint(x); return x == xInt; } else return false; }
public boolean isInteger(Node node) { if(isReal(node)) { Number val = (Number) ((ASTConstant) node).getValue(); double x = val.doubleValue(); double xInt = Math.rint(x); return x == xInt; } return false; }
1,116,136
public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException { useSecurity = req.getParameter("use_security")!=null; numExecutors = Integer.parseInt(req.getParameter("numExecutors")); {// update JDK installations jdks.clear(); String[] names = req.getParameterValues("jdk_name"); String[] homes = req.getParameterValues("jdk_home"); int len = Math.min(names.length,homes.length); for(int i=0;i<len;i++) { jdks.add(new JDK(names[i],homes[i])); } } for( Executor e : executors ) if(e.getCurrentBuild()==null) e.interrupt(); while(executors.size()<numExecutors) executors.add(new Executor(this)); boolean result = true; for( BuildStepDescriptor d : BuildStep.BUILDERS ) result &= d.configure(req); for( BuildStepDescriptor d : BuildStep.PUBLISHERS ) result &= d.configure(req); for( SCMDescriptor scmd : SCMManager.getSupportedSCMs() ) result &= scmd.configure(req); save(); if(result) rsp.sendRedirect("."); // go to the top page else rsp.sendRedirect("configure"); // back to config }
public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException { useSecurity = req.getParameter("use_security")!=null; numExecutors = Integer.parseInt(req.getParameter("numExecutors")); {// update JDK installations jdks.clear(); String[] names = req.getParameterValues("jdk_name"); String[] homes = req.getParameterValues("jdk_home"); int len = Math.min(names.length,homes.length); for(int i=0;i<len;i++) { jdks.add(new JDK(names[i],homes[i])); } } for( Executor e : executors ) if(e.getCurrentBuild()==null) e.interrupt(); while(executors.size()<numExecutors) executors.add(new Executor(this)); boolean result = true; for( BuildStepDescriptor d : BuildStep.BUILDERS ) result &= d.configure(req); for( BuildStepDescriptor d : BuildStep.PUBLISHERS ) result &= d.configure(req); for( SCMDescriptor scmd : SCMManager.getSupportedSCMs() ) result &= scmd.configure(req); save(); if(result) rsp.sendRedirect("."); // go to the top page else rsp.sendRedirect("configure"); // back to config }
1,116,137
void sbCharacters(String s){ if (currentList.equals("FERMENTABLES")) { if (currentElement.equalsIgnoreCase("MALT")) { m.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { m.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("POINTS")) { m.setPppg(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("COSTLB")) { m.setCost( s ); } else if (currentElement.equalsIgnoreCase("UNITS")) { m.setUnits(s); } else if (currentElement.equalsIgnoreCase("LOV")) { m.setLov(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { m.setDescription(s); } } else if (currentList.equalsIgnoreCase("HOPS")) { if (currentElement.equalsIgnoreCase("HOP")) { h.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { h.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("ALPHA")) { h.setAlpha(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("UNITS")) { h.setUnits(s); } else if (currentElement.equalsIgnoreCase("FORM")) { h.setType(s); } else if (currentElement.equalsIgnoreCase("COSTOZ")) { h.setCost( s ); } else if (currentElement.equalsIgnoreCase("ADD")) { h.setAdd(s); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { h.setDescription(s); } else if (currentElement.equalsIgnoreCase("TIME")) { h.setMinutes(Integer.parseInt(s)); } } else if (currentList.equalsIgnoreCase("MISC")) { if (currentElement.equalsIgnoreCase("NAME")) { misc.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { misc.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("UNITS")) { misc.setUnits(s); } else if (currentElement.equalsIgnoreCase("COMMENTS")) { misc.setComments(s); } else if (currentElement.equalsIgnoreCase("COST_PER_U")) { // misc.setCost( Double.parseDouble(s) ); } else if (currentElement.equalsIgnoreCase("ADD")) { h.setAdd(s); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { misc.setDescription(s); } else if (currentElement.equalsIgnoreCase("TIME")) { misc.setTime(Integer.parseInt(s)); } else if (currentElement.equalsIgnoreCase("STAGE")) { misc.setStage(s); } } else if (currentList.equalsIgnoreCase("MASH")) { if (currentElement.equalsIgnoreCase("TYPE")) { type = s; } else if (currentElement.equalsIgnoreCase("TEMP")) { startTemp = Double.parseDouble(s); } else if (currentElement.equalsIgnoreCase("METHOD")) { method = s; } else if (currentElement.equalsIgnoreCase("MIN")) { minutes = Integer.parseInt(s); } else if (currentElement.equalsIgnoreCase("END_TEMP")) { endTemp = Double.parseDouble(s); } else if (currentElement.equalsIgnoreCase("RAMP_MIN")) { rampMin = Integer.parseInt(s); } } else if (currentList.equalsIgnoreCase("DETAILS")) { if (currentElement.equalsIgnoreCase("NAME")) { r.setName(s); } else if (currentElement.equalsIgnoreCase("EFFICIENCY")) { r.setEfficiency(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("ATTENUATION")) { r.setAttenuation(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("PRESIZE")) { r.setPreBoil(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("SIZE")) { r.setPostBoil(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("SIZE_UNITS")) { r.setPreBoilVolUnits(s); r.setPostBoilVolUnits(s); } else if (currentElement.equalsIgnoreCase("STYLE")) { r.setStyle(s); } else if (currentElement.equalsIgnoreCase("BOIL_TIME")) { r.setBoilMinutes(Integer.parseInt(s)); } else if (currentElement.equalsIgnoreCase("HOPS_UNITS")) { r.setHopsUnits(s); } else if (currentElement.equalsIgnoreCase("MALT_UNITS")) { r.setMaltUnits(s); } else if (currentElement.equalsIgnoreCase("MASH_RATIO")) { r.setMashRatio(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("MASH_RATIO_U")) { r.setMashRatioU(s); } else if (currentElement.equalsIgnoreCase("BREWER")) { r.setBrewer(s); } else if (currentElement.equalsIgnoreCase("MASH")) { r.setMashed(Boolean.valueOf(s).booleanValue()); } else if (currentElement.equalsIgnoreCase("YEAST")) { r.setYeastName(s); } } else s = ""; }
void sbCharacters(String s){ if (currentList.equals("FERMENTABLES")) { if (currentElement.equalsIgnoreCase("MALT")) { m.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { m.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("POINTS")) { m.setPppg(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("COSTLB")) { m.setCost( s ); } else if (currentElement.equalsIgnoreCase("UNITS")) { m.setUnits(s); } else if (currentElement.equalsIgnoreCase("LOV")) { m.setLov(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { m.setDescription(s); } } else if (currentList.equalsIgnoreCase("HOPS")) { if (currentElement.equalsIgnoreCase("HOP")) { h.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { h.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("ALPHA")) { h.setAlpha(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("UNITS")) { h.setUnits(s); } else if (currentElement.equalsIgnoreCase("FORM")) { h.setType(s); } else if (currentElement.equalsIgnoreCase("COSTOZ")) { h.setCost( s ); } else if (currentElement.equalsIgnoreCase("ADD")) { h.setAdd(s); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { descrBuf = descrBuf + s; } else if (currentElement.equalsIgnoreCase("TIME")) { h.setMinutes(Integer.parseInt(s)); } } else if (currentList.equalsIgnoreCase("MISC")) { if (currentElement.equalsIgnoreCase("NAME")) { misc.setName(s); } else if (currentElement.equalsIgnoreCase("AMOUNT")) { misc.setAmount(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("UNITS")) { misc.setUnits(s); } else if (currentElement.equalsIgnoreCase("COMMENTS")) { misc.setComments(s); } else if (currentElement.equalsIgnoreCase("COST_PER_U")) { // misc.setCost( Double.parseDouble(s) ); } else if (currentElement.equalsIgnoreCase("ADD")) { h.setAdd(s); } else if (currentElement.equalsIgnoreCase("DescrLookup")) { misc.setDescription(s); } else if (currentElement.equalsIgnoreCase("TIME")) { misc.setTime(Integer.parseInt(s)); } else if (currentElement.equalsIgnoreCase("STAGE")) { misc.setStage(s); } } else if (currentList.equalsIgnoreCase("MASH")) { if (currentElement.equalsIgnoreCase("TYPE")) { type = s; } else if (currentElement.equalsIgnoreCase("TEMP")) { startTemp = Double.parseDouble(s); } else if (currentElement.equalsIgnoreCase("METHOD")) { method = s; } else if (currentElement.equalsIgnoreCase("MIN")) { minutes = Integer.parseInt(s); } else if (currentElement.equalsIgnoreCase("END_TEMP")) { endTemp = Double.parseDouble(s); } else if (currentElement.equalsIgnoreCase("RAMP_MIN")) { rampMin = Integer.parseInt(s); } } else if (currentList.equalsIgnoreCase("DETAILS")) { if (currentElement.equalsIgnoreCase("NAME")) { r.setName(s); } else if (currentElement.equalsIgnoreCase("EFFICIENCY")) { r.setEfficiency(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("ATTENUATION")) { r.setAttenuation(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("PRESIZE")) { r.setPreBoil(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("SIZE")) { r.setPostBoil(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("SIZE_UNITS")) { r.setPreBoilVolUnits(s); r.setPostBoilVolUnits(s); } else if (currentElement.equalsIgnoreCase("STYLE")) { r.setStyle(s); } else if (currentElement.equalsIgnoreCase("BOIL_TIME")) { r.setBoilMinutes(Integer.parseInt(s)); } else if (currentElement.equalsIgnoreCase("HOPS_UNITS")) { r.setHopsUnits(s); } else if (currentElement.equalsIgnoreCase("MALT_UNITS")) { r.setMaltUnits(s); } else if (currentElement.equalsIgnoreCase("MASH_RATIO")) { r.setMashRatio(Double.parseDouble(s)); } else if (currentElement.equalsIgnoreCase("MASH_RATIO_U")) { r.setMashRatioU(s); } else if (currentElement.equalsIgnoreCase("BREWER")) { r.setBrewer(s); } else if (currentElement.equalsIgnoreCase("MASH")) { r.setMashed(Boolean.valueOf(s).booleanValue()); } else if (currentElement.equalsIgnoreCase("YEAST")) { r.setYeastName(s); } } else s = ""; }
1,116,139
public void doStop( StaplerRequest req, StaplerResponse rsp ) throws IOException { if(!Hudson.adminCheck(req,rsp)) return; interrupt(); rsp.sendRedirect(req.getContextPath()); }
public void doStop( StaplerRequest req, StaplerResponse rsp ) throws IOException { if(!Hudson.adminCheck(req,rsp)) return; interrupt(); rsp.sendRedirect(req.getContextPath()+"/"); }
1,116,148
protected void setUp() { j = new DJep(); j.addStandardConstants(); j.addStandardFunctions(); j.addComplex(); //j.setTraverse(true); j.setAllowAssignment(true); j.setAllowUndeclared(true); j.setImplicitMul(true); j.dv.addStandardDiffRules(); }
protected void setUp() { j = new DJep(); j.addStandardConstants(); j.addStandardFunctions(); j.addComplex(); //j.setTraverse(true); j.setAllowAssignment(true); j.setAllowUndeclared(true); j.setImplicitMul(true); j.addStandardDiffRules(); }
1,116,149
public void close() throws IOException { buf.flip(); decoder.decode(buf,out,true); buf.compact(); flushOutput(); writer.close(); }
public void close() throws IOException { buf.flip(); decoder.decode(buf,out,true); buf.compact(); flushOutput(); writer.close(); }
1,116,150
private void decode() throws IOException { buf.flip(); while(true) { CoderResult r = decoder.decode(buf, out, false); if(r==CoderResult.OVERFLOW) { flushOutput(); continue; } if(r==CoderResult.UNDERFLOW) { buf.compact(); return; } // otherwise treat it as an error r.throwException(); } }
private void decode(boolean last) throws IOException { buf.flip(); while(true) { CoderResult r = decoder.decode(buf, out, false); if(r==CoderResult.OVERFLOW) { flushOutput(); continue; } if(r==CoderResult.UNDERFLOW) { buf.compact(); return; } // otherwise treat it as an error r.throwException(); } }
1,116,152
private void decode() throws IOException { buf.flip(); while(true) { CoderResult r = decoder.decode(buf, out, false); if(r==CoderResult.OVERFLOW) { flushOutput(); continue; } if(r==CoderResult.UNDERFLOW) { buf.compact(); return; } // otherwise treat it as an error r.throwException(); } }
private void decode() throws IOException { buf.flip(); while(true) { CoderResult r = decoder.decode(buf, out, last); if(r==CoderResult.OVERFLOW) { flushOutput(); continue; } if(r==CoderResult.UNDERFLOW) { buf.compact(); return; } // otherwise treat it as an error r.throwException(); } }
1,116,153
public void flush() throws IOException { decode(); flushOutput(); writer.flush(); }
public void flush() throws IOException { decode(false); flushOutput(); writer.flush(); }
1,116,154
public void write(int b) throws IOException { if(buf.remaining()==0) decode(); buf.put((byte)b); }
public void write(int b) throws IOException { if(buf.remaining()==0) decode(false); buf.put((byte)b); }
1,116,155
public FindDialog(JFrame frame) { super(frame); recipes = new ArrayList(); files = new ArrayList(); inst = (StrangeSwing) frame; currentDir = new java.io.File("."); initGUI(); dirLocationText.setText(currentDir.getAbsolutePath()); loadRecipes(currentDir); }
public FindDialog(JFrame frame) { super(frame); recipes = new ArrayList(); files = new ArrayList(); inst = (StrangeSwing) frame; currentDir = new java.io.File("."); initGUI(); dirLocationText.setText(currentDir.getAbsolutePath()); }
1,116,156
public void actionPerformed(ActionEvent e) { Object o = e.getSource(); if (o == cancelButton) { setVisible(false); dispose(); return; } else if (o == openButton) { int i = recipeTable.getSelectedRow(); if (i > -1) { inst.setRecipe((Recipe) recipes.get(i), (File) files.get(i)); } setVisible(false); dispose(); return; } }
public void actionPerformed(ActionEvent e) { Object o = e.getSource(); if (o == cancelButton) { setVisible(false); dispose(); return; } else if (o == openButton) { int i = recipeTable.getSelectedRow(); if (i > -1 && i < recipes.size()) { inst.setRecipe((Recipe) recipes.get(i), (File) files.get(i)); } setVisible(false); dispose(); return; } }
1,116,157
private void loadRecipes(File dir) { recipes.clear(); files.clear(); for (int i = 0; i < dir.list().length; i++) { File file = new File(dir.list()[i]); if (file.getName().endsWith("xml") || file.getName().endsWith("qbrew")) { Debug.print("Opening: " + file.getName() + ".\n"); // file.getAbsolutePath doesn't work here for some reason, // so we have to build it ourselves String fileName = dir.getAbsolutePath() + System.getProperty("file.separator") + file.getName(); ImportXml imp = new ImportXml(fileName, "recipe"); Recipe r = imp.handler.getRecipe(); recipes.add(r); files.add(file); } } recipeTableModel.setData(recipes); recipeTable.updateUI(); }
private void loadRecipes(File dir) { recipes.clear(); files.clear(); for (int i = 0; i < dir.list().length; i++) { File file = new File(dir.list()[i]); if (file.getPath().endsWith(".rec") || file.getPath().endsWith(".qbrew") || file.getPath().endsWith(".xml")) { Debug.print("Opening: " + file.getName() + ".\n"); // file.getAbsolutePath doesn't work here for some reason, // so we have to build it ourselves String fileName = dir.getAbsolutePath() + System.getProperty("file.separator") + file.getName(); ImportXml imp = new ImportXml(fileName, "recipe"); Recipe r = imp.handler.getRecipe(); recipes.add(r); files.add(file); } } recipeTableModel.setData(recipes); recipeTable.updateUI(); }
1,116,158
private void loadRecipes(File dir) { recipes.clear(); files.clear(); for (int i = 0; i < dir.list().length; i++) { File file = new File(dir.list()[i]); if (file.getName().endsWith("xml") || file.getName().endsWith("qbrew")) { Debug.print("Opening: " + file.getName() + ".\n"); // file.getAbsolutePath doesn't work here for some reason, // so we have to build it ourselves String fileName = dir.getAbsolutePath() + System.getProperty("file.separator") + file.getName(); ImportXml imp = new ImportXml(fileName, "recipe"); Recipe r = imp.handler.getRecipe(); recipes.add(r); files.add(file); } } recipeTableModel.setData(recipes); recipeTable.updateUI(); }
private void loadRecipes(File dir) { recipes.clear(); files.clear(); for (int i = 0; i < dir.list().length; i++) { File file = new File(dir.list()[i]); if (file.getName().endsWith("xml") || file.getName().endsWith("qbrew")) { Debug.print("Opening: " + file.getName() + ".\n"); // file.getAbsolutePath doesn't work here for some reason, // so we have to build it ourselves String fileName = dir.getAbsolutePath() + System.getProperty("file.separator") + file.getName(); ImportXml imp = new ImportXml(fileName, "recipe"); Recipe r = imp.handler.getRecipe(); recipes.add(r); files.add(file); } } recipeTableModel.setData(recipes); recipeTable.updateUI(); }
1,116,159
public void displayWater(){ String recipeUnitsAbrv = new Quantity().getVolAbrv(myRecipe.getVolUnits()); String mashUnitsAbrv = new Quantity().getVolAbrv(myRecipe.mash.getMashVolUnits()); totalWaterLbl.setText(myRecipe.getTotalWater()); totalUnitsLbl.setText(recipeUnitsAbrv); usedMashLbl.setText(myRecipe.mash.getTotalWaterStr()); usedInMashUnitsLbl.setText(mashUnitsAbrv); absorbedLbl.setText(myRecipe.mash.getAbsorbedStr()); absorbedUnitsLbl.setText(mashUnitsAbrv); spargeWithLbl.setText(myRecipe.getSparge()); spargeUnitsLbl.setText(mashUnitsAbrv); collectTxt.setValue(new Double(myRecipe.getPreBoilVol(myRecipe.getVolUnits()))); collectUnitsLbl.setText(recipeUnitsAbrv); postBoilTxt.setValue(new Double(myRecipe.getPostBoilVol(myRecipe.getVolUnits()))); postBoilUnitsLbl.setText(recipeUnitsAbrv); chillShrinkLbl.setText(myRecipe.getChillShrink()); kettleTxt.setValue(new Double(myRecipe.getKettleLoss())); kettleUnitsLbl.setText(recipeUnitsAbrv); trubLossTxt.setValue(new Double(myRecipe.getTrubLoss())); trubLossUnitsLbl.setText(recipeUnitsAbrv); miscLossTxt.setValue(new Double(myRecipe.getMiscLoss())); miscLosUnitsLbl.setText(recipeUnitsAbrv); finalVolTxt.setValue(new Double(myRecipe.getFinalWortVol())); finalUnitsLbl.setText(recipeUnitsAbrv); }
public void displayWater(){ String recipeUnitsAbrv = new Quantity().getVolAbrv(myRecipe.getVolUnits()); String mashUnitsAbrv = new Quantity().getVolAbrv(myRecipe.mash.getMashVolUnits()); totalWaterLbl.setText(myRecipe.getTotalWater()); totalUnitsLbl.setText(recipeUnitsAbrv); usedMashLbl.setText(myRecipe.mash.getTotalWaterStr()); usedInMashUnitsLbl.setText(mashUnitsAbrv); absorbedLbl.setText(myRecipe.mash.getAbsorbedStr()); absorbedUnitsLbl.setText(mashUnitsAbrv); spargeWithLbl.setText(myRecipe.getSparge()); spargeUnitsLbl.setText(mashUnitsAbrv); collectTxt.setValue(new Double(myRecipe.getPreBoilVol(myRecipe.getVolUnits()))); collectUnitsLbl.setText(recipeUnitsAbrv); postBoilTxt.setValue(new Double(myRecipe.getPostBoilVol(myRecipe.getVolUnits()))); postBoilUnitsLbl.setText(recipeUnitsAbrv); chillShrinkLbl.setText(myRecipe.getChillShrink()); kettleTxt.setValue(new Double(myRecipe.getKettleLoss())); kettleUnitsLbl.setText(recipeUnitsAbrv); trubLossTxt.setValue(new Double(myRecipe.getTrubLoss())); trubLossUnitsLbl.setText(recipeUnitsAbrv); miscLossTxt.setValue(new Double(myRecipe.getMiscLoss())); miscLosUnitsLbl.setText(recipeUnitsAbrv); finalVolTxt.setValue(new Double(myRecipe.getFinalWortVol())); finalUnitsLbl.setText(recipeUnitsAbrv); }
1,116,161
private String getAbrvFromUnit(String t, String s){ int i=0; Converter[] u; if (t == "vol") u = volUnits; else // assume weight u = weightUnits; while (i < u.length && u[i].unit != s) { i++; } if (i >= u.length) return null; else return u[i].abrv; }
private String getAbrvFromUnit(String t, String s){ int i=0; Converter[] u; if (t == "vol") u = volUnits; else // assume weight u = weightUnits; while (i < u.length && !u[i].unit.equalsIgnoreCase(s)) { i++; } if (i >= u.length) return null; else return u[i].abrv; }
1,116,162
public void testSwitchAuthorizedUserSuccess() { Credential credential = new Credential(); User[] users = createUsersWithSameCredential(credential, 2); UserLog userLog = new UserLog(); userLog.setUser(users[0]); UserDetailsAdapter secureUser = new UserDetailsAdapter(userLog); expect(mock.createAndPersistUserLog(users[1])) .andReturn(isA(UserLog.class)); replay(mock); assertTrue(simpleCoreMgr.switchAuthorizedUser(secureUser, "ENT1")); reset(mock); }
public void testSwitchAuthorizedUserSuccess() { Credential credential = new Credential(); User[] users = createUsersWithSameCredential(credential, 2); UserLog userLog = new UserLog(); userLog.setUser(users[0]); UserDetailsAdapter secureUser = new UserDetailsAdapter(userLog); expect(mock.createAndPersistUserLog(users[1])) .andReturn(userLog); replay(mock); assertTrue(simpleCoreMgr.switchAuthorizedUser(secureUser, "ENT1")); reset(mock); }
1,116,164
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
1,116,165
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
1,116,166
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
1,116,167
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( isSearchListVisible ); setFilterPanelVisible( isFilterPanelVisible ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
1,116,168
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( true ) ); viewMenuActionList = Collections.unmodifiableList(actionList); }
public void initComponent( DGuiSettings guiSettings ) { addTabAction( CLEAR_SEARCH_RESULTS_ACTION, new ClearSearchResultsAction() ); addTabAction( CREATE_NEW_SEARCH_ACTION, new CreateNewSearchAction() ); addTabAction( CLOSE_SEARCH_ACTION, new CloseSearchAction() ); CellConstraints cc = new CellConstraints(); FormLayout tabLayout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns "0dlu, p, 2dlu, fill:p:grow, 2dlu"); //rows PanelBuilder tabBuilder = new PanelBuilder(tabLayout, this); buttonBarContainer = new JPanel( new BorderLayout() ); tabBuilder.add( buttonBarContainer, cc.xy(2, 2) ); contentPanel = new JPanel(); FWElegantPanel banner = new FWElegantPanel( Localizer.getString("Search"), contentPanel ); tabBuilder.add(banner, cc.xy(2, 4)); FormLayout contentLayout = new FormLayout( "fill:d:grow", // columns "fill:d:grow"); //rows contentBuilder = new PanelBuilder(contentLayout, contentPanel); searchListPanel = new SearchListPanel( this ); searchListPanel.initializeComponent( guiSettings ); mainSearchPanel = new JPanel(); FormLayout lowerLayout = new FormLayout( "p, 1dlu, fill:d:grow", // columns "fill:d:grow"); //rows PanelBuilder lowerBuilder = new PanelBuilder( lowerLayout, mainSearchPanel ); //searchControlPanel = new SearchControlPanel( this ); searchControlPanel = new SearchControlPanel( this ); searchControlPanel.setMinimumSize(new Dimension(0,0)); lowerBuilder.add( searchControlPanel, cc.xy( 1, 1 ) ); JPanel lowerRightPanel = new JPanel(); FormLayout lowerRightLayout = new FormLayout( "fill:d:grow", // columns "p, fill:d:grow"); //rows PanelBuilder lowerRightBuilder = new PanelBuilder( lowerRightLayout, lowerRightPanel ); searchFilterPanel = new SearchFilterPanel( this ); lowerRightBuilder.add( searchFilterPanel, cc.xy( 1, 1 ) ); searchResultPanel = new SearchResultsPanel( this ); searchResultPanel.initializeComponent( guiSettings ); lowerRightBuilder.add( searchResultPanel, cc.xy( 1, 2 ) ); lowerBuilder.add( lowerRightPanel, cc.xy( 3, 1 ) ); Dimension dim = new Dimension( 400, 200 ); mainSearchPanel.setPreferredSize( dim ); mainSearchPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListPanel.setMinimumSize( new Dimension( 0, 0 ) ); searchListSplitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, searchListPanel, mainSearchPanel ); searchListSplitPane.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0) ); searchListSplitPane.setDividerSize( 4 ); searchListSplitPane.setOneTouchExpandable( false ); boolean isSearchBarVisible = true; if ( guiSettings != null && guiSettings.isSetSearchBarVisible() ) { isSearchBarVisible = guiSettings.isSearchBarVisible(); } setSearchButtonBarVisible( isSearchBarVisible ); setSearchListVisible( true ); List actionList = new ArrayList(); actionList.add( new ToggleSearchBarAction( isSearchBarVisible ) ); actionList.add( new ToggleSearchListAction( isSearchListVisible ) ); actionList.add( filterPanelToggleAction ); viewMenuActionList = Collections.unmodifiableList(actionList); }
1,116,169