Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.cnd
Class CndImporter

    java.lang.Object
      org.modeshape.cnd.CndImporter

    @NotThreadSafe
    public class CndImporter

extends Object

A class that imports the node types contained in a JCR Compact Node Definition (CND) file into graph content. The content is written using the graph structured defined by JCR and the "`nt:nodeType`", "`nt:propertyDefinition`", and " `nt:childNodeDefinition`" node types.

Although instances of this class never change their behavior and all processing is done in local contexts, `Destination` is not thread-safe and therefore this component may not be considered thread-safe.

Field Summary
`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 Destination` | `destination`
`protected boolean` | `jcr170`
`protected NameFactory` | `nameFactory`
`protected Path` | `outputPath`
`protected PathFactory` | `pathFactory`
`protected PropertyFactory` | `propertyFactory`
`protected boolean` | `useVendorExtensions`
`protected List<String>` | `VALID_ON_PARENT_VERSION`
`protected List<String>` | `VALID_PROPERTY_TYPES`
`protected Set<String>` | `VALID_QUERY_OPERATORS`
`protected ValueFactories` | `valueFactories`
`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(Destination destination, Path parentPath)` Create a new importer that will place the content in the supplied destination under the supplied path.
`CndImporter(Destination destination, Path parentPath, boolean compatibleWithPreJcr2)` Create a new importer that will place the content in the supplied destination under the supplied path.
`CndImporter(Destination destination, Path parentPath, boolean compatibleWithPreJcr2, boolean useVendorExtensions)` Create a new importer that will place the content in the supplied destination under the supplied path.

Method Summary
`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 void` | `parse(String content)` Parse the CND content.
`protected void` | `parseChildNodeDefinition(TokenStream tokens, Path nodeTypePath)` Parse a node type's child node definition from the next tokens on the stream.
`protected void` | `parseDefaultType(TokenStream tokens, List<Property> properties)` Parse the child node definition's default type, if they appear next on the token stream.
`protected void` | `parseDefaultValues(TokenStream tokens, List<Property> properties)` 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, List<Property> properties, Name childNodeDefnName, Path childNodeDefnPath)` Parse the child node definition's attributes, if they appear next on the token stream.
`protected void` | `parseNodeTypeDefinition(TokenStream tokens, Path path)` 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, List<Property> properties)` 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, List<Property> properties, Name propDefnName, Path propDefnPath)` Parse the property definition's attributes, if they appear next on the token stream.
`protected void` | `parsePropertyDefinition(TokenStream tokens, Path nodeTypePath)` Parse a node type's property definition from the next tokens on the stream.
`protected void` | `parsePropertyOrChildNodeDefinitions(TokenStream tokens, Path nodeTypePath)` Parse a node type's property or child node definitions that appear next on the token stream.
`protected void` | `parsePropertyType(TokenStream tokens, List<Property> properties, String defaultPropertyType)` Parse the property type, if a valid one appears next on the token stream.
`protected void` | `parseQueryOperators(TokenStream tokens, List<Property> properties)` Parse the property definition's query operators, if they appear next on the token stream.
`protected void` | `parseRequiredPrimaryTypes(TokenStream tokens, List<Property> properties)` 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, List<Property> properties)` 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)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### VALID_PROPERTY_TYPES

    protected final List<String> VALID_PROPERTY_TYPES

### VALID_ON_PARENT_VERSION

    protected final List<String> VALID_ON_PARENT_VERSION

### VALID_QUERY_OPERATORS

    protected final Set<String> VALID_QUERY_OPERATORS

### DEFAULT_USE_VENDOR_EXTENSIONS

    public static final boolean DEFAULT_USE_VENDOR_EXTENSIONS

  The default flag for using vendor extensions is true .

  See Also:
    Constant Field Values

### DEFAULT_COMPATIBLE_WITH_PREJCR2

    public static final boolean DEFAULT_COMPATIBLE_WITH_PREJCR2

  The default flag for supporting pre-JCR 2.0 CND format is true .

  See Also:
    Constant Field Values

### VENDOR_PATTERN_STRING

    protected final String VENDOR_PATTERN_STRING

  The regular expression used to capture the vendor property name and the value. The expression is " `([^\s]+)(\s+(.*))`".

  See Also:
    Constant Field Values

### VENDOR_PATTERN

    protected final Pattern VENDOR_PATTERN

### destination

    protected final Destination destination

### outputPath

    protected final Path outputPath

### propertyFactory

    protected final PropertyFactory propertyFactory

### pathFactory

    protected final PathFactory pathFactory

### nameFactory

    protected final NameFactory nameFactory

### valueFactories

    protected final ValueFactories valueFactories

### jcr170

    protected final boolean jcr170

### useVendorExtensions

    protected final boolean useVendorExtensions

Constructor Detail

