
ru.paymentgate.engine.webservices.merchant.AbstractResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of abyss-acquiring Show documentation
Show all versions of abyss-acquiring Show documentation
Internet acquiring Web Service client library
/**
* AbstractResponse.java
*
* This file was auto-generated from WSDL
* by the Apache Axis2 version: 1.7.5 Built on : May 06, 2017 (03:45:50 BST)
*/
package ru.paymentgate.engine.webservices.merchant;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axis2.databinding.ADBBean;
import org.apache.axis2.databinding.ADBDataSource;
import org.apache.axis2.databinding.ADBException;
import org.apache.axis2.databinding.utils.BeanUtil;
import org.apache.axis2.databinding.utils.ConverterUtil;
/**
* AbstractResponse bean class
*/
public abstract class AbstractResponse implements ADBBean {
private static final long serialVersionUID = 1404049366710229374L;
/**
* field for Operations This was an Array!
*/
protected LoyaltyOperation[] localOperations;
protected boolean localOperationsTracker = false;
/**
* Код ошибки.
* Максимальная длина - 3 цифры.
*/
protected int localErrorCode;
/**
* Описание ошибки на языке, переданном в параметре language в запросе.
* Максимальная длина - 512 символов.
*/
protected String localErrorMessage;
public boolean isOperationsSpecified() {
return localOperationsTracker;
}
/**
* Auto generated getter method
*
* @return LoyaltyOperation[]
*/
public LoyaltyOperation[] getOperations() {
return localOperations;
}
/**
* validate the array for Operations
*/
protected void validateOperations(LoyaltyOperation[] param) {
}
/**
* Auto generated setter method
*
* @param param
* Operations
*/
public void setOperations(LoyaltyOperation[] param) {
validateOperations(param);
localOperationsTracker = true;
this.localOperations = param;
}
/**
* Auto generated add method for the array for convenience
*
* @param param
* LoyaltyOperation
*/
public void addOperations(LoyaltyOperation param) {
if (localOperations == null) {
localOperations = new LoyaltyOperation[] {};
}
// update the setting tracker
localOperationsTracker = true;
@SuppressWarnings("unchecked")
List list = ConverterUtil.toList(localOperations);
list.add(param);
this.localOperations = list.toArray(new LoyaltyOperation[list.size()]);
}
/**
* Код ошибки.
* Максимальная длина - 3 цифры.
*/
public int getErrorCode() {
return localErrorCode;
}
/**
* Код ошибки.
* Максимальная длина - 3 цифры.
*/
public void setErrorCode(int errorCode) {
this.localErrorCode = errorCode;
}
/**
* Описание ошибки на языке, переданном в параметре language в запросе.
* Максимальная длина - 512 символов.
*/
public String getErrorMessage() {
return localErrorMessage;
}
/**
* Описание ошибки на языке, переданном в параметре language в запросе.
* Максимальная длина - 512 символов.
*/
public void setErrorMessage(String errorMessage) {
this.localErrorMessage = errorMessage;
}
/**
*
* @param parentQName
* @param factory
* @return OMElement
*/
public OMElement getOMElement(final QName parentQName, final OMFactory factory) throws ADBException {
return factory.createOMElement(new ADBDataSource(this, parentQName));
}
public void serialize(final QName parentQName, XMLStreamWriter xmlWriter) throws XMLStreamException, ADBException {
serialize(parentQName, xmlWriter, false);
}
public void serialize(final QName parentQName, XMLStreamWriter xmlWriter, boolean serializeType)
throws XMLStreamException, ADBException {
String prefix = null;
String namespace = null;
prefix = parentQName.getPrefix();
namespace = parentQName.getNamespaceURI();
writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter);
if (serializeType) {
String namespacePrefix = registerPrefix(xmlWriter, "http://engine.paymentgate.ru/webservices/merchant");
if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) {
writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type",
namespacePrefix + ":abstractResponse", xmlWriter);
} else {
writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "abstractResponse",
xmlWriter);
}
}
if (localErrorCode != java.lang.Integer.MIN_VALUE) {
writeAttribute("", "errorCode", ConverterUtil.convertToString(localErrorCode), xmlWriter);
} else {
throw new ADBException("required attribute localErrorCode is null");
}
if (localErrorMessage != null) {
writeAttribute("", "errorMessage", ConverterUtil.convertToString(localErrorMessage), xmlWriter);
}
if (localOperationsTracker) {
if (localOperations != null) {
for (int i = 0; i < localOperations.length; i++) {
if (localOperations[i] != null) {
localOperations[i].serialize(new QName("", "operations"), xmlWriter);
} else {
writeStartElement(null, "", "operations", xmlWriter);
// write the nil attribute
writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "nil", "1", xmlWriter);
xmlWriter.writeEndElement();
}
}
} else {
writeStartElement(null, "", "operations", xmlWriter);
// write the nil attribute
writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "nil", "1", xmlWriter);
xmlWriter.writeEndElement();
}
}
xmlWriter.writeEndElement();
}
private static String generatePrefix(String namespace) {
if (namespace.equals("http://engine.paymentgate.ru/webservices/merchant")) {
return "ns1";
}
return BeanUtil.getUniquePrefix();
}
/**
* Utility method to write an element start tag.
*/
private void writeStartElement(String prefix, String namespace, String localPart, XMLStreamWriter xmlWriter)
throws XMLStreamException {
String writerPrefix = xmlWriter.getPrefix(namespace);
if (writerPrefix != null) {
xmlWriter.writeStartElement(writerPrefix, localPart, namespace);
} else {
if (namespace.length() == 0) {
prefix = "";
} else if (prefix == null) {
prefix = generatePrefix(namespace);
}
xmlWriter.writeStartElement(prefix, localPart, namespace);
xmlWriter.writeNamespace(prefix, namespace);
xmlWriter.setPrefix(prefix, namespace);
}
}
/**
* Util method to write an attribute with the ns prefix
*/
private void writeAttribute(String prefix, String namespace, String attName, String attValue,
XMLStreamWriter xmlWriter) throws XMLStreamException {
String writerPrefix = xmlWriter.getPrefix(namespace);
if (writerPrefix != null) {
xmlWriter.writeAttribute(writerPrefix, namespace, attName, attValue);
} else {
xmlWriter.writeNamespace(prefix, namespace);
xmlWriter.setPrefix(prefix, namespace);
xmlWriter.writeAttribute(prefix, namespace, attName, attValue);
}
}
/**
* Util method to write an attribute without the ns prefix
*/
private void writeAttribute(String namespace, String attName, String attValue, XMLStreamWriter xmlWriter)
throws XMLStreamException {
if (namespace.equals("")) {
xmlWriter.writeAttribute(attName, attValue);
} else {
xmlWriter.writeAttribute(registerPrefix(xmlWriter, namespace), namespace, attName, attValue);
}
}
/**
* Register a namespace prefix
*/
private String registerPrefix(XMLStreamWriter xmlWriter, String namespace) throws XMLStreamException {
String prefix = xmlWriter.getPrefix(namespace);
if (prefix == null) {
prefix = generatePrefix(namespace);
NamespaceContext nsContext = xmlWriter.getNamespaceContext();
while (true) {
String uri = nsContext.getNamespaceURI(prefix);
if ((uri == null) || (uri.length() == 0)) {
break;
}
prefix = BeanUtil.getUniquePrefix();
}
xmlWriter.writeNamespace(prefix, namespace);
xmlWriter.setPrefix(prefix, namespace);
}
return prefix;
}
/**
* Factory class that keeps the parse method
*/
public static class Factory {
/**
* static method to create the object Precondition: If this object is an
* element, the current or next start element starts this object and any
* intervening reader events are ignorable If this object is not an
* element, it is a complex type and the reader is at the event just
* after the outer start element Postcondition: If this object is an
* element, the reader is positioned at its end element If this object
* is a complex type, the reader is positioned at the end element of its
* outer element
*/
public static AbstractResponse parse(XMLStreamReader reader) throws Exception {
// AbstractResponse object = null;
String nillableValue = null;
try {
while (!reader.isStartElement() && !reader.isEndElement())
reader.next();
if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) {
String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type");
if (fullTypeName != null) {
String nsPrefix = null;
if (fullTypeName.indexOf(":") > -1) {
nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":"));
}
nsPrefix = (nsPrefix == null) ? "" : nsPrefix;
String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1);
if (!"abstractResponse".equals(type)) {
// find namespace for the prefix
String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix);
return (AbstractResponse) ru.paymentgate.engine.webservices.merchant.ExtensionMapper
.getTypeObject(nsUri, type, reader);
}
throw new ADBException("The an abstract class can not be instantiated !!!");
}
}
// handle attribute "errorCode"
String tempAttribErrorCode = reader.getAttributeValue(null, "errorCode");
if (tempAttribErrorCode != null) {
// object.setErrorCode(ConverterUtil.convertToInt(
// tempAttribErrorCode));
} else {
throw new ADBException("Required attribute errorCode is missing");
}
// handle attribute "errorMessage"
String tempAttribErrorMessage = reader.getAttributeValue(null, "errorMessage");
if (tempAttribErrorMessage != null) {
// object.setErrorMessage(ConverterUtil.convertToString(
// tempAttribErrorMessage));
}
reader.next();
ArrayList list1 = new ArrayList();
while (!reader.isStartElement() && !reader.isEndElement())
reader.next();
if ((reader.isStartElement() && new QName("", "operations").equals(reader.getName()))
|| new QName("", "operations").equals(reader.getName())) {
// Process the array and step past its final element's end.
nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "nil");
if ("true".equals(nillableValue) || "1".equals(nillableValue)) {
list1.add(null);
reader.next();
} else {
list1.add(LoyaltyOperation.Factory.parse(reader));
}
// loop until we find a start element that is not part of
// this array
boolean loopDone1 = false;
while (!loopDone1) {
// We should be at the end element, but make sure
while (!reader.isEndElement())
reader.next();
// Step out of this element
reader.next();
// Step to next element event.
while (!reader.isStartElement() && !reader.isEndElement())
reader.next();
if (reader.isEndElement()) {
// two continuous end elements means we are exiting
// the xml structure
loopDone1 = true;
} else {
if (new QName("", "operations").equals(reader.getName())) {
nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance",
"nil");
if ("true".equals(nillableValue) || "1".equals(nillableValue)) {
list1.add(null);
reader.next();
} else {
list1.add(LoyaltyOperation.Factory.parse(reader));
}
} else {
loopDone1 = true;
}
}
}
// call the converter utility to convert and set the array
// object.setOperations((LoyaltyOperation[])
// ConverterUtil.convertToArray(
// LoyaltyOperation.class,
// list1));
} // End of if for expected property start element
while (!reader.isStartElement() && !reader.isEndElement())
reader.next();
if (reader.isStartElement()) {
// 2 - A start element we are not expecting indicates a
// trailing invalid property
throw new ADBException("Unexpected subelement " + reader.getName());
}
} catch (XMLStreamException e) {
throw new Exception(e);
}
// return object;
return null;
}
} // end of factory class
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy