|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.jcr.CndImporter
@NotThreadSafe public class CndImporter
A class that imports the node types contained in a JCR Compact Node Definition (CND) file into NodeTypeDefinition
instances.
Field Summary | |
---|---|
protected List<String> |
BUILT_INS
|
protected ExecutionContext |
context
|
static boolean |
DEFAULT_COMPATIBLE_WITH_PREJCR2
The default flag for supporting pre-JCR 2.0 CND format is true . |
static boolean |
DEFAULT_USE_VENDOR_EXTENSIONS
The default flag for using vendor extensions is true . |
protected boolean |
jcr170
|
protected LocalNamespaceRegistry |
localRegistry
|
protected NameFactory |
nameFactory
|
protected List<NodeTypeDefinition> |
nodeTypes
|
protected ValueFactory<String> |
stringFactory
|
protected List<String> |
VALID_ON_PARENT_VERSION
|
protected List<String> |
VALID_PROPERTY_TYPES
|
protected Set<String> |
VALID_QUERY_OPERATORS
|
protected ValueFactory |
valueFactory
|
protected Pattern |
VENDOR_PATTERN
|
protected String |
VENDOR_PATTERN_STRING
The regular expression used to capture the vendor property name and the value. |
Constructor Summary | |
---|---|
CndImporter(ExecutionContext context,
boolean compatibleWithPreJcr2)
Create a new importer that will place the content in the supplied destination under the supplied path. |
Method Summary | |
---|---|
protected void |
applyVendorExtensions(org.modeshape.jcr.JcrNodeDefinitionTemplate childDefn,
List<Property> extensions)
Method that is responsible for setting the vendor extensions on the supplied child node type template. |
protected void |
applyVendorExtensions(JcrNodeTypeTemplate nodeType,
List<Property> extensions)
Method that is responsible for setting the vendor extensions on the supplied node type template. |
protected void |
applyVendorExtensions(org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn,
List<Property> extensions)
Method that is responsible for setting the vendor extensions on the supplied property definition template. |
Set<NamespaceRegistry.Namespace> |
getNamespaces()
|
List<NodeTypeDefinition> |
getNodeTypeDefinitions()
|
void |
importBuiltIns(Problems problems)
|
void |
importFrom(File file,
Problems problems)
Import the CND content from the supplied stream, placing the content into the importer's destination. |
void |
importFrom(InputStream stream,
Problems problems,
String resourceName)
Import the CND content from the supplied stream, placing the content into the importer's destination. |
void |
importFrom(String content,
Problems problems,
String resourceName)
Import the CND content from the supplied stream, placing the content into the importer's destination. |
protected String[] |
names(Collection<Name> names)
|
protected void |
parse(String content)
Parse the CND content. |
protected void |
parseChildNodeDefinition(TokenStream tokens,
JcrNodeTypeTemplate nodeType)
Parse a node type's child node definition from the next tokens on the stream. |
protected void |
parseDefaultType(TokenStream tokens,
org.modeshape.jcr.JcrNodeDefinitionTemplate childDefn)
Parse the child node definition's default type, if they appear next on the token stream. |
protected void |
parseDefaultValues(TokenStream tokens,
org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn)
Parse the property definition's default value, if they appear next on the token stream. |
protected Name |
parseName(TokenStream tokens)
Parse the name that is expected to be next on the token stream. |
protected List<Name> |
parseNameList(TokenStream tokens)
Parse a list of names, separated by commas. |
protected void |
parseNamespaceMapping(TokenStream tokens)
Parse the namespace mapping statement that is next on the token stream. |
protected void |
parseNodeAttributes(TokenStream tokens,
org.modeshape.jcr.JcrNodeDefinitionTemplate childDefn,
JcrNodeTypeTemplate nodeType)
Parse the child node definition's attributes, if they appear next on the token stream. |
protected void |
parseNodeTypeDefinition(TokenStream tokens)
Parse the node type definition that is next on the token stream. |
protected Name |
parseNodeTypeName(TokenStream tokens)
Parse a node type name that appears next on the token stream. |
protected void |
parseNodeTypeOptions(TokenStream tokens,
JcrNodeTypeTemplate nodeType)
Parse the options for the node types, including whether the node type is orderable, a mixin, abstract, whether it supports querying, and which property/child node (if any) is the primary item for the node type. |
protected void |
parsePropertyAttributes(TokenStream tokens,
org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn,
JcrNodeTypeTemplate nodeType)
Parse the property definition's attributes, if they appear next on the token stream. |
protected void |
parsePropertyDefinition(TokenStream tokens,
JcrNodeTypeTemplate nodeType)
Parse a node type's property definition from the next tokens on the stream. |
protected void |
parsePropertyOrChildNodeDefinitions(TokenStream tokens,
JcrNodeTypeTemplate nodeType)
Parse a node type's property or child node definitions that appear next on the token stream. |
protected void |
parsePropertyType(TokenStream tokens,
org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn,
String defaultPropertyType)
Parse the property type, if a valid one appears next on the token stream. |
protected void |
parseQueryOperators(TokenStream tokens,
org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn)
Parse the property definition's query operators, if they appear next on the token stream. |
protected void |
parseRequiredPrimaryTypes(TokenStream tokens,
org.modeshape.jcr.JcrNodeDefinitionTemplate childDefn)
Parse the child node definition's list of required primary types, if they appear next on the token stream. |
protected List<String> |
parseStringList(TokenStream tokens)
Parse a list of strings, separated by commas. |
protected List<Name> |
parseSupertypes(TokenStream tokens)
Parse an optional list of supertypes if they appear next on the token stream. |
protected void |
parseValueConstraints(TokenStream tokens,
org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn)
Parse the property definition's value constraints, if they appear next on the token stream. |
protected Property |
parseVendorExtension(String vendorExtension)
Parse the vendor extension, including the curly braces in the CND content. |
protected Property |
parseVendorExtensionContent(String vendorExtension)
Parse the content of the vendor extension excluding the curly braces in the CND content. |
protected void |
parseVendorExtensions(TokenStream tokens,
List<Property> properties)
Parse the vendor extensions that may appear next on the tokenzied stream. |
protected String |
removeQuotes(String text)
|
protected String |
string(Object name)
|
protected String[] |
strings(Collection<String> values)
|
protected Value[] |
values(Collection<String> values)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final List<String> VALID_PROPERTY_TYPES
protected final List<String> VALID_ON_PARENT_VERSION
protected final Set<String> VALID_QUERY_OPERATORS
protected final List<String> BUILT_INS
public static final boolean DEFAULT_USE_VENDOR_EXTENSIONS
public static final boolean DEFAULT_COMPATIBLE_WITH_PREJCR2
protected final String VENDOR_PATTERN_STRING
([^\s]+)(\s+(.*))
".
protected final Pattern VENDOR_PATTERN
protected final ExecutionContext context
protected final LocalNamespaceRegistry localRegistry
protected final NameFactory nameFactory
protected final ValueFactory<String> stringFactory
protected final ValueFactory valueFactory
protected final boolean jcr170
protected final List<NodeTypeDefinition> nodeTypes
Constructor Detail |
---|
public CndImporter(ExecutionContext context, boolean compatibleWithPreJcr2)
context
- the context in which the importing should be performed; may not be nullcompatibleWithPreJcr2
- true if this parser should accept the CND format that was used in the reference implementation
prior to JCR 2.0.Method Detail |
---|
public void importFrom(InputStream stream, Problems problems, String resourceName) throws IOException
stream
- the stream containing the CND contentproblems
- where any problems encountered during import should be reportedresourceName
- 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 importFrom(File file, Problems problems) throws IOException
file
- the file containing the CND contentproblems
- where any problems encountered during import should be reported
IOException
- if there is a problem reading from the supplied streampublic void importFrom(String content, Problems problems, String resourceName)
content
- the string containing the CND contentproblems
- where any problems encountered during import should be reportedresourceName
- a logical name for the resource name to be used when reporting problems; may be null if there is no
useful namepublic void importBuiltIns(Problems problems) throws IOException
IOException
public Set<NamespaceRegistry.Namespace> getNamespaces()
public List<NodeTypeDefinition> getNodeTypeDefinitions()
protected void parse(String content)
content
- the content
ParsingException
- if there is a problem parsing the contentprotected void parseNamespaceMapping(TokenStream tokens)
tokens
- the tokens containing the namespace statement; never null
ParsingException
- if there is a problem parsing the contentprotected void parseNodeTypeDefinition(TokenStream tokens)
tokens
- the tokens containing the node type definition; never null
ParsingException
- if there is a problem parsing the contentprotected Name parseNodeTypeName(TokenStream tokens)
tokens
- the tokens containing the node type name; never null
ParsingException
- if there is a problem parsing the contentprotected List<Name> parseSupertypes(TokenStream tokens)
tokens
- the tokens containing the supertype names; never null
ParsingException
- if there is a problem parsing the contentprotected List<String> parseStringList(TokenStream tokens)
tokens
- the tokens containing the comma-separated strings; never null
ParsingException
- if there is a problem parsing the contentprotected List<Name> parseNameList(TokenStream tokens)
tokens
- the tokens containing the comma-separated strings; never null
ParsingException
- if there is a problem parsing the contentprotected void parseNodeTypeOptions(TokenStream tokens, JcrNodeTypeTemplate nodeType) throws ConstraintViolationException
tokens
- the tokens containing the comma-separated strings; never nullnodeType
- the node type being created; may not be null
ParsingException
- if there is a problem parsing the content
ConstraintViolationException
- not expectedprotected void parsePropertyOrChildNodeDefinitions(TokenStream tokens, JcrNodeTypeTemplate nodeType) throws ConstraintViolationException
tokens
- the tokens containing the definitions; never nullnodeType
- the node type being created; never null
ParsingException
- if there is a problem parsing the content
ConstraintViolationException
- not expectedprotected void parsePropertyDefinition(TokenStream tokens, JcrNodeTypeTemplate nodeType) throws ConstraintViolationException
tokens
- the tokens containing the definition; never nullnodeType
- the node type definition; never null
ParsingException
- if there is a problem parsing the content
ConstraintViolationException
- not expectedprotected void parsePropertyType(TokenStream tokens, org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn, String defaultPropertyType)
tokens
- the tokens containing the definition; never nullpropDefn
- the property definition; never nulldefaultPropertyType
- the default property type if none is actually found
ParsingException
- if there is a problem parsing the contentprotected void parseDefaultValues(TokenStream tokens, org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn)
tokens
- the tokens containing the definition; never nullpropDefn
- the property definition; never null
ParsingException
- if there is a problem parsing the contentprotected void parseValueConstraints(TokenStream tokens, org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn)
tokens
- the tokens containing the definition; never nullpropDefn
- the property definition; never null
ParsingException
- if there is a problem parsing the contentprotected void parsePropertyAttributes(TokenStream tokens, org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn, JcrNodeTypeTemplate nodeType) throws ConstraintViolationException
tokens
- the tokens containing the attributes; never nullpropDefn
- the property definition; never nullnodeType
- the node type; never null
ParsingException
- if there is a problem parsing the content
ConstraintViolationException
- not expectedprotected void parseQueryOperators(TokenStream tokens, org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn)
tokens
- the tokens containing the definition; never nullpropDefn
- the property definition; never null
ParsingException
- if there is a problem parsing the contentprotected void parseChildNodeDefinition(TokenStream tokens, JcrNodeTypeTemplate nodeType) throws ConstraintViolationException
tokens
- the tokens containing the definition; never nullnodeType
- the node type being created; never null
ParsingException
- if there is a problem parsing the content
ConstraintViolationException
- not expectedprotected void parseRequiredPrimaryTypes(TokenStream tokens, org.modeshape.jcr.JcrNodeDefinitionTemplate childDefn) throws ConstraintViolationException
tokens
- the tokens containing the definition; never nullchildDefn
- the child node definition; never null
ParsingException
- if there is a problem parsing the content
ConstraintViolationException
- not expectedprotected void parseDefaultType(TokenStream tokens, org.modeshape.jcr.JcrNodeDefinitionTemplate childDefn) throws ConstraintViolationException
tokens
- the tokens containing the definition; never nullchildDefn
- the child node definition; never null
ParsingException
- if there is a problem parsing the content
ConstraintViolationException
- not expectedprotected void parseNodeAttributes(TokenStream tokens, org.modeshape.jcr.JcrNodeDefinitionTemplate childDefn, JcrNodeTypeTemplate nodeType) throws ConstraintViolationException
tokens
- the tokens containing the attributes; never nullchildDefn
- the child node definition; never nullnodeType
- the node type being created; never null
ParsingException
- if there is a problem parsing the content
ConstraintViolationException
- not expectedprotected Name parseName(TokenStream tokens)
tokens
- the tokens containing the name; never null
ParsingException
- if there is a problem parsing the contentprotected final String removeQuotes(String text)
protected final void parseVendorExtensions(TokenStream tokens, List<Property> properties)
tokens
- token stream; may not be nullproperties
- the list of properties to which any vendor extension properties should be addedprotected final Property parseVendorExtension(String vendorExtension)
vendorExtension
- the vendor extension string
protected final Property parseVendorExtensionContent(String vendorExtension)
vendorExtension
- the vendor extension string; never null
protected void applyVendorExtensions(JcrNodeTypeTemplate nodeType, List<Property> extensions)
nodeType
- the node type definition; never nullextensions
- the extensions; never null but possibly emptyprotected void applyVendorExtensions(org.modeshape.jcr.JcrNodeDefinitionTemplate childDefn, List<Property> extensions)
childDefn
- the child definition; never nullextensions
- the extensions; never null but possibly emptyprotected void applyVendorExtensions(org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn, List<Property> extensions)
propDefn
- the property definition; never nullextensions
- the extensions; never null but possibly emptyprotected final String string(Object name)
protected final String[] names(Collection<Name> names)
protected final String[] strings(Collection<String> values)
protected final Value[] values(Collection<String> values)
|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |