Methods Summary |
---|
public static T[] | asArray(java.lang.Object o)The caller should take appropriate care that the type is correct.
return (T[])Object[].class.cast( o );
|
public static java.lang.Class | asClass(java.lang.Class c)The caller should take appropriate care that the type is correct.
if ( ! ( c instanceof Class ) )
{
throw new IllegalArgumentException( "" + c );
}
return (Class<T>)Class.class.cast( c );
|
public static java.util.Collection | asCollection(java.lang.Object o)The caller should take appropriate care that the type of element
is correct, and may want to call {@link #checkCollection} instead
if there is any doubt.
return (Collection<T>)Collection.class.cast( o );
|
public static java.util.Hashtable | asHashtable(java.lang.Object o)The caller should take appropriate care that the type of element
is correct, and may want to call {@link #checkMap} instead if there is
any doubt.
return (Hashtable<K,V>)Hashtable.class.cast( o );
|
public static java.util.List | asList(java.lang.Object list)The caller should take appropriate care that the type of element
is correct, and may want to call {@link #checkList} instead if there is
any doubt.
return (List<T>)List.class.cast( list );
|
public static java.util.Map | asMap(java.lang.Object m)The caller should take appropriate care that the type of keys/values
is correct, and may want to call {@link #checkMap} instead if there is
any doubt.
return (Map<K,V>)Map.class.cast( m );
|
public static java.util.Collection | asSerializableCollection(java.lang.Object c)The caller should take appropriate care that the type of element
is correct, and may want to call {@link #checkCollection} instead if there is
any doubt.
final Collection<T> result = asCollection( c );
checkSerializable( result );
return result;
|
public static java.util.List | asSerializableList(java.lang.Object list)The caller should take appropriate care that the type of element
is correct, and may want to call{@link #checkList} instead if there is
any doubt.
final List<T> result = asList( list );
checkSerializable( result );
return result;
|
public static java.util.Map | asSerializableMap(java.lang.Object m)The caller should take appropriate care that the type of keys/values
is correct, and may want to call {@link #checkSerializable} instead if there is
any doubt.
final Map<K,V> result = asMap( m );
checkSerializable( result );
return result;
|
public static java.util.Set | asSerializableSet(java.lang.Object s)The caller should take appropriate care that the type of element
is correct, and may want to call {@link #checkSet} instead if there is
any doubt.
final Set<T> result = asSet( s );
checkSerializable( result );
return result;
|
public static java.util.Set | asSet(java.lang.Object s)The caller should take appropriate care that the type of element
is correct, and may want to call {@link #checkSet} instead if there is
any doubt.
return (Set<T>)Set.class.cast( s );
|
public static java.util.SortedSet | asSortedSet(java.lang.Object s)The caller should take appropriate care that the type of element
is correct, and may want to call {@link #checkSet} instead if there is
any doubt.
return (SortedSet<T>)Set.class.cast( s );
|
public static void | checkArray(java.lang.Object[] a, java.lang.Class theClass)Verify that the elements are all assignable to an object of the
specified class.
for( final Object o : a )
{
checkObject( o, theClass );
}
|
public static java.util.Collection | checkCollection(java.util.Collection c, java.lang.Class theClass)Verify that the elements are all assignable to an object of the
specified class.
if ( c != null )
{
for( final Object o : c )
{
checkObject( o, theClass );
}
}
return asCollection(c);
|
public static java.util.List | checkList(java.util.List l, java.lang.Class theClass)Verify that the elements are all assignable to an object of the
specified class.
if ( l != null )
{
for( final Object o : l )
{
checkObject( o, theClass );
}
}
return asList(l);
|
public static java.util.Map | checkMap(java.util.Map m, java.lang.Class keyClass, java.lang.Class valueClass)Verify that the elements are all assignable to an object of the
specified class.
if ( m != null )
{
checkSet( m.keySet(), keyClass );
checkCollection( m.values(), valueClass );
}
return asMap( m );
|
public static T | checkObject(java.lang.Object o, java.lang.Class theClass)Verify that the Object is assignable to an object of the
specified class.
if ( o != null && ! theClass.isAssignableFrom( o.getClass() ) )
{
throw new ClassCastException( "Object of class " + o.getClass().getName() +
" not assignment compatible with: " + theClass.getName() );
}
return (T)o;
|
public static void | checkSerializable(java.lang.Object[] a)Verify that all elements implement java.io.Serializable
for( final Object o : a )
{
checkSerializable( o );
}
|
public static java.util.Collection | checkSerializable(java.util.Collection l)Verify that all elements implement java.io.Serializable
checkSerializable( l, true );
return asCollection( l );
|
public static java.util.Collection | checkSerializable(java.util.Collection l, boolean collectionItself)Verify that all elements implement java.io.Serializable
if ( collectionItself )
{
checkSerializable( (Object)l );
}
checkSerializableElements( l );
return asCollection( l );
|
public static java.util.Map | checkSerializable(java.util.Map m)Verify that the Map itself, and all keys and values
implement java.io.Serializable
checkSerializable( (Object)m );
// the key set used by HashMap isn't Serializable; apparently
// HashMap serializes itself properly, but not by serializing
// the key set directly. So if the Map is Serializable, we
// can't necessarily constrain the key set and value set to be so,
// since it's up to the Map to serialize properly.
checkSerializable( m.keySet(), false);
checkSerializable( m.values(), false);
return asMap( m );
|
public static java.io.Serializable | checkSerializable(java.lang.Object o)Verify that the Object implements java.io.Serializable.
if ( (o != null) && ! (o instanceof Serializable) )
{
throw new ClassCastException( "Object not Serializable, class = " + o.getClass().getName() );
}
return Serializable.class.cast( o );
|
public static void | checkSerializableElements(java.util.Collection l)Verify that all elements implement java.io.Serializable
for( final Object o : l )
{
checkSerializable( o );
}
|
public static java.util.Set | checkSet(java.util.Set s, java.lang.Class theClass)Verify that the elements are all assignable to an object of the
specified class.
if ( s != null )
{
for( final Object o : s )
{
checkObject( o, theClass );
}
}
return asSet(s);
|
public static java.util.Collection | checkedCollection(java.util.Collection c, java.lang.Class theClass)Create a checked Collection, first verifying that all elements
are in fact String.
final Collection<T> cc = checkCollection( c, theClass );
return Collections.checkedCollection( cc, theClass );
|
public static java.util.List | checkedList(java.util.List l, java.lang.Class theClass)Create a checked List, first verifying that all elements
are in fact String.
final List<T> cl = checkList( l, theClass );
return Collections.checkedList( cl, theClass );
|
public static java.util.Map | checkedMap(java.util.Map m, java.lang.Class keyClass, java.lang.Class valueClass)Create a checked Map, first verifying that all keys
and values are in fact String.
final Map<K,V> cm = checkMap( m, keyClass, valueClass );
return Collections.checkedMap( cm, keyClass, valueClass );
|
public static java.util.Set | checkedSet(java.util.Set s, java.lang.Class theClass)Create a checked Set, first verifying that all elements
are in fact String.
final Set<T> cs = checkSet( s, theClass );
return Collections.checkedSet( cs, theClass );
|
public static java.util.Collection | checkedStringCollection(java.util.Collection c)Create a checked Collection, first verifying that all elements
are in fact String.
return checkedCollection( c, String.class );
|
public static java.util.List | checkedStringList(java.util.List l)Create a checked List, first verifying that all elements
are in fact String.
return checkedList( l, String.class );
|
public static java.util.Map | checkedStringMap(java.util.Map m)Create a checked Map, first verifying that all keys
and values are in fact String.
return checkedMap( m, String.class, String.class);
|
public static java.util.Set | checkedStringSet(java.util.Set s)Create a checked Set, first verifying that all elements
are in fact String.
return checkedSet( s, String.class );
|