se.js.jesdob
Interface IDobCollection

All Superinterfaces:
java.lang.Iterable<IDob>
All Known Implementing Classes:
DobCollection

public interface IDobCollection
extends java.lang.Iterable<IDob>

A IDobCollection is a collection containing one or more IDobs (dynamic objects). It is possible to add objects to a collection, and to remove objects from a collection.

It is possible to get IDobs from the collection, by index, or by searching a specific attribute and value. You can also filter the IDobCollection by using a IDobQuery-object. This will make the IDob-object act more like a database.

IDobCollections can be exported to text as json-format, xml-format or dob-format. They can then be saved to files and read as dynamic objects when they are needed.


Method Summary
 IDobCollection add(IDob... dobs)
          Adds one or more dobs to the dob collection.
 IDobCollection add(IDobCollection dobCollection)
          Adds the content of a dob collection to a dob collection.
 IDobCollection add(java.lang.String... dobsData)
          Adds one or more dobs from dob data-strings.
 IDobCollection clear()
          Removes all data from the DobCollection
 IDobCollection filter(IDobQuery query)
          Applies a filter on this DobCollection and returns the filtered version.
 IDob get(int index)
          Returns a Dob from a specific index in the collection.
 IDob get(java.lang.String attribute, java.lang.String value)
          Returns the first dob in the collection where a specific attribute has a specific value.
 IDobCollection getAll(java.lang.String attribute, java.lang.String value)
          Returns a new DobCollection containing all Dobs which have a particular value for a particular attribute.
 boolean isEmpty()
          Returns true or false, depending on if the collection is empty or not.
 boolean remove(java.lang.String attr, java.lang.String value)
          Removes all dobs where a specific attribute has a specific value.
 int size()
          Returns the number of dobs in the collection.
 java.lang.String toDob()
          Returns the content of the collection, in dob-format.
 java.lang.String toJson()
          Returns the content of the collection, in json-format.
 java.util.List<IDob> toList()
          Returns a new list with dobs from the collection.
 java.lang.String toXml()
          Returns the content of the collection, in xml-format.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

filter

IDobCollection filter(IDobQuery query)
Applies a filter on this DobCollection and returns the filtered version. The filtering is done is by the applied IDobQuery object.

Parameters:
query - The query we want to use for filtering the collection.
Returns:
The new collection, produced by filtering the original collection.

add

IDobCollection add(IDob... dobs)
Adds one or more dobs to the dob collection.

Parameters:
dobs - The dobs that should be added to the collection.
Returns:
The DobCollection object, to enable chaining.

add

IDobCollection add(IDobCollection dobCollection)
Adds the content of a dob collection to a dob collection.

Parameters:
dobCollection - The DobCollection we want to add the content from.
Returns:
The DobCollection object, to enable chaining.

add

IDobCollection add(java.lang.String... dobsData)
Adds one or more dobs from dob data-strings. The dob data-strings will be converted to dobs and added to the collection.

Parameters:
dobsData - The dob data we want to convert to dobs and add to the collection.
Returns:
The DobCollection object, to enable chaining.

clear

IDobCollection clear()
Removes all data from the DobCollection

Returns:
The DobCollection, to enable chaining.

size

int size()
Returns the number of dobs in the collection.

Returns:
The number of dobs in the collection.

get

IDob get(int index)
Returns a Dob from a specific index in the collection.

Parameters:
index - A specific Dob index of the collection.
Returns:
The Dob from the specific index in the collection.

isEmpty

boolean isEmpty()
Returns true or false, depending on if the collection is empty or not.

Returns:
True or false, depending on if the collection is empty or not.

toList

java.util.List<IDob> toList()
Returns a new list with dobs from the collection.

Returns:
A new list with dobs from the collection.

toJson

java.lang.String toJson()
Returns the content of the collection, in json-format.

Returns:
The content of the collection, in json-format.

toXml

java.lang.String toXml()
Returns the content of the collection, in xml-format.

Returns:
The content of the collection, in xml-format.

toDob

java.lang.String toDob()
Returns the content of the collection, in dob-format.

Returns:
The content of the collection, in dob-format.

get

IDob get(java.lang.String attribute,
         java.lang.String value)
Returns the first dob in the collection where a specific attribute has a specific value. If no such object exists in the collection, this method will return null.

Parameters:
attribute - The specific attribute.
value - The specific value.
Returns:
A dob object where the specified attribute matches the specified value.

getAll

IDobCollection getAll(java.lang.String attribute,
                      java.lang.String value)
Returns a new DobCollection containing all Dobs which have a particular value for a particular attribute. If no such Dobs exists, an empty collection will be returned.

Parameters:
attribute - The specific attribute.
value - The specific value.
Returns:
A new Dob collection containing all Dobs matching the search criterias.

remove

boolean remove(java.lang.String attr,
               java.lang.String value)
Removes all dobs where a specific attribute has a specific value. Returns true if any objects were removed, and false if no objects were removed.

Parameters:
attr - The attribute we want to check for.
value - The value we want to check for.
Returns:
If any object were removed from the collection.