org.apache.ws.commons.schema.utils
Class CollectionFactory

java.lang.Object
  extended by org.apache.ws.commons.schema.utils.CollectionFactory

public final class CollectionFactory
extends Object

There are many collections of XML Schema objects inside XmlSchema. This class provides consistent construction to centralize policy for thread synchronization and the like.


Method Summary
static void clearProtection()
           
static
<T> List<T>
getList(Class<T> type)
           
static
<T> List<T>
getProtectedList(List<T> list)
          Call this to obtain a list to return from a public API where the caller is not supposed to modify the list.
static
<K,V> Map<K,V>
getProtectedMap(Map<K,V> map)
          Call this to obtain a map to return from a public API where the caller is not supposed to modify the map.
static
<T> Set<T>
getSet(Class<T> type)
           
static void setProtected(boolean b)
          Turns on or off protection of collections for this thread.
static void withSchemaModifiable(Runnable action)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getList

public static <T> List<T> getList(Class<T> type)

getSet

public static <T> Set<T> getSet(Class<T> type)

setProtected

public static void setProtected(boolean b)
Turns on or off protection of collections for this thread. Note that this sets a thread local. If you want to return the thread to default state, use the clearProtection method.

Parameters:
b -

clearProtection

public static void clearProtection()

getProtectedList

public static <T> List<T> getProtectedList(List<T> list)
Call this to obtain a list to return from a public API where the caller is not supposed to modify the list. If org.apache.ws.commons.schema.protectReadOnlyCollections is 'true', this will return a list that checks at runtime.

Type Parameters:
T - Generic parameter type of the list.
Parameters:
list - the list.
Returns:

getProtectedMap

public static <K,V> Map<K,V> getProtectedMap(Map<K,V> map)
Call this to obtain a map to return from a public API where the caller is not supposed to modify the map. If org.apache.ws.commons.schema.protectReadOnlyCollections is 'true', this will return a map that checks at runtime.

Type Parameters:
K - key type
V - value type
Parameters:
map - the map.
Returns:

withSchemaModifiable

public static void withSchemaModifiable(Runnable action)


Copyright © 2004-2015 The Apache Software Foundation. All Rights Reserved.