001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.xml.impl;
017:
018: import java.util.List;
019:
020: import javax.xml.namespace.QName;
021:
022: import org.eclipse.xsd.XSDSchemaContent;
023: import org.geotools.xml.InstanceComponent;
024: import org.geotools.xml.Node;
025: import org.picocontainer.MutablePicoContainer;
026:
027: /**
028: * Class implementing this interface serve has handlers for content of an
029: * instance document as it is parsed.
030: *
031: * <p>
032: * A handler is repsonsible for parsing and validating content. Upon a
033: * successful parse and validation, the handler must return the "parsed"
034: * content from a call to {@link #getValue}.
035: * </p>
036: *
037: * <p>
038: * A handler corresponds to a specific component in a schema. Processing is
039: * delegated to the handler when an instance of the component is encountered in
040: * an instance document.
041: * </p>
042: *
043: * @author Justin Deoliveira,Refractions Research Inc.,jdeolive@refractions.net
044: *
045: */
046: public interface Handler {
047: /**
048: * @return The entity of the schema that corresponds to the handler.
049: */
050: XSDSchemaContent getSchemaContent();
051:
052: /**
053: * @return The instance of the schema content that is currently being
054: * handled.
055: */
056: InstanceComponent getComponent();
057:
058: /**
059: * @return The parse tree for the handler.
060: */
061: Node getParseNode();
062:
063: /**
064: * @return A value which corresponds to an instance of the entity of the
065: * handler.
066: */
067: //Object getValue();
068: /**
069: * @return The context or container in which the instance is to be parsed in.
070: *
071: */
072: MutablePicoContainer getContext();
073:
074: /**
075: * @param context The context in which the the instance is to be parsed in.
076: */
077: void setContext(MutablePicoContainer context);
078:
079: /**
080: * @return The parent handler.
081: *
082: * @see Handler#getChildHandler(QName, SchemaBuilder)
083: */
084: Handler getParentHandler();
085:
086: /**
087: * Returns a handler for a component in the schema which is a child of
088: * this component.
089: * <p>
090: * This method will return null in two situations:
091: * <ol>
092: * <li>The schema component being handled does not support children (for
093: * example, an attribute).</li>
094: * <li>A child with the specified qName could not be found.
095: * </ol>
096: *
097: * @param qName The qualified name of the schema component.
098: *
099: * @return A new handler, or null if one cannot be created.
100: */
101: Handler createChildHandler(QName qName);
102:
103: /**
104: * @return The current list of child handlers executing.
105: */
106: //List getChildHandlers();
107: /**
108: * Called when a child handler is started, on the leading edge of the
109: * child element.
110: *
111: * @param child The executing child handler.
112: */
113: void startChildHandler(Handler child);
114:
115: /**
116: * Called when a child handler is finished, on the trailing edge of the
117: * child element.
118: *
119: * @param child The executing child handler.
120: */
121: void endChildHandler(Handler child);
122: }
|