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

📄 defaulttypemappingimpl.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * Copyright 2001-2004 The Apache Software Foundation. *  * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.axis.encoding;import org.apache.axis.Constants;import org.apache.axis.attachments.OctetStream;import org.apache.axis.encoding.ser.ArrayDeserializerFactory;import org.apache.axis.encoding.ser.ArraySerializerFactory;import org.apache.axis.encoding.ser.Base64DeserializerFactory;import org.apache.axis.encoding.ser.Base64SerializerFactory;import org.apache.axis.encoding.ser.BeanDeserializerFactory;import org.apache.axis.encoding.ser.BeanSerializerFactory;import org.apache.axis.encoding.ser.DateDeserializerFactory;import org.apache.axis.encoding.ser.DateSerializerFactory;import org.apache.axis.encoding.ser.DocumentDeserializerFactory;import org.apache.axis.encoding.ser.DocumentSerializerFactory;import org.apache.axis.encoding.ser.ElementDeserializerFactory;import org.apache.axis.encoding.ser.ElementSerializerFactory;import org.apache.axis.encoding.ser.HexDeserializerFactory;import org.apache.axis.encoding.ser.HexSerializerFactory;import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;import org.apache.axis.encoding.ser.MapDeserializerFactory;import org.apache.axis.encoding.ser.MapSerializerFactory;import org.apache.axis.encoding.ser.QNameDeserializerFactory;import org.apache.axis.encoding.ser.QNameSerializerFactory;import org.apache.axis.encoding.ser.SimpleDeserializerFactory;import org.apache.axis.encoding.ser.SimpleSerializerFactory;import org.apache.axis.encoding.ser.VectorDeserializerFactory;import org.apache.axis.encoding.ser.VectorSerializerFactory;import org.apache.axis.schema.SchemaVersion;import org.apache.axis.types.HexBinary;import org.apache.axis.utils.JavaUtils;import org.apache.axis.utils.Messages;import javax.xml.namespace.QName;import javax.xml.rpc.JAXRPCException;import javax.xml.rpc.encoding.DeserializerFactory;/** * This is the implementation of the axis Default TypeMapping (which extends * the JAX-RPC TypeMapping interface) for SOAP 1.1. * * A TypeMapping contains tuples as follows: * {Java type, SerializerFactory, DeserializerFactory, Type QName) * * In other words, it serves to map Java types to and from XML types using * particular Serializers/Deserializers.  Each TypeMapping is associated with * one or more encodingStyle URIs. * * The wsdl in your web service will use a number of types.  The tuple * information for each of these will be accessed via the TypeMapping. * * This TypeMapping is the "default" one, which includes all the standard * SOAP and schema XSD types.  Individual TypeMappings (associated with * AxisEngines and SOAPServices) will delegate to this one, so if you haven't * overriden a default mapping we'll end up getting it from here. * * @author Rich Scheuerle (scheu@us.ibm.com) */public class DefaultTypeMappingImpl extends TypeMappingImpl {    private static DefaultTypeMappingImpl tm = null;    private boolean inInitMappings = false;    /**     * Obtain the singleton default typemapping.     */    public static synchronized TypeMappingDelegate getSingletonDelegate() {        if (tm == null) {            tm = new DefaultTypeMappingImpl();        }        return new TypeMappingDelegate(tm);    }    protected DefaultTypeMappingImpl() {        initMappings();    }    protected DefaultTypeMappingImpl(boolean noMappings) {        if (!noMappings) {            initMappings();        }    }    protected void initMappings() {        inInitMappings = true;        // Notes:        // 1) The registration statements are order dependent.  The last one        //    wins.  So if two javaTypes of String are registered, the        //    ser factory for the last one registered will be chosen.  Likewise        //    if two javaTypes for XSD_DATE are registered, the deserializer        //    factory for the last one registered will be chosen.        //    Corollary:  Please be very careful with the order.  The        //                runtime, Java2WSDL and WSDL2Java emitters all        //                use this code to get type mapping information.        // 2) Even if the SOAP 1.1 format is used over the wire, an        //    attempt is made to receive SOAP 1.2 format from the wire.        //    This is the reason why the soap encoded primitives are        //    registered without serializers.        // Since the last-registered type wins, I want to add the mime        // String FIRST.        if (JavaUtils.isAttachmentSupported()) {            myRegister(Constants.MIME_PLAINTEXT, java.lang.String.class,                    new JAFDataHandlerSerializerFactory(                            java.lang.String.class,                            Constants.MIME_PLAINTEXT),                    new JAFDataHandlerDeserializerFactory(                            java.lang.String.class,                            Constants.MIME_PLAINTEXT));        }        // HexBinary binary data needs to use the hex binary serializer/deserializer        myRegister(Constants.XSD_HEXBIN,     HexBinary.class,                   new HexSerializerFactory(                        HexBinary.class, Constants.XSD_HEXBIN),                   new HexDeserializerFactory(                        HexBinary.class, Constants.XSD_HEXBIN));        myRegister(Constants.XSD_HEXBIN,     byte[].class,                   new HexSerializerFactory(                        byte[].class, Constants.XSD_HEXBIN),                   new HexDeserializerFactory(                        byte[].class, Constants.XSD_HEXBIN));        // SOAP 1.1        // byte[] -ser-> XSD_BASE64        // XSD_BASE64 -deser-> byte[]        // SOAP_BASE64 -deser->byte[]        //        // Special case:        // If serialization is requested for xsd:byte with byte[],        // the array serializer is used.  If deserialization        // is specifically requested for xsd:byte with byte[], the        // simple deserializer is used.  This is necessary        // to support the serialization/deserialization        // of <element name="a" type="xsd:byte" maxOccurs="unbounded" />        // as discrete bytes without interference with XSD_BASE64.        myRegister(Constants.XSD_BYTE,       byte[].class,                   new ArraySerializerFactory(),                   null        );        myRegister(Constants.XSD_BASE64,     byte[].class,                   new Base64SerializerFactory(byte[].class,                                               Constants.XSD_BASE64 ),                   new Base64DeserializerFactory(byte[].class,                                           Constants.XSD_BASE64));        // anySimpleType is mapped to java.lang.String according to JAX-RPC 1.1 spec.        myRegisterSimple(Constants.XSD_ANYSIMPLETYPE, java.lang.String.class);                // If SOAP 1.1 over the wire, map wrapper classes to XSD primitives.        myRegisterSimple(Constants.XSD_STRING, java.lang.String.class);        myRegisterSimple(Constants.XSD_BOOLEAN, java.lang.Boolean.class);        myRegisterSimple(Constants.XSD_DOUBLE, java.lang.Double.class);        myRegisterSimple(Constants.XSD_FLOAT, java.lang.Float.class);        myRegisterSimple(Constants.XSD_INT, java.lang.Integer.class);        myRegisterSimple(Constants.XSD_INTEGER, java.math.BigInteger.class        );        myRegisterSimple(Constants.XSD_DECIMAL, java.math.BigDecimal.class        );        myRegisterSimple(Constants.XSD_LONG, java.lang.Long.class);        myRegisterSimple(Constants.XSD_SHORT, java.lang.Short.class);        myRegisterSimple(Constants.XSD_BYTE, java.lang.Byte.class);        // The XSD Primitives are mapped to java primitives.        myRegisterSimple(Constants.XSD_BOOLEAN, boolean.class);        myRegisterSimple(Constants.XSD_DOUBLE, double.class);        myRegisterSimple(Constants.XSD_FLOAT, float.class);        myRegisterSimple(Constants.XSD_INT, int.class);        myRegisterSimple(Constants.XSD_LONG, long.class);        myRegisterSimple(Constants.XSD_SHORT, short.class);        myRegisterSimple(Constants.XSD_BYTE, byte.class);        // Map QNAME to the jax rpc QName class        myRegister(Constants.XSD_QNAME,              javax.xml.namespace.QName.class,              new QNameSerializerFactory(javax.xml.namespace.QName.class,                                        Constants.XSD_QNAME),              new QNameDeserializerFactory(javax.xml.namespace.QName.class,                                        Constants.XSD_QNAME)        );        // The closest match for anytype is Object        myRegister(Constants.XSD_ANYTYPE,    java.lang.Object.class,                   null, null);        // See the SchemaVersion classes for where the registration of        // dateTime (for 2001) and timeInstant (for 1999 & 2000) happen.        myRegister(Constants.XSD_DATE,       java.sql.Date.class,                   new DateSerializerFactory(java.sql.Date.class,                                             Constants.XSD_DATE),                   new DateDeserializerFactory(java.sql.Date.class,

⌨️ 快捷键说明

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