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

📄 soapmappingregistry.java

📁 JavaWeb服务应用开发详解的配套源码,欢迎下载
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * The Apache Software License, Version 1.1
 *
 *
 * Copyright (c) 2000 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "SOAP" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation and was
 * originally based on software copyright (c) 2000, International
 * Business Machines, Inc., http://www.apache.org.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */

package org.apache.soap.encoding;

import java.io.*;
import java.util.*;
import java.math.*;
import org.w3c.dom.*;
import org.apache.soap.util.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
import org.apache.soap.encoding.literalxml.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.encoding.xmi.*;

/**
 * A <code>SOAPMappingRegistry</code> object is an
 * <code>XMLJavaMappingRegistry</code> with pre-registered
 * serializers and deserializers to support <em>SOAP</em>.
 *
 * @author Matthew J. Duftler (duftler@us.ibm.com)
 * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
 * @author Francisco Curbera (curbera@us.ibm.com)
 * @author Sam Ruby (rubys@us.ibm.com)
 * @author Glen Daniels (gdaniels@allaire.com)
 */
public class SOAPMappingRegistry extends XMLJavaMappingRegistry
{
  private static final String soapEncURI = Constants.NS_URI_SOAP_ENC;
  
  private static final QName arrayQName = new QName(soapEncURI, "Array");

  private final StringDeserializer stringDeser = new StringDeserializer();
  private final IntDeserializer intDeser =  new IntDeserializer();
  private final DecimalDeserializer decimalDeser =  new DecimalDeserializer();
  private final FloatDeserializer floatDeser =  new FloatDeserializer();
  private final DoubleDeserializer doubleDeser =  new DoubleDeserializer();
  private final BooleanDeserializer booleanDeser =  new BooleanDeserializer();
  private final LongDeserializer longDeser =  new LongDeserializer();
  private final ShortDeserializer shortDeser =  new ShortDeserializer();
  private final ByteDeserializer byteDeser =  new ByteDeserializer();

  private final QNameSerializer qNameSer = new QNameSerializer();
  private final ParameterSerializer paramSer = new ParameterSerializer();
  private final ArraySerializer arraySer = new ArraySerializer();
  private final VectorSerializer vectorSer = new VectorSerializer();
  private final HashtableSerializer hashtableSer = new HashtableSerializer();
  public static final MimePartSerializer partSer = new MimePartSerializer();
  private final XMLParameterSerializer xmlParamSer =
                                                    new XMLParameterSerializer();
  private final DateSerializer dateSer = new DateSerializer();
  private final CalendarSerializer calSer = new CalendarSerializer();
  private final UrTypeDeserializer objDeser = new UrTypeDeserializer();
  
  /**
   * The following stuff is here to deal with the slight differences
   * between 1999 schema and 2000/10 schema.  This system allows us to
   * register type mappings for both sets of QNames, and to default to
   * whichever one is set as current.
   * 
   * !!! The order of the elements in these arrays is critical.  Be
   *     careful when editing.
   */
  QName schema1999QNames [] = {
    Constants.string1999QName,
    Constants.int1999QName,
    Constants.int1999QName,
    Constants.decimal1999QName,
    Constants.float1999QName,
    Constants.float1999QName,
    Constants.double1999QName,
    Constants.double1999QName,
    Constants.boolean1999QName,
    Constants.boolean1999QName,
    Constants.long1999QName,
    Constants.long1999QName,
    Constants.short1999QName,
    Constants.short1999QName,
    Constants.byte1999QName,
    Constants.byte1999QName,
    Constants.qName1999QName,
    Constants.date1999QName,
    Constants.timeInst1999QName,
    Constants.object1999QName,
    Constants.object1999QName,
    Constants.object1999QName,
    Constants.object1999QName,
    Constants.object1999QName,
  };
  
  QName schema2000QNames [] = {
    Constants.string2000QName,
    Constants.int2000QName,
    Constants.int2000QName,
    Constants.decimal2000QName,
    Constants.float2000QName,
    Constants.float2000QName,
    Constants.double2000QName,
    Constants.double2000QName,
    Constants.boolean2000QName,
    Constants.boolean2000QName,
    Constants.long2000QName,
    Constants.long2000QName,
    Constants.short2000QName,
    Constants.short2000QName,
    Constants.byte2000QName,
    Constants.byte2000QName,
    Constants.qName2000QName,
    Constants.date2000QName,
    Constants.timeInst2000QName,
    Constants.object2000QName,
    Constants.object2000QName,
    Constants.object2000QName,
    Constants.object2000QName,
    Constants.object2000QName,
  };
  
  QName schema2001QNames [] = {
    Constants.string2001QName,
    Constants.int2001QName,
    Constants.int2001QName,
    Constants.decimal2001QName,
    Constants.float2001QName,
    Constants.float2001QName,
    Constants.double2001QName,
    Constants.double2001QName,
    Constants.boolean2001QName,
    Constants.boolean2001QName,
    Constants.long2001QName,
    Constants.long2001QName,
    Constants.short2001QName,
    Constants.short2001QName,
    Constants.byte2001QName,
    Constants.byte2001QName,
    Constants.qName2001QName,
    Constants.date2001QName,
    Constants.timeInst2001QName,
    Constants.object2001QName,
    Constants.object2001QName,
    Constants.object2001QName,
    Constants.object2001QName,
    Constants.object2001QName,
  };

  public String schemaURI = Constants.NS_URI_1999_SCHEMA_XSD;
  QName [] schemaQNames = schema1999QNames;
  
  Class classes [] = {
    String.class,
    Integer.class,
    int.class,
    BigDecimal.class,
    Float.class,
    float.class,
    Double.class,
    double.class,
    Boolean.class,
    boolean.class,
    Long.class,
    long.class,
    Short.class,
    short.class,
    Byte.class,
    byte.class,
    QName.class,
    GregorianCalendar.class,
    Date.class,
    javax.mail.internet.MimeBodyPart.class,
    java.io.InputStream.class,
    javax.activation.DataSource.class,
    javax.activation.DataHandler.class,
    Object.class,
  };

  /*
    This serializer runs its content through a mechanism to replace
    the characters {&, ", ', <, >} with their appropriate escape
    sequences.
  */
  Serializer cleanSer = new Serializer()
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException, IOException {
      nsStack.pushScope();

      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                           javaType,
                                           context,
                                           sink,
                                           nsStack,
                                           xjmr);

      sink.write(Utils.cleanString(src.toString()) + "</" + context + '>');

      nsStack.popScope();

⌨️ 快捷键说明

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