001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.schema2beansdev;
043:
044: import java.util.*;
045: import java.io.*;
046:
047: import org.netbeans.modules.schema2beans.*;
048:
049: /**
050: * The DTD parser handler
051: */
052: public interface DocDefHandler {
053: /**
054: * Called once, when the DTD is started to be parsed.
055: *
056: * @param root root elemement name of the document (as the DOCTYPE
057: * specifies in the XML document)
058: */
059: public void startDocument(String root);
060:
061: public void endDocument();
062:
063: /**
064: * Called each time a DTD <!element definition is read.
065: *
066: * @param name the name of the element
067: * @param typeName is the name to use for the attribute
068: * @param type the type (as a constant) of the element (for example
069: * TYPE_ELEMENT or TYPE_ATTLIST)
070: */
071: public void startElement(String uniqueName, String typeName,
072: int type);
073:
074: public void endElement();
075:
076: /**
077: * Does this element exist at this point? Either thru a startElement() creation,
078: * or thru an element() reference.
079: */
080: public boolean doesElementExist(String typeName);
081:
082: /**
083: * These methods are called to signal the beginning of the ( and )
084: * in an ELEMENT declaration. startGroupElements is called when
085: * an open parenthese is found and endGroupElements is called
086: * when the closed parenthese is found. The closing parenthese
087: * might be followed by the character *, + or ?. The instance
088: * value of the method call reflects this character value.
089: */
090: public void startGroupElements();
091:
092: public void endGroupElements(int instance);
093:
094: /**
095: * Called each time a character , ( ) or | is found.
096: */
097: public void character(char c);
098:
099: /**
100: * Called for each name element found within the scope of an element
101: * (<!element (element1, element2, ...)>. The first element name doesn't
102: * generate a call to this method (@see startElement).
103: *
104: * @param name the name of the element defined within the <!element ...>
105: * declaration.
106: * @param instance has one of the three values: INSTANCE_0_1,
107: * INSTANCE_1, INSTANCE_0_N, INSTANCE_1_N
108: *
109: */
110: public void element(String uniqueName, String typeName,
111: String attrName, String attrNamespace, int instance,
112: boolean externalType, String defaultValue);
113:
114: public void element(String uniqueName, String name, int instance);
115:
116: public void setUnion(String uniqueName, String typeName,
117: boolean value) throws Schema2BeansException;
118:
119: public void addExtraDataNode(String uniqueName, String typeName,
120: Object data) throws Schema2BeansException;
121:
122: public void addExtraDataCurLink(Object data);
123:
124: public void setExtension(String uniqueName, String typeName,
125: String extendsName) throws Schema2BeansException;
126:
127: public void nillable(boolean value);
128:
129: /**
130: * Called to request that the current graph node be of a certain
131: * Java class.
132: * @param javaType is the name of a Java class (eg, "java.lang.Integer", or "int").
133: */
134: public void javaType(String uniqueName, String name, String javaType);
135:
136: public void setAbstract(String uniqueName, String name,
137: boolean value);
138:
139: /**
140: * Set the namespace that will be used by default in the documents.
141: */
142: public void setDefaultNamespace(String ns);
143:
144: /**
145: * set a special property to some value.
146: */
147: public void setExtendedProperty(String uniqueName, String typeName,
148: String propertyName, Object value)
149: throws Schema2BeansException;
150:
151: /**
152: * Establish a prefix guesser
153: */
154: public void setPrefixGuesser(PrefixGuesser guesser);
155: }
|