LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  December 2014

HPS-SVN December 2014

Subject:

r1688 - /java/trunk/conditions/src/main/java/org/hps/conditions/api/AbstractConditionsObjectCollection.java

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Thu, 11 Dec 2014 19:18:21 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (186 lines)

Author: [log in to unmask]
Date: Thu Dec 11 11:18:16 2014
New Revision: 1688

Log:
Add metho javadoc.

Modified:
    java/trunk/conditions/src/main/java/org/hps/conditions/api/AbstractConditionsObjectCollection.java

Modified: java/trunk/conditions/src/main/java/org/hps/conditions/api/AbstractConditionsObjectCollection.java
 =============================================================================
--- java/trunk/conditions/src/main/java/org/hps/conditions/api/AbstractConditionsObjectCollection.java	(original)
+++ java/trunk/conditions/src/main/java/org/hps/conditions/api/AbstractConditionsObjectCollection.java	Thu Dec 11 11:18:16 2014
@@ -6,96 +6,149 @@
 import org.hps.conditions.database.DatabaseConditionsManager;
 import org.hps.conditions.database.TableMetaData;
 
+/**
+ * This class implements a collection API for ConditionsObjects, using a <code>LinkedHashSet</code>.
+ * 
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @param <ObjectType> The concrete type of the collection class.
+ */
 public class AbstractConditionsObjectCollection<ObjectType extends ConditionsObject> extends LinkedHashSet<ObjectType> {
 
     protected TableMetaData tableMetaData = null;
     protected int collectionId = -1;
     protected ConditionsRecord conditionsRecord = null;
     
+    /**
+     * This is the no argument constructor that would be used when creating a new collection
+     * that is not in the database.
+     */
     public AbstractConditionsObjectCollection() {
     }
     
+    /**
+     * This constructor uses the given conditions record and table meta data objects and will assign
+     * the collection ID from the conditions record.
+     * @param conditionsRecord
+     * @param tableMetaData
+     */
     public AbstractConditionsObjectCollection(ConditionsRecord conditionsRecord, TableMetaData tableMetaData) {
         this.conditionsRecord = conditionsRecord;
         this.tableMetaData = tableMetaData;
         this.collectionId = conditionsRecord.getCollectionId();
     }
     
+    /**
+     * This constructor is used to explicitly assign all class variable values.
+     * @param conditionsRecord
+     * @param tableMetaData
+     * @param collectionID
+     */
     public AbstractConditionsObjectCollection(ConditionsRecord conditionsRecord, TableMetaData tableMetaData, int collectionID) {
         this.conditionsRecord = conditionsRecord;
         this.tableMetaData = tableMetaData;
         this.collectionId = collectionID;
     }
     
-    public void setTableMetaData(TableMetaData tableMetaData) {
-        /**
-         * Setting this more than once is disallowed.
-         */
+    /**
+     * Set the associated table meta data for this collection.  
+     * Once set it cannot be reassigned, which will cause an exception to be thrown.
+     * @param tableMetaData
+     */
+    public void setTableMetaData(TableMetaData tableMetaData) {                              
         if (this.tableMetaData != null) {
-            throw new RuntimeException("The table meta data cannot be reset.");
+            throw new RuntimeException("The table meta data cannot be reset once assigned.");
         }
         this.tableMetaData = tableMetaData;
     }
     
+    /**
+     * Set the associated conditions record this collection.
+     * Once set it cannot be reassigned, which will cause an exception to be thrown.
+     * @param conditionsRecord
+     */
     public void setConditionsRecord(ConditionsRecord conditionsRecord) {
-        /**
-         * Setting this more than once is disallowed.
-         */
         if (this.conditionsRecord != null) {
-            throw new RuntimeException("The table meta data cannot be reset.");
+            throw new RuntimeException("The conditions record cannot be reset once assigned.");
         }
         this.conditionsRecord = conditionsRecord;
     }
     
+    /**
+     * Add an object to the collection.
+     */
     public boolean add(ObjectType object) {
         if (contains(object)) {
-            throw new IllegalArgumentException("Cannot add duplicate object " + object);
+            throw new IllegalArgumentException("Cannot add duplicate object " + object + " to collection.");
         }
         return super.add(object);
     }
 
+    /**
+     * Get the table meta data.
+     * @return
+     */
     public TableMetaData getTableMetaData() {
         return tableMetaData;
     }
 
+    /**
+     * Get the collection ID.
+     * @return
+     */
     public int getCollectionId() {
         return collectionId;
     }
     
+    /**
+     * Get the conditions record.
+     * @return
+     */
     public ConditionsRecord getConditionsRecord() {
         return conditionsRecord;
     }
         
+    /**
+     * Set the collection ID.  
+     * Once set it cannot be assign again, which will cause an exception.
+     * @param collectionId
+     * @throws ConditionsObjectException
+     */
     public void setCollectionId(int collectionId) throws ConditionsObjectException {
-        if (collectionId != -1) {
+        if (this.collectionId != -1) {
             throw new ConditionsObjectException("The collectionId already has the value " + collectionId + " and cannot be reset."); 
         }
         this.collectionId = collectionId;
     }
-    
+        
     public void insert() throws ConditionsObjectException, SQLException {
+        
+        // TODO: First check here if conditions record and/or collection ID is assigned, 
+        //       in which case an error should be thrown as this is not a new collection.
+        
         DatabaseConditionsManager.getInstance().insertCollection(this);
     }
     
-    // Should select all records into the collection by collection ID.
+    // Should select records into this collection by collection ID.
     public int select() {
-        System.out.println("implement me");
-        return -1;
+        throw new UnsupportedOperationException("The select operation is not implemented yet.");
     }
     
-    // Should delete all records by collection ID in the database and clear the local objects.
+    // Should delete all records by collection ID in the database and then clear the local objects. 
     public int delete() {
-        System.out.println("implement me");
-        return -1;
+        throw new UnsupportedOperationException("The delete operation is not implemented yet.");
     }
     
-    // Should update objects in the database with their values in the set.
+    // Should update objects in the database with their values from this collection.
+    // All objects would need to have valid row IDs for this to work.
     public int update() {
-        System.out.println("implement me");
-        return -1;
+        throw new UnsupportedOperationException("The update operation is not implemented yet.");
     }
     
+    /**
+     * Convert object to string.
+     */
     public String toString() {
+        // TODO: Should print out column headers here.
         StringBuffer buffer = new StringBuffer();
         for (ConditionsObject object : this) {
             buffer.append(object.toString());

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use