⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xsprofile.java

📁 电子地图服务器,搭建自己的地图服务
💻 JAVA
字号:
/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
 * This code is licensed under the GPL 2.0 license, availible at the root
 * application directory.
 */
package org.geoserver.wfs.xml;

import org.geotools.feature.AttributeTypeFactory;
import org.geotools.feature.Name;
import org.geotools.feature.type.ProfileImpl;
import org.geotools.feature.type.SchemaImpl;
import org.geotools.xs.XSSchema;
import org.geotools.xs.bindings.XS;
import org.opengis.feature.type.Schema;

import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.xml.namespace.QName;


/**
 * A profile of {@link XSSchema} which makes the java class to type
 * mapping unique.
 */
public class XSProfile extends TypeMappingProfile {
    static Set profiles = new HashSet();

    static {
        Set proper = new HashSet();
        proper.add(name(XS.BYTE)); //Byte.class
        proper.add(name(XS.HEXBINARY)); //byte[].class 
        proper.add(name(XS.SHORT)); //Short.class
        proper.add(name(XS.INT)); //Integer.class
        proper.add(name(XS.FLOAT)); //Float.class
        proper.add(name(XS.LONG)); //Long.class
        proper.add(name(XS.QNAME)); //Qname.class
        proper.add(name(XS.DATE)); //java.sql.Date.class
        proper.add(name(XS.DATETIME)); //java.sql.Timestamp.class
        proper.add(name(XS.TIME));     //java.sql.Time.class
        proper.add(name(XS.BOOLEAN)); //Boolean.class
        proper.add(name(XS.DOUBLE)); //Double.class
        proper.add(name(XS.STRING)); //String.class
        proper.add(name(XS.INTEGER)); //BigInteger.class
        proper.add(name(XS.DECIMAL)); //BigDecimal.class
        proper.add(name(XS.ANYURI)); //URI.class
        profiles.add( new ProfileImpl( new XSSchema(), proper ) );
        
        //date mappings between java and xml schema are kind of messed up, so 
        // we create a custom schema which also contains a mapping for 
        // java.util.Date
        Schema additional = new SchemaImpl(XS.NAMESPACE);
        additional.put(name(XS.DATETIME), AttributeTypeFactory.newAttributeType("date", Date.class ));
        profiles.add( new ProfileImpl( additional, Collections.singleton( name( XS.DATETIME))));
        
        //profile.add(name(XS.ANYTYPE)); //Map.class
    }

    static Name name(QName qName) {
        return new Name(qName.getNamespaceURI(), qName.getLocalPart());
    }

    public XSProfile() {
        super( profiles );
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -