## org.eclipse.emf.ecore.xmi.impl
Class RootXMLContentHandlerImpl

    java.lang.Object
      org.eclipse.emf.ecore.resource.impl.ContentHandlerImpl
          org.eclipse.emf.ecore.xmi.impl.XMLContentHandlerImpl
              org.eclipse.emf.ecore.xmi.impl.RootXMLContentHandlerImpl

All Implemented Interfaces:
  ContentHandler

    public class RootXMLContentHandlerImpl

extends XMLContentHandlerImpl

A specialized `ContentHandler` implementation that matches root element names and namespaces.

Nested Class Summary
`static class` `RootXMLContentHandlerImpl.Describer` A describer that `creates` a `RootXMLContentHandlerImpl` instance.

Nested classes/interfaces inherited from class org.eclipse.emf.ecore.xmi.impl.XMLContentHandlerImpl
`XMLContentHandlerImpl.XMI`

Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.resource.ContentHandler
`ContentHandler.ByteOrderMark, ContentHandler.Registry, ContentHandler.Validity`

Field Summary
`static java.lang.String` `CONTENT_TYPE_ID` The key in the `constructor`'s parameter map representing the content type identifier String.
`protected java.lang.String` `contentTypeID` The content type identifier for content that matches this handler.
`static java.lang.String` `ELEMENT_NAMES` The key in the `constructor`'s parameter map representing the root element names which are encoded as a space separated list of names.
`protected java.lang.String[]` `elementNames` The expected name of the root element or the first non-XMI element.
`protected java.lang.String[]` `extensions` The file extensions for which this handler applies.
`static java.lang.String` `EXTENSIONS` The key in the `constructor`'s parameter map representing the extensions which are encoded as a space separate list of suffixes.
`protected java.lang.String` `kind` The kind of content that's expected; `XMI content` has special handling.
`static java.lang.String` `KIND` The key in the `constructor`'s parameter map representing the kind of resource being processed; only the value `xmi`is recognized.``
`protected java.lang.String` `namespace` The namespace of the root element or the first non-XMI element.
`static java.lang.String` `NAMESPACE` The key in the `constructor`'s parameter map representing the namespace.
`static java.lang.String` `NAMESPACE_PATTERN` The key in the `constructor`'s parameter map representing the namespace pattern.
`protected java.util.regex.Pattern` `namespacePattern` The namespace pattern of the root element or the first non-XMI element.
`static java.lang.String` `XMI_KIND` A `kind` value indicating XMI content.

Fields inherited from interface org.eclipse.emf.ecore.resource.ContentHandler
`BYTE_ORDER_MARK_PROPERTY, CHARSET_PROPERTY, CONTENT_TYPE_PROPERTY, INVALID_CONTENT_DESCRIPTION, OPTION_REQUESTED_PROPERTIES, UNSPECIFIED_CONTENT_TYPE, VALIDITY_PROPERTY`

Constructor Summary
`RootXMLContentHandlerImpl(java.util.Map<java.lang.String,java.lang.String> parameters)` Creates an instance corresponding to the given parameters.
`RootXMLContentHandlerImpl(java.lang.String contentTypeID, java.lang.String[] extensions, java.lang.String kind, java.util.regex.Pattern namespacePattern, java.lang.String[] elementNames)` Creates an instance initialized with the given arguments.
`RootXMLContentHandlerImpl(java.lang.String contentTypeID, java.lang.String[] extensions, java.lang.String kind, java.lang.String namespace, java.lang.String[] elementNames)` Creates an instance initialized with the given arguments.

Method Summary
`boolean` `canHandle(URI uri)` Returns true if the `extensions` are null or empty, of if the URI's `file extension` matches one of the extension's values.
`java.util.Map<java.lang.String,java.lang.Object>` `contentDescription(URI uri, java.io.InputStream inputStream, java.util.Map<?,?> options, java.util.Map<java.lang.Object,java.lang.Object> context)` Returns a valid content description if the XML content of the input stream has an element that matches the element names and namespace.
`protected boolean` `isMatchingNamespace(java.lang.String rootElementNamespace)` Returns whether the given root element's namespace matches the namespace expected for the content type.

Methods inherited from class org.eclipse.emf.ecore.xmi.impl.XMLContentHandlerImpl
`createXMLResource, getCharset, isXMINameAndNamespace, isXMINamespace, load`

Methods inherited from class org.eclipse.emf.ecore.resource.impl.ContentHandlerImpl
`createContentDescription, getByteOrderMark, getRequestedProperties, isRequestedProperty`

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

Field Detail

### contentTypeID

    protected java.lang.String contentTypeID

  The content type identifier for content that matches this handler.

### extensions

    protected java.lang.String[] extensions

  The file extensions for which this handler applies.

### kind

    protected java.lang.String kind

  The kind of content that's expected; `XMI content` has special handling.

### namespace

    protected java.lang.String namespace

  The namespace of the root element or the first non-XMI element.

### namespacePattern

    protected java.util.regex.Pattern namespacePattern

  The namespace pattern of the root element or the first non-XMI element.

### elementNames

    protected java.lang.String[] elementNames

  The expected name of the root element or the first non-XMI element.

