Public Member Functions | |
Data () | |
Default constructor. | |
Data (Paper paper) | |
Constructor from a Paper. | |
Data (Collection< Paper > papers) | |
Constructor from a collection of Papers. | |
List< Paper > | getPapers () |
Get contained papers. | |
Paper | getFirstPaper () |
Convenience method to return first paper or null, since most Data objects will only contain one paper. | |
Data | setPapers (Collection< Paper > papers) |
Set contained papers. | |
Data | addPaper (Paper paper) |
Add a paper. | |
Data | removePaper (Paper paper) |
Remove a paper. | |
Date | getTimestamp () |
Get the timestamp. | |
Data | setTimestamp (Date timestamp) |
Set the timestamp. | |
String | toString () |
Get a recursive string representation of this data tree. | |
Static Public Member Functions | |
static Data | makeExample () |
Make a data tree for demo purposes. | |
static Experiment | makeExampleExperiment () |
Make an experiment object for demo purposes. | |
static Paper | makeExamplePaper () |
Make a paper object for demo purposes. | |
static Dataset | makeExampleDataset () |
Make a dataset object for demo purposes. | |
static Collection < XAxis > | makeExampleXAxes () |
Make a set of x-axis objects for demo purposes. | |
static Collection < YAxis > | makeExampleYAxes () |
Make a set of y-axis objects for demo purposes. | |
Package Functions | |
Logger | log () |
Neat method to allow every class to get hold of a custom-named Logger. |
The name (which I'll admit isn't particularly intuitive - sorry) comes from the tag hierarchy in HepML: hepml/data/paper/etc. It makes sense when you consider that this class was primarily created for automated mapping to XML (the same applies to the HepML class, but it's located in the HepData XML package and the name is more obvious).
Definition at line 24 of file Data.java.
Data | ( | ) |
Constructor from a Paper.
Definition at line 36 of file Data.java.
References Data.addPaper().
00036 { 00037 addPaper(paper); 00038 }
Constructor from a collection of Papers.
Definition at line 41 of file Data.java.
References Data.setPapers().
00041 { 00042 setPapers(papers); 00043 }
List<Paper> getPapers | ( | ) |
Get contained papers.
Definition at line 50 of file Data.java.
Referenced by Data.addPaper(), Data.getFirstPaper(), Data.removePaper(), Data.setPapers(), and Data.toString().
Paper getFirstPaper | ( | ) |
Set contained papers.
Definition at line 61 of file Data.java.
References Data.getPapers().
Referenced by Data.Data().
00061 { 00062 getPapers().clear(); 00063 for (Paper p : papers) { 00064 getPapers().add(p); 00065 } 00066 return this; 00067 }
Add a paper.
Definition at line 69 of file Data.java.
References Data.getPapers().
Referenced by Data.Data(), and Data.makeExample().
00069 { 00070 getPapers().add(paper); 00071 return this; 00072 }
Remove a paper.
Definition at line 74 of file Data.java.
References Data.getPapers().
00074 { 00075 getPapers().remove(paper); 00076 return this; 00077 }
Date getTimestamp | ( | ) |
Data setTimestamp | ( | Date | timestamp | ) |
String toString | ( | ) |
Get a recursive string representation of this data tree.
Reimplemented from Storeable.
Definition at line 95 of file Data.java.
References Data.getPapers().
00095 { 00096 StringBuffer s = new StringBuffer(); 00097 for (Paper p : getPapers()) { 00098 s.append(p.toString()); 00099 } 00100 return s.toString(); 00101 }
static Data makeExample | ( | ) | [static] |
Make a data tree for demo purposes.
Definition at line 108 of file Data.java.
References Paper.addDataset(), Data.addPaper(), Dataset.addXAxis(), Dataset.addYAxis(), Data.Data(), and Storeable.log().
00108 { 00109 // Have to get a different logger from the inherited one, 00110 // since this is a static method 00111 Logger log = Logger.getLogger(Data.class); 00112 00113 log.debug("Making data structure..."); 00114 Experiment ex = Data.makeExampleExperiment(); 00115 Paper p = Data.makeExamplePaper(); 00116 Dataset d = Data.makeExampleDataset(); 00117 p.addDataset(d); 00118 for (XAxis x : Data.makeExampleXAxes()) d.addXAxis(x); 00119 for (YAxis y : Data.makeExampleYAxes()) d.addYAxis(y); 00120 00121 log.debug("Making data container..."); 00122 Data data = new Data(); 00123 data.addPaper(p); 00124 00125 return data; 00126 }
static Experiment makeExampleExperiment | ( | ) | [static] |
Make an experiment object for demo purposes.
Definition at line 129 of file Data.java.
References Storeable.log(), and Experiment.setComment().
00129 { 00130 Logger log = Logger.getLogger(Data.class); 00131 log.info("Making experiments"); 00132 Experiment ex = new Experiment("CDF1").setInformalName("CDF"); 00133 ex.setComment("CDF r00ls, D0 sux!"); 00134 return ex; 00135 }
static Paper makeExamplePaper | ( | ) | [static] |
Make a paper object for demo purposes.
Definition at line 138 of file Data.java.
References Paper.addAuthor(), and Storeable.log().
00138 { 00139 Logger log = Logger.getLogger(Data.class); 00140 log.info("Making paper"); 00141 Paper p = new Paper("My paper", 54635774); 00142 p.addAuthor("Andy"); 00143 log.debug("Making reference"); 00144 Reference ref = new Reference(RefType.ARXIV, "hep-ph/foobar"); 00145 return p; 00146 }
static Dataset makeExampleDataset | ( | ) | [static] |
Make a dataset object for demo purposes.
Definition at line 149 of file Data.java.
References Dataset.addComment(), and Storeable.log().
00149 { 00150 Logger log = Logger.getLogger(Data.class); 00151 log.info("Making dataset"); 00152 Dataset d = new Dataset(); 00153 d.addComment("My dataset of physics stuff"); 00154 return d; 00155 }
static Collection<XAxis> makeExampleXAxes | ( | ) | [static] |
Make a set of x-axis objects for demo purposes.
Definition at line 158 of file Data.java.
References XAxis.addBin(), and Storeable.log().
00158 { 00159 Logger log = Logger.getLogger(Data.class); 00160 log.info("Making x-axes"); 00161 00162 log.debug("Making unit for x-axis"); 00163 Unit ux1 = Unit.makeGeV(); 00164 log.debug("Making x-axis"); 00165 XAxis x1 = new XAxis("X1", ux1).setId(1); 00166 00167 log.info("Adding bins to x-axis"); 00168 x1.addBin(new Bin(0.0)); 00169 x1.addBin(new Bin(0.2)); 00170 x1.addBin(new Bin(0.4)); 00171 x1.addBin(new Bin(0.6)); 00172 x1.addBin(new Bin(0.8)); 00173 00174 List<XAxis> xAxes = new Vector<XAxis>(); 00175 xAxes.add(x1); 00176 return xAxes; 00177 }
static Collection<YAxis> makeExampleYAxes | ( | ) | [static] |
Make a set of y-axis objects for demo purposes.
Definition at line 180 of file Data.java.
References YAxis.addError(), YAxis.addPoint(), YAxis.getPoints(), and Storeable.log().
00180 { 00181 Logger log = Logger.getLogger(Data.class); 00182 log.info("Making y-axes"); 00183 00184 log.debug("Making units for y-axes"); 00185 Unit uy1a = new Unit(new UnitTerm(BaseUnit.BARN, SiPrefix.NANO, -1)); 00186 Unit uy1b = new Unit(new UnitTerm(BaseUnit.RADIAN, SiPrefix.MILLI, 1)); 00187 log.debug("Making observables for y-axes"); 00188 Observable o1a = new Observable("Random 1", uy1a.canonicalUnit()); 00189 Observable o1b = new Observable("Random 2", uy1b); 00190 log.debug("Making y-axis 1"); 00191 YAxis y1a = new YAxis(o1a, "Y1a", uy1a).setId(2); 00192 log.debug("Making y-axis 2"); 00193 YAxis y1b = new YAxis(o1b, "Y1b", uy1b).setId(1); 00194 00195 log.info("Adding points to the y-axes"); 00196 log.debug("Adding points to y-axis 1"); 00197 y1a.addPoint(new Point(1.0)); 00198 y1a.addPoint(new Point(2.0)); 00199 y1a.addPoint(new Point(4.0)); 00200 y1a.addPoint(new Point(2.0)); 00201 y1a.addPoint(new Point(1.0)); 00202 log.debug("Adding points to y-axis 2"); 00203 y1b.addPoint(new Point(1.0)); 00204 y1b.addPoint(new Point(2.0)); 00205 y1b.addPoint(new Point(3.0)); 00206 y1b.addPoint(new Point(4.0)); 00207 y1b.addPoint(new Point(5.0)); 00208 00209 y1a.addError(new AxisError(Math.random(), ErrorSource.SYS, ErrorNorm.FRAC)); 00210 y1b.addError(new AxisError(100 * Math.random(), ErrorSource.UNKNOWN, ErrorNorm.PCT)); 00211 00212 for (Point p : y1a.getPoints()) { 00213 PointError pe = new PointError(p, Math.random(), ErrorSource.STAT, ErrorNorm.FRAC); 00214 } 00215 for (Point p : y1b.getPoints()) { 00216 PointError pe = new PointError(p, 100 * Math.random(), 100 * Math.random(), ErrorSource.STAT, ErrorNorm.PCT); 00217 } 00218 00219 List<YAxis> yAxes = new Vector<YAxis>(); 00220 yAxes.add(y1a); 00221 yAxes.add(y1b); 00222 return yAxes; 00223 }
Logger log | ( | ) | [package, inherited] |
Neat method to allow every class to get hold of a custom-named Logger.
Definition at line 14 of file Storeable.java.
Referenced by Uncertainty.compareTo(), Reference.compareTo(), PointError.compareTo(), Modification.compareTo(), Experiment.compareTo(), DatasetError.compareTo(), AxisError.compareTo(), Data.makeExample(), Data.makeExampleDataset(), Data.makeExampleExperiment(), Data.makeExamplePaper(), Data.makeExampleXAxes(), Data.makeExampleYAxes(), DatasetError.setNormType(), and Uncertainty.toString().