• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DeserializationContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.axis.encoding.DeserializationContext的典型用法代码示例。如果您正苦于以下问题:Java DeserializationContext类的具体用法?Java DeserializationContext怎么用?Java DeserializationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DeserializationContext类属于org.apache.axis.encoding包,在下文中一共展示了DeserializationContext类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onStartChild

import org.apache.axis.encoding.DeserializationContext; //导入依赖的package包/类
/**
 * This method is invoked when an element start tag is encountered.
 * @param namespace is the namespace of the element
 * @param localName is the name of the element
 * @param prefix is the element's prefix
 * @param attributes are the attributes on the element...used to get the type
 * @param context is the DeserializationContext
 */
public SOAPHandler onStartChild(String namespace,
                                String localName,
                                String prefix,
                                Attributes attributes,
                                DeserializationContext context)
    throws SAXException
{
    QName typeQName = (QName)typesByMemberName.get(localName);
    if (typeQName == null)
        throw new SAXException("Invalid element in Data struct - " + localName);
    
    // These can come in either order.
    Deserializer dSer = context.getDeserializerForType(typeQName);
    try {
        dSer.registerValueTarget(new FieldTarget(value, localName));
    } catch (NoSuchFieldException e) {
        throw new SAXException(e);
    }
    
    if (dSer == null)
        throw new SAXException("No deserializer for a " + typeQName + "???");
    
    return (SOAPHandler)dSer;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:DataDeser.java


示例2: onEndElement

import org.apache.axis.encoding.DeserializationContext; //导入依赖的package包/类
/**
 * {@inheritDoc} Return something even if no characters were found.
 */
@SuppressWarnings("unchecked")
@Override
public void onEndElement(String namespace, String localName, DeserializationContext context) throws SAXException {
    try {
        MessageElement msgElem = context.getCurElement();
        if (msgElem != null) {
            JAXBContext jc = JaxbContextManager.getContextForPackage(javaType.getPackage().getName());
            Unmarshaller unmarshaller = jc.createUnmarshaller();
            // Unmarshall the nested XML element into a jaxb object of type 'javaType'
            value = unmarshaller.unmarshal(msgElem.getAsDOM());
            if (value instanceof JAXBElement) {
            	JAXBElement jaxbElement = (JAXBElement)value;
            	value = jaxbElement.getValue();
            }
        }
    } catch (Exception e) {
    	e.printStackTrace();
        throw new SAXException(e);
    }
}
 
开发者ID:NCIP,项目名称:iso21090,代码行数:24,代码来源:JaxbDeserializer.java


示例3: startElement

import org.apache.axis.encoding.DeserializationContext; //导入依赖的package包/类
/**
 * startElement
 * 
 * The ONLY reason that this method is overridden is so that
 * the object value can be set or a reasonable exception is thrown
 * indicating that the object cannot be created.  This is done
 * at this point so that it occurs BEFORE href/id processing.
 * @param namespace is the namespace of the element
 * @param localName is the name of the element
 * @param prefix is the prefix of the element
 * @param attributes are the attributes on the element...used to get the
 *                   type
 * @param context is the DeserializationContext
 */
public void startElement(String namespace, String localName,
                         String prefix, Attributes attributes,
                         DeserializationContext context)
    throws SAXException
{
    // Create the bean object if it was not already
    // created in the constructor.
    if (value == null) {
        try {
            value=javaType.newInstance();
        } catch (Exception e) {
            // Use first found constructor.
            // Note : the right way is to use XML mapping information
            // for example JSR 109's constructor-parameter-order
            Constructor[] constructors = javaType.getConstructors();
            if (constructors.length > 0) {
                constructorToUse = constructors[0];
            }

            // Failed to create an object if no constructor
            if (constructorToUse == null) {
                throw new SAXException(Messages.getMessage("cantCreateBean00", 
                                                        javaType.getName(), 
                                                        e.toString()));
            }
        }
    }
    // Invoke super.startElement to do the href/id processing.
    super.startElement(namespace, localName, 
                       prefix, attributes, context);
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:46,代码来源:BeanDeserializer.java


示例4: startElement

import org.apache.axis.encoding.DeserializationContext; //导入依赖的package包/类
/**
    * startElement
    * 
    * The ONLY reason that this method is overridden is so that
    * the object value can be set or a reasonable exception is thrown
    * indicating that the object cannot be created.  This is done
    * at this point so that it occurs BEFORE href/id processing.
    * @param namespace is the namespace of the element
    * @param localName is the name of the element
    * @param prefix is the prefix of the element
    * @param attributes are the attributes on the element...used to get the
    *                   type
    * @param context is the DeserializationContext
    */
   @Override
public void startElement(String namespace, String localName,
                            String prefix, Attributes attributes,
                            DeserializationContext context)
       throws SAXException
   {
       // Create the bean object if it was not already
       // created in the constructor.
       if (value == null) {
           try {
               value=javaType.newInstance();
           } catch (Exception e) {
               // Use first found constructor.
               // Note : the right way is to use XML mapping information
               // for example JSR 109's constructor-parameter-order
               Constructor[] constructors = javaType.getConstructors();
               if (constructors.length > 0) {
                   constructorToUse = constructors[0];
               }

               // Failed to create an object if no constructor
               if (constructorToUse == null) {
                   throw new SAXException(Messages.getMessage("cantCreateBean00", 
                                                           javaType.getName(), 
                                                           e.toString()));
               }
           }
       }
       // Invoke super.startElement to do the href/id processing.
       super.startElement(namespace, localName, 
                          prefix, attributes, context);
   }
 
开发者ID:lucee,项目名称:Lucee,代码行数:47,代码来源:BeanDeserializer.java


示例5: onEndElement

import org.apache.axis.encoding.DeserializationContext; //导入依赖的package包/类
public void onEndElement(String namespace, String localName,
                         DeserializationContext context) throws SAXException {
    handleMixedContent();
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:5,代码来源:BeanDeserializer.java


示例6: onEndElement

import org.apache.axis.encoding.DeserializationContext; //导入依赖的package包/类
@Override
public void onEndElement(String namespace, String localName,
                            DeserializationContext context) throws SAXException {
       handleMixedContent();
   }
 
开发者ID:lucee,项目名称:Lucee,代码行数:6,代码来源:BeanDeserializer.java


示例7: deserializeBatchJobMutateResults

import org.apache.axis.encoding.DeserializationContext; //导入依赖的package包/类
public <ResultT> List<ResultT> deserializeBatchJobMutateResults(
    URL url, List<TypeMapping> serviceTypeMappings, Class<ResultT> resultClass, QName resultQName)
    throws Exception {

  List<ResultT> results = Lists.newArrayList();

  // Build a wrapped input stream from the response.
  InputStream wrappedStream = buildWrappedInputStream(url.openStream());

  // Create a MessageContext with a new TypeMappingRegistry that will only
  // contain deserializers derived from serviceTypeMappings and the
  // result class/QName pair.
  MessageContext messageContext = new MessageContext(new AxisClient());
  TypeMappingRegistryImpl typeMappingRegistry = new TypeMappingRegistryImpl(true);
  messageContext.setTypeMappingRegistry(typeMappingRegistry);

  // Construct an Axis deserialization context.
  DeserializationContext deserializationContext =
      new DeserializationContext(
          new InputSource(wrappedStream), messageContext, Message.RESPONSE);

  // Register all type mappings with the new type mapping registry.
  TypeMapping registryTypeMapping =
      typeMappingRegistry.getOrMakeTypeMapping(messageContext.getEncodingStyle());
  registerTypeMappings(registryTypeMapping, serviceTypeMappings);
  
  // Parse the wrapped input stream.
  deserializationContext.parse();

  // Read the deserialized mutate results from the parsed stream.
  SOAPEnvelope envelope = deserializationContext.getEnvelope();
  MessageElement body = envelope.getFirstBody();

  for (Iterator<?> iter = body.getChildElements(); iter.hasNext(); ) {
    Object child = iter.next();
    MessageElement childElm = (MessageElement) child;
    @SuppressWarnings("unchecked")
    ResultT mutateResult = (ResultT) childElm.getValueAsType(resultQName, resultClass);
    results.add(mutateResult);
  }
  return results;
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:43,代码来源:AxisDeserializer.java



注:本文中的org.apache.axis.encoding.DeserializationContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApplicationStateData类代码示例发布时间:2022-05-22
下一篇:
Java Metadata类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap