Package org.opengis.feature.type

Examples of org.opengis.feature.type.Schema


    /**
     * Test that this class can be loaded.
     */
    public static void main(String[] args) {
        Schema schema = new GMLSchema();
        for (Entry<Name, AttributeType> entry : new TreeMap<Name, AttributeType>(schema).entrySet()) {
            System.out.println("Type: " + entry.getValue().getName());
            System.out.println("    Super type: " + entry.getValue().getSuper().getName());
            if (entry.getValue() instanceof ComplexType) {
                for (PropertyDescriptor descriptor : ((ComplexType) entry.getValue())
View Full Code Here


    /**
     * Test that this class can be loaded.
     */
    public static void main(String[] args) {
        Schema schema = new GMXSchema();
        for (Entry<Name, AttributeType> entry : new TreeMap<Name, AttributeType>(schema).entrySet()) {
            System.out.println("Type: " + entry.getValue().getName());
            System.out.println("    Super type: " + entry.getValue().getSuper().getName());
            if (entry.getValue() instanceof ComplexType) {
                for (PropertyDescriptor descriptor : ((ComplexType) entry.getValue())
View Full Code Here

    }

    @Override
    protected void onCreateFoundationTypes() {
       
        Schema schema;

        schema = new SMIL20Schema();
        importSchema(schema);

        schema = new SMIL20LANGSchema();
View Full Code Here

        proper.add(name(DOUBLE)); //Double.class
        proper.add(name(STRING)); //String.class
        proper.add(name(INTEGER)); //BigInteger.class
        proper.add(name(DECIMAL)); //BigDecimal.class
        proper.add(name(ANYURI)); //URI.class
        Schema profile = schema.profile( proper );
       
        return profile;
    }
View Full Code Here

    /**
     * Test that this class can be loaded.
     */
    public static void main(String[] args) {
        Schema schema = new GMDSchema();
        for (Entry<Name, AttributeType> entry : new TreeMap<Name, AttributeType>(schema).entrySet()) {
            System.out.println("Type: " + entry.getValue().getName());
            System.out.println("    Super type: " + entry.getValue().getSuper().getName());
            if (entry.getValue() instanceof ComplexType) {
                for (PropertyDescriptor descriptor : ((ComplexType) entry.getValue())
View Full Code Here

        return featureType;
    }

    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();
            }
        }
View Full Code Here

  static final String URI = "gopher://localhost/test";
 
  SimpleFeatureTypeBuilder builder;
 
  protected void setUp() throws Exception {
    Schema schema = new SchemaImpl( "test" );
   
    FeatureTypeFactoryImpl typeFactory = new FeatureTypeFactoryImpl();
    AttributeType pointType =
      typeFactory.createGeometryType( new NameImpl( "test", "pointType" ), Point.class, null, false, false, Collections.EMPTY_LIST, null, null);   
    schema.put( new NameImpl( "test", "pointType" ), pointType );
   
    AttributeType intType =
      typeFactory.createAttributeType( new NameImpl( "test", "intType" ), Integer.class, false, false, Collections.EMPTY_LIST, null, null);
    schema.put( new NameImpl( "test", "intType" ), intType );
   
    builder = new SimpleFeatureTypeBuilder( new FeatureTypeFactoryImpl() );
    builder.setBindings(schema);
  }
View Full Code Here

  {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
     
        Object[] arguments = (Object[]) argument;
        Schema schema = (Schema) arguments[0];
        String prefix = (String) arguments[1];
        prefix = prefix.toUpperCase();
        SchemaGenerator sg = (SchemaGenerator) arguments[2];
        List<AttributeType> types = sg.sort();

    stringBuffer.append(TEXT_2);
   
        Map<String, String> ns2import = new HashMap<String, String>();
        for (Schema imported : sg.getImports()) {
            String fullClassName = imported.getClass().getName();
            String className = fullClassName.substring(fullClassName.lastIndexOf(".")+1);
            ns2import.put(imported.getURI(), className);

    stringBuffer.append(TEXT_3);
    stringBuffer.append(fullClassName);
    stringBuffer.append(TEXT_4);
   
        }

    stringBuffer.append(TEXT_5);
    stringBuffer.append(prefix);
    stringBuffer.append(TEXT_6);
   
        Map<Name, String> typeBindings = sg.getTypeBindings();
        for (AttributeType type : types) {
            Name name = type.getName();

    stringBuffer.append(TEXT_7);
   
            XSDTypeDefinition xsdType = sg.getXSDType(type);
            StringWriter writer = new StringWriter();

            SAXTransformerFactory txFactory =
                    (SAXTransformerFactory) SAXTransformerFactory.newInstance();
            TransformerHandler xmls;
            try {
                xmls = txFactory.newTransformerHandler();
            } catch (TransformerConfigurationException e) {
                throw new RuntimeException(e);
            }
            xmls.getTransformer().setOutputProperty(OutputKeys.METHOD, "XML");
            xmls.getTransformer().setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "true");
            xmls.getTransformer().setOutputProperty(OutputKeys.INDENT, "true");

            try {
                xmls.getTransformer().transform(new DOMSource(xsdType.getElement()), new StreamResult(writer));
            }
            catch (Exception e) {
                e.printStackTrace();
                return null;
            }

            String[] lines = writer.getBuffer().toString().split("\n");
            for (int i = 0; i < lines.length; i++) {

    stringBuffer.append(TEXT_8);
    stringBuffer.append(lines[i].replaceAll("<","&lt;").replaceAll(">","&gt;"));
   
            }

    stringBuffer.append(TEXT_9);
   
            String uri = name.getNamespaceURI();
            String local = name.getLocalPart();
            String binding;
            if (typeBindings.containsKey(name)) {
                binding = typeBindings.get(name) + ".class";
            } else {
                binding = type.getBinding().getName() + ".class";
            }
            String isIdentified = type.isIdentified() ? "true" : "false";
            String isAbstract = type.isAbstract() ? "true" : "false";
            String restrictions = "null";
            String superType = "null";
            if (type.getSuper() != null) {
                superType = type.getSuper().getName()
                    .getLocalPart().toUpperCase() + "_TYPE";
                String superURI = type.getSuper().getName().getNamespaceURI();
                if (!uri.equals(superURI)) {
                    superType = ns2import.get(superURI) + "." + superType;
                }
            }
            String description = "null";
            if (type instanceof ComplexType && !typeBindings.containsKey(name)) {

    stringBuffer.append(TEXT_10);
    stringBuffer.append(name.getLocalPart().toUpperCase());
    stringBuffer.append(TEXT_11);
    stringBuffer.append(name.getLocalPart().toUpperCase());
    stringBuffer.append(TEXT_12);
    stringBuffer.append(name.getLocalPart().toUpperCase());
    stringBuffer.append(TEXT_13);
    stringBuffer.append(uri);
    stringBuffer.append(TEXT_14);
    stringBuffer.append(local);
    stringBuffer.append(TEXT_15);
    stringBuffer.append(TEXT_16);
    stringBuffer.append(isIdentified);
    stringBuffer.append(TEXT_17);
    stringBuffer.append(isAbstract);
    stringBuffer.append(TEXT_18);
    stringBuffer.append(restrictions);
    stringBuffer.append(TEXT_19);
    stringBuffer.append(description);
    stringBuffer.append(TEXT_20);
   
            } else {

    stringBuffer.append(TEXT_21);
    stringBuffer.append(name.getLocalPart().toUpperCase());
    stringBuffer.append(TEXT_22);
    stringBuffer.append(name.getLocalPart().toUpperCase());
    stringBuffer.append(TEXT_23);
    stringBuffer.append(name.getLocalPart().toUpperCase());
    stringBuffer.append(TEXT_24);
    stringBuffer.append(uri);
    stringBuffer.append(TEXT_25);
    stringBuffer.append(local);
    stringBuffer.append(TEXT_26);
    stringBuffer.append(TEXT_27);
    stringBuffer.append(binding);
    stringBuffer.append(TEXT_28);
    stringBuffer.append(isIdentified);
    stringBuffer.append(TEXT_29);
    stringBuffer.append(isAbstract);
    stringBuffer.append(TEXT_30);
    stringBuffer.append(restrictions);
    stringBuffer.append(TEXT_31);
    stringBuffer.append(description);
    stringBuffer.append(TEXT_32);
         
            }

    stringBuffer.append(TEXT_33);
    stringBuffer.append(superType);
    stringBuffer.append(TEXT_34);
   
            if (type instanceof ComplexType && !typeBindings.containsKey(name)) {
                ComplexType cType = (ComplexType)type;

    stringBuffer.append(TEXT_35);
   
                if (cType.getDescriptors().isEmpty()) {

    stringBuffer.append(TEXT_36);
   
                } else {

    stringBuffer.append(TEXT_37);
   
                    for (PropertyDescriptor pd : cType.getDescriptors()) {
                        if ( !(pd instanceof AttributeDescriptor) ) {
                            continue;
                        }
                        AttributeDescriptor ad = (AttributeDescriptor) pd;
                        AttributeType adType = ad.getType();
                        String adTypeName = adType.getName().getLocalPart().toUpperCase() +
                            "_TYPE";
                        String adTypeURI = adType.getName().getNamespaceURI();
                        if (!uri.equals(adTypeURI)) {
                            adTypeName = ns2import.get(adTypeURI) + "." + adTypeName;
                        }
                        String adName;
                        if (ad.getName().getNamespaceURI() == null) {
                            adName = "new NameImpl(\"" + ad.getName().getLocalPart() + "\")";
                        } else {
                            adName = "new NameImpl(\"" + ad.getName().getNamespaceURI() +
                                "\",\"" + ad.getName().getLocalPart() + "\")";
                        }
                        String min = ad.getMinOccurs() + "";
                        String max = ad.getMaxOccurs() + "";
                        String isNillable = ad.isNillable() ? "true" : "false";        

    stringBuffer.append(TEXT_38);
    stringBuffer.append(TEXT_39);
    stringBuffer.append(adTypeName);
    stringBuffer.append(TEXT_40);
    stringBuffer.append(TEXT_41);
    stringBuffer.append(adName);
    stringBuffer.append(TEXT_42);
    stringBuffer.append(TEXT_43);
    stringBuffer.append(min);
    stringBuffer.append(TEXT_44);
    stringBuffer.append(max);
    stringBuffer.append(TEXT_45);
    stringBuffer.append(isNillable);
    stringBuffer.append(TEXT_46);
   
                    }

    stringBuffer.append(TEXT_47);
   
                }

    stringBuffer.append(TEXT_48);
   
            }

    stringBuffer.append(TEXT_49);
   
       
            if (!type.getUserData().isEmpty()) {
                //attributes
                for (Map.Entry<Object, Object> entry : type.getUserData().entrySet()) {
                    PropertyDescriptor pd = (PropertyDescriptor) entry.getValue();
                    PropertyType pdType = pd.getType();
                    String pdTypeName = pdType.getName().getLocalPart().toUpperCase() +
                        "_TYPE";
                    if (ns2import.containsKey(pdType.getName().getNamespaceURI())) {
                        String importClassName = (String) ns2import.get(pdType.getName().getNamespaceURI());
                        pdTypeName = importClassName + "." + pdTypeName;
                    }
                    String pdName = "new NameImpl(\"" + pd.getName().getNamespaceURI() +
                        "\",\"" + pd.getName().getLocalPart() + "\")";
          

    stringBuffer.append(TEXT_50);
    stringBuffer.append(pdName);
    stringBuffer.append(TEXT_51);
    stringBuffer.append(pdTypeName);
    stringBuffer.append(TEXT_52);
   
                }
            }

    stringBuffer.append(TEXT_53);
   
        }

    stringBuffer.append(TEXT_54);
    stringBuffer.append(prefix);
    stringBuffer.append(TEXT_55);
    stringBuffer.append(schema.getURI());
    stringBuffer.append(TEXT_56);
   
        for (AttributeType type : types) {

    stringBuffer.append(TEXT_57);
View Full Code Here

  {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
     
    Object[] arguments = (Object[]) argument;
    Schema schema = (Schema) arguments[0];
    String prefix = (String) arguments[1];
    prefix = prefix.toUpperCase();
   
    SchemaGenerator sg = (SchemaGenerator) arguments[2];
    List types = sg.sort();

    stringBuffer.append(TEXT_2);
   
    HashMap ns2import = new HashMap();
    for (Iterator itr = sg.getImports().iterator(); itr.hasNext();) {
        Schema imported = (Schema)itr.next();
        String fullClassName = imported.getClass().getName();
        String className = fullClassName.substring(fullClassName.lastIndexOf(".")+1);
       
        ns2import.put(imported.getURI(), className);

    stringBuffer.append(TEXT_3);
    stringBuffer.append(fullClassName);
    stringBuffer.append(TEXT_4);
   
View Full Code Here

                    }
                }
            }
        }

        Schema gtSchema = new SchemaImpl(schema.getTargetNamespace());

        for (Iterator itr = types.values().iterator(); itr.hasNext();) {
            AttributeType gtType = (AttributeType) itr.next();
            if (gtType.getName().getLocalPart() == null ) {
              throw new NullPointerException();
            }
            gtSchema.put(gtType.getName(), gtType);
        }

        Object[] input = new Object[] {
                gtSchema, Schemas.getTargetPrefix(schema), this
            };
View Full Code Here

TOP

Related Classes of org.opengis.feature.type.Schema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.