org.gcube.data.gml.elements
Class InnerElements<T extends BaseInnerElement>

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

public class InnerElements<T extends BaseInnerElement>
extends Object
implements 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(String id)
          Indicates the existence of an element.
 T get(String id)
          Returns an element.
 Iterator<T> iterator()
          
 T remove(String id)
          Removes an element.
 void remove(T e)
          Removes an element from the document.
 int size()
          Returns the number of elements.
 List<T> toList()
          Returns the elements.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

add

public T add(T e)
                               throws IllegalArgumentException,
                                      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:
IllegalArgumentException - if the element is not new (has an identifier) but the document is already tracked for changes.
IllegalStateException - if the element is already bound to another document

get

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

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

contains

public boolean contains(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(String id)
                                  throws IllegalStateException
Removes an element.

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

remove

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

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

toList

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

Returns:
the elements.

iterator

public Iterator<T> iterator()

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

size

public int size()
Returns the number of elements.

Returns:
the number of elements

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.