org.eclipse.emf.ecore.resource.impl
Class ContentHandlerImpl

java.lang.Object
  extended by org.eclipse.emf.ecore.resource.impl.ContentHandlerImpl
All Implemented Interfaces:
ContentHandler
Direct Known Subclasses:
PlatformContentHandlerImpl, XMLContentHandlerImpl

public class ContentHandlerImpl
extends java.lang.Object
implements ContentHandler

An implementation of a content handler.


Nested Class Summary
static class ContentHandlerImpl.Describer
          An implementation of a describer that delegates to a ContentHandler.
 
Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.resource.ContentHandler
ContentHandler.ByteOrderMark, ContentHandler.Registry, ContentHandler.Validity
 
Field Summary
 
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
ContentHandlerImpl()
          Creates an instance.
 
Method Summary
 boolean canHandle(URI uri)
          This implementations always return true; clients are generally expected to override this.
 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)
          This base implementation handles looking up the ContentHandler.BYTE_ORDER_MARK_PROPERTY if that's a requested property.
static java.util.Map<java.lang.String,java.lang.Object> createContentDescription(ContentHandler.Validity validity)
          Creates a map with a single entry from ContentHandler.VALIDITY_PROPERTY to the given validity value.
protected  ContentHandler.ByteOrderMark getByteOrderMark(URI uri, java.io.InputStream inputStream, java.util.Map<?,?> options, java.util.Map<java.lang.Object,java.lang.Object> context)
          Returns the byte order marker at the start of the input stream.
protected  java.util.Set<java.lang.String> getRequestedProperties(java.util.Map<?,?> options)
          Returns the value of ContentHandler.OPTION_REQUESTED_PROPERTIES in the options map.
protected  boolean isRequestedProperty(java.lang.String property, java.util.Map<?,?> options)
          Returns whether the named property is one requested in the options.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentHandlerImpl

public ContentHandlerImpl()
Creates an instance.

Method Detail

createContentDescription

public static java.util.Map<java.lang.String,java.lang.Object> createContentDescription(ContentHandler.Validity validity)
Creates a map with a single entry from ContentHandler.VALIDITY_PROPERTY to the given validity value.

Parameters:
validity - the value of the validity property.
Returns:
a map with a single entry from ContentHandler.VALIDITY_PROPERTY to the given validity value.

getRequestedProperties

protected java.util.Set<java.lang.String> getRequestedProperties(java.util.Map<?,?> options)
Returns the value of ContentHandler.OPTION_REQUESTED_PROPERTIES in the options map.

Parameters:
options - the options in which to look up the property.
Returns:
value of ContentHandler.OPTION_REQUESTED_PROPERTIES in the options map.

isRequestedProperty

protected boolean isRequestedProperty(java.lang.String property,
                                      java.util.Map<?,?> options)
Returns whether the named property is one requested in the options.

Parameters:
property - the property in question.
options - the options in which to look for the requested property.
Returns:
whether the named property is one requested in the options.
See Also:
getRequestedProperties(Map)

canHandle

public boolean canHandle(URI uri)
This implementations always return true; clients are generally expected to override this.

Specified by:
canHandle in interface ContentHandler
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
This base implementation handles looking up the ContentHandler.BYTE_ORDER_MARK_PROPERTY if that's a requested property.

Specified by:
contentDescription in interface ContentHandler
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.

getByteOrderMark

protected ContentHandler.ByteOrderMark getByteOrderMark(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 the byte order marker at the start of the input stream.

Parameters:
uri - the URI of the input stream.
inputStream - the input stream to scan.
options - any options to influence the behavior; this base implementation ignores this.
context - the cache for fetching and storing a previous computation of the byte order marker; this base implementation caches ContentHandler.BYTE_ORDER_MARK_PROPERTY.
Returns:
the byte order marker at the start of the input stream.
Throws:
java.io.IOException

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