Dataset Class Reference

A single result set within a Paper Contains header information and a collection of Axis objects. More...

Inheritance diagram for Dataset:

Inheritance graph
[legend]

Collaboration diagram for Dataset:

Collaboration graph
[legend]

List of all members.


Public Member Functions

 Dataset ()
 Default constructor.
 Dataset (Paper paper)
 Constructor with containing paper as an argument.
Integer getId ()
 Get local dataset ID.
Dataset setId (Integer datasetId)
 Set local dataset ID.
Paper getPaper ()
 Get parent paper.
Dataset setPaper (Paper paper)
 Set parent paper.
List< String > getComments ()
 Get comments.
Dataset setComments (List< String > comments)
 Set comments.
Dataset addComment (String comment)
 Add a comment.
Dataset removeComment (String comment)
 Delete a comment.
Set< DatasetPropertygetProperties ()
 Get dataset properties.
Dataset setProperties (Set< DatasetProperty > properties)
 Set dataset properties.
Dataset addProperty (DatasetProperty property)
 Add a dataset property.
Dataset removeProperty (DatasetProperty property)
 Delete a dataset property.
SortedSet< DatasetErrorgetErrors ()
 Get dataset errors.
Dataset setErrors (SortedSet< DatasetError > datasetErrors)
 Set dataset errors.
Dataset setErrors (Collection< DatasetError > datasetErrors)
 Set dataset errors.
Dataset setErrors (DatasetError[] datasetErrors)
 Set dataset errors.
Dataset addError (DatasetError datasetError)
 Add a dataset error.
Dataset removeError (DatasetError datasetError)
 Remove a dataset error.
SortedSet< XAxisgetXAxes ()
 Get constituent x-axes.
XAxis getXAxis (Integer xAxisId)
 Set constituent x-axes.
Dataset setXAxes (SortedSet< XAxis > xAxes)
 Set constituent x-axes.
Dataset setXAxes (Collection< XAxis > xAxes)
 Set constituent x-axes.
Dataset setXAxes (XAxis[] xAxes)
 Set constituent x-axes.
Dataset addXAxis (XAxis xAxis)
 Add an x-axis.
Dataset removeXAxis (XAxis xAxis)
 Remove a constituent x-axis.
SortedSet< YAxisgetYAxes ()
 Get constituent y-axes.
YAxis getYAxis (Integer yAxisId)
 Set constituent y-axes.
Dataset setYAxes (SortedSet< YAxis > yAxes)
 Set constituent y-axes.
Dataset setYAxes (Collection< YAxis > yAxes)
 Set constituent y-axes.
Dataset setYAxes (YAxis[] yAxes)
 Set constituent y-axes.
Dataset addYAxis (YAxis yAxis)
 Add a y-axis.
Dataset removeYAxis (YAxis yAxis)
 Remove a constituent y-axis.
SortedSet< BingetBins (Integer binId)
 Get the set of bins in this dataset with bin ID = binId.
SortedSet< PointgetPoints (Integer pointId)
 Get the set of points in this dataset with point ID = pointId.
int compareTo (Dataset other)
 Compare datasets.
String toString ()
 String representation.
String toString (Integer indentBy)
 String representation with indent.

Package Functions

.hibernate.annotations. Cascade (value={org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN}) private Set< DatasetProperty > _properties
 Searchable dataset properties.
.hibernate.annotations.CollectionOfElements.hibernate.annotations. CollectionId (columns=@Column(name="DatasetErrorId"), type=@org.hibernate.annotations.Type(type="long"), generator="sequence")@org.hibernate.annotations.Sort(type
 Sorted set of dataset-level errors.
.hibernate.annotations.CollectionOfElements.hibernate.annotations. IndexColumn (name="Posn")@Column(name
 Comments.
.hibernate.annotations. Fetch (value=org.hibernate.annotations.FetchMode.SUBSELECT)@org.hibernate.annotations.Cascade(value
 Contained x-axes.
.hibernate.annotations. Fetch (value=org.hibernate.annotations.FetchMode.SUBSELECT)@org.hibernate.annotations.Cascade(value
 Contained y-axes.
Logger log ()
 Neat method to allow every class to get hold of a custom-named Logger.

Package Attributes

.hibernate.annotations.CollectionOfElements.hibernate.annotations. length

Detailed Description

A single result set within a Paper Contains header information and a collection of Axis objects.

Author:
Andy Buckley
Version:
Date
Revision

Definition at line 18 of file Dataset.java.


Constructor & Destructor Documentation

Dataset (  ) 

Default constructor.

Definition at line 77 of file Dataset.java.

00077 { }

Dataset ( Paper  paper  ) 

Constructor with containing paper as an argument.

Definition at line 81 of file Dataset.java.

00081                                 {
00082         this();
00083         setPaper(paper);
00084     }


Member Function Documentation

.hibernate.annotations. Cascade (  )  [package]

Searchable dataset properties.

.hibernate.annotations.CollectionOfElements.hibernate.annotations. CollectionId ( columns  = @Column(name="DatasetErrorId"),
type  = @org.hibernate.annotations.Type(type="long"),
generator  = "sequence" 
) [package]

Sorted set of dataset-level errors.

.hibernate.annotations.CollectionOfElements.hibernate.annotations. IndexColumn ( name  = "Posn"  )  [package]

Comments.

.hibernate.annotations. Fetch ( value  = org.hibernate.annotations.FetchMode.SUBSELECT  )  [package]

Contained x-axes.

.hibernate.annotations. Fetch ( value  = org.hibernate.annotations.FetchMode.SUBSELECT  )  [package]

Contained y-axes.

Integer getId (  ) 

Get local dataset ID.

Definition at line 92 of file Dataset.java.

Referenced by Paper.addDataset(), and Dataset.compareTo().

00092                            {
00093         return _localId;
00094     }

Dataset setId ( Integer  datasetId  ) 

Set local dataset ID.

Definition at line 97 of file Dataset.java.

Referenced by Paper.addDataset().

00097                                             {
00098         _localId = datasetId;
00099         return this;
00100     }

Paper getPaper (  ) 

Get parent paper.

Definition at line 105 of file Dataset.java.

00105                             {
00106         return _paper;
00107     }

Dataset setPaper ( Paper  paper  ) 

Set parent paper.

Definition at line 110 of file Dataset.java.

References Paper.getDatasets().

Referenced by Paper.addDataset(), and Paper.removeDataset().

00110                                          {
00111         if (paper != null) {
00112             if (getId() == null) {
00113                 int highestId = 0;
00114                 if (paper.getDatasets().size() > 0) {
00115                     highestId = paper.getDatasets().last().getId();
00116                 }
00117                 log().debug("Incrementing dataset ID: " + (highestId + 1));
00118                 setId(highestId + 1);
00119             }
00120             paper.getDatasets().add(this);
00121             _paper = paper;
00122         } else {
00123             log().warn("Tried to attach myself to a null Paper");
00124         }
00125         return this;
00126     }

List<String> getComments (  ) 

Get comments.

Definition at line 131 of file Dataset.java.

00131                                       {
00132         return _comments;
00133     }

Dataset setComments ( List< String >  comments  ) 

Set comments.

Todo:
Bidirectional?

Definition at line 135 of file Dataset.java.

00135                                                       {
00137         _comments = comments;
00138         return this;
00139     }

Dataset addComment ( String  comment  ) 

Add a comment.

Definition at line 141 of file Dataset.java.

Referenced by Data.makeExampleDataset().

00141                                               {
00142         _comments.add(comment);
00143         return this;
00144     }

Dataset removeComment ( String  comment  ) 

Delete a comment.

Definition at line 146 of file Dataset.java.

00146                                                  {
00147         _comments.remove(comment);
00148         return this;
00149     }

Set<DatasetProperty> getProperties (  ) 

Get dataset properties.

Definition at line 154 of file Dataset.java.

00154                                                 {
00155         return _properties;
00156     }

Dataset setProperties ( Set< DatasetProperty properties  ) 

Set dataset properties.

Todo:
Bidirectional?

Definition at line 159 of file Dataset.java.

00159                                                                   {
00161         _properties = properties;
00162         return this;
00163     }

Dataset addProperty ( DatasetProperty  property  ) 

Add a dataset property.

Definition at line 166 of file Dataset.java.

00166                                                          {
00167         if (property != null) {
00168             property.setDataset(this);
00169             _properties.add(property);
00170         } else {
00171             log().warn("Tried to add a null DatasetProperty to a Dataset");
00172         }
00173         return this;
00174     }

Dataset removeProperty ( DatasetProperty  property  ) 

Delete a dataset property.

Definition at line 177 of file Dataset.java.

00177                                                             {
00178         if (property != null) {
00179             _properties.remove(property);
00180             property.setDataset(null);
00181         } else {
00182             log().warn("Tried to remove a null DatasetProperty from a Dataset");
00183         }
00184         return this;
00185     }

SortedSet<DatasetError> getErrors (  ) 

Get dataset errors.

Definition at line 190 of file Dataset.java.

00190                                                {
00191         return _errors;
00192     }

Dataset setErrors ( SortedSet< DatasetError datasetErrors  ) 

Set dataset errors.

Definition at line 195 of file Dataset.java.

00195                                                                     {
00196         getErrors().clear();
00197         for (DatasetError e : datasetErrors) addError(e);
00198         return this;
00199     }

Dataset setErrors ( Collection< DatasetError datasetErrors  ) 

Set dataset errors.

Definition at line 202 of file Dataset.java.

00202                                                                      {
00203         getErrors().clear();
00204         for (DatasetError e : datasetErrors) addError(e);
00205         return this;
00206     }

Dataset setErrors ( DatasetError[]  datasetErrors  ) 

Set dataset errors.

Definition at line 209 of file Dataset.java.

00209                                                            {
00210         setErrors(Arrays.asList(datasetErrors));
00211         return this;
00212     }

Dataset addError ( DatasetError  datasetError  ) 

Add a dataset error.

Definition at line 215 of file Dataset.java.

References DatasetError.getId(), and DatasetError.setId().

Referenced by DatasetError.DatasetError().

00215                                                        {
00216         if (datasetError != null) {
00217             getErrors().add(datasetError);
00218             // Auto-increment the local ID if necessary
00219             if (datasetError.getId() == null) {
00220                 if (getErrors().last() != null && getErrors().last().getId() != null) {
00221                     datasetError.setId(getErrors().last().getId() + 1);
00222                 } else {
00223                     datasetError.setId(getErrors().size() + 1);
00224                 }
00225             }
00226         } else {
00227             log().warn("Tried to add a null DatasetError to a Dataset");
00228         }
00229         return this;
00230     }

Dataset removeError ( DatasetError  datasetError  ) 

Remove a dataset error.

Definition at line 233 of file Dataset.java.

00233                                                           {
00234         if (datasetError != null) {
00235             getErrors().remove(datasetError);
00236         } else {
00237             log().warn("Tried to remove a null DatasetError from a Dataset");
00238         }
00239         return this;
00240     }

SortedSet<XAxis> getXAxes (  ) 

Get constituent x-axes.

Definition at line 245 of file Dataset.java.

Referenced by XAxis.setDataset().

00245                                        {
00246         return _xAxes;
00247     }

XAxis getXAxis ( Integer  xAxisId  ) 

Set constituent x-axes.

Definition at line 250 of file Dataset.java.

00250                                            {
00251         XAxis theXAxis = null;
00252         for (XAxis x : getXAxes()) {
00253             if (x.getId().equals(xAxisId)) {
00254                 theXAxis = x;
00255                 break;
00256             }
00257         }
00258         return theXAxis;
00259     }

Dataset setXAxes ( SortedSet< XAxis xAxes  ) 

Set constituent x-axes.

Todo:
Bidirectional?

Definition at line 262 of file Dataset.java.

00262                                                     {
00264         _xAxes = xAxes;
00265         return this;
00266     }

Dataset setXAxes ( Collection< XAxis xAxes  ) 

Set constituent x-axes.

Definition at line 269 of file Dataset.java.

00269                                                      {
00270         _xAxes.clear();
00271         for (XAxis x : xAxes) addXAxis(x);
00272         return this;
00273     }

Dataset setXAxes ( XAxis[]  xAxes  ) 

Set constituent x-axes.

Definition at line 276 of file Dataset.java.

00276                                            {
00277         setXAxes(Arrays.asList(xAxes));
00278         return this;
00279     }

Dataset addXAxis ( XAxis  xAxis  ) 

Add an x-axis.

Definition at line 282 of file Dataset.java.

References XAxis.getId(), XAxis.setDataset(), and XAxis.setId().

Referenced by Data.makeExample().

00282                                          {
00283         if (xAxis != null) {
00284             if (xAxis.getId() == null) {
00285                 int highestId = 0;
00286                 if (getXAxes().size() > 0) {
00287                     highestId = getXAxes().last().getId();
00288                 }
00289                 log().debug("Incrementing x-axis ID: " + (highestId + 1));
00290                 xAxis.setId(highestId + 1);
00291             }
00292             log().debug("Adding x-axis: ID = " + xAxis.getId());
00293             _xAxes.add(xAxis);
00294             xAxis.setDataset(this);
00295         } else {
00296             log().warn("Tried to add a null XAxis to a Dataset");
00297         }
00298         return this;
00299     }

Dataset removeXAxis ( XAxis  xAxis  ) 

Remove a constituent x-axis.

Todo:
Data orphaning: cascade should handle it. CHECK

Definition at line 302 of file Dataset.java.

References XAxis.setDataset().

00302                                             {
00303         if (xAxis != null) {
00304             xAxis.setDataset(null); 
00305             _xAxes.remove(xAxis);
00306         } else {
00307             log().warn("Tried to remove a null XAxis from a Dataset");
00308         }
00309         return this;
00310     }

SortedSet<YAxis> getYAxes (  ) 

Get constituent y-axes.

Definition at line 316 of file Dataset.java.

Referenced by YAxis.setDataset().

00316                                        {
00317         return _yAxes;
00318     }

YAxis getYAxis ( Integer  yAxisId  ) 

Set constituent y-axes.

Definition at line 321 of file Dataset.java.

00321                                            {
00322         YAxis theYAxis = null;
00323         for (YAxis y : getYAxes()) {
00324             if (y.getId().equals(yAxisId)) {
00325                 theYAxis = y;
00326                 break;
00327             }
00328         }
00329         return theYAxis;
00330     }

Dataset setYAxes ( SortedSet< YAxis yAxes  ) 

Set constituent y-axes.

Definition at line 333 of file Dataset.java.

00333                                                     {
00334         getYAxes().clear();
00335         for (YAxis y : yAxes) addYAxis(y);
00336         return this;
00337     }

Dataset setYAxes ( Collection< YAxis yAxes  ) 

Set constituent y-axes.

Definition at line 340 of file Dataset.java.

00340                                                      {
00341         getYAxes().clear();
00342         for (YAxis y : yAxes) addYAxis(y);
00343         return this;
00344     }

Dataset setYAxes ( YAxis[]  yAxes  ) 

Set constituent y-axes.

Definition at line 347 of file Dataset.java.

00347                                            {
00348         setYAxes(Arrays.asList(yAxes));
00349         return this;
00350     }

Dataset addYAxis ( YAxis  yAxis  ) 

Add a y-axis.

Definition at line 353 of file Dataset.java.

References YAxis.getId(), YAxis.setDataset(), and YAxis.setId().

Referenced by Data.makeExample().

00353                                          {
00354         if (yAxis != null) {
00355             if (yAxis.getId() == null) {
00356                 int highestId = 0;
00357                 if (getYAxes().size() > 0) {
00358                     highestId = getYAxes().last().getId();
00359                 }
00360                 log().debug("Incrementing y-axis ID: " + (highestId + 1));
00361                 yAxis.setId(highestId + 1);
00362             }
00363             log().debug("Adding y-axis to dataset " + getId() + ": ID = " + yAxis.getId());
00364             _yAxes.add(yAxis);
00365             yAxis.setDataset(this);
00366         } else {
00367             log().warn("Tried to add a null YAxis to a Dataset");
00368         }
00369         return this;
00370     }

Dataset removeYAxis ( YAxis  yAxis  ) 

Remove a constituent y-axis.

Todo:
Data orphaning: cascade should handle it. CHECK

Definition at line 373 of file Dataset.java.

References YAxis.setDataset().

00373                                             {
00374         if (yAxis != null) {
00375             yAxis.setDataset(null); 
00376             _yAxes.add(yAxis);
00377         } else {
00378             log().warn("Tried to remove a null XAxis from a Dataset");
00379         }
00380         return this;
00381     }

SortedSet<Bin> getBins ( Integer  binId  ) 

Get the set of bins in this dataset with bin ID = binId.

The bins set will be sorted in order of the IDs of the containing x-axes.

Definition at line 391 of file Dataset.java.

Referenced by Point.getBins(), and Bin.getBins().

00391                                                  {
00392         SortedSet<Bin> matchingBins = new TreeSet<Bin>();
00393         for (XAxis x : getXAxes()) {
00394             Bin mybin = x.getBin(binId);
00395             if (mybin != null) {
00396                 matchingBins.add(mybin);
00397             }
00398         }
00399         return matchingBins;
00400     }

SortedSet<Point> getPoints ( Integer  pointId  ) 

Get the set of points in this dataset with point ID = pointId.

The points set will be sorted in order of the IDs of the containing y-axes.

Definition at line 404 of file Dataset.java.

References YAxis.getPoint().

Referenced by Point.getPoints(), and Bin.getPoints().

00404                                                        {
00405         SortedSet<Point> matchingPoints = new TreeSet<Point>();
00406         for (YAxis y : getYAxes()) {
00407             Point mypoint = y.getPoint(pointId);
00408             if (mypoint != null) {
00409                 matchingPoints.add(mypoint);
00410             }
00411         }
00412         return matchingPoints;
00413     }

int compareTo ( Dataset  other  ) 

Compare datasets.

Definition at line 422 of file Dataset.java.

References Dataset.getId().

00422                                         {
00423         log().debug("Comparing datasets...");
00424         if (getId() == null) {
00425             log().warn("Null dataset ID");
00426             return 1; // Sort null datasets at the end
00427         } else if (getId() > other.getId()) {
00428             log().debug("Greater than");
00429             return 1;
00430         } else if (getId() < other.getId()) {
00431             log().debug("Less than");
00432             return -1;
00433         } else {
00434             log().debug("Equal to");
00435             return 0;
00436         }
00437     }

String toString (  ) 

String representation.

Reimplemented from Storeable.

Definition at line 446 of file Dataset.java.

00446                              {
00447         return toString(0);
00448     }

String toString ( Integer  indentBy  ) 

String representation with indent.

Definition at line 451 of file Dataset.java.

00451                                              {
00452         log().debug("Writing out dataset as a string");
00453         String indent = "";
00454         for (int i  = 0; i < indentBy; ++i) indent += " ";
00455         StringBuffer s = new StringBuffer();
00456 
00457         // Dataset comments
00458         s.append(indent + "Dataset ID: " + getId() + "\n");
00459         if (! getComments().isEmpty()) {
00460             s.append(indent + "Comments: ");
00461             for (String comment : getComments()) {
00462                 s.append("\n" + indent + comment);
00463             }
00464             s.append("\n");
00465         }
00466 
00467         // Axes
00468         s.append(indent + getXAxes().size() + " x-axes, ");
00469         s.append(indent + getYAxes().size() + " y-axes");
00470         for (XAxis xaxis : getXAxes()) {
00471             log().debug("Getting x-axis string representation");
00472             s.append("\n" + xaxis.toString(indentBy + 2));
00473         }
00474         for (YAxis yaxis : getYAxes()) {
00475             log().debug("Getting y-axis string representation");
00476             s.append("\n" + yaxis.toString(indentBy + 2));
00477         }
00478         s.append("\n");
00479 
00480         // Dataset errors
00481         if (! getErrors().isEmpty()) {
00482             s.append(indent + "Dataset errors:");
00483             for (Uncertainty err : getErrors()) {
00484                 log().debug("Getting dataset error string representation");
00485                 s.append("\n" + err.toString(indentBy + 2));
00486             }
00487         }
00488 
00489         return s.toString();
00490     }

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().

00014                  {
00015         return Logger.getLogger(this.getClass());
00016     }


Member Data Documentation

.hibernate.annotations.CollectionOfElements.hibernate.annotations. length [package]

Initial value:

10000)
    private List<String> _comments = new Vector<String>()

Definition at line 51 of file Dataset.java.


The documentation for this class was generated from the following file:
Generated on Thu Sep 20 11:41:38 2007 by  doxygen 1.5.3