org.gcube.contentmanagement.gcubemodellibrary.elements
Class InnerElements<T extends BaseInnerElement>

java.lang.Object
  extended by org.gcube.contentmanagement.gcubemodellibrary.elements.InnerElements<T>
Type Parameters:
T - the element type.
All Implemented Interfaces:
java.lang.Iterable<T>
Direct Known Subclasses:
AnnotationElements, MetadataElements

public class InnerElements<T extends BaseInnerElement>
extends java.lang.Object
implements java.lang.Iterable<T>

Group of typed elements of the document.

Author:
Fabio Simeoni (University of Strathclyde)

Method Summary
 T add(T e)
          Adds an element to the document, binding the element to the document.
 boolean contains(java.lang.String id)
          Indicates the existence of an element.
 T get(java.lang.String id)
          Returns an element.
 java.util.Iterator<T> iterator()
          
 T remove(java.lang.String id)
          Removes an element.
 void remove(T e)
          Removes an element from the document.
 int size()
          
 java.util.List<T> toList()
          Returns the elements.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

add

public T add(T e)
                               throws java.lang.IllegalArgumentException,
                                      java.lang.IllegalStateException
Adds an element to the document, binding the element to the document. InnerElements that have identifiers replace elements with the same identifier already in the document, if any.

Parameters:
e - the element.
Returns:
the element replaced by this element, or null if no element was replaced.
Throws:
java.lang.IllegalArgumentException - if the element is not new (has an identifier) but the document is already tracked for changes.
java.lang.IllegalStateException - if the element is already bound to another document

get

public T get(java.lang.String id)
                               throws java.lang.IllegalStateException
Returns an element.

Parameters:
id - the element's identifier.
Returns:
the element.
Throws:
java.lang.IllegalStateException - if an element with the given identifier does not exist.

contains

public boolean contains(java.lang.String id)
Indicates the existence of an element.

Parameters:
id - the element's identifier.
Returns:
true if an element with the given identifier exists, false otherwise.

remove

public T remove(java.lang.String id)
                                  throws java.lang.IllegalStateException
Removes an element.

Parameters:
id - the element's identifier.
Returns:
the removed element.
Throws:
java.lang.IllegalStateException - if an element with the given identifier does not exist.

remove

public void remove(T e)
            throws java.lang.IllegalStateException
Removes an element from the document.

Parameters:
e - the element.
Throws:
java.lang.IllegalStateException - if the element does not exist.

toList

public java.util.List<T> toList()
Returns the elements.

Returns:
the elements.

iterator

public java.util.Iterator<T> iterator()

Specified by:
iterator in interface java.lang.Iterable<T extends BaseInnerElement>

size

public int size()


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object