001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-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.handlers.xsi;
017:
018: import org.geotools.xml.XSIElementHandler;
019: import org.xml.sax.Attributes;
020: import org.xml.sax.SAXException;
021: import org.xml.sax.SAXNotRecognizedException;
022:
023: /**
024: * FacetHandler purpose.
025: *
026: * <p>
027: * Abstract class representing common Facet abilites + attributes.
028: * </p>
029: *
030: * @author dzwiers, Refractions Research, Inc. http://www.refractions.net
031: * @author $Author:$ (last modification)
032: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/xml/src/main/java/org/geotools/xml/handlers/xsi/FacetHandler.java $
033: * @version $Id: FacetHandler.java 28703 2008-01-10 21:55:35Z saul.farber $
034: */
035: public abstract class FacetHandler extends XSIElementHandler {
036: // /** ENUMERATION */
037: // public static final int ENUMERATION = 1;
038: //
039: // /** FRACTIONDIGITS */
040: // public static final int FRACTIONDIGITS = 2;
041: //
042: // /** LENGTH */
043: // public static final int LENGTH = 4;
044: //
045: // /** MAXEXCLUSIVE */
046: // public static final int MAXEXCLUSIVE = 8;
047: //
048: // /** MAXINCLUSIVE */
049: // public static final int MAXINCLUSIVE = 16;
050: //
051: // /** MAXLENGTH */
052: // public static final int MAXLENGTH = 32;
053: //
054: // /** MINEXCLUSIVE */
055: // public static final int MINEXCLUSIVE = 64;
056: //
057: // /** MININCLUSIVE */
058: // public static final int MININCLUSIVE = 128;
059: //
060: // /** MINLENGTH */
061: // public static final int MINLENGTH = 264;
062: //
063: // /** PATTERN */
064: // public static final int PATTERN = 512;
065: //
066: // /** TOTALDIGITS */
067: // public static final int TOTALDIGITS = 1024;
068: private String value;
069:
070: /**
071: * @see org.geotools.xml.XSIElementHandler#endElement(java.lang.String,
072: * java.lang.String)
073: */
074: public void endElement(String namespaceURI, String localName) {
075: // do nothing
076: }
077:
078: /**
079: * @see java.lang.Object#hashCode()
080: */
081: public int hashCode() {
082: return getHandlerType()
083: * ((value == null) ? 1 : value.hashCode());
084: }
085:
086: /**
087: * <p>
088: * Return the int mask for the facet type.
089: * </p>
090: *
091: */
092: public abstract int getType();
093:
094: /**
095: * @see org.geotools.xml.XSIElementHandler#getHandlerType()
096: */
097: public int getHandlerType() {
098: return FACET;
099: }
100:
101: /**
102: * @see org.geotools.xml.XSIElementHandler#getHandler(java.lang.String,
103: * java.lang.String)
104: */
105: public XSIElementHandler getHandler(String namespaceURI,
106: String localName) throws SAXException {
107: if (localName.equalsIgnoreCase("annotation")
108: || localName.equalsIgnoreCase("documentation")) {
109: return new IgnoreHandler();
110: }
111: throw new SAXNotRecognizedException(
112: "Facets are not allowed to have sub-elements");
113: }
114:
115: /**
116: * @see org.geotools.xml.XSIElementHandler#startElement(java.lang.String,
117: * java.lang.String, org.xml.sax.Attributes)
118: */
119: public void startElement(String namespaceURI, String localName,
120: Attributes atts) {
121: value = atts.getValue("", "value");
122:
123: if (value == null) {
124: value = atts.getValue(namespaceURI, "value");
125: }
126: }
127:
128: /**
129: * <p>
130: * Returns the Facet Value
131: * </p>
132: *
133: */
134: public String getValue() {
135: return value;
136: }
137: }
|