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 25 of file Data.java.
Data | ( | ) |
Constructor from a Paper.
Definition at line 37 of file Data.java.
References Data.addPaper().
00037 { 00038 addPaper(paper); 00039 }
Constructor from a collection of Papers.
Definition at line 42 of file Data.java.
References Data.setPapers().
00042 { 00043 setPapers(papers); 00044 }
List<Paper> getPapers | ( | ) |
Get contained papers.
Definition at line 51 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 62 of file Data.java.
References Data.getPapers().
Referenced by Data.Data().
00062 { 00063 getPapers().clear(); 00064 for (Paper p : papers) { 00065 getPapers().add(p); 00066 } 00067 return this; 00068 }
Add a paper.
Definition at line 70 of file Data.java.
References Data.getPapers().
Referenced by Data.Data(), and Data.makeExample().
00070 { 00071 getPapers().add(paper); 00072 return this; 00073 }
Remove a paper.
Definition at line 75 of file Data.java.
References Data.getPapers().
00075 { 00076 getPapers().remove(paper); 00077 return this; 00078 }
Date getTimestamp | ( | ) |
Data setTimestamp | ( | Date | timestamp | ) |
String toString | ( | ) |
Get a recursive string representation of this data tree.
Reimplemented from Storeable.
Definition at line 96 of file Data.java.
References Data.getPapers().
00096 { 00097 StringBuffer s = new StringBuffer(); 00098 for (Paper p : getPapers()) { 00099 s.append(p.toString()); 00100 } 00101 return s.toString(); 00102 }
static Data makeExample | ( | ) | [static] |
Make a data tree for demo purposes.
Definition at line 109 of file Data.java.
References Paper.addDataset(), Data.addPaper(), Dataset.addXAxis(), Dataset.addYAxis(), Data.Data(), and Storeable.log().
00109 { 00110 // Have to get a different logger from the inherited one, 00111 // since this is a static method 00112 Logger log = Logger.getLogger(Data.class); 00113 00114 log.debug("Making data structure..."); 00115 Experiment ex = Data.makeExampleExperiment(); 00116 Paper p = Data.makeExamplePaper(); 00117 Dataset d = Data.makeExampleDataset(); 00118 p.addDataset(d); 00119 for (XAxis x : Data.makeExampleXAxes()) d.addXAxis(x); 00120 for (YAxis y : Data.makeExampleYAxes()) d.addYAxis(y); 00121 00122 log.debug("Making data container..."); 00123 Data data = new Data(); 00124 data.addPaper(p); 00125 00126 return data; 00127 }
static Experiment makeExampleExperiment | ( | ) | [static] |
Make an experiment object for demo purposes.
Definition at line 130 of file Data.java.
References Storeable.log(), and Experiment.setComment().
00130 { 00131 Logger log = Logger.getLogger(Data.class); 00132 log.info("Making experiments"); 00133 Experiment ex = new Experiment("CDF1").setInformalName("CDF"); 00134 ex.setComment("CDF r00ls, D0 sux!"); 00135 return ex; 00136 }
static Paper makeExamplePaper | ( | ) | [static] |
Make a paper object for demo purposes.
Definition at line 139 of file Data.java.
References Paper.addAuthor(), and Storeable.log().
00139 { 00140 Logger log = Logger.getLogger(Data.class); 00141 log.info("Making paper"); 00142 Paper p = new Paper("My paper", 54635774); 00143 p.addAuthor("Andy"); 00144 log.debug("Making reference"); 00145 Reference ref = new Reference(RefType.ARXIV, "hep-ph/foobar"); 00146 return p; 00147 }
static Dataset makeExampleDataset | ( | ) | [static] |
Make a dataset object for demo purposes.
Definition at line 150 of file Data.java.
References Dataset.addComment(), and Storeable.log().
00150 { 00151 Logger log = Logger.getLogger(Data.class); 00152 log.info("Making dataset"); 00153 Dataset d = new Dataset(); 00154 d.addComment("My dataset of physics stuff"); 00155 return d; 00156 }
static Collection<XAxis> makeExampleXAxes | ( | ) | [static] |
Make a set of x-axis objects for demo purposes.
Definition at line 159 of file Data.java.
References Storeable.log(), and XAxis.setBins().
00159 { 00160 Logger log = Logger.getLogger(Data.class); 00161 log.info("Making x-axes"); 00162 00163 log.debug("Making unit for x-axis"); 00164 Unit ux1 = Unit.makeGeV(); 00165 log.debug("Making x-axis"); 00166 XAxis x1 = new XAxis("X1", ux1).setId(1); 00167 00168 log.info("Adding bins to x-axis"); 00169 double bincentres[] = { 0.0, 0.2, 0.4, 0.6, 0.8 }; 00170 x1.setBins(bincentres); 00171 00172 List<XAxis> xAxes = new Vector<XAxis>(); 00173 xAxes.add(x1); 00174 return xAxes; 00175 }
static Collection<YAxis> makeExampleYAxes | ( | ) | [static] |
Make a set of y-axis objects for demo purposes.
Definition at line 178 of file Data.java.
References YAxis.addError(), YAxis.getPoints(), Storeable.log(), and YAxis.setPoints().
00178 { 00179 Logger log = Logger.getLogger(Data.class); 00180 log.info("Making y-axes"); 00181 00182 log.debug("Making units for y-axes"); 00183 Unit uy1a = new Unit(new UnitTerm(BaseUnit.BARN, SiPrefix.NANO, -1)); 00184 Unit uy1b = new Unit(new UnitTerm(BaseUnit.RADIAN, SiPrefix.MILLI, 1)); 00185 log.debug("Making y-axis 2"); 00186 YAxis y1a = new YAxis("Y1a", "RandomObs2", uy1a).setId(2); 00187 log.debug("Making y-axis 1"); 00188 YAxis y1b = new YAxis("Y1b", "RandomObs1", uy1b).setId(1); 00189 00190 log.info("Adding points to the y-axes"); 00191 log.debug("Adding points to y-axis 1"); 00192 double pointvals1[] = { 1.0, 2.0, 4.0, 2.0, 1.0 }; 00193 y1a.setPoints(pointvals1); 00194 log.debug("Adding points to y-axis 2"); 00195 double pointvals2[] = { 1.0, 2.0, 3.0, 4.0, 5.0 }; 00196 y1b.setPoints(pointvals2); 00197 00198 y1a.addError(new AxisError(Math.random(), ErrorSource.SYS, ErrorNorm.FRAC)); 00199 y1b.addError(new AxisError(100 * Math.random(), ErrorSource.UNKNOWN, ErrorNorm.PCT)); 00200 00201 for (Point p : y1a.getPoints()) { 00202 PointError pe = new PointError(p, Math.random(), ErrorSource.STAT, ErrorNorm.FRAC); 00203 } 00204 for (Point p : y1b.getPoints()) { 00205 PointError pe = new PointError(p, 100 * Math.random(), 100 * Math.random(), ErrorSource.STAT, ErrorNorm.PCT); 00206 } 00207 00208 List<YAxis> yAxes = new Vector<YAxis>(); 00209 yAxes.add(y1a); 00210 yAxes.add(y1b); 00211 return yAxes; 00212 }
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(), AxisError.setAxis(), DatasetError.setDataset(), DatasetError.setNormType(), PointError.setPoint(), and Uncertainty.toString().