|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.jcr.CndNodeTypeReader
NodeTypeManager.registerNodeTypes(java.io.InputStream, boolean)
instead
@Deprecated public class CndNodeTypeReader
A class that reads files in the standard CND format defined by the JCR 2.0 specification.
Typically, the class will be used like this:
Session session = ... CndNodeTypeReader reader = new CndNodeTypeReader(session); reader.read(file); // or stream or resource file if (!reader.getProblems().isEmpty()) { // Report problems } else { boolean allowUpdate = false; session.getWorkspace().getNodeTypeManager().registerNodeTypes(reader.getNodeTypeDefinitions(), allowUpdate); }
Field Summary | |
---|---|
protected ValueFactory<Boolean> |
booleanFactory
|
protected ExecutionContext |
context
|
protected List<NodeTypeDefinition> |
immutableTypes
|
protected NameFactory |
nameFactory
|
protected PathFactory |
pathFactory
|
protected Problems |
problems
|
protected Path |
root
|
protected ValueFactory<String> |
stringFactory
|
protected List<NodeTypeDefinition> |
types
|
protected ValueFactories |
valueFactories
|
Constructor Summary | |
---|---|
CndNodeTypeReader(ExecutionContext context)
Deprecated. Create a new node type factory that reads CND files. |
|
CndNodeTypeReader(Session session)
Deprecated. Create a new node type factory that reads CND files. |
Method Summary | |
---|---|
protected NodeDefinitionTemplate |
childNodeDefinitionFrom(Subgraph nodeTypeGraph,
Location childNodeLocation)
|
ExecutionContext |
getExecutionContext()
Get the execution context used by this reader. |
NamespaceRegistry |
getNamespaceRegistry()
Get the namespace registry used by this reader. |
Set<NamespaceRegistry.Namespace> |
getNamespaces()
Get the namespaces that were created when reading in node types. |
NodeTypeDefinition[] |
getNodeTypeDefinitions()
Deprecated. Returns the node type definitions created by this factory. |
Problems |
getProblems()
Deprecated. Get the problems where warnings and error messages were recorded by this factory. |
protected void |
importFrom(Destination destination,
Path path,
String content,
String resourceName)
Deprecated. Method that loads into the graph destination the content containing the node type definitions. |
Iterator<NodeTypeDefinition> |
iterator()
Deprecated. |
protected Name |
name(String name)
|
protected Name |
nameFrom(SubgraphNode node)
|
protected NodeTypeTemplate |
nodeTypeFrom(SubgraphNode nodeTypeNode,
Subgraph subgraph)
|
protected PropertyDefinitionTemplate |
propertyDefinitionFrom(Subgraph nodeTypeGraph,
Location propertyLocation)
|
void |
read(File file)
Deprecated. Import the node types from the supplied file and add all of the node type definitions to this factory's list. |
void |
read(Graph graph,
Path parentOfTypes,
Collection<Name> nodeTypesToRead,
String resourceName)
Import the node types from the supplied location in the specified graph. |
void |
read(Graph graph,
Path parentOfTypes,
String resourceName)
Deprecated. Import the node types from the supplied location in the specified graph. |
void |
read(InputStream stream,
String resourceName)
Deprecated. Import the node types from the supplied stream and add all of the node type definitions to this factory's list. |
void |
read(String resourceFile)
Deprecated. Import the node types from the file at the supplied path, and add all of the node type definitions to this factory's list. |
void |
read(String content,
String resourceName)
Deprecated. Import the node types from the supplied string and add all of the node type definitions to this factory's list. |
void |
read(Subgraph subgraph,
Location locationOfParent,
String resourceName)
Deprecated. Import the node types from the supplied location in the specified graph. |
void |
read(URL url)
Deprecated. Import the node types from the file at the supplied URL and add all of the node type definitions to this factory's list. |
protected boolean |
readBoolean(SubgraphNode node,
Name propertyName,
boolean defaultValue)
|
protected boolean |
readBoolean(SubgraphNode node,
String propertyName,
boolean defaultValue)
|
protected void |
readBuiltInTypes()
Deprecated. |
protected Name |
readName(SubgraphNode node,
Name propertyName,
Name defaultValue)
|
protected Name |
readName(SubgraphNode node,
String propertyName,
Name defaultValue)
|
protected List<Name> |
readNames(SubgraphNode node,
Name propertyName,
Name defaultIfNone)
|
protected List<Name> |
readNames(SubgraphNode node,
String propertyName,
Name defaultIfNone)
|
protected String |
readString(SubgraphNode node,
Name propertyName,
String defaultValue)
|
protected String |
readString(SubgraphNode node,
String propertyName,
String defaultValue)
|
protected List<String> |
readStrings(SubgraphNode node,
Name propertyName)
|
protected List<String> |
readStrings(SubgraphNode node,
String propertyName)
|
protected List<NodeTypeDefinition> |
readTypesFrom(Graph graph,
Path parentOfTypes,
Collection<Name> nodeTypesToRead)
|
protected List<NodeTypeDefinition> |
readTypesFrom(Subgraph nodeTypeSubgraph,
Location locationOfParentOfNodeTypes,
Collection<Name> nodeTypesToRead)
|
protected List<Value> |
readValues(SubgraphNode node,
Name propertyName,
int requiredType)
|
protected String |
string(Object value)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Problems problems
protected final List<NodeTypeDefinition> types
protected final List<NodeTypeDefinition> immutableTypes
protected final ExecutionContext context
protected final ValueFactories valueFactories
protected final PathFactory pathFactory
protected final NameFactory nameFactory
protected final ValueFactory<Boolean> booleanFactory
protected final ValueFactory<String> stringFactory
protected final Path root
Constructor Detail |
---|
public CndNodeTypeReader(Session session)
session
- the session that will be used to register the node types; may not be nullpublic CndNodeTypeReader(ExecutionContext context)
context
- the context that will be used to load the node types; may not be nullMethod Detail |
---|
public void read(InputStream stream, String resourceName) throws IOException
stream
- the stream containing the node typesresourceName
- a logical name for the resource name to be used when reporting problems; may be null if there is no
useful name
IOException
- if there is a problem reading from the supplied streampublic void read(File file) throws IOException
file
- the file containing the node types
IllegalArgumentException
- if the supplied file reference is null, or if the file does not exist or is not readable
IOException
- if there is a problem reading from the supplied streampublic void read(URL url) throws IOException
url
- the URL to the file containing the node types
IllegalArgumentException
- if the supplied URL is null
IOException
- if there is a problem opening or reading the stream to the supplied URLpublic void read(String resourceFile) throws IOException
resourceFile
- the name of the resource file on the classpath containing the node types
IllegalArgumentException
- if the supplied string is null or empty
IOException
- if there is a problem reading from the supplied resource, or if the resource could not be foundpublic void read(String content, String resourceName)
content
- the string containing the node typesresourceName
- a logical name for the resource name to be used when reporting problems; may be null if there is no
useful namepublic void read(Graph graph, Path parentOfTypes, String resourceName)
graph
- the graph containing the standard ModeShape CND contentparentOfTypes
- the path to the parent of the node type definition nodesresourceName
- a logical name for the resource name to be used when reporting problems; may be null if there is no
useful namepublic void read(Subgraph subgraph, Location locationOfParent, String resourceName)
subgraph
- the subgraph containing the standard ModeShape CND contentlocationOfParent
- the location to the parent of the node type definition nodesresourceName
- a logical name for the resource name to be used when reporting problems; may be null if there is no
useful namepublic Problems getProblems()
public NodeTypeDefinition[] getNodeTypeDefinitions()
NodeTypeDefinition
spublic Iterator<NodeTypeDefinition> iterator()
iterator
in interface Iterable<NodeTypeDefinition>
Iterable.iterator()
protected void readBuiltInTypes() throws IOException
IOException
protected void importFrom(Destination destination, Path path, String content, String resourceName) throws Exception
destination
- the destination to which the node type content should be written; never nullpath
- the path within the destination at which the node type content should be rooted; never nullcontent
- the content containing some string representation of the node types to be imported; never nullresourceName
- a descriptive name for this import (used only for error messages); may be null
Exception
- if there is a problem importing from the content; this will be automatically recorded in the problemsGraphNodeTypeReader.importFrom(org.modeshape.graph.io.Destination,
org.modeshape.graph.property.Path, java.lang.String, java.lang.String)
public void read(Graph graph, Path parentOfTypes, Collection<Name> nodeTypesToRead, String resourceName)
graph
- the graph containing the standard ModeShape CND contentparentOfTypes
- the path to the parent of the node type definition nodesnodeTypesToRead
- the names of the node types that should be read; null means that all node types should be readresourceName
- a logical name for the resource name to be used when reporting problems; may be null if there is no
useful namepublic ExecutionContext getExecutionContext()
NamespaceRegistry
. This prevents the reader from modifying the registry in the supplied context.
public NamespaceRegistry getNamespaceRegistry()
public Set<NamespaceRegistry.Namespace> getNamespaces()
protected List<NodeTypeDefinition> readTypesFrom(Graph graph, Path parentOfTypes, Collection<Name> nodeTypesToRead)
protected List<NodeTypeDefinition> readTypesFrom(Subgraph nodeTypeSubgraph, Location locationOfParentOfNodeTypes, Collection<Name> nodeTypesToRead)
protected NodeTypeTemplate nodeTypeFrom(SubgraphNode nodeTypeNode, Subgraph subgraph) throws ConstraintViolationException
ConstraintViolationException
protected PropertyDefinitionTemplate propertyDefinitionFrom(Subgraph nodeTypeGraph, Location propertyLocation) throws ConstraintViolationException
ConstraintViolationException
protected NodeDefinitionTemplate childNodeDefinitionFrom(Subgraph nodeTypeGraph, Location childNodeLocation) throws ConstraintViolationException
ConstraintViolationException
protected Name nameFrom(SubgraphNode node)
protected Name name(String name)
protected String string(Object value)
protected boolean readBoolean(SubgraphNode node, String propertyName, boolean defaultValue)
protected boolean readBoolean(SubgraphNode node, Name propertyName, boolean defaultValue)
protected String readString(SubgraphNode node, String propertyName, String defaultValue)
protected String readString(SubgraphNode node, Name propertyName, String defaultValue)
protected List<String> readStrings(SubgraphNode node, String propertyName)
protected List<String> readStrings(SubgraphNode node, Name propertyName)
protected List<Value> readValues(SubgraphNode node, Name propertyName, int requiredType)
protected Name readName(SubgraphNode node, String propertyName, Name defaultValue)
protected Name readName(SubgraphNode node, Name propertyName, Name defaultValue)
protected List<Name> readNames(SubgraphNode node, String propertyName, Name defaultIfNone)
protected List<Name> readNames(SubgraphNode node, Name propertyName, Name defaultIfNone)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |