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

    java.lang.Object
      org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl
          org.eclipse.emf.ecore.xmi.impl.ResourceEntityHandlerImpl

All Implemented Interfaces:
  XMLResource.ResourceEntityHandler, XMLResource.URIHandler

    public class ResourceEntityHandlerImpl

extends URIHandlerImpl
implements XMLResource.ResourceEntityHandler

This resource entity handler implementation extends the URI handler implementation so that this object can be used as both a resource entity handler and a URI handler since it's far more efficient to deresolve a URI once to compute the entity value than to deresolve it for each use and then map that deresolved result to an entity. For this reason, this implementation overrides `deresolve(org.eclipse.emf.common.util.URI)` to return the incoming URI.

Nested Class Summary

Nested classes/interfaces inherited from class org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl
`URIHandlerImpl.PlatformSchemeAware`

Field Summary
`protected int` `count`
`protected java.lang.String` `entityName`
`protected java.util.Map<java.lang.String,java.lang.String>` `nameToValueMap`
`protected java.util.Map<java.lang.String,java.lang.String>` `valueToNameMap`

Fields inherited from class org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl
`baseURI, resolve`

Constructor Summary
`ResourceEntityHandlerImpl(java.lang.String entityName)` Creates an instance that will generate entity names based on the given entity name followed by the `count` starting from 1 to ensure uniqueness.

Method Summary
`URI` `deresolve(URI uri)` Returns the given URI.
`protected URI` `doDeresolve(URI uri)` Returns the deresolved URI by calling super.
`protected void` `doSetBaseURI(URI uri)` Sets the base URI by calling super.
`protected java.lang.String` `generateEntityName(java.lang.String entityValue)` Generates a new unique entity name for the given entity value.
`java.lang.String` `getEntityName(java.lang.String entityValue)` Returns the name associated with the entity value; a new name will be generated if there is not yet a name associated with the entity value.
`java.util.Map<java.lang.String,java.lang.String>` `getNameToValueMap()` Returns the map of entity names to entity values to be recorded in the document during save.
`void` `handleEntity(java.lang.String entityName, java.lang.String entityValue)` Records the entity name to entity value mapping.
`void` `reset()` Resets the handler to its initial state.
`void` `setBaseURI(URI uri)` Sets the base URI and if the URI has changed, resolves all the entity URIs values against the old base URI and then deresolves them against the new baseURI.

Methods inherited from class org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl
`resolve`

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

Field Detail

### entityName

    protected java.lang.String entityName

### count

    protected int count

### nameToValueMap

    protected java.util.Map<java.lang.String,java.lang.String> nameToValueMap

### valueToNameMap

    protected java.util.Map<java.lang.String,java.lang.String> valueToNameMap

Constructor Detail

### ResourceEntityHandlerImpl

    public ResourceEntityHandlerImpl(java.lang.String entityName)

  Creates an instance that will generate entity names based on the given entity name followed by the `count` starting from 1 to ensure uniqueness.

  Parameters:
    `entityName` -

Method Detail

### deresolve

    public URI deresolve(URI uri)

  Returns the given URI.

  Specified by:
    `deresolve` in interface `XMLResource.URIHandler`
  Overrides:
    `deresolve` in class `URIHandlerImpl`
  Parameters:
    `uri` - the URI to deresolve.
  Returns:
    the URI resolved against the base URI.
  See Also:
    `URI.deresolve(URI)`

### doDeresolve

    protected URI doDeresolve(URI uri)

  Returns the deresolved URI by calling super.

  Parameters:
    `uri` - the URI to deresolve.

### setBaseURI

    public void setBaseURI(URI uri)

  Sets the base URI and if the URI has changed, resolves all the entity URIs values against the old base URI and then deresolves them against the new baseURI.

  Specified by:
    `setBaseURI` in interface `XMLResource.URIHandler`
  Overrides:
    `setBaseURI` in class `URIHandlerImpl`
  Parameters:
    `uri` - the new base URI.

### doSetBaseURI

    protected void doSetBaseURI(URI uri)

  Sets the base URI by calling super.

  Parameters:
    `uri` -

### reset

    public void reset()

  Resets the handler to its initial state.

  Specified by:
    `reset` in interface `XMLResource.ResourceEntityHandler`

### getEntityName

    public java.lang.String getEntityName(java.lang.String entityValue)

  Description copied from interface: `XMLResource.ResourceEntityHandler`
  Returns the name associated with the entity value; a new name will be generated if there is not yet a name associated with the entity value.

  Specified by:
    `getEntityName` in interface `XMLResource.ResourceEntityHandler`
  Parameters:
    `entityValue` - the entity value for which a named entity is needed.
  Returns:
    the name associated with the entity value.

### generateEntityName

    protected java.lang.String generateEntityName(java.lang.String entityValue)

  Generates a new unique entity name for the given entity value.

  Parameters:
    `entityValue` - the value for which an entity name is needed.
  Returns:
    a new unique entity name.

### handleEntity

    public void handleEntity(java.lang.String entityName,
                             java.lang.String entityValue)

  Description copied from interface: `XMLResource.ResourceEntityHandler`
  Records the entity name to entity value mapping.

  Specified by:
    `handleEntity` in interface `XMLResource.ResourceEntityHandler`
  Parameters:
    `entityName` - the name of the entity.
    `entityValue` - the associated value of the entity.

### getNameToValueMap

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

  Description copied from interface: `XMLResource.ResourceEntityHandler`
  Returns the map of entity names to entity values to be recorded in the document during save.

  Specified by:
    `getNameToValueMap` in interface `XMLResource.ResourceEntityHandler`
  Returns:
    the map of entity names to entity values to be recorded in the document during save.

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