### CONTENT_TYPE_ID

    public static final java.lang.String CONTENT_TYPE_ID

  The key in the `constructor`'s parameter map representing the content type identifier String.

  See Also:
    `contentTypeID`, Constant Field Values

### EXTENSIONS

    public static final java.lang.String EXTENSIONS

  The key in the `constructor`'s parameter map representing the extensions which are encoded as a space separate list of suffixes.

  See Also:
    `extensions`, Constant Field Values

### KIND

    public static final java.lang.String KIND

  The key in the `constructor`'s parameter map representing the kind of resource being processed; only the value `xmi`is recognized.

  See Also:
    `kind`, Constant Field Values
  ``

### XMI_KIND

    public static final java.lang.String XMI_KIND

  A `kind` value indicating XMI content.

  See Also:
    Constant Field Values

### NAMESPACE

    public static final java.lang.String NAMESPACE

  The key in the `constructor`'s parameter map representing the namespace.

  See Also:
    `namespace`, Constant Field Values

### NAMESPACE_PATTERN

    public static final java.lang.String NAMESPACE_PATTERN

  The key in the `constructor`'s parameter map representing the namespace pattern.

  See Also:
    `namespacePattern`, Constant Field Values

### ELEMENT_NAMES

    public static final java.lang.String ELEMENT_NAMES

  The key in the `constructor`'s parameter map representing the root element names which are encoded as a space separated list of names.

  See Also:
    `elementNames`, Constant Field Values

Constructor Detail

### RootXMLContentHandlerImpl

    public RootXMLContentHandlerImpl(java.util.Map<java.lang.String,java.lang.String> parameters)

  Creates an instance corresponding to the given parameters.

  Parameters:
    `parameters` - the map of key value pairs.
  See Also:
    `CONTENT_TYPE_ID`, `EXTENSIONS`, `KIND`, `NAMESPACE`, `ELEMENT_NAMES`

### RootXMLContentHandlerImpl

    public RootXMLContentHandlerImpl(java.lang.String contentTypeID,
                                     java.lang.String[] extensions,
                                     java.lang.String kind,
                                     java.lang.String namespace,
                                     java.lang.String[] elementNames)

  Creates an instance initialized with the given arguments.

  Parameters:
    `contentTypeID` - the content type identifier for content recognized this this handler.
    `extensions` - the `extensions` handled by this instance; `null` or an empty array specifies that this handler applies for all URIs.
    `kind` - the kind of content that's expected; `XMI_KIND` supports special handling.
    `namespace` - the expected namespace of the root element or first non-XMI element.
    `elementNames` - the expected element names of the root element or the first non-XMI element; `null` or an empty array specifies that any root element name is allowed.

### RootXMLContentHandlerImpl

    public RootXMLContentHandlerImpl(java.lang.String contentTypeID,
                                     java.lang.String[] extensions,
                                     java.lang.String kind,
                                     java.util.regex.Pattern namespacePattern,
                                     java.lang.String[] elementNames)

  Creates an instance initialized with the given arguments.

  Parameters:
    `contentTypeID` - the content type identifier for content recognized this this handler.
    `extensions` - the `extensions` handled by this instance; `null` or an empty array specifies that this handler applies for all URIs.
    `kind` - the kind of content that's expected; `XMI_KIND` supports special handling.
    `namespacePattern` - a pattern that will match the expected namespace of the root element or first non-XMI element.
    `elementNames` - the expected element names of the root element or the first non-XMI element; `null` or an empty array specifies that any root element name is allowed.

Method Detail

### canHandle

    public boolean canHandle(URI uri)

  Returns true if the `extensions` are null or empty, of if the URI's `file extension` matches one of the extension's values.

  Specified by:
    `canHandle` in interface `ContentHandler`
  Overrides:
    `canHandle` in class `ContentHandlerImpl`
  Parameters:
    `uri` - the URI in questions.
  Returns:
    true;

### contentDescription

    public java.util.Map<java.lang.String,java.lang.Object> contentDescription(URI uri,
                                                                               java.io.InputStream inputStream,
                                                                               java.util.Map<?,?> options,
                                                                               java.util.Map<java.lang.Object,java.lang.Object> context)
                                                                        throws java.io.IOException

  Returns a valid content description if the XML content of the input stream has an element that matches the element names and namespace.

  Specified by:
    `contentDescription` in interface `ContentHandler`
  Overrides:
    `contentDescription` in class `XMLContentHandlerImpl`
  Parameters:
    `uri` - the URI for which to determine the content description.
    `inputStream` - the input stream associated with the given URI.
    `options` - a map of options to direct what kind of description is needed.
    `context` - a map of contextual information that content handlers use to store partially computed results.
  Returns:
    a map of properties that describe the content of the given URI's corresponding input stream.
  Throws:
    `java.io.IOException` - if there is a problem reading the stream.

### isMatchingNamespace

    protected boolean isMatchingNamespace(java.lang.String rootElementNamespace)

  Returns whether the given root element's namespace matches the namespace expected for the content type.

Copyright 2001-2006 IBM Corporation and others. All Rights Reserved.