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.ArrayList;
019: import java.util.Collections;
020: import java.util.List;
021:
022: import javax.xml.namespace.QName;
023:
024: import org.eclipse.xsd.XSDSchemaContent;
025: import org.geotools.xml.InstanceComponent;
026: import org.geotools.xml.Node;
027:
028: public class DocumentHandlerImpl extends HandlerImpl implements
029: DocumentHandler {
030: /** factory used to create a handler for the root element **/
031: HandlerFactory factory;
032:
033: /** root node of the parse tree */
034: Node tree;
035: //ElementHandler handler;
036:
037: /** the parser */
038: ParserHandler parser;
039:
040: public DocumentHandlerImpl(HandlerFactory factory,
041: ParserHandler parser) {
042: this .factory = factory;
043: this .parser = parser;
044: }
045:
046: public XSDSchemaContent getSchemaContent() {
047: return null;
048: }
049:
050: public InstanceComponent getComponent() {
051: return null;
052: }
053:
054: public Object getValue() {
055: //jsut return the root of the parse tree's value
056: if (tree != null) {
057: return tree.getValue();
058: }
059: // //just return the root handler value
060: // if (handler != null) {
061: // return handler.getValue();
062: // }
063:
064: return null;
065: }
066:
067: public Node getParseNode() {
068: return tree;
069: }
070:
071: public Handler createChildHandler(QName qName) {
072: return factory.createElementHandler(qName, this , parser);
073: }
074:
075: // public List getChildHandlers() {
076: // if ( handler == null ) {
077: // return Collections.EMPTY_LIST;
078: // }
079: //
080: // ArrayList list = new ArrayList();
081: // list.add( handler );
082: //
083: // return list;
084: // }
085:
086: public void startChildHandler(Handler child) {
087: this .tree = child.getParseNode();
088: //this.handler = (ElementHandler) child;
089: }
090:
091: public void endChildHandler(Handler child) {
092: //this.handler = null;
093: }
094:
095: public Handler getParentHandler() {
096: //always null, this is the root handler
097: return null;
098: }
099:
100: // public ElementHandler getDocumentElementHandler() {
101: // return handler;
102: // }
103: }
|