Class CollectionFactory

java.lang.Object
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.
  • Field Details

    • PROTECT_READ_ONLY_COLLECTIONS_PROP

      private static final String 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

      private static final ThreadLocal<Boolean> PROTECT_READ_ONLY_COLLECTIONS
  • Constructor Details

    • CollectionFactory

      private CollectionFactory()
  • Method Details

    • getList

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

      public static <T> Set<T> getSet(Class<T> type)
    • 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

      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)