edu.sdsc.grid.io
Class MetaDataRecordList

java.lang.Object
  extended by edu.sdsc.grid.io.MetaDataRecordList
Direct Known Subclasses:
IRODSMetaDataRecordList, LocalMetaDataRecordList, SRBMetaDataRecordList

public abstract class MetaDataRecordList
extends java.lang.Object

The results of a query.

Results of long queries will only return a partial list to save on bandwidth which can be iterated through by further calls to the server.

Subclasses work closely with the file server to do a multi-step query that does not have to return everything immediately. The SRBMetaDataRecordList class, for instance, works with partial query results and, on need, issues a query for the next batch of results.


Field Summary
protected  MetaDataField[] fields
          Stores the descriptions and names of the related fields for all the values returned.
protected  java.lang.Object[] records
          The query returned from the server might look like:
 
Constructor Summary
protected MetaDataRecordList(MetaDataField[] fields, java.lang.Object[] recordValues)
           
  MetaDataRecordList(MetaDataField field, float recordValue)
          Create a new MetaDataRecordList with this field and recordValue.
  MetaDataRecordList(MetaDataField field, java.lang.Float recordValue)
          Create a new MetaDataRecordList with this field and recordValue.
  MetaDataRecordList(MetaDataField field, int recordValue)
          Create a new MetaDataRecordList with this field and recordValue.
  MetaDataRecordList(MetaDataField field, java.lang.Integer recordValue)
          Create a new MetaDataRecordList with this field and recordValue.
  MetaDataRecordList(MetaDataField field, MetaDataTable recordValue)
          Create a new MetaDataRecordList with this field and recordValue.
  MetaDataRecordList(MetaDataField field, java.lang.String recordValue)
          Create a new MetaDataRecordList with this field and recordValue.
 
Method Summary
 void addRecord(MetaDataField field, float recordValue)
           
 void addRecord(MetaDataField field, int recordValue)
           
 void addRecord(MetaDataField field, MetaDataTable recordValue)
           
protected  boolean addRecord(MetaDataField field, java.lang.Object recordValue)
           
 void addRecord(MetaDataField field, java.lang.String recordValue)
           
 boolean equals(java.lang.Object obj)
          Tests this abstract pathname for equality with the given object.
protected  void finalize()
          Finalizes the object by explicitly letting go of each of its internally held values.
static MetaDataRecordList[] getAllResults(MetaDataRecordList[] rl)
          Gets all of the query results of a particular query and returns them in a single array.
 MetaDataField getField(int index)
          Get the MetaDataField object describing the indicated field.
 int getFieldCount()
          Returns the number of fields for each record in the list.
 int getFieldIndex(java.lang.String fieldName)
          Get the index for the named field.
 java.lang.String getFieldName(int index)
          Get the field name for the indicated field.
 MetaDataField[] getFields()
          Get the MetaDataFields for this record list.
 int getFieldType(int index)
          Get the data type for the field's values.
 float getFloatValue(int index)
          Get the value for the field.
 int getIntValue(int index)
          Get the value for the field.
abstract  MetaDataRecordList[] getMoreResults()
          By default a query will only return the first so many values which match the query to make querying faster.
abstract  MetaDataRecordList[] getMoreResults(int numOfResults)
          Same as getMoreResults(), but returns numOfResults instead of the default amount.
 int getRecordCount()
          Returns the number of records in the list.
 java.lang.String getStringValue(int index)
          Get the value for the field.
 MetaDataTable getTableValue(int index)
          Get the value for the field.
 java.lang.Object getValue(int index)
          Returns the values in the list.
 java.lang.Object getValue(MetaDataField field)
          Returns the value matching this field.
 java.lang.Object getValue(java.lang.String field)
          Returns the value matching this field.
abstract  boolean isQueryComplete()
          Tests if the query has more values to be retrieved.
 void removeRecord(int index)
           
 void removeRecord(MetaDataField field)
           
 void setValue(int index, float value)
           
 void setValue(int index, int value)
           
 void setValue(int index, MetaDataTable value)
           
 void setValue(int index, java.lang.String value)
           
 boolean setValue(MetaDataField field, float value)
          Changes the value in this MetaDataRecordList for the approproate field.
 boolean setValue(MetaDataField field, int value)
          Changes the value in this MetaDataRecordList for the approproate field.
 boolean setValue(MetaDataField field, MetaDataTable value)
          Changes the value in this MetaDataRecordList for the approproate field.
 boolean setValue(MetaDataField field, java.lang.String value)
          Changes the value in this MetaDataRecordList for the approproate field.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fields

protected MetaDataField[] fields
Stores the descriptions and names of the related fields for all the values returned.


records

protected java.lang.Object[] records
The query returned from the server might look like:

field name: "data name" "owner" "size"
record1: test1.txt testuser 300
record2: test2.txt testuser 500
record3: image1.jpg demouser 14000

Constructor Detail

MetaDataRecordList

protected MetaDataRecordList(MetaDataField[] fields,
                             java.lang.Object[] recordValues)

MetaDataRecordList

public MetaDataRecordList(MetaDataField field,
                          int recordValue)
Create a new MetaDataRecordList with this field and recordValue.


MetaDataRecordList

public MetaDataRecordList(MetaDataField field,
                          float recordValue)
Create a new MetaDataRecordList with this field and recordValue.


MetaDataRecordList

public MetaDataRecordList(MetaDataField field,
                          java.lang.Integer recordValue)
Create a new MetaDataRecordList with this field and recordValue.


MetaDataRecordList

public MetaDataRecordList(MetaDataField field,
                          java.lang.Float recordValue)
Create a new MetaDataRecordList with this field and recordValue.


MetaDataRecordList

public MetaDataRecordList(MetaDataField field,
                          java.lang.String recordValue)
