Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

CutCollection Class Reference

Inheritance diagram for CutCollection:

Inheritance graph
[legend]
Collaboration diagram for CutCollection:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CutCollection ()
 CutCollection (Integer id)
boolean addCut (Cut cut)
CutCollection clear ()
boolean equals (CutCollection cuts)
Vector< CutgetCuts ()
int getIdDontRetrieve ()
int getId ()
CutCollection setId (Integer id)
boolean isWithin (CutCollection cuts)
CutCollection union (CutCollection cuts)
boolean store () throws JetWebException
boolean retrieve () throws JetWebException

Private Member Functions

boolean bothEmpty (CutCollection cuts)

Private Attributes

Vector< Cutcuts_ = new Vector<Cut>()
Integer id_ = -1

Constructor & Destructor Documentation

CutCollection  ) 
 

Definition at line 13 of file CutCollection.java.

Referenced by CutCollection.union().

00013                           {
00014     
00015     }

CutCollection Integer  id  ) 
 

Definition at line 17 of file CutCollection.java.

References CutCollection.id_.

00017                                     {
00018     id_ = id;
00019     try{
00020         DBJobManager.selectFromDB(this);
00021     }catch(JetWebException err){
00022         System.out.println
00023         ("CutCollection: Unable to query database "+
00024          "to instantiate CutCollection from Id");
00025         err.printStackTrace();
00026         System.out.println(err.getMessage());
00027     }
00028     }


Member Function Documentation

boolean addCut Cut  cut  ) 
 

add a new cut to this collection of cuts. if an existing cut is already higher then no need to do anything. (assumes all cuts are lower bounds for the moment!)

Returns:
true if the cut was added, false otherwise

Definition at line 38 of file CutCollection.java.

References CutCollection.cuts_, Cut.getName(), Cut.lt(), and CutCollection.setId().

Referenced by ServletUtils.modifyPlots(), and CutCollection.union().

00038                                   {
00039     Vector<Cut> cutsToRemove = new Vector<Cut>();
00040     for(Cut existingCut: cuts_){
00041         if(cut.lt(existingCut)) return false;
00042         String name1 = existingCut.getName();
00043         String name2 = cut.getName();
00044         if(name1!=null && name2!=null &&name1.equals(name2)){
00045         cutsToRemove.add(existingCut);
00046         }
00047     }
00048 
00049     for(Cut remove: cutsToRemove){
00050         cuts_.remove(remove);
00051     }
00052 
00053     setId(-1);
00054     cuts_.add(cut);
00055     return true;
00056     }

boolean bothEmpty CutCollection  cuts  )  [private]
 

Definition at line 192 of file CutCollection.java.

References CutCollection.cuts_, CutCollection.getCuts(), CutCollection.getId(), and CutCollection.id_.

Referenced by CutCollection.equals(), and CutCollection.isWithin().

00192                                                  {
00193     return 
00194         (id_==-1 &&
00195          cuts.getId()==-1 &&
00196          cuts_.size()==0 &&
00197          cuts.getCuts().size()==0
00198          );
00199     }

CutCollection clear  ) 
 

Definition at line 58 of file CutCollection.java.

References CutCollection.cuts_.

00058                                 {
00059     cuts_.clear();
00060     return this;
00061     }

boolean equals CutCollection  cuts  ) 
 

Definition at line 63 of file CutCollection.java.

References CutCollection.bothEmpty(), CutCollection.cuts_, CutCollection.getCuts(), CutCollection.getId(), CutCollection.id_, and CutCollection.retrieve().

Referenced by RunSeriesCollection.add(), MergedPlot.addPlot(), and JobUtils.doJobRequest().

00063                                              {
00064     try{
00065         if(id_< 0 && cuts_.size()!=0) retrieve();
00066         if(cuts.getId()<0 && cuts.getCuts().size()!=0)cuts.retrieve();
00067     }catch(JetWebException err){
00068         System.out.println
00069         ("CutCollection.equals(): Unable to retrieve cut.");
00070         err.printStackTrace();
00071         System.out.println(err.getMessage());
00072     }
00073     if(id_>0 && id_ == cuts.getId()) return true;
00074     if(bothEmpty(cuts)) return true;
00075     return false;
00076     }

Vector<Cut> getCuts  ) 
 

Definition at line 78 of file CutCollection.java.

References CutCollection.cuts_, CutCollection.id_, and CutCollection.retrieve().

Referenced by CutCollection.bothEmpty(), JobUtils.doJobRequest(), CutCollection.equals(), and CutCollection.isWithin().

00078                                 {
00079     try{
00080         if(id_>0 &&cuts_.size()==0) retrieve();
00081     }catch(JetWebException err){
00082         System.out.println
00083      ("CutCollection.getCuts(): Unable to retrieve CutCollection from DB");
00084         err.printStackTrace();
00085     }
00086     return cuts_;
00087     }

int getId  ) 
 

Get the unique ID of the object

Implements Storeable.

Definition at line 93 of file CutCollection.java.

References CutCollection.cuts_, CutCollection.id_, and CutCollection.retrieve().

