All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.paymentgate.engine.webservices.merchant.PaymentBonus Maven / Gradle / Ivy

The newest version!
/**
 * PaymentBonus.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 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;

/**
 * PaymentBonus bean class
 */
public class PaymentBonus implements ADBBean {

	private static final long serialVersionUID = 4330638865223706260L;

	/**
	 * field for ApprovedAmountBonus This was an Attribute!
	 */
	protected int localApprovedAmountBonus;

	/**
	 * field for DepositedAmountBonus This was an Attribute!
	 */
	protected int localDepositedAmountBonus;

	/**
	 * field for RefundedAmountBonus This was an Attribute!
	 */
	protected int localRefundedAmountBonus;

	/**
	 * field for PcId This was an Attribute!
	 */
	protected String localPcId;

	/**
	 * field for Successful This was an Attribute!
	 */
	protected boolean localSuccessful;

	/**
	 * field for PaymentOperation This was an Attribute!
	 */
	protected Operation localPaymentOperation;

	/**
	 * Auto generated getter method
	 * 
	 * @return int
	 */
	public int getApprovedAmountBonus() {
		return localApprovedAmountBonus;
	}

	/**
	 * Auto generated setter method
	 * 
	 * @param param
	 *            ApprovedAmountBonus
	 */
	public void setApprovedAmountBonus(int param) {
		this.localApprovedAmountBonus = param;
	}

	/**
	 * Auto generated getter method
	 * 
	 * @return int
	 */
	public int getDepositedAmountBonus() {
		return localDepositedAmountBonus;
	}

	/**
	 * Auto generated setter method
	 * 
	 * @param param
	 *            DepositedAmountBonus
	 */
	public void setDepositedAmountBonus(int param) {
		this.localDepositedAmountBonus = param;
	}

	/**
	 * Auto generated getter method
	 * 
	 * @return int
	 */
	public int getRefundedAmountBonus() {
		return localRefundedAmountBonus;
	}

	/**
	 * Auto generated setter method
	 * 
	 * @param param
	 *            RefundedAmountBonus
	 */
	public void setRefundedAmountBonus(int param) {
		this.localRefundedAmountBonus = param;
	}

	/**
	 * Auto generated getter method
	 * 
	 * @return String
	 */
	public String getPcId() {
		return localPcId;
	}

	/**
	 * Auto generated setter method
	 * 
	 * @param param
	 *            PcId
	 */
	public void setPcId(String param) {
		this.localPcId = param;
	}

	/**
	 * Auto generated getter method
	 * 
	 * @return boolean
	 */
	public boolean getSuccessful() {
		return localSuccessful;
	}

	/**
	 * Auto generated setter method
	 * 
	 * @param param
	 *            Successful
	 */
	public void setSuccessful(boolean param) {
		this.localSuccessful = param;
	}

	/**
	 * Auto generated getter method
	 * 
	 * @return Operation
	 */
	public Operation getPaymentOperation() {
		return localPaymentOperation;
	}

	/**
	 * Auto generated setter method
	 * 
	 * @param param
	 *            PaymentOperation
	 */
	public void setPaymentOperation(Operation param) {
		this.localPaymentOperation = param;
	}

	/**
	 *
	 * @param parentQName
	 * @param factory
	 * @return OMElement
	 */
	@Override
	public OMElement getOMElement(final QName parentQName, final OMFactory factory) throws ADBException {
		return factory.createOMElement(new ADBDataSource(this, parentQName));
	}

	@Override
	public void serialize(final QName parentQName, XMLStreamWriter xmlWriter) throws XMLStreamException, ADBException {
		serialize(parentQName, xmlWriter, false);
	}

	@Override
	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 + ":paymentBonus", xmlWriter);
			} else {
				writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "paymentBonus", xmlWriter);
			}
		}

		if (localApprovedAmountBonus != Integer.MIN_VALUE) {
			writeAttribute("", "approvedAmountBonus", ConverterUtil.convertToString(localApprovedAmountBonus),
					xmlWriter);
		}

		if (localDepositedAmountBonus != Integer.MIN_VALUE) {
			writeAttribute("", "depositedAmountBonus", ConverterUtil.convertToString(localDepositedAmountBonus),
					xmlWriter);
		}

		if (localRefundedAmountBonus != Integer.MIN_VALUE) {
			writeAttribute("", "refundedAmountBonus", ConverterUtil.convertToString(localRefundedAmountBonus),
					xmlWriter);
		}

		if (localPcId != null) {
			writeAttribute("", "pcId", ConverterUtil.convertToString(localPcId), xmlWriter);
		}

		if (true) {
			writeAttribute("", "successful", ConverterUtil.convertToString(localSuccessful), xmlWriter);
		}

		if (localPaymentOperation != null) {
			writeAttribute("", "paymentOperation", localPaymentOperation.toString(), xmlWriter);
		}

		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 PaymentBonus parse(XMLStreamReader reader) throws Exception {
			PaymentBonus object = new PaymentBonus();

			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 (!"paymentBonus".equals(type)) {
							// find namespace for the prefix
							String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix);

							return (PaymentBonus) ExtensionMapper.getTypeObject(nsUri, type, reader);
						}
					}
				}

				// handle attribute "approvedAmountBonus"
				String tempAttribApprovedAmountBonus = reader.getAttributeValue(null, "approvedAmountBonus");

				if (tempAttribApprovedAmountBonus != null) {
					object.setApprovedAmountBonus(ConverterUtil.convertToInt(tempAttribApprovedAmountBonus));
				} else {
					object.setApprovedAmountBonus(Integer.MIN_VALUE);
				}

				// handle attribute "depositedAmountBonus"
				String tempAttribDepositedAmountBonus = reader.getAttributeValue(null, "depositedAmountBonus");

				if (tempAttribDepositedAmountBonus != null) {
					object.setDepositedAmountBonus(ConverterUtil.convertToInt(tempAttribDepositedAmountBonus));
				} else {
					object.setDepositedAmountBonus(Integer.MIN_VALUE);
				}

				// handle attribute "refundedAmountBonus"
				String tempAttribRefundedAmountBonus = reader.getAttributeValue(null, "refundedAmountBonus");

				if (tempAttribRefundedAmountBonus != null) {
					object.setRefundedAmountBonus(ConverterUtil.convertToInt(tempAttribRefundedAmountBonus));
				} else {
					object.setRefundedAmountBonus(Integer.MIN_VALUE);
				}

				// handle attribute "pcId"
				String tempAttribPcId = reader.getAttributeValue(null, "pcId");

				if (tempAttribPcId != null) {
					object.setPcId(ConverterUtil.convertToString(tempAttribPcId));
				}

				// handle attribute "successful"
				String tempAttribSuccessful = reader.getAttributeValue(null, "successful");

				if (tempAttribSuccessful != null) {
					object.setSuccessful(ConverterUtil.convertToBoolean(tempAttribSuccessful));
				}

				// handle attribute "paymentOperation"
				String tempAttribPaymentOperation = reader.getAttributeValue(null, "paymentOperation");

				if (tempAttribPaymentOperation != null) {
					object.setPaymentOperation(Operation.Factory.fromString(reader, tempAttribPaymentOperation));
				}

				reader.next();

				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;
		}
	} // end of factory class

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy