001: /*
002: * Created on Feb 5, 2004
003: *
004: * To change the template for this generated file go to
005: * Window - Preferences - Java - Code Generation - Code and Comments
006: */
007: package org.vfny.geoserver.global.xml;
008:
009: /**
010: * NameSpaceElement purpose.
011: * <p>
012: * NameSpaceElement sub classes will represent a particular element
013: * found within a particular namespace. Most of the methods below
014: * should return constants to improve performance.
015: * </p>
016: *
017: * @author dzwiers, Refractions Research, Inc.
018: * @author $Author: dmzwiers $ (last modification)
019: * @version $Id: NameSpaceElement.java 6177 2007-02-19 10:11:27Z aaime $
020: */
021: public abstract class NameSpaceElement {
022: /** the namespace prefix to use for qualification*/
023: protected final String prefix;
024:
025: /**
026: * NameSpaceElement constructor.
027: * <p>
028: * Creates an instance of this NameSpaceElement.
029: * </p>
030: * <p>
031: * The prefix is to be used for the qualification routines.
032: * If the prefix passed is null, then qualified names will be
033: * null unless they have a prefix specified.
034: * </p>
035: * @param prefix The prefix to use for qualification.
036: */
037: public NameSpaceElement(String prefix) {
038: this .prefix = prefix;
039: }
040:
041: /**
042: * NameSpaceElement constructor.
043: * <p>
044: * Creates an instance of this NameSpaceElement.
045: * </p>
046: * <p>
047: * The prefix is to be used for the qualification routines is set to null.
048: * the qualified names of the elements will be null
049: * </p>
050: */
051: public NameSpaceElement() {
052: this .prefix = null;
053: }
054:
055: /**
056: * getTypeDefName purpose.
057: * <p>
058: * This will return the name of the definition of the element.
059: * This method is useful when defining a new type and wish to
060: * extend an existing defined type, such as
061: * <code>gml:AbstractFeatureType</code>.
062: * </p>
063: * <p>
064: * <code>
065: * <xs:complexType name="Lines_Type">
066: * <xs:complexContent>
067: * <xs:extension base="gml:AbstractFeatureType">
068: * <xs:sequence>
069: * <xs:element name="id" type="xs:string"/>
070: * <xs:element ref="gml:lineStringProperty" minOccurs="0"/>
071: * </xs:sequence>
072: * </xs:extension>
073: * </xs:complexContent>
074: * </xs:complexType>
075: * </code>
076: * </p>
077: * @return The type def. name, for the above example AbstractFeatureType.
078: */
079: public abstract String getTypeDefName();
080:
081: /**
082: * getTypeDefName purpose.
083: * <p>
084: * This will return the name of the element.
085: * This method is useful when defining a new element and wish to
086: * extend an existing element, such as <code>xs:string</code>.
087: * </p>
088: * <p>
089: * <code>
090: * <xs:element name="id" type="xs:string"/>
091: * <xs:element ref="gml:lineStringProperty" minOccurs="0"/>
092: * </code>
093: * </p>
094: * @return The element name, for the above example string or lineStringProperty.
095: */
096: public abstract String getTypeRefName();
097:
098: /**
099: * getQualifiedTypeDefName purpose.
100: * <p>
101: * Returns a qualified type definition name <code>prefix:definition name</code>.
102: * </p>
103: * @return the name if the default prefix is non null, null otherwise
104: * @see getTypeDefName()
105: */
106: public abstract String getQualifiedTypeDefName();
107:
108: /**
109: * getQualifiedTypeRefName purpose.
110: * <p>
111: * Returns a qualified type reference name <code>prefix:reference name</code>.
112: * </p>
113: * @return the name if the default prefix is non null, null otherwise
114: * @see getTypeRefName()
115: */
116: public abstract String getQualifiedTypeRefName();
117:
118: /**
119: * getQualifiedTypeDefName purpose.
120: * <p>
121: * Returns a qualified type definition name <code>prefix:definition name</code> with the specified prefix.
122: * </p>
123: * @param prefix The prefix to use for qualification.
124: * @return the name if either the specified or default prefix is non null, null otherwise
125: * @see getTypeDefName()
126: */
127: public abstract String getQualifiedTypeDefName(String prefix);
128:
129: /**
130: * getQualifiedTypeRefName purpose.
131: * <p>
132: * Returns a qualified type reference name <code>prefix:reference name</code> with the specified prefix.
133: * </p>
134: * @param prefix The prefix to use for qualification.
135: * @return the name if either the specified or default prefix is non null, null otherwise
136: * @see getTypeRefName()
137: */
138: public abstract String getQualifiedTypeRefName(String prefix);
139:
140: /**
141: * getJavaClass purpose.
142: * <p>
143: * Returns an instance of the Class object which would best represent this element.
144: * </p>
145: * <p>
146: * for example an element of type xs:int would return <code>Integer.class</code>.
147: * </p>
148: * @return Class instance of the Class object which would best represent this element.
149: */
150: public abstract Class getJavaClass();
151:
152: /**
153: * This is a bit of a hack, so that GeoServer can generate with the best
154: * (default) xml mappings for each Java class. This should be implemented
155: * the other way around, with a nice lookup table to get the one and only
156: * default. But this is far easier to implement, as we just add this
157: * method set to true for the namespace element classes we like best. If
158: * for some reason we set two NSE's that map to the same java class to true
159: * then things will behave randomly, which is why this is a bit of a hack.
160: * Apologies, it's late, and I need to finish my docs.
161: */
162: public boolean isDefault() {
163: return false;
164: }
165:
166: /* (non-Javadoc)
167: * @see java.lang.Object#toString()
168: */
169: public String toString() {
170: return getQualifiedTypeDefName(prefix);
171: }
172:
173: public abstract boolean isAbstract();
174: }
|