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

Particle.java

Go to the documentation of this file.
00001 package cedar.jetweb.model;
00002 
00003 import java.util.Vector;
00004 import java.util.Enumeration;
00005 
00006 import cedar.jetweb.*;
00007 import cedar.jetweb.util.Match;
00008 import cedar.jetweb.db.DBManager;
00009 
00017 public class Particle  {
00018 
00019     private double energy;
00020     private String name;
00021     private int hashCode_;
00022     private boolean dirtyHashCode_;
00023 
00028     public static String PROTON = "p";
00033     public static String ANTIPROTON = "pbar";
00038     public static String POSITRON = "e+";
00043     public static String ELECTRON = "e-";
00048     public static String PHOTON = "gamma";
00049 
00050 
00054     public Particle() {}
00058     public Particle(String desc,double E) {
00059     name=desc;
00060     energy=E;
00061     dirtyHashCode_=true;
00062     }
00063 
00064     public double getEnergy(){
00065     return energy;
00066     }
00067  
00068     public void setEnergy(double e){
00069     dirtyHashCode_=true;
00070     energy=e;
00071     }
00072     public String getName(){ return name; }
00073 
00074 
00075     public String toString(){
00076     return energy+" GeV "+name;
00077     }
00078 
00082     public void setName(String p){
00083     dirtyHashCode_=true;
00084     name = p;
00085     }
00090     public boolean equals(Object obj){
00091 
00092     if (obj==null) { return false; }
00093 
00094     if ( !this.getClass().equals(obj.getClass())  ) { return false; }
00095 
00096     Particle c = (Particle)obj;
00097     return (name.equals(c.getName()) && 
00098             Match.compareDouble(energy,c.getEnergy()));         
00099     }
00100 
00101     public int hashCode(){ 
00102     if (dirtyHashCode_){
00103         hashCode_ = (new Double(energy)).hashCode()+name.hashCode();
00104         dirtyHashCode_=false;
00105     }
00106     return hashCode_; 
00107     }
00108  
00109 
00110 }
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 

Generated Wed Jan 17 09:14:27 GMT 2007