@NotThreadSafe public class CndImporter extends Object
NodeTypeDefinition
instances.Modifier and Type | Field and Description |
---|---|
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 static String |
JSR283_BUILTINS |
protected LocalNamespaceRegistry |
localRegistry |
protected static String |
MODESHAPE_BUILT_INS |
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 and Description |
---|
CndImporter(ExecutionContext context)
Create a new importer that will place the content in the supplied destination under the supplied path.
|
Modifier and Type | Method and Description |
---|---|
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) |
protected static final String MODESHAPE_BUILT_INS
protected static final String JSR283_BUILTINS
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 List<NodeTypeDefinition> nodeTypes
public CndImporter(ExecutionContext context)
context
- the context in which the importing should be performed; may not be nullpublic 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 nameIOException
- 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 reportedIOException
- 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 contentParsingException
- if there is a problem parsing the contentprotected void parseNamespaceMapping(TokenStream tokens)
tokens
- the tokens containing the namespace statement; never nullParsingException
- if there is a problem parsing the contentprotected void parseNodeTypeDefinition(TokenStream tokens)
tokens
- the tokens containing the node type definition; never nullParsingException
- if there is a problem parsing the contentprotected Name parseNodeTypeName(TokenStream tokens)
tokens
- the tokens containing the node type name; never nullParsingException
- if there is a problem parsing the contentprotected List<Name> parseSupertypes(TokenStream tokens)
tokens
- the tokens containing the supertype names; never nullParsingException
- if there is a problem parsing the contentprotected List<String> parseStringList(TokenStream tokens)
tokens
- the tokens containing the comma-separated strings; never nullParsingException
- if there is a problem parsing the contentprotected List<Name> parseNameList(TokenStream tokens)
tokens
- the tokens containing the comma-separated strings; never nullParsingException
- 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 nullParsingException
- if there is a problem parsing the contentConstraintViolationException
- not expectedprotected void parsePropertyOrChildNodeDefinitions(TokenStream tokens, JcrNodeTypeTemplate nodeType) throws ConstraintViolationException
tokens
- the tokens containing the definitions; never nullnodeType
- the node type being created; never nullParsingException
- if there is a problem parsing the contentConstraintViolationException
- not expectedprotected void parsePropertyDefinition(TokenStream tokens, JcrNodeTypeTemplate nodeType) throws ConstraintViolationException
tokens
- the tokens containing the definition; never nullnodeType
- the node type definition; never nullParsingException
- if there is a problem parsing the contentConstraintViolationException
- 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 foundParsingException
- 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 nullParsingException
- 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 nullParsingException
- 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 nullParsingException
- if there is a problem parsing the contentConstraintViolationException
- not expectedprotected void parseQueryOperators(TokenStream tokens, org.modeshape.jcr.JcrPropertyDefinitionTemplate propDefn)
tokens
- the tokens containing the definition; never nullpropDefn
- the property definition; never nullParsingException
- 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 nullParsingException
- if there is a problem parsing the contentConstraintViolationException
- 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 nullParsingException
- if there is a problem parsing the contentConstraintViolationException
- 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 nullParsingException
- if there is a problem parsing the contentConstraintViolationException
- 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 nullParsingException
- if there is a problem parsing the contentConstraintViolationException
- not expectedprotected Name parseName(TokenStream tokens)
tokens
- the tokens containing the name; never nullParsingException
- if there is a problem parsing the contentprotected 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 stringprotected final Property parseVendorExtensionContent(String vendorExtension)
vendorExtension
- the vendor extension string; never nullprotected 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[] names(Collection<Name> names)
protected final String[] strings(Collection<String> values)
protected final Value[] values(Collection<String> values)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.