org.archive.crawler.settings
Class ListType<T>

java.lang.Object
  extended by javax.management.Attribute
      extended by org.archive.crawler.settings.Type
          extended by org.archive.crawler.settings.ListType<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<java.lang.Object>, java.util.Collection<java.lang.Object>, java.util.List<java.lang.Object>
Direct Known Subclasses:
DoubleList, FloatList, IntegerList, LongList, StringList

public abstract class ListType<T>
extends Type
implements java.util.List<java.lang.Object>

Super type for all lists.

Author:
John Erik Halse
See Also:
Serialized Form

Constructor Summary
ListType(java.lang.String name, java.lang.String description)
          Constructs a new ListType.
 
Method Summary
 void add(int index, java.lang.Object element)
          Inserts the specified element at the specified position in this list.
 boolean add(java.lang.Object element)
          Appends the specified element to the end of this list.
 boolean addAll(java.util.Collection<? extends java.lang.Object> c)
           
 boolean addAll(int index, java.util.Collection<? extends java.lang.Object> c)
           
protected  void addAll(ListType<T> l)
          Appends all of the elements in the specified list to the end of this list, in the order that they are returned by the specified lists's iterator.
abstract  T checkType(java.lang.Object element)
          Check if element is of right type for this list.
 void clear()
          Removes all elements from this list.
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection c)
           
 java.lang.Object get(int index)
          Returns the object stored at the index specified
 java.lang.Object getDefaultValue()
          The default value for this type
 java.lang.String getDescription()
          Get the description of this type The description should be suitable for showing in a user interface.
 java.lang.Object[] getLegalValues()
          The getLegalValues is not applicable for list so this method will always return null.
 java.lang.Object getValue()
          Returns this object.
 int indexOf(java.lang.Object o)
           
 boolean isEmpty()
          Returns true if this list contains no elements.
 java.util.Iterator<java.lang.Object> iterator()
          Returns an iterator over the elements in this list in proper sequence.
 int lastIndexOf(java.lang.Object o)
           
 java.util.ListIterator<java.lang.Object> listIterator()
           
 java.util.ListIterator<java.lang.Object> listIterator(int index)
           
 java.lang.Object remove(int index)
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection c)
           
 boolean retainAll(java.util.Collection c)
           
 java.lang.Object set(int index, java.lang.Object element)
          Replaces the element at the specified position in this list with the specified element.
 int size()
          Get the number of elements in this list.
 java.util.List<java.lang.Object> subList(int fromIndex, int toIndex)
           
 java.lang.Object[] toArray()
           
<X> X[]
toArray(X[] a)
           
 java.util.List<T> typesafe()
          Returns a compile-time typesafe version of this list.
 
Methods inherited from class org.archive.crawler.settings.Type
addConstraint, equals, getConstraints, getLegalValueType, isExpertSetting, isOverrideable, isTransient, setExpertSetting, setLegalValueType, setOverrideable, setTransient
 
Methods inherited from class javax.management.Attribute
getName, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 

Constructor Detail

ListType

public ListType(java.lang.String name,
                java.lang.String description)
Constructs a new ListType.

Parameters:
name - the name of the list
description - the description of the list
Method Detail

add

public boolean add(java.lang.Object element)
Appends the specified element to the end of this list.

Specified by:
add in interface java.util.Collection<java.lang.Object>
Specified by:
add in interface java.util.List<java.lang.Object>
Parameters:
element - element to be appended to this list.
Returns:
true if this collection changed as a result of the call (as per the Collections.add contract).
Throws:
java.lang.ClassCastException - is thrown if the element was of wrong type and could not be converted.

add

public void add(int index,
                java.lang.Object element)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Specified by:
add in interface java.util.List<java.lang.Object>
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
java.lang.ClassCastException - is thrown if the element was of wrong type and could not be converted.

addAll

protected void addAll(ListType<T> l)
Appends all of the elements in the specified list to the end of this list, in the order that they are returned by the specified lists's iterator. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. This method is a helper method for subclasses.

Parameters:
l - list whose elements are to be added to this list.

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Replaces the element at the specified position in this list with the specified element.

Specified by:
set in interface java.util.List<java.lang.Object>
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Returns:
the element previously at the specified position.
Throws:
java.lang.ClassCastException - is thrown if the element was of wrong type and could not be converted.

iterator

public java.util.Iterator<java.lang.Object> iterator()
Returns an iterator over the elements in this list in proper sequence.

Specified by:
iterator in interface java.lang.Iterable<java.lang.Object>
Specified by:
iterator in interface java.util.Collection<java.lang.Object>
Specified by:
iterator in interface java.util.List<java.lang.Object>
Returns:
an iterator over the elements in this list.

size

public int size()
Get the number of elements in this list.

Specified by:
size in interface java.util.Collection<java.lang.Object>
Specified by:
size in interface java.util.List<java.lang.Object>
Returns:
number of elements.

isEmpty

public boolean isEmpty()
Returns true if this list contains no elements.

Specified by:
isEmpty in interface java.util.Collection<java.lang.Object>
Specified by:
isEmpty in interface java.util.List<java.lang.Object>
Returns:
true if this list contains no elements.

checkType

public abstract T checkType(java.lang.Object element)
                     throws java.lang.ClassCastException
Check if element is of right type for this list. If this method gets a String, it should try to convert it to the right element type before throwing an exception.

Parameters:
element - element to check.
Returns:
element of the right type.
Throws:
java.lang.ClassCastException - is thrown if the element was of wrong type and could not be converted.

getDefaultValue

public java.lang.Object getDefaultValue()
Description copied from class: Type
The default value for this type

Specified by:
getDefaultValue in class Type
Returns:
this type's default value

getDescription

public java.lang.String getDescription()
Description copied from class: Type
Get the description of this type The description should be suitable for showing in a user interface.

Specified by:
getDescription in class Type
Returns:
this type's description

clear

public void clear()
Removes all elements from this list.

Specified by:
clear in interface java.util.Collection<java.lang.Object>
Specified by:
clear in interface java.util.List<java.lang.Object>

get

public java.lang.Object get(int index)
Returns the object stored at the index specified

Specified by:
get in interface java.util.List<java.lang.Object>
Parameters:
index - The location of the object to get within the list.
Returns:
the object stored at the index specified

getLegalValues

public java.lang.Object[] getLegalValues()
The getLegalValues is not applicable for list so this method will always return null.

Specified by:
getLegalValues in class Type
Returns:
null
See Also:
Type.getLegalValues()

getValue

public java.lang.Object getValue()
Returns this object. This method is implemented to be able to treat the ListType as an subclass of Attribute.

Overrides:
getValue in class javax.management.Attribute
Returns:
this object.
See Also:
Attribute.getValue()

addAll

public boolean addAll(java.util.Collection<? extends java.lang.Object> c)
Specified by:
addAll in interface java.util.Collection<java.lang.Object>
Specified by:
addAll in interface java.util.List<java.lang.Object>

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends java.lang.Object> c)
Specified by:
addAll in interface java.util.List<java.lang.Object>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<java.lang.Object>
Specified by:
contains in interface java.util.List<java.lang.Object>

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Collection<java.lang.Object>
Specified by:
containsAll in interface java.util.List<java.lang.Object>

indexOf

public int indexOf(java.lang.Object o)
Specified by:
indexOf in interface java.util.List<java.lang.Object>

lastIndexOf

public int lastIndexOf(java.lang.Object o)
Specified by:
lastIndexOf in interface java.util.List<java.lang.Object>

listIterator

public java.util.ListIterator<java.lang.Object> listIterator()
Specified by:
listIterator in interface java.util.List<java.lang.Object>

listIterator

public java.util.ListIterator<java.lang.Object> listIterator(int index)
Specified by:
listIterator in interface java.util.List<java.lang.Object>

subList

public java.util.List<java.lang.Object> subList(int fromIndex,
                                                int toIndex)
Specified by:
subList in interface java.util.List<java.lang.Object>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<java.lang.Object>
Specified by:
toArray in interface java.util.List<java.lang.Object>

toArray

public <X> X[] toArray(X[] a)
Specified by:
toArray in interface java.util.Collection<java.lang.Object>
Specified by:
toArray in interface java.util.List<java.lang.Object>

remove

public java.lang.Object remove(int index)
Specified by:
remove in interface java.util.List<java.lang.Object>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<java.lang.Object>
Specified by:
remove in interface java.util.List<java.lang.Object>

removeAll

public boolean removeAll(java.util.Collection c)
Specified by:
removeAll in interface java.util.Collection<java.lang.Object>
Specified by:
removeAll in interface java.util.List<java.lang.Object>

retainAll

public boolean retainAll(java.util.Collection c)
Specified by:
retainAll in interface java.util.Collection<java.lang.Object>
Specified by:
retainAll in interface java.util.List<java.lang.Object>

typesafe

public java.util.List<T> typesafe()
Returns a compile-time typesafe version of this list. Unlike this List, the returned list will not accept String values as elements.

Returns:
a typesafe version of this list


Copyright © 2003-2011 Internet Archive. All Rights Reserved.