本文整理汇总了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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例5: onEndElement
import org.apache.axis.encoding.DeserializationContext; //导入依赖的package包/类
public void onEndElement(String namespace, String localName,
DeserializationContext context) throws SAXException {
handleMixedContent();
}
示例6: onEndElement
import org.apache.axis.encoding.DeserializationContext; //导入依赖的package包/类
@Override
public void onEndElement(String namespace, String localName,
DeserializationContext context) throws SAXException {
handleMixedContent();
}
示例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;
}