|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.dna.jcr.CndNodeTypeSource
@Immutable public class CndNodeTypeSource
Class to parse one or more Compact Node Definition (CND) files containing custom node type definitions into a format that can
be registered with the JcrNodeTypeManager
.
The class contains methods for determining whether the CND files were parsed successfully and what errors occurred. Typically, the class will be used like this:
try { String[] cndFilePaths = // The URIs for the resource files on the classpath JcrNodeTypeSource nodeTypeSource = new CndNodeTypeSource(cndFilePaths); if (!nodeTypeSource.isValid()) { Problems problems = nodeTypeSource.getProblems(); // Report problems } else { jcrNodeTypeManager.registerNodeTypes(nodeTypeSource); } } catch (IOException ioe) { System.err.println("Could not find one of the CND files."); ioe.printStackTrace(); }
Constructor Summary | |
---|---|
CndNodeTypeSource(String resourceName)
Creates a new JcrNodeTypeSource with based on the CND file with the given resource name. |
|
CndNodeTypeSource(String[] resourceNames)
Creates a new JcrNodeTypeSource based on the CND files at the given resource names. |
Method Summary | |
---|---|
Graph |
getNodeTypes()
Returns the node type information to be registered in graph form. |
Problems |
getProblems()
Returns the problems (if any) that were encountered parsing the CND files. |
boolean |
isValid()
Returns true if no errors were encountered while parsing the CND file or files |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CndNodeTypeSource(String resourceName) throws IOException
JcrNodeTypeSource
with based on the CND file with the given resource name.
resourceName
- the name of the resource; this resource must be on the classpath
IOException
- if an error loading or reading the resource occurspublic CndNodeTypeSource(String[] resourceNames) throws IOException
JcrNodeTypeSource
based on the CND files at the given resource names.
resourceNames
- the name of the resources to load; these resources must be on the classpath
IOException
- if an error loading or reading the any of the resources occursMethod Detail |
---|
public boolean isValid()
public Problems getProblems()
public final Graph getNodeTypes()
The root node of the graph should have zero or more children. Each child of the root node represents a type to be
registered and the name of the node should be the name of the node type to be registered. Additionally, any facets of the
node type that are specified should be set in a manner consistent with the JCR specification for the nt:nodeType
built-in node type. The jcr:primaryType
property does not need to be set on these nodes, but the nodes must be
semantically valid as if the jcr:primaryType
property was set.
Each node type node may have zero or more children, each with the name jcr:propertyDefinition
or jcr:childNodeDefinition
, as per the definition of the nt:nodeType
built-in type. Each property definition and
child node definition must obey the semantics of jcr:propertyDefinition
and jcr:childNodeDefinition
respectively However these nodes also do not need to have the jcr:primaryType
property set.
For example, one valid graph is:
<root> +---- test:testMixinType +--- jcr:nodeTypeName = test:testMixinType (PROPERTY) +--- jcr:isMixin = true (PROPERTY) +--- jcr:childNodeDefinition (CHILD NODE) | +--- jcr:name = test:childNodeA (PROPERTY) | +--- jcr:mandatory = true (PROPERTY) | +--- jcr:autoCreated = true (PROPERTY) | +--- jcr:defaultPrimaryType = nt:base (PROPERTY) | +--- jcr:requiredPrimaryTypes = nt:base (PROPERTY) +--- jcr:propertyDefinition (CHILD NODE) +--- jcr:name = test:propertyA (PROPERTY) +--- jcr:multiple = true (PROPERTY) +--- jcr:requiredType = String (PROPERTY)This graph (when registered) would create a mixin node named "test:testMixinType" with a mandatory, autocreated child node named "test:childNodeA" with a default and required primary type of "nt:base" and a multi-valued string property named "test:propertyA".
getNodeTypes
in interface JcrNodeTypeSource
JcrNodeTypeSource.getNodeTypes()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |