org.modeshape.jcr

## Class NodeTypes

- java.lang.Object
- - org.modeshape.jcr.NodeTypes

-     @Immutable
      public class NodeTypes
      extends Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `NodeTypes.NodeCardinality` List of ways to filter the returned node definitions
    `static class` | `NodeTypes.PropertyCardinality` List of ways to filter the returned property definitions
    `static interface` | `NodeTypes.Supplier`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `NodeTypes(ExecutionContext context)`
    `protected` | `NodeTypes(ExecutionContext context, Iterable<org.modeshape.jcr.JcrNodeType> nodeTypes, int version)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `disallowsSameNameSiblings(Name primaryType, Set<Name> mixinTypes)`
    `protected org.modeshape.jcr.JcrNodeDefinition` | `findChildNodeDefinitionForUnstructured(boolean requireSns)`
    `protected org.modeshape.jcr.JcrNodeType` | `findTypeInMapOrList(Name typeName, Collection<org.modeshape.jcr.JcrNodeType> pendingList)` Finds the named type in the given collection of types pending registration if it exists, else returns the type definition from the repository
    `Set<Name>` | `getAllNodeTypeNames()` Return an immutable snapshot of the names of the node types currently registered in this node type manager.
    `Collection<org.modeshape.jcr.JcrNodeType>` | `getAllNodeTypes()` Return the immutable list of node types that are currently registered in this node type manager.
    `Collection<org.modeshape.jcr.JcrPropertyDefinition>` | `getAllPropertyDefinitions()`
    `Collection<org.modeshape.jcr.JcrNodeDefinition>` | `getAutoCreatedChildNodeDefinitions(Name nodeType)` Get the auto-created child node definitions for the named node type.
    `Collection<org.modeshape.jcr.JcrPropertyDefinition>` | `getAutoCreatedPropertyDefinitions(Name nodeType)` Get the auto-created property definitions for the named node type.
    `org.modeshape.jcr.JcrNodeDefinition` | `getChildNodeDefinition(org.modeshape.jcr.NodeDefinitionId id)`
    `Collection<org.modeshape.jcr.JcrNodeDefinition>` | `getMandatoryChildNodeDefinitions(Name primaryType, Set<Name> mixinTypes)` Get the mandatory child node definitions for a node with the named primary type and mixin types.
    `Collection<org.modeshape.jcr.JcrPropertyDefinition>` | `getMandatoryPropertyDefinitions(Name primaryType, Set<Name> mixinTypes)` Get the mandatory property definitions for a node with the named primary type and mixin types.
    `Collection<org.modeshape.jcr.JcrNodeType>` | `getMixinNodeTypes()` Return an immutable snapshot of the mixin node types that are currently registered in this node type manager.
    `Collection<org.modeshape.jcr.JcrNodeType>` | `getPrimaryNodeTypes()` Return an immutable snapshot of the primary node types that are currently registered in this node type manager.
    `org.modeshape.jcr.JcrPropertyDefinition` | `getPropertyDefinition(org.modeshape.jcr.PropertyDefinitionId id)`
    `int` | `getVersion()` Get the version number of this cache.
    `boolean` | `hasMandatoryChildNodeDefinitions(Name primaryType, Set<Name> mixinTypes)` Determine if the named primary node type or mixin types has at least one mandatory child node definitions declared on it or any of its supertypes.
    `boolean` | `hasMandatoryPropertyDefinitions(Name primaryType, Set<Name> mixinTypes)` Determine if the named primary node type or mixin types has at least one mandatory property definitions declared on it or any of its supertypes.
    `boolean` | `isCreated(Name primaryType, Set<Name> mixinTypes)` Determine if at least one of the named primary node type or mixin types is or subtypes the 'mix:created' mixin type.
    `boolean` | `isETag(Name primaryType, Set<Name> mixinTypes)` Determine if at least one of the named primary node type or mixin types is or subtypes the 'mix:etag' mixin type.
    `boolean` | `isFullyDefinedType(Name primaryTypeName, Set<Name> mixinTypeNames)` Determine if the named node type does not appear in any of the other sets.
    `boolean` | `isLastModified(Name primaryType, Set<Name> mixinTypes)` Determine if at least one of the named primary node type or mixin types is or subtypes the 'mix:lastModified' mixin type.
    `boolean` | `isMixin(Name nodeTypeName)` Determine whether the node type given by the supplied name is a mixin node type.
    `boolean` | `isNtResource(Name primaryType)` Determine if the named primary node type is or subtypes the 'nt:resource' node type.
    `boolean` | `isReferenceable(Name primaryType, Set<Name> mixinTypes)` Determine if at least one of the named primary node type or mixin types is or subtypes the 'mix:referenceable' mixin type.
    `boolean` | `isTypeOrSubtype(Name[] nodeTypeNames, Name candidateSupertypeName)` Determine whether at least one of the node's given node types matches or extends the node type with the supplied name.
    `boolean` | `isTypeOrSubtype(Name nodeTypeName, Name candidateSupertypeName)` Determine whether the node's given node type matches or extends the node type with the supplied name.
    `boolean` | `isTypeOrSubtype(Set<Name> nodeTypeNames, Name candidateSupertypeName)` Determine whether at least one of the node's given node types matches or extends the node type with the supplied name.
    `boolean` | `isVersionable(Name primaryType, Set<Name> mixinTypes)` Determine if at least one of the named primary node type or mixin types is or subtypes the 'mix:versionable' mixin type.
    `protected NameFactory` | `nameFactory()`
    `protected List<org.modeshape.jcr.JcrNodeType>` | `supertypesFor(NodeTypeDefinition nodeType, Collection<org.modeshape.jcr.JcrNodeType> pendingTypes)` Returns the list of node types for the supertypes defined in the given node type.
    `String` | `toString()`
    `protected void` | `validate(org.modeshape.jcr.JcrNodeType nodeType, List<org.modeshape.jcr.JcrNodeType> supertypes, List<org.modeshape.jcr.JcrNodeType> pendingTypes)` Validates that the given node type definition is valid under the ModeShape and JCR type rules within the given context.
    `protected NodeTypes` | `with(Collection<org.modeshape.jcr.JcrNodeType> addedNodeTypes)` Obtain a new version of this cache with the specified node types added to the new cache.
    `protected NodeTypes` | `without(Collection<org.modeshape.jcr.JcrNodeType> removedNodeTypes)` Obtain a new version of this cache with the specified node types removed from the new cache.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### NodeTypes

          protected NodeTypes(ExecutionContext context)

    - #### NodeTypes

          protected NodeTypes(ExecutionContext context,
                   Iterable<org.modeshape.jcr.JcrNodeType> nodeTypes,
                   int version)

  - ### Method Detail

    - #### without

          protected NodeTypes without(Collection<org.modeshape.jcr.JcrNodeType> removedNodeTypes)

      Obtain a new version of this cache with the specified node types removed from the new cache.
      Parameters:
        `removedNodeTypes` - the node types that are to be removed from the resulting cache; may not be null but may be empty
      Returns:
        the resulting cache that contains all of the node types within this cache but without the supplied node types; never null

    - #### with

          protected NodeTypes with(Collection<org.modeshape.jcr.JcrNodeType> addedNodeTypes)

      Obtain a new version of this cache with the specified node types added to the new cache.
      Parameters:
        `addedNodeTypes` - the node types that are to be added to the resulting cache; may not be null but may be empty
      Returns:
        the resulting cache that contains all of the node types within this cache and the supplied node types; never null

    - #### nameFactory

          protected final NameFactory nameFactory()

      Returns:
        nameFactory

    - #### getVersion

          public int getVersion()

      Get the version number of this cache. This essentially acts as an ETag, allowing other components to cache node type information as long as the version number stays the same.
      Returns:
        the version number of this cache

    - #### isFullyDefinedType

          public boolean isFullyDefinedType(Name primaryTypeName,
                                   Set<Name> mixinTypeNames)

      Determine if the named node type does not appear in any of the other sets. Such node types are fully-defined, in that nodes using them require no additional processing prior to save.

      Note that this method's signature is different from the other methods. This is because a node's primary type and mixin types must all be fully-defined types.

      Parameters:
        `primaryTypeName` - the name of the primary node type; may not be null
        `mixinTypeNames` - the set of mixin type names; may be null or empty
      Returns:
        true if the named node type is fully-defined, or false otherwise

    - #### isTypeOrSubtype

          public boolean isTypeOrSubtype(Name nodeTypeName,
                                Name candidateSupertypeName)

      Determine whether the node's given node type matches or extends the node type with the supplied name.
      Parameters:
        `nodeTypeName` - the name of the node type of a node; may not be null
        `candidateSupertypeName` - the name of the potential supertype node type; may not be null
      Returns:
        true if the node type does extend or match the node type given by the supplied name, or false otherwise

    - #### isTypeOrSubtype

          public boolean isTypeOrSubtype(Set<Name> nodeTypeNames,
                                Name candidateSupertypeName)

      Determine whether at least one of the node's given node types matches or extends the node type with the supplied name.
      Parameters:
        `nodeTypeNames` - the names of the node types of a node; may not be null
        `candidateSupertypeName` - the name of the potential supertype node type; may not be null
      Returns:
        true if the node type does extend or match the node type given by at least one of the supplied names, or false otherwise

    - #### isTypeOrSubtype

          public boolean isTypeOrSubtype(Name[] nodeTypeNames,
                                Name candidateSupertypeName)

      Determine whether at least one of the node's given node types matches or extends the node type with the supplied name.
      Parameters:
        `nodeTypeNames` - the names of the node types of a node; may not be null
        `candidateSupertypeName` - the name of the potential supertype node type; may not be null
      Returns:
        true if the node type does extend or match the node type given by at least one of the supplied names, or false otherwise

    - #### isCreated

          public boolean isCreated(Name primaryType,
                          Set<Name> mixinTypes)

      Determine if at least one of the named primary node type or mixin types is or subtypes the 'mix:created' mixin type.
      Parameters:
        `primaryType` - the primary type name; may not be null
        `mixinTypes` - the mixin type names; may be null or empty
      Returns:
        true if any of the named node types is a created type, or false if there are none

    - #### isLastModified

          public boolean isLastModified(Name primaryType,
                               Set<Name> mixinTypes)

      Determine if at least one of the named primary node type or mixin types is or subtypes the 'mix:lastModified' mixin type.
      Parameters:
        `primaryType` - the primary type name; may not be null
        `mixinTypes` - the mixin type names; may be null or empty
      Returns:
        true if any of the named node types is a last-modified type, or false if there are none

    - #### isNtResource

          public boolean isNtResource(Name primaryType)

      Determine if the named primary node type is or subtypes the 'nt:resource' node type.
      Parameters:
        `primaryType` - the primary type name; may not be null
      Returns:
        true if the primary node type is an 'nt:resource' node type (or subtype), or false otherwise

    - #### isETag

          public boolean isETag(Name primaryType,
                       Set<Name> mixinTypes)

      Determine if at least one of the named primary node type or mixin types is or subtypes the 'mix:etag' mixin type.
      Parameters:
        `primaryType` - the primary type name; may not be null
        `mixinTypes` - the mixin type names; may be null or empty
      Returns:
        true if any of the named node types has an ETag, or false if there are none

    - #### isReferenceable

          public boolean isReferenceable(Name primaryType,
                                Set<Name> mixinTypes)

      Determine if at least one of the named primary node type or mixin types is or subtypes the 'mix:referenceable' mixin type.
      Parameters:
        `primaryType` - the primary type name; may not be null
        `mixinTypes` - the mixin type names; may be null or empty
      Returns:
        true if the primary node type is an 'mix:referenceable' node type (or subtype), or false otherwise

    - #### disallowsSameNameSiblings

          public boolean disallowsSameNameSiblings(Name primaryType,
                                          Set<Name> mixinTypes)

    - #### isVersionable

          public boolean isVersionable(Name primaryType,
                              Set<Name> mixinTypes)

      Determine if at least one of the named primary node type or mixin types is or subtypes the 'mix:versionable' mixin type.
      Parameters:
        `primaryType` - the primary type name; may be null
        `mixinTypes` - the mixin type names; may not be null but may be empty
      Returns:
        true if any of the named node types is versionable, or false if there are none

    - #### hasMandatoryPropertyDefinitions

          public boolean hasMandatoryPropertyDefinitions(Name primaryType,
                                                Set<Name> mixinTypes)

      Determine if the named primary node type or mixin types has at least one mandatory property definitions declared on it or any of its supertypes.
      Parameters:
        `primaryType` - the primary type name; may not be null
        `mixinTypes` - the mixin type names; may not be null but may be empty
      Returns:
        true if any of the named node types has one or more mandatory property definitions, or false if there are none

    - #### hasMandatoryChildNodeDefinitions

          public boolean hasMandatoryChildNodeDefinitions(Name primaryType,
                                                 Set<Name> mixinTypes)

      Determine if the named primary node type or mixin types has at least one mandatory child node definitions declared on it or any of its supertypes.
      Parameters:
        `primaryType` - the primary type name; may not be null
        `mixinTypes` - the mixin type names; may not be null but may be empty
      Returns:
        true if any of the the named node types has one or more mandatory child node definitions, or false if there are none

    - #### getMandatoryPropertyDefinitions

          public Collection<org.modeshape.jcr.JcrPropertyDefinition> getMandatoryPropertyDefinitions(Name primaryType,
                                                                                            Set<Name> mixinTypes)

      Get the mandatory property definitions for a node with the named primary type and mixin types. Note that the `hasMandatoryPropertyDefinitions(Name, Set)` method should first be called with the primary type and mixin types; if that method returns `true`, then this method will never return an empty collection.
      Parameters:
        `primaryType` - the primary type name; may not be null
        `mixinTypes` - the mixin type names; may not be null but may be empty
      Returns:
        the collection of mandatory property definitions; never null but possibly empty

    - #### getMandatoryChildNodeDefinitions

          public Collection<org.modeshape.jcr.JcrNodeDefinition> getMandatoryChildNodeDefinitions(Name primaryType,
                                                                                         Set<Name> mixinTypes)

      Get the mandatory child node definitions for a node with the named primary type and mixin types. Note that the `hasMandatoryChildNodeDefinitions(Name, Set)` method should first be called with the primary type and mixin types; if that method returns `true`, then this method will never return an empty collection.
      Parameters:
        `primaryType` - the primary type name; may not be null
        `mixinTypes` - the mixin type names; may not be null but may be empty
      Returns:
        the collection of mandatory child node definitions; never null but possibly empty

    - #### getAutoCreatedPropertyDefinitions

          public Collection<org.modeshape.jcr.JcrPropertyDefinition> getAutoCreatedPropertyDefinitions(Name nodeType)

      Get the auto-created property definitions for the named node type. This method is used when `creating nodes`, which only needs the auto-created properties for the primary type. It's also used when `adding a mixin`.
      Parameters:
        `nodeType` - the node type name; may not be null
      Returns:
        the collection of auto-created property definitions; never null but possibly empty

    - #### getAutoCreatedChildNodeDefinitions

          public Collection<org.modeshape.jcr.JcrNodeDefinition> getAutoCreatedChildNodeDefinitions(Name nodeType)

      Get the auto-created child node definitions for the named node type. This method is used when `creating nodes`, which only needs the auto-created properties for the primary type. It's also used when `adding a mixin`.
      Parameters:
        `nodeType` - the node type name; may not be null
      Returns:
        the collection of auto-created child node definitions; never null but possibly empty

    - #### getAllNodeTypes

          public Collection<org.modeshape.jcr.JcrNodeType> getAllNodeTypes()

      Return the immutable list of node types that are currently registered in this node type manager.
      Returns:
        the immutable collection of (immutable) node types; never null

    - #### getAllNodeTypeNames

          public Set<Name> getAllNodeTypeNames()

      Return an immutable snapshot of the names of the node types currently registered in this node type manager.
      Returns:
        the immutable collection of (immutable) node type names; never null

    - #### getMixinNodeTypes

          public Collection<org.modeshape.jcr.JcrNodeType> getMixinNodeTypes()

      Return an immutable snapshot of the mixin node types that are currently registered in this node type manager.
      Returns:
        the immutable collection of (immutable) mixin node types; never null
      See Also:
        `getPrimaryNodeTypes()`

    - #### isMixin

          public boolean isMixin(Name nodeTypeName)

      Determine whether the node type given by the supplied name is a mixin node type.
      Parameters:
        `nodeTypeName` - the name of the node type
      Returns:
        true if there is an existing mixin node type with the supplied name, or false otherwise

    - #### getPrimaryNodeTypes

          public Collection<org.modeshape.jcr.JcrNodeType> getPrimaryNodeTypes()

      Return an immutable snapshot of the primary node types that are currently registered in this node type manager.
      Returns:
        the immutable collection of (immutable) primary node types; never null
      See Also:
        `getMixinNodeTypes()`

    - #### getPropertyDefinition

          public org.modeshape.jcr.JcrPropertyDefinition getPropertyDefinition(org.modeshape.jcr.PropertyDefinitionId id)

    - #### getAllPropertyDefinitions

          public Collection<org.modeshape.jcr.JcrPropertyDefinition> getAllPropertyDefinitions()

    - #### getChildNodeDefinition

          public org.modeshape.jcr.JcrNodeDefinition getChildNodeDefinition(org.modeshape.jcr.NodeDefinitionId id)

    - #### findChildNodeDefinitionForUnstructured

          protected final org.modeshape.jcr.JcrNodeDefinition findChildNodeDefinitionForUnstructured(boolean requireSns)

    - #### findTypeInMapOrList

          protected org.modeshape.jcr.JcrNodeType findTypeInMapOrList(Name typeName,
                                                          Collection<org.modeshape.jcr.JcrNodeType> pendingList)

      Finds the named type in the given collection of types pending registration if it exists, else returns the type definition from the repository
      Parameters:
        `typeName` - the name of the type to retrieve
        `pendingList` - a collection of types that have passed validation but have not yet been committed to the repository
      Returns:
        the node type with the given name from `pendingList` if it exists in the collection or from the `registered types` if it exists there; may be null

    - #### supertypesFor

          protected List<org.modeshape.jcr.JcrNodeType> supertypesFor(NodeTypeDefinition nodeType,
                                                          Collection<org.modeshape.jcr.JcrNodeType> pendingTypes)
                                                               throws RepositoryException

      Returns the list of node types for the supertypes defined in the given node type.
      Parameters:
        `nodeType` - a node type with a non-null array of supertypes
        `pendingTypes` - the list of types that have been processed in this type batch but not yet committed to the repository's set of types
      Returns:
        a list of node types where each element is the node type for the corresponding element of the array of supertype names
      Throws:
        `RepositoryException` - if any of the names in the array of supertype names does not correspond to an already-registered node type or a node type that is pending registration

    - #### validate

          protected void validate(org.modeshape.jcr.JcrNodeType nodeType,
                      List<org.modeshape.jcr.JcrNodeType> supertypes,
                      List<org.modeshape.jcr.JcrNodeType> pendingTypes)
                           throws RepositoryException

      Validates that the given node type definition is valid under the ModeShape and JCR type rules within the given context.
      Parameters:
        `nodeType` - the node type to attempt to validate
        `supertypes` - the names of the supertypes of the node type
        `pendingTypes` - the list of types previously registered in this batch but not yet committed to the repository
      Throws:
        `RepositoryException` - if the given node type template is not valid

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.