1.1 restoration
[mir.git] / source / mir / entity / EntityList.java
index 0de6bba..a2e6cce 100755 (executable)
@@ -27,7 +27,7 @@
  * exception to your version of the file, but you are not obligated to do so.
  * If you do not wish to do so, delete this exception statement from your version.
  */
-package  mir.entity;
+package mir.entity;
 
 import java.util.ArrayList;
 import java.util.Set;
@@ -52,38 +52,35 @@ import mir.storage.store.StoreUtil;
  * @version 1.1 (cleaned up)
  */
 public class EntityList implements StorableObject {
-  protected static MirPropertiesConfiguration configuration;
+  protected static MirPropertiesConfiguration configuration  = MirPropertiesConfiguration.instance();
   protected LoggerWrapper logger;
   private ArrayList           theEntityArrayList = new ArrayList();
   private String              whereClause, orderClause;
-  private StorageObject       theStorage;
+  private StorageObject       storage;
   private int                 count, offset, limit;
-  private int                 offsetnext = -1, offsetprev = -1;
+  private int                 nextOffset = -1;
+  private int                 previousOffset = -1;
 
-  static {
-    try {
-      configuration = MirPropertiesConfiguration.instance();
-    }
-    catch (PropertiesConfigExc e) {
-      throw new RuntimeException("Unable to get configuration: " + e.getMessage());
-    }
-  }
-
-  /**
-   * Constructor.
-   */
   public EntityList(){
     logger = new LoggerWrapper("Entity.List");
   }
 
 /* get/set EntityClass of Objects stored in EntityList */
-  public void setStorage(StorageObject storage) { this.theStorage=storage; }
-  public StorageObject getStorage() { return theStorage; }
+  public void setStorage(StorageObject aStorage) {
+    storage=aStorage;
+  }
+
+  public StorageObject getStorage() {
+    return storage;
+  }
 
-  public void setLimit(int limit) { this.limit = limit; }
+  public void setLimit(int aLimit) {
+    limit = aLimit;
+  }
 
   /**
    * Sets the WHERE clause that fetched the Entities of this EntityList from the database.
+   *
    * @param wc The string that contains the WHERE clause
    */
   public void setWhere(String wc) {
@@ -92,15 +89,16 @@ public class EntityList implements StorableObject {
 
   /**
    * Returns the WHERE clause that returned this EntityList from the database
+   *
    * @return whereClause The WHERE clause
    */
   public String getWhere() {
     return whereClause;
   }
 
-
   /**
    * Sets the sorting criterium of this EntityList
+   *
    * @param oc
    */
   public void setOrder(String oc) {
@@ -109,6 +107,7 @@ public class EntityList implements StorableObject {
 
   /**
    * Returns the sorting criterium.
+   *
    * @return orderClause The sort order
    */
   public String getOrder() {
@@ -117,14 +116,16 @@ public class EntityList implements StorableObject {
 
   /**
    * Sets the number of rows that match the WHERE clause
+   *
    * @param i The number of rows that match the WHERE clause
    */
   public void setCount(int i) {
-    this.count = i;
+    count = i;
   }
 
   /**
    * Returns the number of rows that match the WHERE clause
+   *
    * @return The number of rows ...
    */
   public int getCount() {
@@ -133,6 +134,7 @@ public class EntityList implements StorableObject {
 
   /**
    * Sets the offset
+   *
    * @param i The offset
    */
   public void setOffset(int i) {
@@ -141,6 +143,7 @@ public class EntityList implements StorableObject {
 
   /**
    * Returns the offset
+   *
    * @return offset
    */
   public int getOffset() {
@@ -149,54 +152,61 @@ public class EntityList implements StorableObject {
 
   /**
    * Sets the offset of the next batch of Entities.
+   *
    * @param i The next offset
    */
   public void setNextBatch(int i) {
-    offsetnext = i;
+    nextOffset = i;
   }
 
   /**
    * Returns the offset of the next batch of Entities.
+   *
    * @return offset of the next batch
    */
   public int getNextBatch() {
-    return offsetnext;
+    return nextOffset;
   }
 
   /**
    * Returns whether there is a next batch within the WHERE clause
+   *
    * @return true if yes, false if no.
    */
   public boolean hasNextBatch() {
-    return (offsetnext >= 0);
+    return (nextOffset >= 0);
   }
 
   /**
    * Sets the offset of the previous batch.
+   *
    * @param i the previous offset
    */
   public void setPrevBatch(int i) {
-    offsetprev = i;
+    previousOffset = i;
   }
 
   /**
    * Returns the offset of the previous batch.
+   *
    * @return offset of the previous batch
    */
   public int getPrevBatch() {
-    return offsetprev;
+    return previousOffset;
   }
 
   /**
    * Returns whether there is a previous batch.
+   *
    * @return true if yes, false if no
    */
   public boolean hasPrevBatch() {
-    return (offsetprev >= 0);
+    return (previousOffset >= 0);
   }
 
   /**
    * Returns the start index of the batch.
+   *
    * @return
    */
   public int getFrom() {
@@ -205,17 +215,19 @@ public class EntityList implements StorableObject {
 
   /**
    * Returns the end index of the batch.
+   *
    * @return
    */
   public int getTo() {
     if (hasNextBatch())
-      return offsetnext;
+      return nextOffset;
     else
       return count;
   }
 
   /**
    * Inserts an Entity into the EntityList.
+   *
    * @param anEntity The entity to be inserted.
    */
 
@@ -243,8 +255,8 @@ public class EntityList implements StorableObject {
    */
 
   public Entity elementAt(int i) {
-    /** @todo check if i is in list.size() */
-    return (Entity)theEntityArrayList.get(i);
+    /** todo check if i is in list.size() */
+    return (Entity) theEntityArrayList.get(i);
   }
 
 
@@ -254,14 +266,18 @@ public class EntityList implements StorableObject {
   public Set getNotifyOnReleaseSet() { return null; }
 
   public StoreIdentifier getStoreIdentifier() {
-    if ( theStorage!=null ) {
+    if ( storage!=null ) {
       return
-      new StoreIdentifier( this, StoreContainerType.STOC_TYPE_ENTITYLIST,
-      StoreUtil.getEntityListUniqueIdentifierFor( theStorage.getTableName(),
-      whereClause, orderClause, offset, limit ));
+        new StoreIdentifier(
+                this, StoreContainerType.STOC_TYPE_ENTITYLIST,
+                StoreUtil.getEntityListUniqueIdentifierFor( storage.getTableName(),
+                whereClause, orderClause, offset, limit ));
+    }
+    else {
+      logger.warn("EntityList could not return StoreIdentifier");
+      
+      return null;
     }
-    logger.warn("EntityList could not return StoreIdentifier");
-    return null;
   }
 
 }