@Override protected Schema buildTypeMappingProfile(Schema typeSchema) { // reuse the regular gml3 type mapping profile bindings, but override // the namespace uri Schema gml3Profile = org.geotools.gml3.GML.getInstance().getTypeMappingProfile(); Set profile = new LinkedHashSet(); for (Name n : gml3Profile.keySet()) { n = new NameImpl(NAMESPACE, n.getLocalPart()); if (typeSchema.get(n) != null) { profile.add(n); } } return typeSchema.profile(profile); }
AttributeType findType(Class binding) { for (Schema schema : typeMappingProfiles) { for (Map.Entry<Name, AttributeType> e : schema.entrySet()) { AttributeType at = e.getValue(); if (at.getBinding() != null && at.getBinding().equals(binding)) { return at; } } for (AttributeType at : schema.values()) { if (binding.isAssignableFrom(at.getBinding())) { return at; } } } return null; } }
@SuppressWarnings("unchecked") protected void importSchema(Schema schema) { for (Iterator it = schema.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Entry) it.next(); Name key = (Name) entry.getKey(); Object value = entry.getValue(); if (typeRegistry.containsKey(key)) { LOGGER.finer( "Ignoring " + key + " as it already exists. type " + value.getClass().getName()); } else { LOGGER.finer("Importing " + key + " of type " + value.getClass().getName()); if (value instanceof AttributeType) { AttributeType type = (AttributeType) value; register(type, false); } else if (value instanceof AttributeDescriptor) { AttributeDescriptor descriptor = (AttributeDescriptor) value; register(descriptor); } } } LOGGER.fine("Schema " + schema.getURI() + " imported successfully"); }
protected final AttributeType findType(XSDTypeDefinition xsdType) { Name name = name(xsdType); if (imports != null) { for (Iterator itr = imports.values().iterator(); itr.hasNext();) { Schema imported = (Schema) itr.next(); if (imported.containsKey(name)) { return (AttributeType) imported.get(name); } } } throw new IllegalStateException("Could not find imported type: " + name); }
/** Sets up a profile which uniquely maps a set of java classes to a schema element. */ protected Schema buildTypeMappingProfile(Schema typeSchema) { return typeSchema.profile(Collections.EMPTY_SET); }
public AttributeType get(Object key) { if (profile.contains(key)) { return parent.get(key); } return null; }
public String getURI() { return parent.getURI(); }
/** * Specifies a number of attribute type bindings. * * @param schema The schema containing the attribute types. * @see {@link #addBinding(AttributeType)}. */ public void addBindings(Schema schema) { for (Iterator<AttributeType> itr = schema.values().iterator(); itr.hasNext(); ) { AttributeType type = itr.next(); addBinding(type); } }
for (Entry<Name, AttributeType> entry : profile.entrySet()) { AttributeType type = entry.getValue(); if (type.getBinding().isAssignableFrom(binding)) {
throw new NullPointerException(); gtSchema.put(gtType.getName(), gtType);
public Schema profile(Set<Name> profile) { if (!this.profile.containsAll(profile)) { Set<Name> set = new TreeSet<Name>(profile); set.removeAll(this.profile); throw new IllegalArgumentException("Unable to profile the following names: " + set); } return parent.profile(profile); }
private synchronized Map<Name, AttributeType> contents() { if (contents == null) { contents = new LinkedHashMap(); for (Iterator i = profile.iterator(); i.hasNext(); ) { Object key = i.next(); contents.put(key, parent.get(key)); } } return contents; } }
private Class mapTypeName(String typeName) { // try xs simple type Schema xsTypeMappingProfile = XS.getInstance().getTypeMappingProfile(); NameImpl name = new NameImpl(XS.NAMESPACE, typeName); if (xsTypeMappingProfile.containsKey(name)) { AttributeType type = xsTypeMappingProfile.get(name); if (type.getBinding() != null) { return type.getBinding(); } } // try gml geometry types Geometries g = Geometries.getForName(typeName); if (g != null) { return g.getBinding(); } // default return String.class; } }
/** * Adds an imported schema to be used for type lookups. */ public void addImport(Schema imported) { imports.put(imported.getURI(), imported); }
/** * Load the indicated schema to map Java class to your Type System. (please us a profile to * prevent binding conflicts). * * @param schema */ public void load(Schema schema) { for (Iterator itr = schema.values().iterator(); itr.hasNext(); ) { AttributeType type = (AttributeType) itr.next(); addBinding(type.getBinding(), type); } }
builder.setName("date"); builder.setBinding(Date.class); hack.put(new NameImpl(XS.DATETIME), builder.buildType());
AttributeType findType(Class binding) { for (Schema schema : typeMappingProfiles) { for (Map.Entry<Name,AttributeType> e : schema.entrySet()) { AttributeType at = e.getValue(); if (at.getBinding() != null && at.getBinding().equals(binding)) { return at; } } for (AttributeType at : schema.values()) { if (binding.isAssignableFrom(at.getBinding())) { return at; } } } return null; } }
@Override protected Schema buildTypeMappingProfile(Schema typeSchema) { //reuse the regular gml3 type mapping profile bindings, but override // the namespace uri Schema gml3Profile = org.geotools.gml3.GML.getInstance().getTypeMappingProfile(); Set profile = new LinkedHashSet(); for (Name n : gml3Profile.keySet()) { n = new NameImpl(NAMESPACE, n.getLocalPart()); if (typeSchema.get(n) != null) { profile.add(n); } } return typeSchema.profile(profile); }
@Override protected Schema buildTypeMappingProfile(Schema typeSchema) { Set profile = new LinkedHashSet(); profile.add(name(GML.PointPropertyType)); profile.add(name(GML.MultiPointPropertyType)); profile.add(name(GML.LineStringPropertyType)); profile.add(name(GML.MultiLineStringPropertyType)); profile.add(name(GML.PolygonPropertyType)); profile.add(name(GML.MultiPolygonPropertyType)); profile.add(name(GML.GeometryPropertyType)); return typeSchema.profile(profile); }
@SuppressWarnings("unchecked") private void importSchema(Schema schema) { for (Iterator it = schema.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Entry) it.next(); Name key = (Name) entry.getKey(); Object value = entry.getValue(); if (typeRegistry.containsKey(key)) { LOGGER.finer("Ignoring " + key + " as it already exists. type " + value.getClass().getName()); } else { LOGGER.finer("Importing " + key + " of type " + value.getClass().getName()); if (value instanceof AttributeType) { AttributeType type = (AttributeType) value; register(type, false); } else if (value instanceof AttributeDescriptor) { AttributeDescriptor descriptor = (AttributeDescriptor) value; register(descriptor); } } } LOGGER.fine("Schema " + schema.getURI() + " imported successfully"); }