org.apache.cayenne.map
Class MapLoader

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.cayenne.map.MapLoader
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class MapLoader
extends DefaultHandler

Default MapLoader. Its responsibilities include reading DataMaps from XML files and saving DataMap objects back to XML.

Author:
Misha Shengaout, Andrus Adamchik, Andriy Shapochka

Field Summary
static String DATA_MAP_TAG
           
static String DB_ATTRIBUTE_DERIVED_TAG
           
static String DB_ATTRIBUTE_PAIR_TAG
           
static String DB_ATTRIBUTE_REF_TAG
           
static String DB_ATTRIBUTE_TAG
           
static String DB_ENTITY_TAG
           
static String DB_GENERATOR_NAME_TAG
           
static String DB_GENERATOR_TYPE_TAG
           
static String DB_KEY_CACHE_SIZE_TAG
           
static String DB_KEY_GENERATOR_TAG
           
static String DB_RELATIONSHIP_REF_TAG
           
static String DB_RELATIONSHIP_TAG
           
static String EMBEDDABLE_ATTRIBUTE_OVERRIDE_TAG
           
static String EMBEDDABLE_ATTRIBUTE_TAG
           
static String EMBEDDABLE_TAG
           
static String EMBEDDED_ATTRIBUTE_TAG
           
static String FALSE
           
static String OBJ_ATTRIBUTE_TAG
           
static String OBJ_ENTITY_TAG
           
static String OBJ_RELATIONSHIP_TAG
           
static String PROCEDURE_PARAMETER_TAG
           
static String PROCEDURE_TAG
           
static String PROPERTY_TAG
           
static String QUERY_ORDERING_TAG
           
static String QUERY_PREFETCH_TAG
           
static String QUERY_QUALIFIER_TAG
           
static String QUERY_SQL_TAG
           
static String QUERY_TAG
           
static String TRUE
           
 
Constructor Summary
MapLoader()
           
 
Method Summary
 void characters(char[] text, int start, int length)
           
protected  ResourceLocator configLocator()
          Creates, configures and returns ResourceLocator object used to lookup DataMap files.
 void endElement(String namespaceURI, String localName, String qName)
           
 DataMap loadDataMap(InputSource src)
          Loads a DataMap from XML input source.
 DataMap loadDataMap(String uri)
          Loads DataMap from file specified by uri parameter.
protected  String mapNameFromLocation(String location)
          Helper method to guess the map name from its location.
 void startElement(String namespaceUri, String localName, String qName, Attributes attributes)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_MAP_TAG

public static final String DATA_MAP_TAG
See Also:
Constant Field Values

PROPERTY_TAG

public static final String PROPERTY_TAG
See Also:
Constant Field Values

EMBEDDABLE_TAG

public static final String EMBEDDABLE_TAG
Since:
3.0
See Also:
Constant Field Values

EMBEDDABLE_ATTRIBUTE_TAG

public static final String EMBEDDABLE_ATTRIBUTE_TAG
Since:
3.0
See Also:
Constant Field Values

EMBEDDED_ATTRIBUTE_TAG

public static final String EMBEDDED_ATTRIBUTE_TAG
Since:
3.0
See Also:
Constant Field Values

EMBEDDABLE_ATTRIBUTE_OVERRIDE_TAG

public static final String EMBEDDABLE_ATTRIBUTE_OVERRIDE_TAG
Since:
3.0
See Also:
Constant Field Values

DB_ENTITY_TAG

public static final String DB_ENTITY_TAG
See Also:
Constant Field Values

OBJ_ENTITY_TAG

public static final String OBJ_ENTITY_TAG
See Also:
Constant Field Values

DB_ATTRIBUTE_TAG

public static final String DB_ATTRIBUTE_TAG
See Also:
Constant Field Values

DB_ATTRIBUTE_DERIVED_TAG

public static final String DB_ATTRIBUTE_DERIVED_TAG
See Also:
Constant Field Values

DB_ATTRIBUTE_REF_TAG

public static final String DB_ATTRIBUTE_REF_TAG
See Also:
Constant Field Values

OBJ_ATTRIBUTE_TAG

public static final String OBJ_ATTRIBUTE_TAG
See Also:
Constant Field Values

OBJ_RELATIONSHIP_TAG

public static final String OBJ_RELATIONSHIP_TAG
See Also:
Constant Field Values

DB_RELATIONSHIP_TAG

public static final String DB_RELATIONSHIP_TAG
See Also:
Constant Field Values

DB_RELATIONSHIP_REF_TAG

public static final String DB_RELATIONSHIP_REF_TAG
See Also:
Constant Field Values

DB_ATTRIBUTE_PAIR_TAG

public static final String DB_ATTRIBUTE_PAIR_TAG
See Also:
Constant Field Values

PROCEDURE_TAG

public static final String PROCEDURE_TAG
See Also:
Constant Field Values

PROCEDURE_PARAMETER_TAG

public static final String PROCEDURE_PARAMETER_TAG
See Also:
Constant Field Values

QUERY_TAG

public static final String QUERY_TAG
See Also:
Constant Field Values

QUERY_SQL_TAG

public static final String QUERY_SQL_TAG
See Also:
Constant Field Values

QUERY_QUALIFIER_TAG

public static final String QUERY_QUALIFIER_TAG
See Also:
Constant Field Values

QUERY_ORDERING_TAG

public static final String QUERY_ORDERING_TAG
See Also:
Constant Field Values

QUERY_PREFETCH_TAG

public static final String QUERY_PREFETCH_TAG
See Also:
Constant Field Values

TRUE

public static final String TRUE
See Also:
Constant Field Values

FALSE

public static final String FALSE
See Also:
Constant Field Values

DB_KEY_GENERATOR_TAG

public static final String DB_KEY_GENERATOR_TAG
See Also:
Constant Field Values

DB_GENERATOR_TYPE_TAG

public static final String DB_GENERATOR_TYPE_TAG
See Also:
Constant Field Values

DB_GENERATOR_NAME_TAG

public static final String DB_GENERATOR_NAME_TAG
See Also:
Constant Field Values

DB_KEY_CACHE_SIZE_TAG

public static final String DB_KEY_CACHE_SIZE_TAG
See Also:
Constant Field Values
Constructor Detail

MapLoader

public MapLoader()
Method Detail

loadDataMap

public DataMap loadDataMap(InputSource src)
                    throws CayenneRuntimeException
Loads a DataMap from XML input source.

Throws:
CayenneRuntimeException

loadDataMap

public DataMap loadDataMap(String uri)
                    throws CayenneRuntimeException
Loads DataMap from file specified by uri parameter.

Throws:
CayenneRuntimeException - if source URI does not resolve to a valid map files

mapNameFromLocation

protected String mapNameFromLocation(String location)
Helper method to guess the map name from its location.


configLocator

protected ResourceLocator configLocator()
Creates, configures and returns ResourceLocator object used to lookup DataMap files.


startElement

public void startElement(String namespaceUri,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

characters

public void characters(char[] text,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException


Copyright © 2001-2007 Apache Cayenne. All Rights Reserved.