0001: /*
0002: * GeoTools - OpenSource mapping toolkit
0003: * http://geotools.org
0004: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
0005: *
0006: * This library is free software; you can redistribute it and/or
0007: * modify it under the terms of the GNU Lesser General Public
0008: * License as published by the Free Software Foundation;
0009: * version 2.1 of the License.
0010: *
0011: * This library is distributed in the hope that it will be useful,
0012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014: * Lesser General Public License for more details.
0015: */
0016: package org.geotools.xml.xsi;
0017:
0018: import java.io.IOException;
0019: import java.net.URI;
0020: import java.net.URISyntaxException;
0021: import java.util.Calendar;
0022: import java.util.HashMap;
0023: import java.util.Locale;
0024: import java.util.Map;
0025: import java.util.TimeZone;
0026:
0027: import javax.naming.OperationNotSupportedException;
0028:
0029: import org.geotools.xml.PrintHandler;
0030: import org.geotools.xml.schema.Attribute;
0031: import org.geotools.xml.schema.AttributeValue;
0032: import org.geotools.xml.schema.ComplexType;
0033: import org.geotools.xml.schema.Element;
0034: import org.geotools.xml.schema.ElementGrouping;
0035: import org.geotools.xml.schema.ElementValue;
0036: import org.geotools.xml.schema.Facet;
0037: import org.geotools.xml.schema.Schema;
0038: import org.geotools.xml.schema.SimpleType;
0039: import org.geotools.xml.schema.Type;
0040: import org.geotools.xml.schema.impl.AttributeValueGT;
0041: import org.xml.sax.Attributes;
0042: import org.xml.sax.SAXException;
0043:
0044: /**
0045: * <p>
0046: * This class represents the pre-defined simpletypes included within the XML
0047: * schema definition.
0048: * </p>
0049: *
0050: * @author dzwiers www.refractions.net
0051: *
0052: * @see Schema
0053: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/xml/src/main/java/org/geotools/xml/xsi/XSISimpleTypes.java $
0054: */
0055: public class XSISimpleTypes {
0056: private static Map m;
0057:
0058: /** DOCUMENT ME! */
0059: public static final URI NAMESPACE = makeURI("http://www.w3.org/2001/XMLSchema");
0060:
0061: // convinience method to deal with the URISyntaxException
0062: private static URI makeURI(java.lang.String s) {
0063: try {
0064: return new URI(s);
0065: } catch (URISyntaxException e) {
0066: // do nothing
0067: return null;
0068: }
0069: }
0070:
0071: /**
0072: * <p>
0073: * Searches for the requested SimpleType, if not found this method returns
0074: * null;
0075: * </p>
0076: *
0077: * @param type the element localName
0078: *
0079: * @return SimpleType
0080: */
0081: public static SimpleType find(java.lang.String type) {
0082: if (m == null) {
0083: load();
0084: }
0085:
0086: SimpleType r = (SimpleType) m.get(type);
0087:
0088: return r;
0089: }
0090:
0091: /**
0092: * DOCUMENT ME!
0093: *
0094: * @param type DOCUMENT ME!
0095: *
0096: * @return SimpleType
0097: */
0098: public static SimpleType find(Class type) {
0099: // assuming strings and class values will not conflict
0100: if (m == null) {
0101: load();
0102: }
0103:
0104: SimpleType r = (SimpleType) m.get(type);
0105:
0106: return r;
0107: }
0108:
0109: /*
0110: * loads the mapping of names -> simpletypes on demand
0111: */
0112: private static void load() {
0113: m = new HashMap();
0114: m.put(Integer.getInstance().getName(), Integer.getInstance());
0115: m.put(Decimal.getInstance().getName(), Decimal.getInstance());
0116: m.put(NegativeInteger.getInstance().getName(), NegativeInteger
0117: .getInstance());
0118: m.put(PositiveInteger.getInstance().getName(), PositiveInteger
0119: .getInstance());
0120: m.put(NonNegativeInteger.getInstance().getName(),
0121: NonNegativeInteger.getInstance());
0122: m.put(NonPositiveInteger.getInstance().getName(),
0123: NonPositiveInteger.getInstance());
0124: m.put(Long.getInstance().getName(), Long.getInstance());
0125: m.put(Int.getInstance().getName(), Int.getInstance());
0126: m.put(Short.getInstance().getName(), Short.getInstance());
0127: m.put(Byte.getInstance().getName(), Byte.getInstance());
0128: m.put(UnsignedLong.getInstance().getName(), UnsignedLong
0129: .getInstance());
0130: m.put(UnsignedShort.getInstance().getName(), UnsignedShort
0131: .getInstance());
0132: m.put(UnsignedInt.getInstance().getName(), UnsignedInt
0133: .getInstance());
0134: m.put(UnsignedByte.getInstance().getName(), UnsignedByte
0135: .getInstance());
0136: m.put(Float.getInstance().getName(), Float.getInstance());
0137: m.put(Double.getInstance().getName(), Double.getInstance());
0138:
0139: m.put(Date.getInstance().getName(), Date.getInstance());
0140: m.put(DateTime.getInstance().getName(), DateTime.getInstance());
0141: m.put(Duration.getInstance().getName(), Duration.getInstance());
0142: m.put(gDay.getInstance().getName(), gDay.getInstance());
0143: m.put(gMonth.getInstance().getName(), gMonth.getInstance());
0144: m.put(gMonthDay.getInstance().getName(), gMonthDay
0145: .getInstance());
0146: m.put(gYear.getInstance().getName(), gYear.getInstance());
0147: m.put(gYearMonth.getInstance().getName(), gYearMonth
0148: .getInstance());
0149: m.put(Time.getInstance().getName(), Time.getInstance());
0150:
0151: m.put(ID.getInstance().getName(), ID.getInstance());
0152: m.put(IDREF.getInstance().getName(), IDREF.getInstance());
0153: m.put(IDREFS.getInstance().getName(), IDREFS.getInstance());
0154: m.put(ENTITY.getInstance().getName(), ENTITY.getInstance());
0155: m.put(ENTITIES.getInstance().getName(), ENTITIES.getInstance());
0156: m.put(NMTOKEN.getInstance().getName(), NMTOKEN.getInstance());
0157: m.put(NMTOKENS.getInstance().getName(), NMTOKENS.getInstance());
0158: m.put(NOTATION.getInstance().getName(), NOTATION.getInstance());
0159:
0160: m.put(String.getInstance().getName(), String.getInstance());
0161: m.put(NormalizedString.getInstance().getName(),
0162: NormalizedString.getInstance());
0163: m.put(Token.getInstance().getName(), Token.getInstance());
0164: m.put(QName.getInstance().getName(), QName.getInstance());
0165: m.put(Name.getInstance().getName(), Name.getInstance());
0166: m.put(NCName.getInstance().getName(), NCName.getInstance());
0167: m.put(Boolean.getInstance().getName(), Boolean.getInstance());
0168: m.put(AnyURI.getInstance().getName(), AnyURI.getInstance());
0169: m.put(Base64Binary.getInstance().getName(), Base64Binary
0170: .getInstance());
0171: m.put(HexBinary.getInstance().getName(), HexBinary
0172: .getInstance());
0173: m.put(Language.getInstance().getName(), Language.getInstance());
0174:
0175: m.put(Integer.getInstance().getInstanceType(), Integer
0176: .getInstance());
0177: m.put(Decimal.getInstance().getInstanceType(), Decimal
0178: .getInstance());
0179: m.put(NegativeInteger.getInstance().getInstanceType(),
0180: NegativeInteger.getInstance());
0181: m.put(PositiveInteger.getInstance().getInstanceType(),
0182: PositiveInteger.getInstance());
0183: m.put(NonNegativeInteger.getInstance().getInstanceType(),
0184: NonNegativeInteger.getInstance());
0185: m.put(NonPositiveInteger.getInstance().getInstanceType(),
0186: NonPositiveInteger.getInstance());
0187: m.put(Long.getInstance().getInstanceType(), Long.getInstance());
0188: m.put(Int.getInstance().getInstanceType(), Int.getInstance());
0189: m.put(Short.getInstance().getInstanceType(), Short
0190: .getInstance());
0191: m.put(Byte.getInstance().getInstanceType(), Byte.getInstance());
0192: m.put(UnsignedLong.getInstance().getInstanceType(),
0193: UnsignedLong.getInstance());
0194: m.put(UnsignedShort.getInstance().getInstanceType(),
0195: UnsignedShort.getInstance());
0196: m.put(UnsignedInt.getInstance().getInstanceType(), UnsignedInt
0197: .getInstance());
0198: m.put(UnsignedByte.getInstance().getInstanceType(),
0199: UnsignedByte.getInstance());
0200: m.put(Float.getInstance().getInstanceType(), Float
0201: .getInstance());
0202: m.put(Double.getInstance().getInstanceType(), Double
0203: .getInstance());
0204:
0205: m.put(Date.getInstance().getInstanceType(), Date.getInstance());
0206: m.put(DateTime.getInstance().getInstanceType(), DateTime
0207: .getInstance());
0208: m.put(Duration.getInstance().getInstanceType(), Duration
0209: .getInstance());
0210: m.put(gDay.getInstance().getInstanceType(), gDay.getInstance());
0211: m.put(gMonth.getInstance().getInstanceType(), gMonth
0212: .getInstance());
0213: m.put(gMonthDay.getInstance().getInstanceType(), gMonthDay
0214: .getInstance());
0215: m.put(gYear.getInstance().getInstanceType(), gYear
0216: .getInstance());
0217: m.put(gYearMonth.getInstance().getInstanceType(), gYearMonth
0218: .getInstance());
0219: m.put(Time.getInstance().getInstanceType(), Time.getInstance());
0220:
0221: m.put(ID.getInstance().getInstanceType(), ID.getInstance());
0222: m.put(IDREF.getInstance().getInstanceType(), IDREF
0223: .getInstance());
0224: m.put(IDREFS.getInstance().getInstanceType(), IDREFS
0225: .getInstance());
0226: m.put(ENTITY.getInstance().getInstanceType(), ENTITY
0227: .getInstance());
0228: m.put(ENTITIES.getInstance().getInstanceType(), ENTITIES
0229: .getInstance());
0230: m.put(NMTOKEN.getInstance().getInstanceType(), NMTOKEN
0231: .getInstance());
0232: m.put(NMTOKENS.getInstance().getInstanceType(), NMTOKENS
0233: .getInstance());
0234: m.put(NOTATION.getInstance().getInstanceType(), NOTATION
0235: .getInstance());
0236:
0237: m.put(String.getInstance().getInstanceType(), String
0238: .getInstance());
0239: m.put(NormalizedString.getInstance().getInstanceType(),
0240: NormalizedString.getInstance());
0241: m.put(Token.getInstance().getInstanceType(), Token
0242: .getInstance());
0243: m.put(QName.getInstance().getInstanceType(), QName
0244: .getInstance());
0245: m.put(Name.getInstance().getInstanceType(), Name.getInstance());
0246: m.put(NCName.getInstance().getInstanceType(), NCName
0247: .getInstance());
0248: m.put(Boolean.getInstance().getInstanceType(), Boolean
0249: .getInstance());
0250: m.put(AnyURI.getInstance().getInstanceType(), AnyURI
0251: .getInstance());
0252: m.put(Base64Binary.getInstance().getInstanceType(),
0253: Base64Binary.getInstance());
0254: m.put(HexBinary.getInstance().getInstanceType(), HexBinary
0255: .getInstance());
0256: m.put(Language.getInstance().getInstanceType(), Language
0257: .getInstance());
0258: }
0259:
0260: /**
0261: * <p>
0262: * A generic implementation of a SimpleType for use by the xsi Schema.
0263: * </p>
0264: *
0265: * @author dzwiers
0266: */
0267: protected static abstract class XSISimpleType implements SimpleType {
0268: /**
0269: * @param name
0270: *
0271: * @see org.geotools.xml.schema.Type#findChildElement(java.lang.String)
0272: */
0273: public Element findChildElement(String name) {
0274: return null;
0275: }
0276:
0277: /**
0278: * @see org.geotools.xml.schema.SimpleType#canCreateAttributes(org.geotools.xml.schema.Attribute,
0279: * java.lang.Object, java.util.Map)
0280: */
0281: public boolean canCreateAttributes(Attribute attribute,
0282: Object value, Map hints) {
0283: // TODO ensure equals works here
0284: return (value != null)
0285: && value.getClass().equals(getInstanceType())
0286: && (attribute.getSimpleType() != null)
0287: && this .getClass().equals(
0288: attribute.getSimpleType().getClass());
0289: }
0290:
0291: /**
0292: * @see org.geotools.xml.schema.Type#canEncode(org.geotools.xml.schema.Element,
0293: * java.lang.Object, java.util.Map)
0294: */
0295: public boolean canEncode(Element element, Object value,
0296: Map hints) {
0297: // TODO ensure equals works here
0298: return (value != null)
0299: && value.getClass().equals(getInstanceType())
0300: && (element.getType() != null)
0301: && this .getClass().equals(
0302: element.getType().getClass());
0303: }
0304:
0305: /**
0306: * @see org.geotools.xml.schema.SimpleType#toAttribute(org.geotools.xml.schema.Attribute,
0307: * java.lang.Object, java.util.Map)
0308: */
0309: public AttributeValue toAttribute(Attribute attribute,
0310: Object value, Map hints) {
0311: return new AttributeValueGT(attribute, value.toString());
0312: }
0313:
0314: /**
0315: * @see org.geotools.xml.schema.Type#encode(org.geotools.xml.schema.Element,
0316: * java.lang.Object, org.geotools.xml.PrintHandler,
0317: * java.util.Map)
0318: */
0319: public void encode(Element element, Object value,
0320: PrintHandler output, Map hints) throws IOException {
0321: if (element == null) {
0322: output.startElement(getNamespace(), getName(), null);
0323: output.characters(value.toString());
0324: output.endElement(getNamespace(), getName());
0325: } else {
0326: output.startElement(element.getNamespace(), element
0327: .getName(), null);
0328: output.characters(((value == null) ? "" : value
0329: .toString()));
0330: output.endElement(element.getNamespace(), element
0331: .getName());
0332: }
0333: }
0334:
0335: /**
0336: * <p>
0337: * This method is intended to return an instance of the implemented
0338: * type.
0339: * </p>
0340: *
0341: * @return SimpleType
0342: *
0343: * @throws RuntimeException when not overridden
0344: */
0345: public static SimpleType getInstance() {
0346: throw new RuntimeException(
0347: "This method must be overwritten");
0348: }
0349:
0350: /**
0351: * @see org.geotools.xml.xsi.Type#getParent()
0352: */
0353: public Type getParent() {
0354: return null;
0355: }
0356:
0357: /**
0358: * @see org.geotools.xml.xsi.Type#getNamespace()
0359: */
0360: public URI getNamespace() {
0361: return NAMESPACE;
0362: }
0363:
0364: /**
0365: * @see org.geotools.xml.xsi.SimpleType#getFinal()
0366: */
0367: public int getFinal() {
0368: return SimpleType.NONE;
0369: }
0370:
0371: /**
0372: * @see org.geotools.xml.xsi.SimpleType#getId()
0373: */
0374: public java.lang.String getId() {
0375: return null;
0376: }
0377:
0378: /**
0379: * @see org.geotools.xml.schema.SimpleType#getChildType()
0380: */
0381: public int getChildType() {
0382: return NONE; // this should be ok
0383: }
0384:
0385: /**
0386: * @see org.geotools.xml.schema.SimpleType#getParents()
0387: */
0388: public SimpleType[] getParents() {
0389: return null;
0390: }
0391:
0392: /**
0393: * @see org.geotools.xml.schema.SimpleType#getFacets()
0394: */
0395: public Facet[] getFacets() {
0396: return null;
0397: }
0398:
0399: /**
0400: * @see org.geotools.xml.schema.Type#findChildElement(java.lang.String)
0401: */
0402: public Element findChildElement(java.lang.String name) {
0403: return null;
0404: }
0405: }
0406:
0407: /**
0408: * <p>
0409: * XSI Schema Integer
0410: * </p>
0411: *
0412: * @author dzwiers
0413: */
0414: public static class Integer extends XSISimpleType {
0415: private static SimpleType instance = new Integer();
0416:
0417: /**
0418: * @see org.geotools.xml.xsi.Type#getName()
0419: */
0420: public java.lang.String getName() {
0421: return "integer";
0422: }
0423:
0424: /**
0425: * @param element
0426: * @param value
0427: * @param attrsgetValue
0428: * @param hints
0429: * @throws SAXException
0430: * @see org.geotools.xml.xsi.Type#getValue(org.geotools.xml.xsi.Element,
0431: * org.geotools.xml.xsi.ElementValue[], org.xml.sax.Attributes)
0432: */
0433: public Object getValue(Element element, ElementValue[] value,
0434: Attributes attrsgetValue, Map hints) {
0435: if ((value.length >= 1) && (value[0].getValue() != null)) {
0436: return new java.lang.Integer(
0437: (java.lang.String) value[0].getValue());
0438: }
0439:
0440: return null;
0441: }
0442:
0443: /**
0444: * @see org.geotools.xml.xsi.Type#getInstanceType()
0445: */
0446: public Class getInstanceType() {
0447: return java.lang.Integer.class;
0448: }
0449:
0450: /**
0451: * @see org.geotools.xml.schemas.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0452: */
0453: public static SimpleType getInstance() {
0454: return instance;
0455: }
0456: }
0457:
0458: /**
0459: * <p>
0460: * XSI Schema instance of Decimal
0461: * </p>
0462: *
0463: * @author dzwiers
0464: */
0465: public static class Decimal extends XSISimpleType {
0466: private static SimpleType instance = new Decimal();
0467:
0468: /**
0469: * @see org.geotools.xml.schemas.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0470: */
0471: public static SimpleType getInstance() {
0472: return instance;
0473: }
0474:
0475: /**
0476: * @see org.geotools.xml.xsi.Type#getName()
0477: */
0478: public java.lang.String getName() {
0479: return "decimal";
0480: }
0481:
0482: /**
0483: * @param element
0484: * @param value
0485: * @param attrs
0486: * @param hints
0487: * @throws SAXException
0488: * @see org.geotools.xml.xsi.Type#getValue(org.geotools.xml.xsi.Element,
0489: * org.geotools.xml.xsi.ElementValue[], org.xml.sax.Attributes)
0490: */
0491: public Object getValue(Element element, ElementValue[] value,
0492: Attributes attrs, Map hints) {
0493: if ((value.length == 1) && (value[0].getValue() != null)) {
0494: return new java.lang.Double((java.lang.String) value[0]
0495: .getValue());
0496: }
0497:
0498: return null;
0499: }
0500:
0501: /**
0502: * @see org.geotools.xml.xsi.Type#getInstanceType()
0503: */
0504: public Class getInstanceType() {
0505: return java.lang.Double.class;
0506: }
0507: }
0508:
0509: /**
0510: * <p>
0511: * XSI Schema instance of NegativeInteger
0512: * </p>
0513: *
0514: * @author dzwiers
0515: */
0516: public static class NegativeInteger extends XSISimpleType {
0517: private static SimpleType instance = new NegativeInteger();
0518:
0519: /**
0520: * @see org.geotools.xml.schemas.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0521: */
0522: public static SimpleType getInstance() {
0523: return instance;
0524: }
0525:
0526: /**
0527: * @see org.geotools.xml.xsi.Type#getName()
0528: */
0529: public java.lang.String getName() {
0530: return "negativeInteger";
0531: }
0532:
0533: /**
0534: * @see org.geotools.xml.xsi.Type#getValue(org.geotools.xml.xsi.Element,
0535: * org.geotools.xml.xsi.ElementValue[], org.xml.sax.Attributes)
0536: */
0537: public Object getValue(Element element, ElementValue[] value,
0538: Attributes attrs, Map hints) {
0539: if ((value.length == 1) && (value[0].getValue() != null)) {
0540: java.lang.Integer i = new java.lang.Integer(
0541: (java.lang.String) value[0].getValue());
0542:
0543: return (i.intValue() < 0) ? i : null;
0544: }
0545:
0546: return null;
0547: }
0548:
0549: /**
0550: * @see org.geotools.xml.xsi.Type#getInstanceType()
0551: */
0552: public Class getInstanceType() {
0553: return java.lang.Integer.class;
0554: }
0555: }
0556:
0557: /**
0558: * <p>
0559: * XSI Schema instance of NonNegativeInteger
0560: * </p>
0561: *
0562: * @author dzwiers
0563: */
0564: public static class NonNegativeInteger extends XSISimpleType {
0565: private static SimpleType instance = new NonNegativeInteger();
0566:
0567: /**
0568: * @see org.geotools.xml.schemas.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0569: */
0570: public static SimpleType getInstance() {
0571: return instance;
0572: }
0573:
0574: /**
0575: * @see org.geotools.xml.xsi.Type#getName()
0576: */
0577: public java.lang.String getName() {
0578: return "nonNegativeInteger";
0579: }
0580:
0581: /**
0582: *
0583: * TODO summary sentence for getValue ...
0584: *
0585: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element, org.geotools.xml.schema.ElementValue[], org.xml.sax.Attributes, java.util.Map)
0586: * @param element
0587: * @param value
0588: * @param attrs
0589: * @param hints
0590: * @return Object
0591: */
0592: public Object getValue(Element element, ElementValue[] value,
0593: Attributes attrs, Map hints) {
0594: if ((value.length == 1) && (value[0].getValue() != null)) {
0595: java.lang.Integer i = new java.lang.Integer(
0596: (java.lang.String) value[0].getValue());
0597:
0598: return (i.intValue() >= 0) ? i : null;
0599: }
0600:
0601: return null;
0602: }
0603:
0604: /**
0605: * @see org.geotools.xml.xsi.Type#getInstanceType()
0606: */
0607: public Class getInstanceType() {
0608: return java.lang.Integer.class;
0609: }
0610: }
0611:
0612: /**
0613: * <p>
0614: * XSI Schema instance of PositiveInteger
0615: * </p>
0616: *
0617: * @author dzwiers
0618: */
0619: public static class PositiveInteger extends XSISimpleType {
0620: private static SimpleType instance = new PositiveInteger();
0621:
0622: /**
0623: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0624: */
0625: public static SimpleType getInstance() {
0626: return instance;
0627: }
0628:
0629: /**
0630: * @see schema.SimpleType#getName()
0631: */
0632: public java.lang.String getName() {
0633: return "positiveInteger";
0634: }
0635:
0636: /**
0637: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
0638: */
0639: public Object getValue(Element element, ElementValue[] value,
0640: Attributes attrs, Map hints) {
0641: if ((value.length == 1) && (value[0].getValue() != null)) {
0642: java.lang.Integer i = new java.lang.Integer(
0643: (java.lang.String) value[0].getValue());
0644:
0645: return (i.intValue() > 0) ? i : null;
0646: }
0647:
0648: return null;
0649: }
0650:
0651: /**
0652: * @see org.geotools.xml.xsi.Type#getInstanceType()
0653: */
0654: public Class getInstanceType() {
0655: return java.lang.Integer.class;
0656: }
0657: }
0658:
0659: /**
0660: * <p>
0661: * XSI Schema instance of NonPositiveInteger
0662: * </p>
0663: *
0664: * @author dzwiers
0665: */
0666: public static class NonPositiveInteger extends XSISimpleType {
0667: private static SimpleType instance = new NonPositiveInteger();
0668:
0669: /**
0670: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0671: */
0672: public static SimpleType getInstance() {
0673: return instance;
0674: }
0675:
0676: /**
0677: * @see schema.SimpleType#getName()
0678: */
0679: public java.lang.String getName() {
0680: return "nonPositiveInteger";
0681: }
0682:
0683: /**
0684: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
0685: */
0686: public Object getValue(Element element, ElementValue[] value,
0687: Attributes attrs, Map hints) {
0688: if ((value.length == 1) && (value[0].getValue() != null)) {
0689: java.lang.Integer i = new java.lang.Integer(
0690: (java.lang.String) value[0].getValue());
0691:
0692: return (i.intValue() <= 0) ? i : null;
0693: }
0694:
0695: return null;
0696: }
0697:
0698: /**
0699: * @see org.geotools.xml.xsi.Type#getInstanceType()
0700: */
0701: public Class getInstanceType() {
0702: return java.lang.Integer.class;
0703: }
0704: }
0705:
0706: /**
0707: * <p>
0708: * XSI Schema instance of Long
0709: * </p>
0710: *
0711: * @author dzwiers
0712: */
0713: public static class Long extends XSISimpleType {
0714: private static SimpleType instance = new Long();
0715:
0716: /**
0717: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0718: */
0719: public static SimpleType getInstance() {
0720: return instance;
0721: }
0722:
0723: /**
0724: * @see schema.SimpleType#getName()
0725: */
0726: public java.lang.String getName() {
0727: return "long";
0728: }
0729:
0730: /**
0731: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
0732: */
0733: public Object getValue(Element element, ElementValue[] value,
0734: Attributes attrs, Map hints) {
0735: if ((value.length == 1) && (value[0].getValue() != null)) {
0736: java.lang.Long i = new java.lang.Long(
0737: (java.lang.String) value[0].getValue());
0738:
0739: return i;
0740: }
0741:
0742: return null;
0743: }
0744:
0745: /**
0746: * @see org.geotools.xml.xsi.Type#getInstanceType()
0747: */
0748: public Class getInstanceType() {
0749: return java.lang.Long.class;
0750: }
0751: }
0752:
0753: /**
0754: * <p>
0755: * XSI Schema instance of Int
0756: * </p>
0757: *
0758: * @author dzwiers
0759: */
0760: public static class Int extends XSISimpleType {
0761: private static SimpleType instance = new Int();
0762:
0763: /**
0764: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0765: */
0766: public static SimpleType getInstance() {
0767: return instance;
0768: }
0769:
0770: /**
0771: * @see schema.SimpleType#getName()
0772: */
0773: public java.lang.String getName() {
0774: return "int";
0775: }
0776:
0777: /**
0778: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
0779: */
0780: public Object getValue(Element element, ElementValue[] value,
0781: Attributes attrs, Map hints) {
0782: if ((value.length == 1) && (value[0].getValue() != null)) {
0783: java.lang.Integer i = new java.lang.Integer(
0784: (java.lang.String) value[0].getValue());
0785:
0786: return i;
0787: }
0788:
0789: return null;
0790: }
0791:
0792: /**
0793: * @see org.geotools.xml.xsi.Type#getInstanceType()
0794: */
0795: public Class getInstanceType() {
0796: return java.lang.Integer.class;
0797: }
0798: }
0799:
0800: /**
0801: * <p>
0802: * XSI Schema instance of Short
0803: * </p>
0804: *
0805: * @author dzwiers
0806: */
0807: public static class Short extends XSISimpleType {
0808: private static SimpleType instance = new Short();
0809:
0810: /**
0811: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0812: */
0813: public static SimpleType getInstance() {
0814: return instance;
0815: }
0816:
0817: /**
0818: * @see schema.SimpleType#getName()
0819: */
0820: public java.lang.String getName() {
0821: return "short";
0822: }
0823:
0824: /**
0825: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
0826: */
0827: public Object getValue(Element element, ElementValue[] value,
0828: Attributes attrs, Map hints) {
0829: if ((value.length == 1) && (value[0].getValue() != null)) {
0830: java.lang.Short i = new java.lang.Short(
0831: (java.lang.String) value[0].getValue());
0832:
0833: return i;
0834: }
0835:
0836: return null;
0837: }
0838:
0839: /**
0840: * @see org.geotools.xml.xsi.Type#getInstanceType()
0841: */
0842: public Class getInstanceType() {
0843: return java.lang.Short.class;
0844: }
0845: }
0846:
0847: /**
0848: * <p>
0849: * XSI Schema instance of Byte
0850: * </p>
0851: *
0852: * @author dzwiers
0853: */
0854: public static class Byte extends XSISimpleType {
0855: private static SimpleType instance = new Byte();
0856:
0857: /**
0858: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0859: */
0860: public static SimpleType getInstance() {
0861: return instance;
0862: }
0863:
0864: /**
0865: * @see schema.SimpleType#getName()
0866: */
0867: public java.lang.String getName() {
0868: return "byte";
0869: }
0870:
0871: /**
0872: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
0873: */
0874: public Object getValue(Element element, ElementValue[] value,
0875: Attributes attrs, Map hints) {
0876: if ((value.length == 1) && (value[0].getValue() != null)) {
0877: java.lang.Byte i = new java.lang.Byte(
0878: (java.lang.String) value[0].getValue());
0879:
0880: return i;
0881: }
0882:
0883: return null;
0884: }
0885:
0886: /**
0887: * @see org.geotools.xml.xsi.Type#getInstanceType()
0888: */
0889: public Class getInstanceType() {
0890: return java.lang.Byte.class;
0891: }
0892: }
0893:
0894: /**
0895: * <p>
0896: * XSI Schema instance of UnsignedLong
0897: * </p>
0898: *
0899: * @author dzwiers
0900: */
0901: public static class UnsignedLong extends XSISimpleType {
0902: private static SimpleType instance = new UnsignedLong();
0903:
0904: /**
0905: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0906: */
0907: public static SimpleType getInstance() {
0908: return instance;
0909: }
0910:
0911: /**
0912: * @see schema.SimpleType#getName()
0913: */
0914: public java.lang.String getName() {
0915: return "unsignedLong";
0916: }
0917:
0918: /**
0919: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
0920: */
0921: public Object getValue(Element element, ElementValue[] value,
0922: Attributes attrs, Map hints) {
0923: if ((value.length == 1) && (value[0].getValue() != null)) {
0924: java.lang.Long i = new java.lang.Long(
0925: (java.lang.String) value[0].getValue());
0926:
0927: return i;
0928: }
0929:
0930: return null;
0931: }
0932:
0933: /**
0934: * @see org.geotools.xml.xsi.Type#getInstanceType()
0935: */
0936: public Class getInstanceType() {
0937: return java.lang.Long.class;
0938: }
0939: }
0940:
0941: /**
0942: * <p>
0943: * XSI Schema instance of UnsignedShort
0944: * </p>
0945: *
0946: * @author dzwiers
0947: */
0948: public static class UnsignedShort extends XSISimpleType {
0949: private static SimpleType instance = new UnsignedShort();
0950:
0951: /**
0952: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
0953: */
0954: public static SimpleType getInstance() {
0955: return instance;
0956: }
0957:
0958: /**
0959: * @see schema.SimpleType#getName()
0960: */
0961: public java.lang.String getName() {
0962: return "unsignedShort";
0963: }
0964:
0965: /**
0966: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
0967: */
0968: public Object getValue(Element element, ElementValue[] value,
0969: Attributes attrs, Map hints) {
0970: if ((value.length == 1) && (value[0].getValue() != null)) {
0971: java.lang.Short i = new java.lang.Short(
0972: (java.lang.String) value[0].getValue());
0973:
0974: return i;
0975: }
0976:
0977: return null;
0978: }
0979:
0980: /**
0981: * @see org.geotools.xml.xsi.Type#getInstanceType()
0982: */
0983: public Class getInstanceType() {
0984: return java.lang.Short.class;
0985: }
0986: }
0987:
0988: /**
0989: * <p>
0990: * XSI Schema instance of UnsignedInt
0991: * </p>
0992: *
0993: * @author dzwiers
0994: */
0995: public static class UnsignedInt extends XSISimpleType {
0996: private static SimpleType instance = new UnsignedInt();
0997:
0998: /**
0999: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1000: */
1001: public static SimpleType getInstance() {
1002: return instance;
1003: }
1004:
1005: /**
1006: * @see schema.SimpleType#getName()
1007: */
1008: public java.lang.String getName() {
1009: return "unsignedInt";
1010: }
1011:
1012: /**
1013: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1014: */
1015: public Object getValue(Element element, ElementValue[] value,
1016: Attributes attrs, Map hints) {
1017: if ((value.length == 1) && (value[0].getValue() != null)) {
1018: java.lang.Integer i = new java.lang.Integer(
1019: (java.lang.String) value[0].getValue());
1020:
1021: return i;
1022: }
1023:
1024: return null;
1025: }
1026:
1027: /**
1028: * @see org.geotools.xml.xsi.Type#getInstanceType()
1029: */
1030: public Class getInstanceType() {
1031: return java.lang.Integer.class;
1032: }
1033: }
1034:
1035: /**
1036: * <p>
1037: * XSI Schema instance of UnsignedByte
1038: * </p>
1039: *
1040: * @author dzwiers
1041: */
1042: public static class UnsignedByte extends XSISimpleType {
1043: private static SimpleType instance = new UnsignedByte();
1044:
1045: /**
1046: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1047: */
1048: public static SimpleType getInstance() {
1049: return instance;
1050: }
1051:
1052: /**
1053: * @see schema.SimpleType#getName()
1054: */
1055: public java.lang.String getName() {
1056: return "unsignedByte";
1057: }
1058:
1059: /**
1060: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1061: */
1062: public Object getValue(Element element, ElementValue[] value,
1063: Attributes attrs, Map hints) {
1064: if ((value.length == 1) && (value[0].getValue() != null)) {
1065: java.lang.Byte i = new java.lang.Byte(
1066: (java.lang.String) value[0].getValue());
1067:
1068: return i;
1069: }
1070:
1071: return null;
1072: }
1073:
1074: /**
1075: * @see org.geotools.xml.xsi.Type#getInstanceType()
1076: */
1077: public Class getInstanceType() {
1078: return java.lang.Byte.class;
1079: }
1080: }
1081:
1082: /**
1083: * <p>
1084: * XSI Schema instance of Float
1085: * </p>
1086: *
1087: * @author dzwiers
1088: */
1089: public static class Float extends XSISimpleType {
1090: private static SimpleType instance = new Float();
1091:
1092: /**
1093: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1094: */
1095: public static SimpleType getInstance() {
1096: return instance;
1097: }
1098:
1099: /**
1100: * @see schema.SimpleType#getName()
1101: */
1102: public java.lang.String getName() {
1103: return "float";
1104: }
1105:
1106: /**
1107: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1108: */
1109: public Object getValue(Element element, ElementValue[] value,
1110: Attributes attrs, Map hints) {
1111: if ((value.length == 1) && (value[0].getValue() != null)) {
1112: java.lang.Float i = new java.lang.Float(
1113: (java.lang.String) value[0].getValue());
1114:
1115: return i;
1116: }
1117:
1118: return null;
1119: }
1120:
1121: /**
1122: * @see org.geotools.xml.xsi.Type#getInstanceType()
1123: */
1124: public Class getInstanceType() {
1125: return java.lang.Float.class;
1126: }
1127: }
1128:
1129: /**
1130: * <p>
1131: * XSI Schema instance of Double
1132: * </p>
1133: *
1134: * @author dzwiers
1135: */
1136: public static class Double extends XSISimpleType {
1137: private static SimpleType instance = new Double();
1138:
1139: /**
1140: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1141: */
1142: public static SimpleType getInstance() {
1143: return instance;
1144: }
1145:
1146: /**
1147: * @see schema.SimpleType#getName()
1148: */
1149: public java.lang.String getName() {
1150: return "double";
1151: }
1152:
1153: /**
1154: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1155: */
1156: public Object getValue(Element element, ElementValue[] value,
1157: Attributes attrs, Map hints) {
1158: if ((value.length == 1) && (value[0].getValue() != null)) {
1159: java.lang.Double i = new java.lang.Double(
1160: (java.lang.String) value[0].getValue());
1161:
1162: return i;
1163: }
1164:
1165: return null;
1166: }
1167:
1168: /**
1169: * @see org.geotools.xml.xsi.Type#getInstanceType()
1170: */
1171: public Class getInstanceType() {
1172: return java.lang.Double.class;
1173: }
1174: }
1175:
1176: /**
1177: * <p>
1178: * XSI Schema instance of Date
1179: * </p>
1180: *
1181: * @author dzwiers
1182: */
1183: public static class Date extends XSISimpleType {
1184: private static SimpleType instance = new Date();
1185:
1186: /**
1187: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1188: */
1189: public static SimpleType getInstance() {
1190: return instance;
1191: }
1192:
1193: /**
1194: * @see schema.SimpleType#getName()
1195: */
1196: public java.lang.String getName() {
1197: return "date";
1198: }
1199:
1200: /**
1201: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1202: */
1203: public Object getValue(Element element, ElementValue[] value,
1204: Attributes attrs, Map hints) throws SAXException {
1205: if ((value.length == 1) && (value[0].getValue() != null)) {
1206: java.lang.String svalue = (java.lang.String) value[0]
1207: .getValue();
1208: java.lang.String[] values = svalue.split("\\-");
1209:
1210: if (values.length != 3) {
1211: throw new SAXException(
1212: "Could not parse the DateTime " + value);
1213: }
1214:
1215: int year;
1216: int month;
1217: int day;
1218: year = java.lang.Integer.parseInt(values[0]);
1219: month = java.lang.Integer.parseInt(values[1]);
1220: day = java.lang.Integer.parseInt(values[2]);
1221:
1222: Calendar c = Calendar.getInstance();
1223: c.clear();
1224: c.set(year, month, day);
1225:
1226: return c.getTime();
1227: }
1228:
1229: return null;
1230: }
1231:
1232: /**
1233: * @see org.geotools.xml.xsi.Type#getInstanceType()
1234: */
1235: public Class getInstanceType() {
1236: return java.util.Date.class;
1237: }
1238: }
1239:
1240: /**
1241: * <p>
1242: * XSI Schema instance of DateTime
1243: * </p>
1244: *
1245: * @author dzwiers
1246: */
1247: public static class DateTime extends XSISimpleType {
1248: private static SimpleType instance = new DateTime();
1249:
1250: /**
1251: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1252: */
1253: public static SimpleType getInstance() {
1254: return instance;
1255: }
1256:
1257: /**
1258: * @see schema.SimpleType#getName()
1259: */
1260: public java.lang.String getName() {
1261: return "dateTime";
1262: }
1263:
1264: /**
1265: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1266: */
1267: public Object getValue(Element element, ElementValue[] value,
1268: Attributes attrs, Map hints) throws SAXException {
1269: if ((value.length == 1) && (value[0].getValue() != null)) {
1270: java.lang.String svalue = (java.lang.String) value[0]
1271: .getValue();
1272: java.lang.String[] values = svalue.split("T");
1273:
1274: if (values.length != 2) {
1275: throw new SAXException(
1276: "Could not parse the DateTime " + value);
1277: }
1278:
1279: java.lang.String date = values[0];
1280: java.lang.String time = values[1];
1281:
1282: values = date.split("\\-");
1283:
1284: if (values.length != 3) {
1285: throw new SAXException(
1286: "Could not parse the DateTime " + value);
1287: }
1288:
1289: int year;
1290: int month;
1291: int day;
1292: year = java.lang.Integer.parseInt(values[0]);
1293: month = java.lang.Integer.parseInt(values[1]);
1294: day = java.lang.Integer.parseInt(values[2]);
1295:
1296: values = time.split("\\:", 3);
1297:
1298: if (values.length != 3) {
1299: throw new SAXException(
1300: "Could not parse the DateTime " + value);
1301: }
1302:
1303: int hour;
1304: int minute;
1305: int second;
1306: hour = java.lang.Integer.parseInt(values[0]);
1307: minute = java.lang.Integer.parseInt(values[1]);
1308:
1309: int i = values[2].indexOf("-");
1310: Calendar c = null;
1311:
1312: if (i == -1) {
1313: i = values[2].indexOf("+");
1314: }
1315:
1316: if (i == -1) {
1317: if (values[2].endsWith("Z")) {
1318: second = (int) java.lang.Float
1319: .parseFloat(values[2].substring(0,
1320: values[2].length() - 1));
1321: } else {
1322: second = (int) java.lang.Float
1323: .parseFloat(values[2]);
1324: }
1325:
1326: TimeZone tz = TimeZone.getTimeZone("GMT");
1327: c = Calendar.getInstance(tz);
1328: c.clear();
1329: } else {
1330: second = (int) java.lang.Float.parseFloat(values[2]
1331: .substring(0, i));
1332:
1333: TimeZone tz = TimeZone.getTimeZone("GMT"
1334: + values[2].substring(i));
1335: c = Calendar.getInstance(tz);
1336: c.clear();
1337: }
1338:
1339: c.set(year, month, day, hour, minute, second);
1340:
1341: java.util.Date r = c.getTime();
1342:
1343: return r;
1344: }
1345:
1346: return null;
1347: }
1348:
1349: /**
1350: * @see org.geotools.xml.xsi.Type#getInstanceType()
1351: */
1352: public Class getInstanceType() {
1353: return java.util.Date.class;
1354: }
1355: }
1356:
1357: /**
1358: * <p>
1359: * XSI Schema instance of Duration
1360: * </p>
1361: *
1362: * @author dzwiers
1363: */
1364: public static class Duration extends XSISimpleType {
1365: private static SimpleType instance = new Duration();
1366:
1367: /**
1368: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1369: */
1370: public static SimpleType getInstance() {
1371: return instance;
1372: }
1373:
1374: /**
1375: * @see schema.SimpleType#getName()
1376: */
1377: public java.lang.String getName() {
1378: return "duration";
1379: }
1380:
1381: /**
1382: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1383: */
1384: public Object getValue(Element element, ElementValue[] value,
1385: Attributes attrs, Map hints) throws SAXException {
1386: if ((value.length == 1) && (value[0].getValue() != null)) {
1387: int year;
1388: int month;
1389: int day;
1390: int hour;
1391: int minute;
1392: int second;
1393: year = month = day = hour = minute = second = 0;
1394:
1395: int index = 0;
1396: java.lang.String svalue = (java.lang.String) value[0]
1397: .getValue();
1398:
1399: if (svalue.indexOf("P") == 0) {
1400: index++;
1401: } else {
1402: throw new SAXException("Malformed Duration: "
1403: + svalue);
1404: }
1405:
1406: java.lang.String[] svalues = svalue.split("\\D");
1407: int sindex = 0;
1408:
1409: if (svalues == null) {
1410: return null;
1411: }
1412:
1413: if ((svalue.length() < index)
1414: && (svalue.charAt(1 + svalues[sindex].length()) == 'Y')
1415: && (sindex < svalues.length)) {
1416: year = java.lang.Integer.parseInt(svalues[sindex]);
1417: index += (svalues[sindex].length() + 1);
1418: sindex++;
1419: }
1420:
1421: if ((svalue.length() < index)
1422: && (svalue.charAt(1 + svalues[sindex].length()) == 'M')
1423: && (sindex < svalues.length)) {
1424: month = java.lang.Integer.parseInt(svalues[sindex]);
1425: index += (svalues[sindex].length() + 1);
1426: sindex++;
1427: }
1428:
1429: if ((svalue.length() < index)
1430: && (svalue.charAt(1 + svalues[sindex].length()) == 'D')
1431: && (sindex < svalues.length)) {
1432: day = java.lang.Integer.parseInt(svalues[sindex]);
1433: index += (svalues[sindex].length() + 1);
1434: sindex++;
1435: }
1436:
1437: index++; // T
1438:
1439: if ((svalue.length() < index)
1440: && (svalue.charAt(1 + svalues[sindex].length()) == 'H')
1441: && (sindex < svalues.length)) {
1442: hour = java.lang.Integer.parseInt(svalues[sindex]);
1443: index += (svalues[sindex].length() + 1);
1444: sindex++;
1445: }
1446:
1447: if ((svalue.length() < index)
1448: && (svalue.charAt(1 + svalues[sindex].length()) == 'M')
1449: && (sindex < svalues.length)) {
1450: minute = java.lang.Integer
1451: .parseInt(svalues[sindex]);
1452: index += (svalues[0].length() + 1);
1453: sindex++;
1454: }
1455:
1456: if ((svalue.length() < index)
1457: && (svalue.charAt(1 + svalues[sindex].length()) == 'S')
1458: && (sindex < svalues.length)) {
1459: second = java.lang.Integer
1460: .parseInt(svalues[sindex]);
1461: index += (svalues[sindex].length() + 1);
1462: sindex++;
1463: }
1464:
1465: Calendar c = Calendar.getInstance();
1466: c.clear();
1467: c.set(year, month, day, hour, minute, second);
1468:
1469: java.util.Date r = c.getTime();
1470:
1471: return r;
1472: }
1473:
1474: return null;
1475: }
1476:
1477: /**
1478: * @see org.geotools.xml.xsi.Type#getInstanceType()
1479: */
1480: public Class getInstanceType() {
1481: return java.util.Date.class;
1482: }
1483: }
1484:
1485: /**
1486: * <p>
1487: * XSI Schema instance of gDay
1488: * </p>
1489: *
1490: * @author dzwiers
1491: */
1492: public static class gDay extends XSISimpleType {
1493: private static SimpleType instance = new gDay();
1494:
1495: /**
1496: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1497: */
1498: public static SimpleType getInstance() {
1499: return instance;
1500: }
1501:
1502: /**
1503: * @see schema.SimpleType#getName()
1504: */
1505: public java.lang.String getName() {
1506: return "gDay";
1507: }
1508:
1509: /**
1510: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1511: */
1512: public Object getValue(Element element, ElementValue[] value,
1513: Attributes attrs, Map hints) {
1514: if ((value.length == 1) && (value[0].getValue() != null)) {
1515: java.lang.String svalue = (java.lang.String) value[0]
1516: .getValue();
1517: svalue = svalue.split("\\D*")[0]; // get digits;
1518:
1519: Calendar c = Calendar.getInstance();
1520: c.clear();
1521: c.set(Calendar.DAY_OF_MONTH, java.lang.Integer
1522: .parseInt(svalue));
1523:
1524: return c.getTime();
1525: }
1526:
1527: return null;
1528: }
1529:
1530: /**
1531: * @see org.geotools.xml.xsi.Type#getInstanceType()
1532: */
1533: public Class getInstanceType() {
1534: return java.util.Date.class;
1535: }
1536: }
1537:
1538: /**
1539: * <p>
1540: * XSI Schema instance of gMonth
1541: * </p>
1542: *
1543: * @author dzwiers
1544: */
1545: public static class gMonth extends XSISimpleType {
1546: private static SimpleType instance = new gMonth();
1547:
1548: /**
1549: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1550: */
1551: public static SimpleType getInstance() {
1552: return instance;
1553: }
1554:
1555: /**
1556: * @see schema.SimpleType#getName()
1557: */
1558: public java.lang.String getName() {
1559: return "gMonth";
1560: }
1561:
1562: /**
1563: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1564: */
1565: public Object getValue(Element element, ElementValue[] value,
1566: Attributes attrs, Map hints) {
1567: if ((value.length == 1) && (value[0].getValue() != null)) {
1568: java.lang.String svalue = (java.lang.String) value[0]
1569: .getValue();
1570: svalue = svalue.split("\\D*")[0]; // get digits;
1571:
1572: Calendar c = Calendar.getInstance();
1573: c.clear();
1574: c.set(Calendar.MONTH, java.lang.Integer
1575: .parseInt(svalue));
1576:
1577: return c.getTime();
1578: }
1579:
1580: return null;
1581: }
1582:
1583: /**
1584: * @see org.geotools.xml.xsi.Type#getInstanceType()
1585: */
1586: public Class getInstanceType() {
1587: return java.util.Date.class;
1588: }
1589: }
1590:
1591: /**
1592: * <p>
1593: * XSI Schema instance of gMonthDay
1594: * </p>
1595: *
1596: * @author dzwiers
1597: */
1598: public static class gMonthDay extends XSISimpleType {
1599: private static SimpleType instance = new gMonthDay();
1600:
1601: /**
1602: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1603: */
1604: public static SimpleType getInstance() {
1605: return instance;
1606: }
1607:
1608: /**
1609: * @see schema.SimpleType#getName()
1610: */
1611: public java.lang.String getName() {
1612: return "gMonthDay";
1613: }
1614:
1615: /**
1616: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1617: */
1618: public Object getValue(Element element, ElementValue[] value,
1619: Attributes attrs, Map hints) {
1620: if ((value.length == 1) && (value[0].getValue() != null)) {
1621: java.lang.String svalue = (java.lang.String) value[0]
1622: .getValue();
1623: java.lang.String[] t = svalue.split("\\D*"); // get digits;
1624:
1625: Calendar c = Calendar.getInstance();
1626: c.clear();
1627: c.set(Calendar.DAY_OF_MONTH, java.lang.Integer
1628: .parseInt(t[0]));
1629: c.set(Calendar.MONTH, java.lang.Integer.parseInt(t[1]));
1630:
1631: return c.getTime();
1632: }
1633:
1634: return null;
1635: }
1636:
1637: /**
1638: * @see org.geotools.xml.xsi.Type#getInstanceType()
1639: */
1640: public Class getInstanceType() {
1641: return java.util.Date.class;
1642: }
1643: }
1644:
1645: /**
1646: * <p>
1647: * XSI Schema instance of gYear
1648: * </p>
1649: *
1650: * @author dzwiers
1651: */
1652: public static class gYear extends XSISimpleType {
1653: private static SimpleType instance = new gYear();
1654:
1655: /**
1656: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1657: */
1658: public static SimpleType getInstance() {
1659: return instance;
1660: }
1661:
1662: /**
1663: * @see schema.SimpleType#getName()
1664: */
1665: public java.lang.String getName() {
1666: return "gYear";
1667: }
1668:
1669: /**
1670: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1671: */
1672: public Object getValue(Element element, ElementValue[] value,
1673: Attributes attrs, Map hints) {
1674: if ((value.length == 1) && (value[0].getValue() != null)) {
1675: java.lang.String svalue = (java.lang.String) value[0]
1676: .getValue();
1677: java.lang.String[] t = svalue.split("\\D*"); // get digits;
1678:
1679: Calendar c = Calendar.getInstance();
1680: c.clear();
1681: c.set(Calendar.YEAR, java.lang.Integer.parseInt(t[0]));
1682:
1683: return c.getTime();
1684: }
1685:
1686: return null;
1687: }
1688:
1689: /**
1690: * @see org.geotools.xml.xsi.Type#getInstanceType()
1691: */
1692: public Class getInstanceType() {
1693: return java.util.Date.class;
1694: }
1695: }
1696:
1697: /**
1698: * <p>
1699: * XSI Schema instance of gYearMonth
1700: * </p>
1701: *
1702: * @author dzwiers
1703: */
1704: public static class gYearMonth extends XSISimpleType {
1705: private static SimpleType instance = new gYearMonth();
1706:
1707: /**
1708: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1709: */
1710: public static SimpleType getInstance() {
1711: return instance;
1712: }
1713:
1714: /**
1715: * @see schema.SimpleType#getName()
1716: */
1717: public java.lang.String getName() {
1718: return "gYearMonth";
1719: }
1720:
1721: /**
1722: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1723: */
1724: public Object getValue(Element element, ElementValue[] value,
1725: Attributes attrs, Map hints) {
1726: if ((value.length == 1) && (value[0].getValue() != null)) {
1727: java.lang.String svalue = (java.lang.String) value[0]
1728: .getValue();
1729: java.lang.String[] t = svalue.split("\\D*"); // get digits;
1730:
1731: Calendar c = Calendar.getInstance();
1732: c.clear();
1733: c.set(Calendar.MONTH, java.lang.Integer.parseInt(t[1]));
1734: c.set(Calendar.YEAR, java.lang.Integer.parseInt(t[0]));
1735:
1736: return c.getTime();
1737: }
1738:
1739: return null;
1740: }
1741:
1742: /**
1743: * @see org.geotools.xml.xsi.Type#getInstanceType()
1744: */
1745: public Class getInstanceType() {
1746: return java.util.Date.class;
1747: }
1748: }
1749:
1750: /**
1751: * <p>
1752: * XSI Schema instance of Time
1753: * </p>
1754: *
1755: * @author dzwiers
1756: */
1757: public static class Time extends XSISimpleType {
1758: private static SimpleType instance = new Time();
1759:
1760: /**
1761: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1762: */
1763: public static SimpleType getInstance() {
1764: return instance;
1765: }
1766:
1767: /**
1768: * @see schema.SimpleType#getName()
1769: */
1770: public java.lang.String getName() {
1771: return "time";
1772: }
1773:
1774: /**
1775: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1776: */
1777: public Object getValue(Element element, ElementValue[] value,
1778: Attributes attrs, Map hints) throws SAXException {
1779: if ((value.length == 1) && (value[0].getValue() != null)) {
1780: java.lang.String svalue = (java.lang.String) value[0]
1781: .getValue();
1782: java.lang.String[] values = svalue.split("\\:", 3);
1783:
1784: if (values.length != 3) {
1785: throw new SAXException(
1786: "Could not parse the DateTime " + value);
1787: }
1788:
1789: int hour;
1790: int minute;
1791: int second;
1792: hour = java.lang.Integer.parseInt(values[0]);
1793: minute = java.lang.Integer.parseInt(values[1]);
1794:
1795: int i = values[2].indexOf("-");
1796: Calendar c = null;
1797:
1798: if (i == -1) {
1799: i = values[2].indexOf("+");
1800: }
1801:
1802: if (i == -1) {
1803: if (values[2].endsWith("Z")) {
1804: second = (int) java.lang.Float
1805: .parseFloat(values[2].substring(0,
1806: values[2].length() - 1));
1807: } else {
1808: second = (int) java.lang.Float
1809: .parseFloat(values[2]);
1810: }
1811:
1812: TimeZone tz = TimeZone.getTimeZone("GMT");
1813: c = Calendar.getInstance(tz);
1814: c.clear();
1815: } else {
1816: second = (int) java.lang.Float.parseFloat(values[2]
1817: .substring(0, i));
1818:
1819: TimeZone tz = TimeZone.getTimeZone("GMT"
1820: + values[2].substring(i));
1821: c = Calendar.getInstance(tz);
1822: c.clear();
1823: }
1824:
1825: c.set(Calendar.HOUR_OF_DAY, hour);
1826: c.set(Calendar.MINUTE, minute);
1827: c.set(Calendar.SECOND, second);
1828:
1829: java.util.Date r = c.getTime();
1830:
1831: return r;
1832: }
1833:
1834: return null;
1835: }
1836:
1837: /**
1838: * @see org.geotools.xml.xsi.Type#getInstanceType()
1839: */
1840: public Class getInstanceType() {
1841: return java.util.Date.class;
1842: }
1843: }
1844:
1845: /**
1846: * <p>
1847: * XSI Schema instance of ID
1848: * </p>
1849: *
1850: * @author dzwiers
1851: */
1852: public static class ID extends XSISimpleType {
1853: private static SimpleType instance = new ID();
1854:
1855: /**
1856: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1857: */
1858: public static SimpleType getInstance() {
1859: return instance;
1860: }
1861:
1862: /**
1863: * @see schema.SimpleType#getName()
1864: */
1865: public java.lang.String getName() {
1866: return "ID";
1867: }
1868:
1869: /**
1870: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1871: */
1872: public Object getValue(Element element, ElementValue[] value,
1873: Attributes attrs, Map hints) {
1874: if ((value.length == 1) && (value[0].getValue() != null)) {
1875: java.lang.String i = (java.lang.String) value[0]
1876: .getValue();
1877:
1878: return i;
1879: }
1880:
1881: return null;
1882: }
1883:
1884: /**
1885: * @see org.geotools.xml.xsi.Type#getInstanceType()
1886: */
1887: public Class getInstanceType() {
1888: return java.lang.String.class;
1889: }
1890: }
1891:
1892: /**
1893: * <p>
1894: * XSI Schema instance of IDREF
1895: * </p>
1896: *
1897: * @author dzwiers
1898: */
1899: public static class IDREF extends XSISimpleType {
1900: private static SimpleType instance = new IDREF();
1901:
1902: /**
1903: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1904: */
1905: public static SimpleType getInstance() {
1906: return instance;
1907: }
1908:
1909: /**
1910: * @see schema.SimpleType#getName()
1911: */
1912: public java.lang.String getName() {
1913: return "IDREF";
1914: }
1915:
1916: /**
1917: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1918: */
1919: public Object getValue(Element element, ElementValue[] value,
1920: Attributes attrs, Map hints) {
1921: if ((value.length == 1) && (value[0].getValue() != null)) {
1922: java.lang.String i = (java.lang.String) value[0]
1923: .getValue();
1924:
1925: return i;
1926: }
1927:
1928: return null;
1929: }
1930:
1931: /**
1932: * @see org.geotools.xml.xsi.Type#getInstanceType()
1933: */
1934: public Class getInstanceType() {
1935: return java.lang.String.class;
1936: }
1937: }
1938:
1939: /**
1940: * <p>
1941: * XSI Schema instance of IDREFS
1942: * </p>
1943: *
1944: * @author dzwiers
1945: */
1946: public static class IDREFS extends XSISimpleType {
1947: private static SimpleType instance = new IDREFS();
1948:
1949: /**
1950: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1951: */
1952: public static SimpleType getInstance() {
1953: return instance;
1954: }
1955:
1956: /**
1957: * @see schema.SimpleType#getName()
1958: */
1959: public java.lang.String getName() {
1960: return "IDREFS";
1961: }
1962:
1963: /**
1964: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
1965: */
1966: public Object getValue(Element element, ElementValue[] value,
1967: Attributes attrs, Map hints) {
1968: if ((value.length == 1) && (value[0].getValue() != null)) {
1969: java.lang.String[] i = ((java.lang.String) value[0]
1970: .getValue()).split("\\s");
1971:
1972: return i;
1973: }
1974:
1975: return null;
1976: }
1977:
1978: /**
1979: * @see org.geotools.xml.xsi.Type#getInstanceType()
1980: */
1981: public Class getInstanceType() {
1982: return java.lang.String[].class;
1983: }
1984: }
1985:
1986: /**
1987: * <p>
1988: * XSI Schema instance of ENTITY
1989: * </p>
1990: *
1991: * @author dzwiers
1992: */
1993: public static class ENTITY extends XSISimpleType {
1994: private static SimpleType instance = new ENTITY();
1995:
1996: /**
1997: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
1998: */
1999: public static SimpleType getInstance() {
2000: return instance;
2001: }
2002:
2003: /**
2004: * @see schema.SimpleType#getName()
2005: */
2006: public java.lang.String getName() {
2007: return "ENTITY";
2008: }
2009:
2010: /**
2011: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2012: */
2013: public Object getValue(Element element, ElementValue[] value,
2014: Attributes attrs, Map hints) {
2015: if ((value.length == 1) && (value[0].getValue() != null)) {
2016: java.lang.String i = ((java.lang.String) value[0]
2017: .getValue());
2018:
2019: return i;
2020: }
2021:
2022: return null;
2023: }
2024:
2025: /**
2026: * @see org.geotools.xml.xsi.Type#getInstanceType()
2027: */
2028: public Class getInstanceType() {
2029: return java.lang.String.class;
2030: }
2031: }
2032:
2033: /**
2034: * <p>
2035: * XSI Schema instance of ENTITIES
2036: * </p>
2037: *
2038: * @author dzwiers
2039: */
2040: public static class ENTITIES extends XSISimpleType {
2041: private static SimpleType instance = new ENTITIES();
2042:
2043: /**
2044: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2045: */
2046: public static SimpleType getInstance() {
2047: return instance;
2048: }
2049:
2050: /**
2051: * @see schema.SimpleType#getName()
2052: */
2053: public java.lang.String getName() {
2054: return "ENTITIES";
2055: }
2056:
2057: /**
2058: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2059: */
2060: public Object getValue(Element element, ElementValue[] value,
2061: Attributes attrs, Map hints) {
2062: if ((value.length == 1) && (value[0].getValue() != null)) {
2063: java.lang.String[] i = ((java.lang.String) value[0]
2064: .getValue()).split("\\s");
2065:
2066: return i;
2067: }
2068:
2069: return null;
2070: }
2071:
2072: /**
2073: * @see org.geotools.xml.xsi.Type#getInstanceType()
2074: */
2075: public Class getInstanceType() {
2076: return java.lang.String[].class;
2077: }
2078: }
2079:
2080: /**
2081: * <p>
2082: * XSI Schema instance of NMTOKEN
2083: * </p>
2084: *
2085: * @author dzwiers
2086: */
2087: public static class NMTOKEN extends XSISimpleType {
2088: private static SimpleType instance = new NMTOKEN();
2089:
2090: /**
2091: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2092: */
2093: public static SimpleType getInstance() {
2094: return instance;
2095: }
2096:
2097: /**
2098: * @see schema.SimpleType#getName()
2099: */
2100: public java.lang.String getName() {
2101: return "NMTOKEN";
2102: }
2103:
2104: /**
2105: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2106: */
2107: public Object getValue(Element element, ElementValue[] value,
2108: Attributes attrs, Map hints) {
2109: if ((value.length == 1) && (value[0].getValue() != null)) {
2110: java.lang.String i = ((java.lang.String) value[0]
2111: .getValue());
2112:
2113: return i;
2114: }
2115:
2116: return null;
2117: }
2118:
2119: /**
2120: * @see org.geotools.xml.xsi.Type#getInstanceType()
2121: */
2122: public Class getInstanceType() {
2123: return java.lang.String.class;
2124: }
2125: }
2126:
2127: /**
2128: * <p>
2129: * XSI Schema instance of NMTOKENS
2130: * </p>
2131: *
2132: * @author dzwiers
2133: */
2134: public static class NMTOKENS extends XSISimpleType {
2135: private static SimpleType instance = new NMTOKENS();
2136:
2137: /**
2138: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2139: */
2140: public static SimpleType getInstance() {
2141: return instance;
2142: }
2143:
2144: /**
2145: * @see schema.SimpleType#getName()
2146: */
2147: public java.lang.String getName() {
2148: return "NMTOKENS";
2149: }
2150:
2151: /**
2152: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2153: */
2154: public Object getValue(Element element, ElementValue[] value,
2155: Attributes attrs, Map hints) {
2156: if ((value.length == 1) && (value[0].getValue() != null)) {
2157: java.lang.String[] i = ((java.lang.String) value[0]
2158: .getValue()).split("\\s");
2159:
2160: return i;
2161: }
2162:
2163: return null;
2164: }
2165:
2166: /**
2167: * @see org.geotools.xml.xsi.Type#getInstanceType()
2168: */
2169: public Class getInstanceType() {
2170: return java.lang.String[].class;
2171: }
2172: }
2173:
2174: /**
2175: * <p>
2176: * XSI Schema instance of NOTATION
2177: * </p>
2178: *
2179: * @author dzwiers
2180: */
2181: public static class NOTATION extends XSISimpleType {
2182: private static SimpleType instance = new NOTATION();
2183:
2184: /**
2185: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2186: */
2187: public static SimpleType getInstance() {
2188: return instance;
2189: }
2190:
2191: /**
2192: * @see schema.SimpleType#getName()
2193: */
2194: public java.lang.String getName() {
2195: return "NOTATION";
2196: }
2197:
2198: /**
2199: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2200: */
2201: public Object getValue(Element element, ElementValue[] value,
2202: Attributes attrs, Map hints) {
2203: if ((value.length == 1) && (value[0].getValue() != null)) {
2204: java.lang.String i = ((java.lang.String) value[0]
2205: .getValue());
2206:
2207: return i;
2208: }
2209:
2210: return null;
2211: }
2212:
2213: /**
2214: * @see org.geotools.xml.xsi.Type#getInstanceType()
2215: */
2216: public Class getInstanceType() {
2217: return java.lang.String.class;
2218: }
2219: }
2220:
2221: /**
2222: * <p>
2223: * XSI Schema instance of String
2224: * </p>
2225: *
2226: * @author dzwiers
2227: */
2228: public static class String extends XSISimpleType {
2229: private static SimpleType instance = new String();
2230:
2231: /**
2232: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2233: */
2234: public static SimpleType getInstance() {
2235: return instance;
2236: }
2237:
2238: /**
2239: * @see schema.SimpleType#getName()
2240: */
2241: public java.lang.String getName() {
2242: return "string";
2243: }
2244:
2245: /**
2246: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2247: */
2248: public Object getValue(Element element, ElementValue[] value,
2249: Attributes attrs, Map hints) {
2250: if ((value.length == 1) && (value[0].getValue() != null)) {
2251: java.lang.String i = ((java.lang.String) value[0]
2252: .getValue());
2253:
2254: return i;
2255: }
2256:
2257: return null;
2258: }
2259:
2260: /**
2261: * @see org.geotools.xml.xsi.Type#getInstanceType()
2262: */
2263: public Class getInstanceType() {
2264: return java.lang.String.class;
2265: }
2266: }
2267:
2268: /**
2269: * <p>
2270: * XSI Schema instance of NormalizedString
2271: * </p>
2272: *
2273: * @author dzwiers
2274: */
2275: public static class NormalizedString extends XSISimpleType {
2276: private static SimpleType instance = new NormalizedString();
2277:
2278: /**
2279: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2280: */
2281: public static SimpleType getInstance() {
2282: return instance;
2283: }
2284:
2285: /**
2286: * @see schema.SimpleType#getName()
2287: */
2288: public java.lang.String getName() {
2289: return "normalizedString";
2290: }
2291:
2292: /**
2293: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2294: */
2295: public Object getValue(Element element, ElementValue[] value,
2296: Attributes attrs, Map hints) {
2297: if ((value.length == 1) && (value[0].getValue() != null)) {
2298: java.lang.String i = ((java.lang.String) value[0]
2299: .getValue()).replaceAll("\\s", " ");
2300:
2301: return i;
2302: }
2303:
2304: return null;
2305: }
2306:
2307: /**
2308: * @see org.geotools.xml.xsi.Type#getInstanceType()
2309: */
2310: public Class getInstanceType() {
2311: return java.lang.String.class;
2312: }
2313: }
2314:
2315: /**
2316: * <p>
2317: * XSI Schema instance of Token
2318: * </p>
2319: *
2320: * @author dzwiers
2321: */
2322: public static class Token extends XSISimpleType {
2323: private static SimpleType instance = new Token();
2324:
2325: /**
2326: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2327: */
2328: public static SimpleType getInstance() {
2329: return instance;
2330: }
2331:
2332: /**
2333: * @see schema.SimpleType#getName()
2334: */
2335: public java.lang.String getName() {
2336: return "token";
2337: }
2338:
2339: /**
2340: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2341: */
2342: public Object getValue(Element element, ElementValue[] value,
2343: Attributes attrs, Map hints) {
2344: if ((value.length == 1) && (value[0].getValue() != null)) {
2345: java.lang.String i = ((java.lang.String) value[0]
2346: .getValue()).replaceAll("\\s", " ");
2347:
2348: return i;
2349: }
2350:
2351: return null;
2352: }
2353:
2354: /**
2355: * @see org.geotools.xml.xsi.Type#getInstanceType()
2356: */
2357: public Class getInstanceType() {
2358: return java.lang.String.class;
2359: }
2360: }
2361:
2362: /**
2363: * <p>
2364: * XSI Schema instance of QName
2365: * </p>
2366: *
2367: * @author dzwiers
2368: */
2369: public static class QName extends XSISimpleType {
2370: private static SimpleType instance = new QName();
2371:
2372: /**
2373: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2374: */
2375: public static SimpleType getInstance() {
2376: return instance;
2377: }
2378:
2379: /**
2380: * @see schema.SimpleType#getName()
2381: */
2382: public java.lang.String getName() {
2383: return "QName";
2384: }
2385:
2386: /**
2387: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2388: */
2389: public Object getValue(Element element, ElementValue[] value,
2390: Attributes attrs, Map hints) {
2391: if ((value.length == 1) && (value[0].getValue() != null)) {
2392: java.lang.String i = ((java.lang.String) value[0]
2393: .getValue());
2394:
2395: return i;
2396: }
2397:
2398: return null;
2399: }
2400:
2401: /**
2402: * @see org.geotools.xml.xsi.Type#getInstanceType()
2403: */
2404: public Class getInstanceType() {
2405: return java.lang.String.class;
2406: }
2407: }
2408:
2409: /**
2410: * <p>
2411: * XSI Schema instance of Name
2412: * </p>
2413: *
2414: * @author dzwiers
2415: */
2416: public static class Name extends XSISimpleType {
2417: private static SimpleType instance = new Name();
2418:
2419: /**
2420: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2421: */
2422: public static SimpleType getInstance() {
2423: return instance;
2424: }
2425:
2426: /**
2427: * @see schema.SimpleType#getName()
2428: */
2429: public java.lang.String getName() {
2430: return "Name";
2431: }
2432:
2433: /**
2434: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2435: */
2436: public Object getValue(Element element, ElementValue[] value,
2437: Attributes attrs, Map hints) {
2438: if ((value.length == 1) && (value[0].getValue() != null)) {
2439: java.lang.String i = ((java.lang.String) value[0]
2440: .getValue());
2441:
2442: return i;
2443: }
2444:
2445: return null;
2446: }
2447:
2448: /**
2449: * @see org.geotools.xml.xsi.Type#getInstanceType()
2450: */
2451: public Class getInstanceType() {
2452: return java.lang.String.class;
2453: }
2454: }
2455:
2456: /**
2457: * <p>
2458: * XSI Schema instance of NCNAME
2459: * </p>
2460: *
2461: * @author dzwiers
2462: */
2463: public static class NCName extends XSISimpleType {
2464: private static SimpleType instance = new NCName();
2465:
2466: /**
2467: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2468: */
2469: public static SimpleType getInstance() {
2470: return instance;
2471: }
2472:
2473: /**
2474: * @see schema.SimpleType#getName()
2475: */
2476: public java.lang.String getName() {
2477: return "NCName";
2478: }
2479:
2480: /**
2481: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2482: */
2483: public Object getValue(Element element, ElementValue[] value,
2484: Attributes attrs, Map hints) {
2485: if ((value.length == 1) && (value[0].getValue() != null)) {
2486: java.lang.String i = ((java.lang.String) value[0]
2487: .getValue());
2488:
2489: return i;
2490: }
2491:
2492: return null;
2493: }
2494:
2495: /**
2496: * @see org.geotools.xml.xsi.Type#getInstanceType()
2497: */
2498: public Class getInstanceType() {
2499: return java.lang.String.class;
2500: }
2501: }
2502:
2503: /**
2504: * <p>
2505: * XSI Schema instance of Boolean
2506: * </p>
2507: *
2508: * @author dzwiers
2509: */
2510: public static class Boolean extends XSISimpleType {
2511: private static SimpleType instance = new Boolean();
2512:
2513: /**
2514: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2515: */
2516: public static SimpleType getInstance() {
2517: return instance;
2518: }
2519:
2520: /**
2521: * @see schema.SimpleType#getName()
2522: */
2523: public java.lang.String getName() {
2524: return "boolean";
2525: }
2526:
2527: /**
2528: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2529: */
2530: public Object getValue(Element element, ElementValue[] value,
2531: Attributes attrs, Map hints) {
2532: if ((value.length == 1) && (value[0].getValue() != null)) {
2533: java.lang.Boolean i = new java.lang.Boolean(
2534: (java.lang.String) value[0].getValue());
2535:
2536: return i;
2537: }
2538:
2539: return null;
2540: }
2541:
2542: /**
2543: * @see org.geotools.xml.xsi.Type#getInstanceType()
2544: */
2545: public Class getInstanceType() {
2546: return java.lang.Boolean.class;
2547: }
2548: }
2549:
2550: /**
2551: * <p>
2552: * XSI Schema instance of AnyURI
2553: * </p>
2554: *
2555: * @author dzwiers
2556: */
2557: public static class AnyURI extends XSISimpleType {
2558: private static SimpleType instance = new AnyURI();
2559:
2560: /**
2561: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2562: */
2563: public static SimpleType getInstance() {
2564: return instance;
2565: }
2566:
2567: /**
2568: * @see schema.SimpleType#getName()
2569: */
2570: public java.lang.String getName() {
2571: return "anyURI";
2572: }
2573:
2574: /**
2575: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2576: */
2577: public Object getValue(Element element, ElementValue[] value,
2578: Attributes attrs, Map hints) throws SAXException {
2579: if ((value.length == 1) && (value[0].getValue() != null)) {
2580: try {
2581: URI i = new URI((java.lang.String) value[0]
2582: .getValue());
2583:
2584: return i;
2585: } catch (URISyntaxException e) {
2586: throw new SAXException(e);
2587: }
2588: }
2589:
2590: return null;
2591: }
2592:
2593: /**
2594: * @see org.geotools.xml.xsi.Type#getInstanceType()
2595: */
2596: public Class getInstanceType() {
2597: return URI.class;
2598: }
2599: }
2600:
2601: /**
2602: * <p>
2603: * XSI Schema instance of Base64Binary
2604: * </p>
2605: *
2606: * @author dzwiers
2607: */
2608: public static class Base64Binary extends XSISimpleType {
2609: private static SimpleType instance = new Base64Binary();
2610:
2611: /**
2612: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2613: */
2614: public static SimpleType getInstance() {
2615: return instance;
2616: }
2617:
2618: /**
2619: * @see schema.SimpleType#getName()
2620: */
2621: public java.lang.String getName() {
2622: return "base64Binary";
2623: }
2624:
2625: /**
2626: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2627: */
2628: public Object getValue(Element element, ElementValue[] value,
2629: Attributes attrs, Map hints) {
2630: if ((value.length == 1) && (value[0].getValue() != null)) {
2631: java.lang.String i = ((java.lang.String) value[0]
2632: .getValue());
2633:
2634: return i;
2635: }
2636:
2637: return null;
2638: }
2639:
2640: /**
2641: * @see org.geotools.xml.xsi.Type#getInstanceType()
2642: */
2643: public Class getInstanceType() {
2644: return java.lang.String.class;
2645: }
2646: }
2647:
2648: /**
2649: * <p>
2650: * XSI Schema instance of HexBinary
2651: * </p>
2652: *
2653: * @author dzwiers
2654: */
2655: public static class HexBinary extends XSISimpleType {
2656: private static SimpleType instance = new HexBinary();
2657:
2658: /**
2659: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2660: */
2661: public static SimpleType getInstance() {
2662: return instance;
2663: }
2664:
2665: /**
2666: * @see schema.SimpleType#getName()
2667: */
2668: public java.lang.String getName() {
2669: return "hexBinary";
2670: }
2671:
2672: /**
2673: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2674: */
2675: public Object getValue(Element element, ElementValue[] value,
2676: Attributes attrs, Map hints) {
2677: if ((value.length == 1) && (value[0].getValue() != null)) {
2678: java.lang.String i = ((java.lang.String) value[0]
2679: .getValue());
2680:
2681: return i;
2682: }
2683:
2684: return null;
2685: }
2686:
2687: /**
2688: * @see org.geotools.xml.xsi.Type#getInstanceType()
2689: */
2690: public Class getInstanceType() {
2691: return java.lang.String.class;
2692: }
2693: }
2694:
2695: /**
2696: * <p>
2697: * XSI Schema instance of Language
2698: * </p>
2699: *
2700: * @author dzwiers
2701: */
2702: public static class Language extends XSISimpleType {
2703: private static SimpleType instance = new Language();
2704:
2705: /**
2706: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2707: */
2708: public static SimpleType getInstance() {
2709: return instance;
2710: }
2711:
2712: /**
2713: * @see schema.SimpleType#getName()
2714: */
2715: public java.lang.String getName() {
2716: return "language";
2717: }
2718:
2719: /**
2720: * @see schema.Type#getValue(java.lang.Object, org.xml.sax.Attributes)
2721: */
2722: public Object getValue(Element element, ElementValue[] value,
2723: Attributes attrs, Map hints) {
2724: if ((value.length == 1) && (value[0].getValue() != null)) {
2725: Locale i = new Locale((java.lang.String) value[0]
2726: .getValue());
2727:
2728: return i;
2729: }
2730:
2731: return null;
2732: }
2733:
2734: /**
2735: * @see org.geotools.xml.xsi.Type#getInstanceType()
2736: */
2737: public Class getInstanceType() {
2738: return Locale.class;
2739: }
2740: }
2741:
2742: public static class AnyType extends XSISimpleType implements
2743: ComplexType {
2744:
2745: private static SimpleType instance = new AnyType();
2746:
2747: /**
2748: * @see schema.xsi.XSISimpleTypes.XSISimpleType#getInstance()
2749: */
2750: public static SimpleType getInstance() {
2751: return instance;
2752: }
2753:
2754: /**
2755: * TODO summary sentence for isAbstract ...
2756: *
2757: * @see org.geotools.xml.schema.ComplexType#isAbstract()
2758: */
2759: public boolean isAbstract() {
2760: return false;
2761: }
2762:
2763: /**
2764: * TODO summary sentence for getAnyAttributeNameSpace ...
2765: *
2766: * @see org.geotools.xml.schema.ComplexType#getAnyAttributeNameSpace()
2767: */
2768: public java.lang.String getAnyAttributeNameSpace() {
2769: return null;
2770: }
2771:
2772: /**
2773: * TODO summary sentence for getAttributes ...
2774: *
2775: * @see org.geotools.xml.schema.ComplexType#getAttributes()
2776: */
2777: public Attribute[] getAttributes() {
2778: return null;
2779: }
2780:
2781: /**
2782: * TODO summary sentence for getBlock ...
2783: *
2784: * @see org.geotools.xml.schema.ComplexType#getBlock()
2785: */
2786: public int getBlock() {
2787: return 0;
2788: }
2789:
2790: /**
2791: * TODO summary sentence for getChild ...
2792: *
2793: * @see org.geotools.xml.schema.ComplexType#getChild()
2794: */
2795: public ElementGrouping getChild() {
2796: return null;
2797: }
2798:
2799: /**
2800: * TODO summary sentence for getChildElements ...
2801: *
2802: * @see org.geotools.xml.schema.ComplexType#getChildElements()
2803: */
2804: public Element[] getChildElements() {
2805: return null;
2806: }
2807:
2808: /**
2809: * TODO summary sentence for isMixed ...
2810: *
2811: * @see org.geotools.xml.schema.ComplexType#isMixed()
2812: */
2813: public boolean isMixed() {
2814: return false;
2815: }
2816:
2817: /**
2818: * TODO summary sentence for isDerived ...
2819: *
2820: * @see org.geotools.xml.schema.ComplexType#isDerived()
2821: */
2822: public boolean isDerived() {
2823: return false;
2824: }
2825:
2826: /**
2827: * TODO summary sentence for cache ...
2828: *
2829: * @see org.geotools.xml.schema.ComplexType#cache(org.geotools.xml.schema.Element, java.util.Map)
2830: * @param element
2831: * @param hints
2832: */
2833: public boolean cache(Element element, Map hints) {
2834: return false;
2835: }
2836:
2837: /**
2838: * TODO summary sentence for getValue ...
2839: *
2840: * @see org.geotools.xml.schema.Type#getValue(org.geotools.xml.schema.Element, org.geotools.xml.schema.ElementValue[], org.xml.sax.Attributes, java.util.Map)
2841: * @param element
2842: * @param value
2843: * @param attrs
2844: * @param hints
2845: * @throws SAXException
2846: * @throws OperationNotSupportedException
2847: */
2848: public Object getValue(Element element, ElementValue[] value,
2849: Attributes attrs, Map hints)
2850: throws OperationNotSupportedException {
2851: if (element == null || element.getType() == null
2852: || value == null)
2853: throw new OperationNotSupportedException();
2854: if (value.length == 1 && value[0].getElement() == null)
2855: return value[0].getValue();
2856: Object[] r = new Object[value.length];
2857: for (int i = 0; i < r.length; i++)
2858: r[i] = value[i].getValue();
2859:
2860: return r;
2861: }
2862:
2863: /**
2864: * TODO summary sentence for getName ...
2865: *
2866: * @see org.geotools.xml.schema.Type#getName()
2867: */
2868: public java.lang.String getName() {
2869: return "AnyType";
2870: }
2871:
2872: /**
2873: * TODO summary sentence for getInstanceType ...
2874: *
2875: * @see org.geotools.xml.schema.Type#getInstanceType()
2876: */
2877: public Class getInstanceType() {
2878: return null;
2879: }
2880: }
2881: }
|