/*
 * TeleStax, Open Source Cloud Communications  Copyright 2012.
 * and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.mobicents.protocols.ss7.cap.errors;

import javolution.xml.XMLFormat;
import javolution.xml.stream.XMLStreamException;

import org.mobicents.protocols.asn.AsnInputStream;
import org.mobicents.protocols.asn.AsnOutputStream;
import org.mobicents.protocols.ss7.cap.api.CAPException;
import org.mobicents.protocols.ss7.cap.api.CAPParsingComponentException;
import org.mobicents.protocols.ss7.cap.api.errors.CAPErrorMessageParameterless;

/**
 * The CAP ReturnError message without any parameters
 *
 * @author sergey vetyutnev
 *
 */
public class CAPErrorMessageParameterlessImpl extends CAPErrorMessageImpl implements CAPErrorMessageParameterless {

    public CAPErrorMessageParameterlessImpl(Long errorCode) {
        super(errorCode);
    }

    public CAPErrorMessageParameterlessImpl() {
        super(0L);
    }

    @Override
    public boolean isEmParameterless() {
        return true;
    }

    @Override
    public CAPErrorMessageParameterless getEmParameterless() {
        return this;
    }

    @Override
    public int getTag() throws CAPException {
        throw new CAPException("CAPErrorMessageParameterless does not support encoding");
    }

    @Override
    public int getTagClass() {
        return 0;
    }

    @Override
    public boolean getIsPrimitive() {
        return false;
    }

    @Override
    public void decodeAll(AsnInputStream ansIS) throws CAPParsingComponentException {
    }

    @Override
    public void decodeData(AsnInputStream ansIS, int length) throws CAPParsingComponentException {
    }

    @Override
    public void encodeAll(AsnOutputStream asnOs) throws CAPException {
    }

    @Override
    public void encodeAll(AsnOutputStream asnOs, int tagClass, int tag) throws CAPException {
    }

    @Override
    public void encodeData(AsnOutputStream asnOs) throws CAPException {
    }

    @Override
    public String toString() {
        return "CAPErrorMessageParameterless [errorCode=" + this.errorCode + "]";
    }

    /**
     * XML Serialization/Deserialization
     */
    protected static final XMLFormat<CAPErrorMessageParameterlessImpl> CAP_ERROR_MESSAGE_PARAMETERLESS_XML = new XMLFormat<CAPErrorMessageParameterlessImpl>(
            CAPErrorMessageParameterlessImpl.class) {

        @Override
        public void read(javolution.xml.XMLFormat.InputElement xml, CAPErrorMessageParameterlessImpl errorMessage)
                throws XMLStreamException {
            CAP_ERROR_MESSAGE_XML.read(xml, errorMessage);
        }

        @Override
        public void write(CAPErrorMessageParameterlessImpl errorMessage, javolution.xml.XMLFormat.OutputElement xml)
                throws XMLStreamException {
            CAP_ERROR_MESSAGE_XML.write(errorMessage, xml);
        }
    };

}

@@ -1344,32 +1344,96 @@
 onentException;%0A
+import org.mobicents.protocols.ss7.cap.api.errors.CAPErrorCode;%0A
 import org.mobic
@@ -1496,16 +1496,16 @@
 erless;%0A
-
 %0A/**%0A * 
@@ -3011,29 +3011,1792 @@
 %22 + 
-this.errorCode + %22%5D%22;
+capErrorCodeName() + %22%5D%22;%0A    %7D%0A%0A    private String capErrorCodeName() %7B%0A        if (errorCode == null)%0A            return %22N/A%22;%0A        switch (errorCode.intValue()) %7B%0A            case CAPErrorCode.canceled:%0A                return %22canceled%22;%0A            case CAPErrorCode.cancelFailed:%0A                return %22cancelFailed%22;%0A            case CAPErrorCode.eTCFailed:%0A                return %22eTCFailed%22;%0A            case CAPErrorCode.improperCallerResponse:%0A                return %22improperCallerResponse%22;%0A            case CAPErrorCode.missingCustomerRecord:%0A                return %22missingCustomerRecord%22;%0A            case CAPErrorCode.missingParameter:%0A                return %22missingParameter%22;%0A            case CAPErrorCode.parameterOutOfRange:%0A                return %22parameterOutOfRange%22;%0A            case CAPErrorCode.requestedInfoError:%0A                return %22requestedInfoError%22;%0A            case CAPErrorCode.systemFailure:%0A                return %22systemFailure%22;%0A            case CAPErrorCode.taskRefused:%0A                return %22taskRefused%22;%0A            case CAPErrorCode.unavailableResource:%0A                return %22unavailableResource%22;%0A            case CAPErrorCode.unexpectedComponentSequence:%0A                return %22unexpectedComponentSequence%22;%0A            case CAPErrorCode.unexpectedDataValue:%0A                return %22unexpectedDataValue%22;%0A            case CAPErrorCode.unexpectedParameter:%0A                return %22unexpectedParameter%22;%0A            case CAPErrorCode.unknownCSID:%0A                return %22unknownCSID%22;%0A            case CAPErrorCode.unknownLegID:%0A                return %22unknownLegID%22;%0A            case CAPErrorCode.unknownPDPID:%0A                return %22unknownPDPID%22;%0A            default:%0A                return errorCode.toString();%0A        %7D
 %0A   

Enhance logging in CAPErrorMessageParameterlessImpl