AttributesImpl atts = createStandardAttributes(attribute);
/** * Encode object o, which must be an instance of FeatureType. If it is not an * IllegalArgumentException will be thrown. * * @param o DOCUMENT ME! * @throws IllegalArgumentException if supplied object is not an instance of FeatureType * @see org.geotools.xml.transform.Translator#encode(java.lang.Object) */ public void encode(Object o) throws IllegalArgumentException { if (o instanceof SimpleFeatureType) { encode((SimpleFeatureType) o); } else { throw new IllegalArgumentException( "Translator does not know how to translate " + o.getClass().getName()); } }
/** * Encode an AttributeType. * * @param attribute * @throws SAXException * @throws RuntimeException DOCUMENT ME! */ protected void encode(AttributeDescriptor attribute) throws SAXException { Class type = attribute.getType().getBinding(); if (Number.class.isAssignableFrom(type)) { encodeNumber(attribute); } else if (Date.class.isAssignableFrom(type)) { encodeDate(attribute); } else if (type == String.class) { encodeString(attribute); } else if (Geometry.class.isAssignableFrom(type)) { encodeGeometry(attribute); } else if (type == Boolean.class) { encodeBoolean(attribute); /*} else if (FeatureType.class.isAssignableFrom(type)) { encodeFeature(attribute);*/ } else { throw new RuntimeException("Cannot encode " + type.getName()); } }
AttributesImpl atts = createStandardAttributes(attribute);
AttributesImpl atts = createStandardAttributes(attribute);
AttributesImpl atts = createStandardAttributes(attribute);
AttributesImpl atts = createStandardAttributes(attribute);
AttributesImpl atts = createStandardAttributes(attribute);
AttributesImpl atts = createStandardAttributes(attribute);
/** * Encode an AttributeType. * * @param attribute * * @throws SAXException * @throws RuntimeException DOCUMENT ME! */ protected void encode(AttributeType attribute) throws SAXException { Class type = attribute.getType(); if (Number.class.isAssignableFrom(type)) { encodeNumber(attribute); } else if (Date.class.isAssignableFrom(type)) { encodeDate(attribute); } else if (type == String.class) { encodeString(attribute); } else if (Geometry.class.isAssignableFrom(type)) { encodeGeometry(attribute); } else if (type == Boolean.class) { encodeBoolean(attribute); /*} else if (FeatureType.class.isAssignableFrom(type)) { encodeFeature(attribute);*/ } else { throw new RuntimeException("Cannot encode " + type.getName()); } }
/** * Encode an AttributeType. * * @param attribute * * @throws SAXException * @throws RuntimeException DOCUMENT ME! */ protected void encode(AttributeDescriptor attribute) throws SAXException { Class type = attribute.getType().getBinding(); if (Number.class.isAssignableFrom(type)) { encodeNumber(attribute); } else if (Date.class.isAssignableFrom(type)) { encodeDate(attribute); } else if (type == String.class) { encodeString(attribute); } else if (Geometry.class.isAssignableFrom(type)) { encodeGeometry(attribute); } else if (type == Boolean.class) { encodeBoolean(attribute); /*} else if (FeatureType.class.isAssignableFrom(type)) { encodeFeature(attribute);*/ } else { throw new RuntimeException("Cannot encode " + type.getName()); } }
/** * Encode object o, which must be an instance of FeatureType. If it is * not an IllegalArgumentException will be thrown. * * @param o DOCUMENT ME! * * @throws IllegalArgumentException if supplied object is not an * instance of FeatureType * * @see org.geotools.xml.transform.Translator#encode(java.lang.Object) */ public void encode(Object o) throws IllegalArgumentException { if (o instanceof FeatureType) { encode((FeatureType) o); } else { throw new IllegalArgumentException( "Translator does not know how to translate " + o.getClass().getName()); } }
/** * Encode an AttributeType whose value type is a Date. * * @param attribute * * @throws SAXException */ protected void encodeDate(AttributeType attribute) throws SAXException { AttributesImpl atts = createStandardAttributes(attribute); if(java.sql.Date.class.isAssignableFrom(attribute.getType())) atts.addAttribute("", "type", "type", "", "xs:date"); else if(java.sql.Time.class.isAssignableFrom(attribute.getType())) atts.addAttribute("", "type", "type", "", "xs:time"); else atts.addAttribute("", "type", "type", "", "xs:dateTime"); contentHandler.startElement(SCHEMA_NS, "element", "xs:element", atts); contentHandler.endElement(SCHEMA_NS, "element", "xs:element"); }
/** * Encode an AttributeType whose value type is a Date. * * @param attribute * * @throws SAXException */ protected void encodeDate(AttributeDescriptor attribute) throws SAXException { AttributesImpl atts = createStandardAttributes(attribute); Class binding = attribute.getType().getBinding(); if(java.sql.Date.class.isAssignableFrom(binding)) atts.addAttribute("", "type", "type", "", "xs:date"); else if(java.sql.Time.class.isAssignableFrom(binding)) atts.addAttribute("", "type", "type", "", "xs:time"); else atts.addAttribute("", "type", "type", "", "xs:dateTime"); contentHandler.startElement(SCHEMA_NS, "element", "xs:element", atts); contentHandler.endElement(SCHEMA_NS, "element", "xs:element"); }
/** * Encode the supplied feature type. * * @param type the feature type to encode * * @throws RuntimeException DOCUMENT ME! */ protected void encode(SimpleFeatureType type) { List attributes = type.getAttributeDescriptors(); try { startSchemaType(type.getTypeName(), type.getName().getNamespaceURI()); for (int i = 0; i < attributes.size(); i++) { encode((AttributeDescriptor) attributes.get(i)); } endSchemaType(); } catch (SAXException e) { throw new RuntimeException(e); } }
/** * Encode the supplied feature type. * * @param type the feature type to encode * * @throws RuntimeException DOCUMENT ME! */ protected void encode(FeatureType type) { AttributeType[] attributes = type.getAttributeTypes(); try { startSchemaType(type.getTypeName(), type.getNamespace()); for (int i = 0; i < attributes.length; i++) { encode(attributes[i]); } endSchemaType(); } catch (SAXException e) { throw new RuntimeException(e); } }
/** * Encode object o, which must be an instance of FeatureType. If it is * not an IllegalArgumentException will be thrown. * * @param o DOCUMENT ME! * * @throws IllegalArgumentException if supplied object is not an * instance of FeatureType * * @see org.geotools.xml.transform.Translator#encode(java.lang.Object) */ public void encode(Object o) throws IllegalArgumentException { if (o instanceof SimpleFeatureType) { encode((SimpleFeatureType) o); } else { throw new IllegalArgumentException( "Translator does not know how to translate " + o.getClass().getName()); } }
/** * Encode an AttributeType whose value type is a Boolean. * * @param attribute * * @throws SAXException */ protected void encodeBoolean(AttributeType attribute) throws SAXException { AttributesImpl atts = createStandardAttributes(attribute); atts.addAttribute("", "type", "type", "", "xs:boolean"); contentHandler.startElement(SCHEMA_NS, "element", "xs:element", atts); contentHandler.endElement(SCHEMA_NS, "element", "xs:element"); }
/** * Encode an AttributeType whose value type is a Boolean. * * @param attribute * * @throws SAXException */ protected void encodeBoolean(AttributeDescriptor attribute) throws SAXException { AttributesImpl atts = createStandardAttributes(attribute); atts.addAttribute("", "type", "type", "", "xs:boolean"); contentHandler.startElement(SCHEMA_NS, "element", "xs:element", atts); contentHandler.endElement(SCHEMA_NS, "element", "xs:element"); }
/** * Creates a Translator that is capable to translate FeatureType objects * into a XML schema fragment. * * @param handler the content handler to use * * @return DOCUMENT ME! */ public Translator createTranslator(ContentHandler handler) { FeatureTypeTranslator translator = new FeatureTypeTranslator(handler); return translator; }