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

org.apache.axiom.soap.impl.intf.SOAPHelper Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.axiom.soap.impl.intf;

import javax.xml.namespace.QName;

import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.impl.common.OMNamespaceImpl;
import org.apache.axiom.soap.SOAPConstants;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPVersion;

/**
 * Encapsulates certain SOAP version specific behaviors. This API defines methods that could also be
 * added to {@link SOAPVersion}, but that are not relevant for application code and should therefore
 * not be part of the public API.
 */
public abstract class SOAPHelper {
    private final SOAPVersion version;
    private final OMNamespace namespace;
    private final String specName;
    private final Class envelopeClass;
    private final Class headerClass;
    private final QName headerQName;
    private final Class headerBlockClass;
    private final Class bodyClass;
    private final QName bodyQName;
    private final Class faultClass;
    private final QName faultQName;
    private final Class faultCodeClass;
    private final Class faultReasonClass;
    private final Class faultRoleClass;
    private final Class faultDetailClass;
    private final QName mustUnderstandAttributeQName;
    private final QName roleAttributeQName;
    private final QName relayAttributeQName;
    
    protected SOAPHelper(SOAPVersion version, String specName,
            Class envelopeClass,
            Class headerClass,
            Class headerBlockClass,
            Class bodyClass,
            Class faultClass,
            Class faultCodeClass,
            Class faultReasonClass,
            Class faultRoleClass,
            Class faultDetailClass,
            String roleAttributeLocalName, String relayAttributeLocalName) {
        this.version = version;
        namespace = new OMNamespaceImpl(version.getEnvelopeURI(),
                SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX);
        this.specName = specName;
        this.envelopeClass = envelopeClass;
        this.headerClass = headerClass;
        headerQName = new QName(version.getEnvelopeURI(), SOAPConstants.HEADER_LOCAL_NAME,
                SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX);
        this.headerBlockClass = headerBlockClass;
        this.bodyClass = bodyClass;
        bodyQName = new QName(version.getEnvelopeURI(), SOAPConstants.BODY_LOCAL_NAME,
                SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX);
        this.faultClass = faultClass;
        faultQName = new QName(version.getEnvelopeURI(), SOAPConstants.SOAPFAULT_LOCAL_NAME,
                SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX);
        this.faultCodeClass = faultCodeClass;
        this.faultReasonClass = faultReasonClass;
        this.faultRoleClass = faultRoleClass;
        this.faultDetailClass = faultDetailClass;
        mustUnderstandAttributeQName = new QName(
                version.getEnvelopeURI(), SOAPConstants.ATTR_MUSTUNDERSTAND, SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX);
        roleAttributeQName = new QName(
                version.getEnvelopeURI(), roleAttributeLocalName, SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX);
        relayAttributeQName = relayAttributeLocalName == null ? null :
            new QName(version.getEnvelopeURI(), relayAttributeLocalName, SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX);
    }
    
    public final SOAPVersion getVersion() {
        return version;
    }
    
    public abstract SOAPFactory getSOAPFactory(OMMetaFactory metaFactory);
    
    public final String getEnvelopeURI() {
        return version.getEnvelopeURI();
    }

    public final OMNamespace getNamespace() {
        return namespace;
    }

    public final String getSpecName() {
        return specName;
    }

    public final Class getEnvelopeClass() {
        return envelopeClass;
    }

    public final Class getHeaderClass() {
        return headerClass;
    }

    public final QName getHeaderQName() {
        return headerQName;
    }

    public final Class getHeaderBlockClass() {
        return headerBlockClass;
    }

    public final Class getBodyClass() {
        return bodyClass;
    }

    public final QName getBodyQName() {
        return bodyQName;
    }

    public final Class getFaultClass() {
        return faultClass;
    }

    public final QName getFaultQName() {
        return faultQName;
    }

    public final Class getFaultCodeClass() {
        return faultCodeClass;
    }

    public final QName getFaultCodeQName() {
        return version.getFaultCodeQName();
    }

    public final Class getFaultReasonClass() {
        return faultReasonClass;
    }

    public final QName getFaultReasonQName() {
        return version.getFaultReasonQName();
    }

    public final Class getFaultRoleClass() {
        return faultRoleClass;
    }

    public final QName getFaultRoleQName() {
        return version.getFaultRoleQName();
    }

    public final Class getFaultDetailClass() {
        return faultDetailClass;
    }

    public final QName getFaultDetailQName() {
        return version.getFaultDetailQName();
    }

    public final QName getMustUnderstandAttributeQName() {
        return mustUnderstandAttributeQName;
    }

    public final QName getRoleAttributeQName() {
        return roleAttributeQName;
    }

    public final QName getRelayAttributeQName() {
        return relayAttributeQName;
    }

    public abstract Boolean parseBoolean(String literal);
    public abstract String formatBoolean(boolean value);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy