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

PlotSwitch Class Reference

Inheritance diagram for PlotSwitch:

Inheritance graph
[legend]
Collaboration diagram for PlotSwitch:

Collaboration graph
[legend]
List of all members.

Detailed Description

Switch which tells JetWeb which process a plot should be generated by under various conditions
Author:
Jon Butterworth, UCL.
Version:
Date
2006-11-01 18:27:58 +0000 (Wed, 01 Nov 2006)

Definition at line 18 of file PlotSwitch.java.


Public Member Functions

 PlotSwitch (int newId) throws JetWebException
 PlotSwitch () throws JetWebException
boolean retrieve () throws JetWebException
boolean store () throws JetWebException
int getId ()
int getMCProcessTypeId ()
MCProcessType getMCProcessType ()
String getGeneratorName ()
double getGeneratorVersion ()
Double getParameterValueLow ()
Double getParameterValueHigh ()
String getParameterName ()
void setGeneratorName (String gen)
void setPlotId (int newId)
int getPlotId ()
void setGeneratorVersion (double vers)
void setParameterName (String pname)
void setParameterValueHigh (double val)
void setParameterValueLow (double val)
void setMCProcessTypeId (int id)
boolean equals (Object obj)
int hashCode ()

Static Public Member Functions

Iterator< String > getAllowedParameters ()
boolean isAllowedParameter (String parameter)
synchronized void initializeParameterList ()
MCProcessType defaultProc (Collision c)

Private Attributes

int id
int plotId
MCProcessType proc
int procId
String parameterName
Double parameterValueLow = Double.NEGATIVE_INFINITY
Double parameterValueHigh = Double.POSITIVE_INFINITY
String generatorName
double generatorVersion = -1.0

Static Private Attributes

HashSet< String > allowedParameters

Constructor & Destructor Documentation

PlotSwitch int  newId  )  throws JetWebException
 

Create a plotSwitch based on an ID

Definition at line 35 of file PlotSwitch.java.

References PlotSwitch.retrieve().

00035                                                         {
00036     id = newId;
00037     retrieve();
00038     } 

PlotSwitch  )  throws JetWebException
 

Create an empty plotSwitch

Definition at line 43 of file PlotSwitch.java.

00043                                                {
00044     } 


Member Function Documentation

MCProcessType defaultProc Collision  c  )  [static]
 

Definition at line 252 of file PlotSwitch.java.

References PlotSwitch.proc, MCProcessType.setCollision(), and MCProcessType.setMCProcessName().

00252                                                         {
00253 
00254     MCProcessType proc = new MCProcessType();
00255     proc.setCollision(c);
00256     proc.setMCProcessName("High ET");
00257     return proc;
00258 
00259     }

boolean equals Object  obj  ) 
 

Override the Object equals method. Two PlotSwitches are equal if their id's are valid and equal. If one or two of the id's are invalid, they are equal if all their fields are equal.

Definition at line 156 of file PlotSwitch.java.

References PlotSwitch.generatorName, PlotSwitch.generatorVersion, PlotSwitch.getGeneratorName(), PlotSwitch.getGeneratorVersion(), PlotSwitch.getId(), PlotSwitch.getMCProcessTypeId(), PlotSwitch.getParameterName(), PlotSwitch.getParameterValueHigh(), PlotSwitch.getParameterValueLow(), PlotSwitch.parameterName, PlotSwitch.parameterValueHigh, PlotSwitch.parameterValueLow, and PlotSwitch.procId.

00156                                      {
00157 
00158     if (obj==null) { return false; }
00159 
00160     if ( !this.getClass().equals(obj.getClass())  ) { return false; }
00161 
00162     PlotSwitch ps = (PlotSwitch)obj;
00163     //System.out.println("Checking equality "+ps.getId()+" : "+id);
00164 
00165 
00166     if ( (ps.getId()>0) && id>0 ){
00167         return (id==ps.getId());
00168     } else {
00169 
00170         //System.out.println("here 1");
00171 
00172         if ( procId!=ps.getMCProcessTypeId() ) { return false; }
00173 
00174         //System.out.println("here 2");
00175 
00176         if (parameterName!=null) {
00177         if  (!parameterName.equals(ps.getParameterName())) {return false;}
00178         } else {
00179         if ( ps.getParameterName()!=null) { return false; }
00180         }
00181 
00182         //System.out.println("here 3");
00183 
00184         if (generatorName!=null) {      
00185             if ( !generatorName.equals(ps.getGeneratorName())) {return false;}
00186         } else {
00187         if ( ps.getGeneratorName()!=null ) { return false; }
00188         }
00189 
00190         //System.out.println("here 4");
00191 
00192         if (generatorVersion!=ps.getGeneratorVersion()) {return false; }
00193 
00194         boolean check = true;
00195         if ( parameterValueHigh!=ps.getParameterValueHigh() ) {
00196         // 1% accuracy check.
00197         check = check && ( Math.abs( parameterValueHigh-ps.getParameterValueHigh() )
00198                    / (Math.abs(ps.getParameterValueHigh())
00199                       +Math.abs(parameterValueHigh))
00200                    >0.01 ); 
00201         }
00202 
00203         if ( parameterValueLow!=ps.getParameterValueLow() ) {
00204         check = check && ( Math.abs( parameterValueLow-ps.getParameterValueLow() )
00205                    / (Math.abs(ps.getParameterValueLow())
00206                       +Math.abs(parameterValueLow))
00207                    >0.01 ); 
00208         }
00209 
00210         //System.out.println("here 5 "+check);
00211 
00212         return check;
00213     }
00214     }

Iterator<String> getAllowedParameters  )  [static]
 

Return an enumeration of all the parameter names which will be understood by the switching infrastructure.

Definition at line 220 of file PlotSwitch.java.

References PlotSwitch.allowedParameters.

00220                                                          {
00221 
00222     return allowedParameters.iterator();
00223 
00224     }

String getGeneratorName  ) 
 

Return the generator name for which this works

Definition at line 102 of file PlotSwitch.java.

Referenced by PlotSwitch.equals(), and RealPlot.getMCProcessType().

00102 { return generatorName; }

double getGeneratorVersion  ) 
 

Return the generator name for which this works

Definition at line 107 of file PlotSwitch.java.

Referenced by PlotSwitch.equals().

00107 { return generatorVersion; }

int getId  ) 
 

return the id of this switch

Implements Storeable.

Definition at line 79 of file PlotSwitch.java.

Referenced by PlotSwitch.equals(), DataPlot.getProcIdWanted(), ServletUtils.modifyPlots(), and HTMLPaperWriter.writePlotEntry().

00079 { return id; }

MCProcessType getMCProcessType  ) 
 

return processType

Definition at line 89 of file PlotSwitch.java.

References PlotSwitch.proc, and PlotSwitch.procId.

Referenced by RealPlot.getMCProcessType().

00089                                            {
00090 
00091     //System.out.println("PlotSwitch: procId = "+procId);
00092      
00093     if (proc==null){
00094         proc=new MCProcessType(procId);
00095     }
00096     return proc;
00097     }

int getMCProcessTypeId  ) 
 

return the id of processType

Definition at line 84 of file PlotSwitch.java.

Referenced by PlotSwitch.equals(), DataPlot.getProcIdWanted(), and ServletUtils.modifyPlots().

00084 { return procId; }

String getParameterName  ) 
 

Return the parmater name on which the switching is based

Definition at line 122 of file PlotSwitch.java.

Referenced by PlotSwitch.equals(), and RealPlot.getMCProcessType().

00122 { return parameterName; }

Double getParameterValueHigh  ) 
 

Return the parameter value at which switching occurs.

Definition at line 117 of file PlotSwitch.java.

Referenced by PlotSwitch.equals().

00117 { return parameterValueHigh; }

Double getParameterValueLow  ) 
 

Return the low parameter value at which switching occurs.

Definition at line 112 of file PlotSwitch.java.

Referenced by PlotSwitch.equals().

00112 { return parameterValueLow; }

int getPlotId  ) 
 

Definition at line 131 of file PlotSwitch.java.

00131                           {
00132     return plotId;
00133     }

int hashCode  ) 
 

Definition at line 250 of file PlotSwitch.java.

00250 { return 9999; }

synchronized void initializeParameterList  )  [static]
 

Initialize the list of allowed parameters for switching. Currently hardwired but maybe should be done from the properties files eventually?

Definition at line 243 of file PlotSwitch.java.

References PlotSwitch.allowedParameters.

00243                                                              {
00244 
00245     allowedParameters = new HashSet<String>();
00246     allowedParameters.add("pthat");
00247     allowedParameters.add("Q2");
00248     } 

boolean isAllowedParameter String  parameter  )  [static]
 

Return true if the input string matches one of the parameter names which is understood by the switching infrastructure.

Definition at line 230 of file PlotSwitch.java.

References PlotSwitch.allowedParameters.

00230                                                               {
00231 
00232     if (allowedParameters.contains(parameter)) { return true; }
00233     return false;
00234 
00235     }

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 47 of file PlotSwitch.java.

Referenced by PlotSwitch.PlotSwitch().

00047                                                      {
00048     try {
00049         DBPlotManager.selectPlotSwitch(this);       
00050     } catch (JetWebException jwe){
00051         throw jwe;
00052     }
00053     return true;
00054     }

void setGeneratorName String  gen  ) 
 

Definition at line 125 of file PlotSwitch.java.

References PlotSwitch.generatorName.

Referenced by ServletUtils.decodeSwitch().

00125                                             {
00126     generatorName = gen;
00127     }

void setGeneratorVersion double  vers  ) 
 

Definition at line 134 of file PlotSwitch.java.

References PlotSwitch.generatorVersion.

Referenced by ServletUtils.decodeSwitch().

00134                                                 {
00135     generatorVersion = vers;
00136     }

void setMCProcessTypeId int  id  ) 
 

Definition at line 146 of file PlotSwitch.java.

References PlotSwitch.procId.

Referenced by ServletUtils.addPlot(), and ServletUtils.decodeSwitch().

00146                                           {
00147     procId = id;
00148     }

void setParameterName String  pname  ) 
 

Definition at line 137 of file PlotSwitch.java.

References PlotSwitch.parameterName.

Referenced by ServletUtils.decodeSwitch().

00137                                               {
00138     parameterName = pname;
00139     }

void setParameterValueHigh double  val  ) 
 

Definition at line 140 of file PlotSwitch.java.

References PlotSwitch.parameterValueHigh.

Referenced by ServletUtils.decodeSwitch().

00140                                                  {
00141     parameterValueHigh = val;
00142     }

void setParameterValueLow double  val  ) 
 

Definition at line 143 of file PlotSwitch.java.

References PlotSwitch.parameterValueLow.

Referenced by ServletUtils.decodeSwitch().

00143                                                 {
00144     parameterValueLow = val;
00145     }

void setPlotId int  newId  ) 
 

Definition at line 128 of file PlotSwitch.java.

References PlotSwitch.plotId.

Referenced by ServletUtils.addPlot(), and ServletUtils.modifyPlots().

00128                                     {
00129     plotId = newId;
00130     }

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 56 of file PlotSwitch.java.

References PlotSwitch.plotId.

Referenced by ServletUtils.addPlot(), and DataPlot.storeSwitches().

00056                                                   {
00057 
00058     // If this switch has an Id, update it using this Id.
00059     if (id>0) {
00060         DBPlotManager.update(this);
00061         return false;
00062     }
00063 
00064     // If the switch currently has no id, must determine whether it is identical
00065     // to an existing switch. If it is, do nothing. If not, add it as a new switch.
00066 
00067     // Get the switches which are already in the DB.
00068     HashSet<PlotSwitch> slist = DBPlotManager.getSwitches(plotId);
00069     if (!slist.contains(this)){
00070         DBPlotManager.add(this);
00071         return true;
00072     }
00073     return false;
00074     }


Member Data Documentation

HashSet<String> allowedParameters [static, private]
 

Definition at line 30 of file PlotSwitch.java.

Referenced by PlotSwitch.getAllowedParameters(), PlotSwitch.initializeParameterList(), and PlotSwitch.isAllowedParameter().

String generatorName [private]
 

Definition at line 27 of file PlotSwitch.java.

Referenced by PlotSwitch.equals(), and PlotSwitch.setGeneratorName().

double generatorVersion = -1.0 [private]
 

Definition at line 28 of file PlotSwitch.java.

Referenced by PlotSwitch.equals(), and PlotSwitch.setGeneratorVersion().

int id [private]
 

Definition at line 20 of file PlotSwitch.java.

String parameterName [private]
 

Definition at line 24 of file PlotSwitch.java.

Referenced by PlotSwitch.equals(), and PlotSwitch.setParameterName().

Double parameterValueHigh = Double.POSITIVE_INFINITY [private]
 

Definition at line 26 of file PlotSwitch.java.

Referenced by PlotSwitch.equals(), and PlotSwitch.setParameterValueHigh().

Double parameterValueLow = Double.NEGATIVE_INFINITY [private]
 

Definition at line 25 of file PlotSwitch.java.

Referenced by PlotSwitch.equals(), and PlotSwitch.setParameterValueLow().

int plotId [private]
 

Definition at line 21 of file PlotSwitch.java.

Referenced by PlotSwitch.setPlotId(), and PlotSwitch.store().

MCProcessType proc [private]
 

Definition at line 22 of file PlotSwitch.java.

Referenced by PlotSwitch.defaultProc(), and PlotSwitch.getMCProcessType().

int procId [private]
 

Definition at line 23 of file PlotSwitch.java.

Referenced by PlotSwitch.equals(), PlotSwitch.getMCProcessType(), and PlotSwitch.setMCProcessTypeId().


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

Generated Wed Jan 17 09:14:27 GMT 2007