Class CollectionFactory
java.lang.Object
org.apache.ws.commons.schema.utils.CollectionFactory
There are many collections of XML Schema objects inside XmlSchema. This class provides consistent
construction to centralize policy for thread synchronization and the like.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanprivate static final ThreadLocal<Boolean> private static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic <T> List<T> 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> private static booleanstatic voidsetProtected(boolean b) Turns on or off protection of collections for this thread.static voidwithSchemaModifiable(Runnable action)
-
Field Details
-
PROTECT_READ_ONLY_COLLECTIONS_PROP
- See Also:
-
DEFAULT_PROTECT_READ_ONLY_COLLECTIONS
private static final boolean DEFAULT_PROTECT_READ_ONLY_COLLECTIONS -
PROTECT_READ_ONLY_COLLECTIONS
-
-
Constructor Details
-
CollectionFactory
private CollectionFactory()
-
-
Method Details
-
getList
-
getSet
-
isProtected
private static boolean isProtected() -
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
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
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 typeV- value type- Parameters:
map- the map.- Returns:
-
withSchemaModifiable
-