### CndImporter

    public CndImporter(Destination destination,
                       Path parentPath,
                       boolean compatibleWithPreJcr2,
                       boolean useVendorExtensions)

  Create a new importer that will place the content in the supplied destination under the supplied path.

  Parameters:
    `destination` - the destination where content is to be written
    `parentPath` - the path in the destination below which the generated content is to appear
    `compatibleWithPreJcr2` - true if this parser should accept the CND format that was used in the reference implementation prior to JCR 2.0.
    `useVendorExtensions` - true if the vendor extensions should be used, or false if they should be ignored
  Throws:
    `IllegalArgumentException` - if either parameter is null

### CndImporter

    public CndImporter(Destination destination,
                       Path parentPath,
                       boolean compatibleWithPreJcr2)

  Create a new importer that will place the content in the supplied destination under the supplied path.

  Parameters:
    `destination` - the destination where content is to be written
    `parentPath` - the path in the destination below which the generated content is to appear
    `compatibleWithPreJcr2` - true if this parser should accept the CND format that was used in the reference implementation prior to JCR 2.0.
  Throws:
    `IllegalArgumentException` - if either parameter is null

### CndImporter

    public CndImporter(Destination destination,
                       Path parentPath)

  Create a new importer that will place the content in the supplied destination under the supplied path. This parser will accept the CND format that was used in the reference implementation prior to JCR 2.0, and will support vendor extensions.

  Parameters:
    `destination` - the destination where content is to be written
    `parentPath` - the path in the destination below which the generated content is to appear
  Throws:
    `IllegalArgumentException` - if either parameter is null

Method Detail

### importFrom

    public void importFrom(InputStream stream,
                           Problems problems,
                           String resourceName)
                    throws IOException

  Import the CND content from the supplied stream, placing the content into the importer's destination.

  Parameters:
    `stream` - the stream containing the CND content
    `problems` - where any problems encountered during import should be reported
    `resourceName` - a logical name for the resource name to be used when reporting problems; may be null if there is no useful name
  Throws:
    `IOException` - if there is a problem reading from the supplied stream

### importFrom

    public void importFrom(File file,
                           Problems problems)
                    throws IOException

  Import the CND content from the supplied stream, placing the content into the importer's destination.

  Parameters:
    `file` - the file containing the CND content
    `problems` - where any problems encountered during import should be reported
  Throws:
    `IOException` - if there is a problem reading from the supplied stream

### importFrom

    public void importFrom(String content,
                           Problems problems,
                           String resourceName)

  Import the CND content from the supplied stream, placing the content into the importer's destination.

  Parameters:
    `content` - the string containing the CND content
    `problems` - where any problems encountered during import should be reported
    `resourceName` - a logical name for the resource name to be used when reporting problems; may be null if there is no useful name

### parse

    protected void parse(String content)

  Parse the CND content.

  Parameters:
    `content` - the content
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseNamespaceMapping

    protected void parseNamespaceMapping(TokenStream tokens)

  Parse the namespace mapping statement that is next on the token stream.

  Parameters:
    `tokens` - the tokens containing the namespace statement; never null
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseNodeTypeDefinition

    protected void parseNodeTypeDefinition(TokenStream tokens,
                                           Path path)

  Parse the node type definition that is next on the token stream.

  Parameters:
    `tokens` - the tokens containing the node type definition; never null
    `path` - the path in the destination under which the node type definition should be stored; never null
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseNodeTypeName

    protected Name parseNodeTypeName(TokenStream tokens)

  Parse a node type name that appears next on the token stream.

  Parameters:
    `tokens` - the tokens containing the node type name; never null
  Returns:
    the node type name
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseSupertypes

    protected List<Name> parseSupertypes(TokenStream tokens)

  Parse an optional list of supertypes if they appear next on the token stream.

  Parameters:
    `tokens` - the tokens containing the supertype names; never null
  Returns:
    the list of supertype names; never null, but possibly empty
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseStringList

    protected List<String> parseStringList(TokenStream tokens)

  Parse a list of strings, separated by commas. Any quotes surrounding the strings are removed.

  Parameters:
    `tokens` - the tokens containing the comma-separated strings; never null
  Returns:
    the list of string values; never null, but possibly empty
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseNameList

    protected List<Name> parseNameList(TokenStream tokens)

  Parse a list of names, separated by commas. Any quotes surrounding the names are removed.

  Parameters:
    `tokens` - the tokens containing the comma-separated strings; never null
  Returns:
    the list of string values; never null, but possibly empty
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseNodeTypeOptions

    protected void parseNodeTypeOptions(TokenStream tokens,
                                        List<Property> properties)

  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.

  Parameters:
    `tokens` - the tokens containing the comma-separated strings; never null
    `properties` - the list into which the properties that represent the options should be placed
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parsePropertyOrChildNodeDefinitions

    protected void parsePropertyOrChildNodeDefinitions(TokenStream tokens,
                                                       Path nodeTypePath)

  Parse a node type's property or child node definitions that appear next on the token stream.

  Parameters:
    `tokens` - the tokens containing the definitions; never null
    `nodeTypePath` - the path in the destination where the node type has been created, and under which the property and child node type definitions should be placed
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parsePropertyDefinition

    protected void parsePropertyDefinition(TokenStream tokens,
                                           Path nodeTypePath)

  Parse a node type's property definition from the next tokens on the stream.

  Parameters:
    `tokens` - the tokens containing the definition; never null
    `nodeTypePath` - the path in the destination where the node type has been created, and under which the property and child node type definitions should be placed
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parsePropertyType

    protected void parsePropertyType(TokenStream tokens,
                                     List<Property> properties,
                                     String defaultPropertyType)

  Parse the property type, if a valid one appears next on the token stream.

  Parameters:
    `tokens` - the tokens containing the definition; never null
    `properties` - the list into which the property that represents the property type should be placed
    `defaultPropertyType` - the default property type if none is actually found
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseDefaultValues

    protected void parseDefaultValues(TokenStream tokens,
                                      List<Property> properties)

  Parse the property definition's default value, if they appear next on the token stream.

  Parameters:
    `tokens` - the tokens containing the definition; never null
    `properties` - the list into which the property that represents the default values should be placed
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseValueConstraints

    protected void parseValueConstraints(TokenStream tokens,
                                         List<Property> properties)

  Parse the property definition's value constraints, if they appear next on the token stream.

  Parameters:
    `tokens` - the tokens containing the definition; never null
    `properties` - the list into which the property that represents the value constraints should be placed
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parsePropertyAttributes

    protected void parsePropertyAttributes(TokenStream tokens,
                                           List<Property> properties,
                                           Name propDefnName,
                                           Path propDefnPath)

  Parse the property definition's attributes, if they appear next on the token stream.

  Parameters:
    `tokens` - the tokens containing the attributes; never null
    `properties` - the list into which the properties that represents the attributes should be placed
    `propDefnName` - the name of the property definition; never null
    `propDefnPath` - the path in the destination to the property definition node; never null
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseQueryOperators

    protected void parseQueryOperators(TokenStream tokens,
                                       List<Property> properties)

  Parse the property definition's query operators, if they appear next on the token stream.

  Parameters:
    `tokens` - the tokens containing the definition; never null
    `properties` - the list into which the property that represents the value constraints should be placed
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseChildNodeDefinition

    protected void parseChildNodeDefinition(TokenStream tokens,
                                            Path nodeTypePath)

  Parse a node type's child node definition from the next tokens on the stream.

  Parameters:
    `tokens` - the tokens containing the definition; never null
    `nodeTypePath` - the path in the destination where the node type has been created, and under which the child node type definitions should be placed
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseRequiredPrimaryTypes

    protected void parseRequiredPrimaryTypes(TokenStream tokens,
                                             List<Property> properties)

  Parse the child node definition's list of required primary types, if they appear next on the token stream.

  Parameters:
    `tokens` - the tokens containing the definition; never null
    `properties` - the list into which the property that represents the required types should be placed
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseDefaultType

    protected void parseDefaultType(TokenStream tokens,
                                    List<Property> properties)

  Parse the child node definition's default type, if they appear next on the token stream.

  Parameters:
    `tokens` - the tokens containing the definition; never null
    `properties` - the list into which the property that represents the default primary type should be placed
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseNodeAttributes

    protected void parseNodeAttributes(TokenStream tokens,
                                       List<Property> properties,
                                       Name childNodeDefnName,
                                       Path childNodeDefnPath)

  Parse the child node definition's attributes, if they appear next on the token stream.

  Parameters:
    `tokens` - the tokens containing the attributes; never null
    `properties` - the list into which the properties that represents the attributes should be placed
    `childNodeDefnName` - the name of the child node definition; never null
    `childNodeDefnPath` - the path in the destination to the child node definition node; never null
  Throws:
    `ParsingException` - if there is a problem parsing the content

### parseName

    protected Name parseName(TokenStream tokens)

  Parse the name that is expected to be next on the token stream.

  Parameters:
    `tokens` - the tokens containing the name; never null
  Returns:
    the name; never null
  Throws:
    `ParsingException` - if there is a problem parsing the content

### removeQuotes

    protected final String removeQuotes(String text)

### parseVendorExtensions

    protected final void parseVendorExtensions(TokenStream tokens,
                                               List<Property> properties)

  Parse the vendor extensions that may appear next on the tokenzied stream.

  Parameters:
    `tokens` - token stream; may not be null
    `properties` - the list of properties to which any vendor extension properties should be added

### parseVendorExtension

    protected final Property parseVendorExtension(String vendorExtension)

  Parse the vendor extension, including the curly braces in the CND content.

  Parameters:
    `vendorExtension` - the vendor extension string
  Returns:
    the property representing the vendor extension, or null if the vendor extension is incomplete

### parseVendorExtensionContent

    protected final Property parseVendorExtensionContent(String vendorExtension)

  Parse the content of the vendor extension excluding the curly braces in the CND content.

  Parameters:
    `vendorExtension` - the vendor extension string; never null
  Returns:
    the property representing the vendor extension, or null if the vendor extension is incomplete

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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