Create a new MetaDataRecordList with this field and recordValue.


MetaDataRecordList

public MetaDataRecordList(MetaDataField field,
                          MetaDataTable recordValue)
Create a new MetaDataRecordList with this field and recordValue.

Method Detail

finalize

protected void finalize()
Finalizes the object by explicitly letting go of each of its internally held values.

Overrides:
finalize in class java.lang.Object

getFieldCount

public int getFieldCount()
Returns the number of fields for each record in the list. This field count will generally equal the number of fields intially selected by the query.


getFields

public MetaDataField[] getFields()
Get the MetaDataFields for this record list.


getField

public MetaDataField getField(int index)
Get the MetaDataField object describing the indicated field.


getFieldName

public java.lang.String getFieldName(int index)
Get the field name for the indicated field. This is a shorthand for:
getField(index).getName()


getFieldType

public int getFieldType(int index)
Get the data type for the field's values. This is a shorthand for:
getField(index).getType()


getFieldIndex

public int getFieldIndex(java.lang.String fieldName)
Get the index for the named field.

Returns:
the index of the field, or -1 if this recordlist does not contain that field

getRecordCount

public int getRecordCount()
Returns the number of records in the list.


getIntValue

public int getIntValue(int index)
Get the value for the field. The call's data type (int, float, or string) need not match the value's data type (as returned by getFieldType), except in the case of tables.

Throws:
java.lang.IllegalArgumentException - If the value at this index is a table.

getFloatValue

public float getFloatValue(int index)
Get the value for the field. The call's data type (int, float, or string) need not match the value's data type (as returned by getFieldType), except in the case of tables.

Throws:
java.lang.IllegalArgumentException - If the value at this index is a table.

getStringValue

public java.lang.String getStringValue(int index)
Get the value for the field. The call's data type (int, float, or string) need not match the value's data type (as returned by getFieldType), except in the case of tables.

Throws:
java.lang.IllegalArgumentException - If the value at this index is a table.

getTableValue

public MetaDataTable getTableValue(int index)
Get the value for the field. The call's data type must be a table or an IllegalArgumentException will be thrown.

Throws:
java.lang.IllegalArgumentException - If the value at this index is not a table.

getValue

public java.lang.Object getValue(int index)
Returns the values in the list.


getValue

public java.lang.Object getValue(MetaDataField field)
Returns the value matching this field.


getValue

public java.lang.Object getValue(java.lang.String field)
Returns the value matching this field.


setValue

public void setValue(int index,
                     int value)
              throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException

setValue

public void setValue(int index,
                     float value)
              throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException

setValue

public void setValue(int index,
                     java.lang.String value)
              throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException

setValue

public void setValue(int index,
                     MetaDataTable value)
              throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException

setValue

public boolean setValue(MetaDataField field,
                        int value)
                 throws java.lang.ArrayIndexOutOfBoundsException
Changes the value in this MetaDataRecordList for the approproate field. Returns false if the MetaDataField does not exist in this MetaDataRecordList.

Throws:
java.lang.ArrayIndexOutOfBoundsException

setValue

public boolean setValue(MetaDataField field,
                        float value)
                 throws java.lang.ArrayIndexOutOfBoundsException
Changes the value in this MetaDataRecordList for the approproate field. Returns false if the MetaDataField does not exist in this MetaDataRecordList.

Throws:
java.lang.ArrayIndexOutOfBoundsException

setValue

public boolean setValue(MetaDataField field,
                        java.lang.String value)
                 throws java.lang.ArrayIndexOutOfBoundsException
Changes the value in this MetaDataRecordList for the approproate field. Returns false if the MetaDataField does not exist in this MetaDataRecordList.

Throws:
java.lang.ArrayIndexOutOfBoundsException

setValue

public boolean setValue(MetaDataField field,
                        MetaDataTable value)
                 throws java.lang.ArrayIndexOutOfBoundsException
Changes the value in this MetaDataRecordList for the approproate field. Returns false if the MetaDataField does not exist in this MetaDataRecordList.

Throws:
java.lang.ArrayIndexOutOfBoundsException

addRecord

protected boolean addRecord(MetaDataField field,
                            java.lang.Object recordValue)

addRecord

public void addRecord(MetaDataField field,
                      int recordValue)

addRecord

public void addRecord(MetaDataField field,
                      float recordValue)

addRecord

public void addRecord(MetaDataField field,
                      java.lang.String recordValue)

addRecord

public void addRecord(MetaDataField field,
                      MetaDataTable recordValue)

removeRecord

public void removeRecord(int index)

removeRecord

public void removeRecord(MetaDataField field)

isQueryComplete

public abstract boolean isQueryComplete()
Tests if the query has more values to be retrieved.


getMoreResults

public abstract MetaDataRecordList[] getMoreResults()
                                             throws java.io.IOException
By default a query will only return the first so many values which match the query to make querying faster. If this query has more results those results will be appended to this object.

Throws:
java.io.IOException - If an IOException occurs.

getMoreResults

public abstract MetaDataRecordList[] getMoreResults(int numOfResults)
                                             throws java.io.IOException
Same as getMoreResults(), but returns numOfResults instead of the default amount.

Throws:
java.io.IOException - If an IOException occurs.

getAllResults

public static MetaDataRecordList[] getAllResults(MetaDataRecordList[] rl)
                                          throws java.io.IOException
Gets all of the query results of a particular query and returns them in a single array. Queries with a very large result set could take a excessively long time. Use this method sparingly or make it optional.

Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Tests this abstract pathname for equality with the given object. Returns true if and only if the argument is not null and is a MetaDataRecordList with all values equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to be compared with this MetaDataRecordList
Returns:
true if and only if the objects are the same; false otherwise