org.omnaest.utils.xml
Class JAXBCollection<E>

java.lang.Object
  extended by org.omnaest.utils.xml.JAXBCollection<E>
Type Parameters:
E -
All Implemented Interfaces:
Iterable<E>, Collection<E>

public class JAXBCollection<E>
extends Object
implements Collection<E>

Collection wrapper which acts as an XmlRootElement for any Collection. Since the exact type of the internal Collection instance is determined at runtime, each of the objects have its own schema definition. This will cause some overhead in comparison to a Collection which is wrapped not by its interface.

Example output:

 <collection>
     <string>value1</string>
     <string>value2</string>
     <string>value3</string>
 </collection>
 
See JAXBList for further details on conversion syntax.

Author:
Omnaest
See Also:
newInstance(Collection), JAXBList, JAXBMap, JAXBSet

Field Summary
protected  Collection<E> collection
           
 
Constructor Summary
protected JAXBCollection()
          Used internally when JAXB does create a new default instance.
protected JAXBCollection(Collection<E> collection)
           
 
Method Summary
 boolean add(E arg0)
           
 boolean addAll(Collection<? extends E> arg0)
           
 void clear()
           
 boolean contains(Object arg0)
           
 boolean containsAll(Collection<?> arg0)
           
 boolean isEmpty()
           
 Iterator<E> iterator()
           
static
<E> JAXBCollection<E>
newInstance(Collection<E> collection)
          Creates a new instance of a JAXBCollection for a given Collection.
 boolean remove(Object arg0)
           
 boolean removeAll(Collection<?> arg0)
           
 boolean retainAll(Collection<?> arg0)
           
 int size()
           
 Object[] toArray()
           
<T> T[]
toArray(T[] arg0)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

collection

protected Collection<E> collection
Constructor Detail

JAXBCollection

protected JAXBCollection(Collection<E> collection)
Parameters:
collection -
See Also:
newInstance(Collection)

JAXBCollection

protected JAXBCollection()
Used internally when JAXB does create a new default instance.

Parameters:
list -
Method Detail

newInstance

public static <E> JAXBCollection<E> newInstance(Collection<E> collection)
Creates a new instance of a JAXBCollection for a given Collection.

Type Parameters:
E -
Parameters:
collection -
Returns:
new instance or null if collection param is null

add

public boolean add(E arg0)
Specified by:
add in interface Collection<E>

addAll

public boolean addAll(Collection<? extends E> arg0)
Specified by:
addAll in interface Collection<E>

clear

public void clear()
Specified by:
clear in interface Collection<E>

contains

public boolean contains(Object arg0)
Specified by:
contains in interface Collection<E>

containsAll

public boolean containsAll(Collection<?> arg0)
Specified by:
containsAll in interface Collection<E>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>

remove

public boolean remove(Object arg0)
Specified by:
remove in interface Collection<E>

removeAll

public boolean removeAll(Collection<?> arg0)
Specified by:
removeAll in interface Collection<E>

retainAll

public boolean retainAll(Collection<?> arg0)
Specified by:
retainAll in interface Collection<E>

size

public int size()
Specified by:
size in interface Collection<E>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<E>

toArray

public <T> T[] toArray(T[] arg0)
Specified by:
toArray in interface Collection<E>


Copyright © 2013. All Rights Reserved.