Referenced by RunSeriesCollection.add(), CutCollection.bothEmpty(), DBPlotManager.delete(), CutCollection.equals(), DBPlotManager.insertCrossSection(), DBPlotManager.insertFittedPrediction(), DBPlotManager.plotExists(), DBPlotManager.populateSelection(), DBPlotManager.selectPlotSwitch(), DBPlotManager.update(), and DBPlotManager.updateCrossSectionLabels().

00093                       {
00094 
00095     try{
00096         if(id_<0 && cuts_.size()!=0) retrieve();
00097     }catch(JetWebException err){
00098         System.out.println
00099         ("Unable to retrieve cut_collection_id from database");
00100         System.out.println(err.getMessage());
00101         err.printStackTrace();
00102     }
00103     return id_;
00104     }

int getIdDontRetrieve  ) 
 

Definition at line 89 of file CutCollection.java.

00089                                   {
00090     return id_;
00091     }

boolean isWithin CutCollection  cuts  ) 
 

returns true if the phase space of this CutCollection lies entirely within the phase space of the argument collection of cuts. Also returns true if either of the CutCollections is empty

Definition at line 117 of file CutCollection.java.

References CutCollection.bothEmpty(), and CutCollection.getCuts().

Referenced by JobUtils.doJobRequest(), DBFitManager.fill(), DBPlotManager.getPredictedPapers(), and LogFile.makePlots().

00117                                                {
00118     
00119     if(bothEmpty(cuts)) return true;
00120 
00121     for(Cut cut1: cuts_){
00122         for(Cut cut2: cuts.getCuts()){
00123         if( cut1.lt(cut2) )return false;
00124         }
00125     }
00126     return true;
00127     }

boolean retrieve  )  throws JetWebException
 

Populate the object in memory from the database. Return true if the information retrieved is up to date.

Implements Storeable.

Definition at line 184 of file CutCollection.java.

Referenced by CutCollection.equals(), CutCollection.getCuts(), and CutCollection.getId().

00185                           {
00186 
00187     DBJobManager.selectFromDB(this);
00188 
00189     return true;
00190     }

CutCollection setId Integer  id  ) 
 

Definition at line 106 of file CutCollection.java.

References CutCollection.id_.

Referenced by CutCollection.addCut(), and DBPlotManager.insertCrossSection().

00106                                           {
00107     id_ = id;
00108     return this;
00109     }

boolean store  )  throws JetWebException
 

Write the object in memory to the database. If the ID does not exist in the DB the object is inserted as a new entry. If the ID exists, that entry is updated.

Returns:
true if the object was inserted, false otherwise.

Implements Storeable.

Definition at line 173 of file CutCollection.java.

Referenced by DBManager.addRunSeries(), DBPlotManager.insertCrossSection(), and DBPlotManager.updateCrossSectionLabels().

00174                           {
00175     for(Cut cut: cuts_){
00176         cut.store();
00177     }
00178 
00179     DBJobManager.addToDB(this);
00180 
00181     return true;
00182     }

CutCollection union CutCollection  cuts  ) 
 

Returns a CutCollection whose phase space contains this CutCollection and the argument CutCollection. i.e. if you call isWithin on this or the argument CutCollection with the return value (ps) as argument the result will always be true:

this.isWithin(ps) = true cuts.isWithin(ps) = true

Definition at line 139 of file CutCollection.java.

References CutCollection.addCut(), CutCollection.CutCollection(), and CutCollection.cuts_.

00139                                                   {
00140 
00141     CutCollection ps = new CutCollection();
00142     Vector<String> foundNames = new Vector<String>();
00143     for(Cut cut1: cuts.getCuts()){
00144         String name1 = cut1.getName();
00145         boolean found = false;
00146         for(Cut cut2: cuts_){
00147         String name2 = cut2.getName();
00148         if(name1.equals(name2)){
00149             found = true;
00150             foundNames.add(name2);
00151             if(cut1.getValue()<cut2.getValue()){
00152             ps.addCut(cut1);
00153             }else{
00154             ps.addCut(cut2);
00155             }
00156         }
00157         }
00158         if(!found) ps.addCut(cut1);
00159     }
00160 
00161     if(foundNames.size()!=cuts_.size()){
00162         for(Cut cut: cuts_){
00163         if(!foundNames.contains(cut.getName())){
00164             ps.addCut(cut);
00165         }
00166         }
00167     }
00168 
00169     return ps;
00170     }


Member Data Documentation

Vector<Cut> cuts_ = new Vector<Cut>() [private]
 

Definition at line 10 of file CutCollection.java.

Referenced by CutCollection.addCut(), CutCollection.bothEmpty(), CutCollection.clear(), CutCollection.equals(), CutCollection.getCuts(), CutCollection.getId(), and CutCollection.union().

Integer id_ = -1 [private]
 

Definition at line 11 of file CutCollection.java.

Referenced by CutCollection.bothEmpty(), CutCollection.CutCollection(), CutCollection.equals(), CutCollection.getCuts(), CutCollection.getId(), and CutCollection.setId().


The documentation for this class was generated from the following file:

Generated Wed Jan 17 09:14:27 GMT 2007