/*
(non-Javadoc)

@see org.restcomm.protocols.ss7.map.primitives.MAPAsnPrimitive#encodeData (org.mobicents.protocols.asn.AsnOutputStream)
513644
public void encodeData(AsnOutputStream asnOs) throws MAPException {

        if (this.ssCode == null)
            throw new MAPException("Error while encoding " + _PrimitiveName + ": ssCode required.");

        if (this.ssStatus == null)
            throw new MAPException("Error while encoding " + _PrimitiveName + ": ssStatus required.");

        if (this.basicServiceGroupList != null
                && (this.basicServiceGroupList.size() < 1 || this.basicServiceGroupList.size() > 32)) {
            throw new MAPException("Error while encoding " + _PrimitiveName
                    + ": Parameter basicServiceGroupList size must be from 1 to 32, found: "
                    + this.basicServiceGroupList.size());
        }

        try {

            ((SSCodeImpl) this.ssCode).encodeAll(asnOs);

            ((ExtSSStatusImpl) this.ssStatus).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _TAG_ss_Status);

            if (this.ssSubscriptionOption != null) {
                ((SSSubscriptionOptionImpl) this.ssSubscriptionOption).encodeAll(asnOs);
            }

            if (this.basicServiceGroupList != null) {
                asnOs.writeTag(Tag.CLASS_UNIVERSAL, false, Tag.SEQUENCE);
                int pos = asnOs.StartContentDefiniteLength();
                for (ExtBasicServiceCode serviceItem : this.basicServiceGroupList) {
                    ((ExtBasicServiceCodeImpl) serviceItem).encodeAll(asnOs);
                }
                asnOs.FinalizeContent(pos);
            }

            if (this.extensionContainer != null)
                ((MAPExtensionContainerImpl) this.extensionContainer).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                        _TAG_extensionContainer);
        } catch (AsnException e) {
            throw new MAPException("AsnException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
        }
    }
163640
public void encodeData(AsnOutputStream asnOs) throws MAPException {

        if (this.cugSubscriptionList == null)
            throw new MAPException("Error while encoding " + _PrimitiveName + ": cugSubscriptionList required.");
        if (this.cugSubscriptionList.size() > 10) {
            throw new MAPException("Error while encoding " + _PrimitiveName
                    + ": Parameter cugSubscriptionList size must be from 0 to 10, found: " + this.cugSubscriptionList.size());
        }

        if (this.cugFeatureList != null) {
            if (this.cugFeatureList.size() < 1 || this.cugFeatureList.size() > 32) {
                throw new MAPException("Error while encoding " + _PrimitiveName
                        + ": Parameter cugFeatureList size must be from 1 to 32, found: " + this.cugFeatureList.size());
            }
        }

        try {

            asnOs.writeTag(Tag.CLASS_UNIVERSAL, false, Tag.SEQUENCE);
            int posa = asnOs.StartContentDefiniteLength();
            for (CUGSubscription subscriptionItem : this.cugSubscriptionList) {
                ((CUGSubscriptionImpl) subscriptionItem).encodeAll(asnOs);
            }
            asnOs.FinalizeContent(posa);

            if (this.cugFeatureList != null) {
                asnOs.writeTag(Tag.CLASS_UNIVERSAL, false, Tag.SEQUENCE);
                int posb = asnOs.StartContentDefiniteLength();
                for (CUGFeature featureItem : this.cugFeatureList) {
                    ((CUGFeatureImpl) featureItem).encodeAll(asnOs);
                }
                asnOs.FinalizeContent(posb);
            }

            if (this.extensionContainer != null)
                ((MAPExtensionContainerImpl) this.extensionContainer).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                        _TAG_extensionContainer);
        } catch (AsnException e) {
            throw new MAPException("AsnException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
        }
    }
494778
public void encodeData(AsnOutputStream asnOs) throws MAPException {

        int cnt = 0;
        if (this.forwardingInfo != null)
            cnt++;
        if (this.callBarringInfo != null)
            cnt++;
        if (this.cugInfo != null)
            cnt++;
        if (this.ssData != null)
            cnt++;
        if (this.emlppInfo != null)
            cnt++;

        if (cnt != 1)
            throw new MAPException("Error while encoding " + _PrimitiveName + ": one and only one choice is required.");

        if (this.forwardingInfo != null) {
            ((ExtForwInfoImpl) this.forwardingInfo).encodeData(asnOs);
            return;
        }

        if (this.callBarringInfo != null) {
            ((ExtCallBarInfoImpl) this.callBarringInfo).encodeData(asnOs);
            return;
        }

        if (this.cugInfo != null) {
            ((CUGInfoImpl) this.cugInfo).encodeData(asnOs);
            return;
        }

        if (this.ssData != null) {
            ((ExtSSDataImpl) this.ssData).encodeData(asnOs);
            return;
        }

        if (this.emlppInfo != null) {
            ((EMLPPInfoImpl) this.emlppInfo).encodeData(asnOs);
            return;
        }
    }
673474
@Benchmark
  @BenchmarkMode(Mode.AverageTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public byte[] encodeSpanBinary(Data data) {
    return data.propagation.getBinaryFormat().toByteArray(data.spanToEncode.getContext());
  }
720935
public static void sendPostData(HttpURLConnection conn, String encodedData) throws IOException {

        StreamManager sm = new StreamManager();

        try {

            conn.setDoOutput(true);
            conn.setRequestMethod("POST");
            if (conn.getRequestProperty("Content-Type") == null) {
                conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            }
            if (encodedData != null) {
                if (conn.getRequestProperty("Content-Length") == null) {
                    conn.setRequestProperty("Content-Length", String.valueOf(encodedData.getBytes("UTF-8").length));
                }
                DataOutputStream out = new DataOutputStream(sm.handle(conn.getOutputStream()));
                out.write(encodedData.getBytes());
                out.close();
            }
        } finally {
            sm.closeAll();
        }
    }
202542
public static byte[] encode(final byte[] data) throws IOException {
        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        DeflaterOutputStream deflateOut = null;
        try {
            deflateOut = new DeflaterOutputStream(byteOut);
            deflateOut.write(data);
            deflateOut.close();
            byteOut.close();
            return byteOut.toByteArray();
        } finally {
            deflateOut.close();
            byteOut.close();
        }
    }
341409
@Override
    public byte[] encodeAsBytes(long time, int sequence) {
        byte[] buffer = new byte[16];
        buffer[0] = (byte) (time >>> 56);
        buffer[1] = (byte) (time >>> 48);
        buffer[2] = (byte) (time >>> 40);
        buffer[3] = (byte) (time >>> 32);
        buffer[4] = (byte) (time >>> 24);
        buffer[5] = (byte) (time >>> 16);
        buffer[6] = (byte) (time >>> 8);
        buffer[7] = (byte) (time);

        long rest = shiftedMachineId | (0x0000FFFF & sequence);
        buffer[8] = (byte) (rest >>> 56);
        buffer[9] = (byte) (rest >>> 48);
        buffer[10] = (byte) (rest >>> 40);
        buffer[11] = (byte) (rest >>> 32);
        buffer[12] = (byte) (rest >>> 24);
        buffer[13] = (byte) (rest >>> 16);
        buffer[14] = (byte) (rest >>> 8);
        buffer[15] = (byte) (rest);

        return buffer;
    }
841447
public void encodeData(AsnOutputStream asnOs) throws MAPException {
        if (this.responseTimeCategory == null) {
            throw new MAPException("Error while encoding " + _PrimitiveName
                    + " the mandatory parameter responseTimeCategory is not defined");
        }
        try {
            asnOs.writeInteger(Tag.CLASS_UNIVERSAL, Tag.ENUMERATED, this.responseTimeCategory.getCategory());
        } catch (IOException e) {
            throw new MAPException("IOException when encoding responseTimeCategory: ", e);
        } catch (AsnException e) {
            throw new MAPException("AsnException when encoding responseTimeCategory: ", e);
        }
    }
953874
public void encodeData(AsnOutputStream asnOs) throws MAPException {

        if (this.ssStatus == null)
            throw new MAPException("Error while encoding " + _PrimitiveName + ": ssStatus required.");

        try {

            if (this.basicService != null)
                ((ExtBasicServiceCodeImpl) this.basicService).encodeAll(asnOs);

            ((ExtSSStatusImpl) this.ssStatus).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _TAG_ss_Status);

            if (this.forwardedToNumber != null)
                ((ISDNAddressStringImpl) this.forwardedToNumber).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                        _TAG_forwardedToNumber);

            if (this.forwardedToSubaddress != null)
                ((ISDNSubaddressStringImpl) this.forwardedToSubaddress).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                        _TAG_forwardedToSubaddress);

            if (this.forwardingOptions != null)
                ((ExtForwOptionsImpl) this.forwardingOptions).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                        _TAG_forwardingOptions);

            if (this.noReplyConditionTime != null)
                asnOs.writeInteger(Tag.CLASS_CONTEXT_SPECIFIC, _TAG_noReplyConditionTime, this.noReplyConditionTime);

            if (this.extensionContainer != null)
                ((MAPExtensionContainerImpl) this.extensionContainer).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                        _TAG_extensionContainer);

            if (this.longForwardedToNumber != null)
                ((FTNAddressStringImpl) this.longForwardedToNumber).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                        _TAG_longForwardedToNumber);
        } catch (IOException e) {
            throw new MAPException("IOException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
        } catch (AsnException e) {
            throw new MAPException("AsnException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
        }
    }
634835
public void encodeData(AsnOutputStream asnOs) throws MAPException {

        if (this.cliRestrictionOption == null && this.overrideCategory == null)
            throw new MAPException("Error while encoding " + _PrimitiveName
                    + ": missing cliRestrictionOption and overrideCategory.");

        if (this.cliRestrictionOption != null && this.overrideCategory != null)
            throw new MAPException("Error while encoding " + _PrimitiveName
                    + ": both cliRestrictionOption and overrideCategory are defined.");

        try {

            if (this.cliRestrictionOption != null) {
                asnOs.writeIntegerData(this.cliRestrictionOption.getCode());
            } else {
                asnOs.writeIntegerData(this.overrideCategory.getCode());
            }
        } catch (IOException e) {
            throw new MAPException("IOException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
        }
    }
722468
public void encodeData(AsnOutputStream asnOs) throws MAPException {
        if (this.locationEstimate == null) {
            throw new MAPException("Error while encoding " + _PrimitiveName
                    + " the mandatory parameter locationEstimate is not defined");
        }

        ((ExtGeographicalInformationImpl) this.locationEstimate).encodeAll(asnOs);

        if (this.ageOfLocationEstimate != null) {
            try {
                asnOs.writeInteger(Tag.CLASS_CONTEXT_SPECIFIC, _TAG_AGE_OF_LOCATION_ESTIMATE, this.ageOfLocationEstimate);
            } catch (IOException e) {
                throw new MAPException("IOException while encoding parameter " + _PrimitiveName + " .ageOfLocationEstimate", e);
            } catch (AsnException e) {
                throw new MAPException("AsnException while encoding parameter " + _PrimitiveName + " .ageOfLocationEstimate", e);
            }
        }

        if (this.extensionContainer != null) {
            ((MAPExtensionContainerImpl) this.extensionContainer).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                    _TAG_EXTENSIONCONTAINER);
        }

        if (this.additionalLocationEstimate != null) {
            ((AddGeographicalInformationImpl) this.additionalLocationEstimate).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                    _TAG_ADD_LOCATION_ESTIMATE);
        }

        if (this.deferredMTLRResponseIndicator) {
            try {
                asnOs.writeNull(Tag.CLASS_CONTEXT_SPECIFIC, _TAG_DEFERRED_MT_LR_RESPONSE_IND);
            } catch (IOException e) {
                throw new MAPException("IOException while encoding parameter " + _PrimitiveName
                        + " .deferredMTLRResponseIndicator", e);
            } catch (AsnException e) {
                throw new MAPException("AsnException while encoding parameter " + _PrimitiveName
                        + " .deferredMTLRResponseIndicator", e);
            }
        }

        if (this.geranPositioningData != null) {
            ((PositioningDataInformationImpl) this.geranPositioningData).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                    _TAG_GERAN_POSITIONING_DATA);
        }

        if (this.utranPositioningData != null) {
            ((UtranPositioningDataInfoImpl) this.utranPositioningData).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                    _TAG_UTRAN_POSITIONING_DATA);
        }

        if (this.cellGlobalIdOrServiceAreaIdOrLAI != null) {
            try {
                asnOs.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _TAG_CELL_ID_OR_SAI);
                int pos = asnOs.StartContentDefiniteLength();
                ((CellGlobalIdOrServiceAreaIdOrLAIImpl) this.cellGlobalIdOrServiceAreaIdOrLAI).encodeAll(asnOs);
                asnOs.FinalizeContent(pos);
            } catch (AsnException e) {
                throw new MAPException("AsnException while encoding parameter " + _PrimitiveName
                        + " .cellGlobalIdOrServiceAreaIdOrLAI", e);
            }
        }

        if (this.saiPresent) {
            try {
                asnOs.writeNull(Tag.CLASS_CONTEXT_SPECIFIC, _TAG_SAI_PRESENT);
            } catch (IOException e) {
                throw new MAPException("IOException while encoding parameter " + _PrimitiveName + " .saiPresent", e);
            } catch (AsnException e) {
                throw new MAPException("AsnException while encoding parameter " + _PrimitiveName + " saiPresent", e);
            }
        }

        if (this.accuracyFulfilmentIndicator != null) {
            try {
                asnOs.writeInteger(Tag.CLASS_CONTEXT_SPECIFIC, _TAG_ACCURACY_FULFILMENT_INDICATOR,
                        this.accuracyFulfilmentIndicator.getIndicator());
            } catch (IOException e) {
                throw new MAPException("IOException while encoding parameter " + _PrimitiveName
                        + " .accuracyFulfilmentIndicator", e);
            } catch (AsnException e) {
                throw new MAPException("AsnException while encoding parameter " + _PrimitiveName
                        + " .accuracyFulfilmentIndicator", e);
            }
        }

        if (this.velocityEstimate != null) {
            ((VelocityEstimateImpl) this.velocityEstimate).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _TAG_velocityEstimate);
        }

        if (this.moLrShortCircuitIndicator) {
            try {
                asnOs.writeNull(Tag.CLASS_CONTEXT_SPECIFIC, _TAG_mo_lrShortCircuitIndicator);
            } catch (IOException e) {
                throw new MAPException(
                        "IOException while encoding parameter " + _PrimitiveName + " .moLrShortCircuitIndicator", e);
            } catch (AsnException e) {
                throw new MAPException(
                        "AsnException while encoding parameter " + _PrimitiveName + " moLrShortCircuitIndicator", e);
            }
        }

        if (this.geranGANSSpositioningData != null) {
            ((GeranGANSSpositioningDataImpl) this.geranGANSSpositioningData).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                    _TAG_geranGANSSpositioningData);
        }

        if (this.utranGANSSpositioningData != null) {
            ((UtranGANSSpositioningDataImpl) this.utranGANSSpositioningData).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                    _TAG_utranGANSSpositioningData);
        }

        if (this.targetServingNodeForHandover != null) {
            try {
                asnOs.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _TAG_targetServingNodeForHandover);
                int pos = asnOs.StartContentDefiniteLength();
                ((ServingNodeAddressImpl) this.targetServingNodeForHandover).encodeAll(asnOs);
                asnOs.FinalizeContent(pos);
            } catch (AsnException e) {
                throw new MAPException("AsnException while encoding parameter " + _PrimitiveName
                        + " .targetServingNodeForHandover", e);
            }
        }
    }
726771
public void encodeData(AsnOutputStream asnOs) throws MAPException {
        try {

            if (this.locationInformation != null)
                ((LocationInformationImpl) this.locationInformation).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _ID_locationInformation);

            if (this.subscriberState != null) {
                asnOs.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _ID_subscriberState);
                int pos = asnOs.StartContentDefiniteLength();
                ((SubscriberStateImpl) this.subscriberState).encodeAll(asnOs);
                asnOs.FinalizeContent(pos);
            }

            if (this.extensionContainer != null)
                ((MAPExtensionContainerImpl) this.extensionContainer).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _ID_extensionContainer);

            if (this.locationInformationGPRS != null)
                ((LocationInformationGPRSImpl) this.locationInformationGPRS).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                        _ID_locationInformationGPRS);

            if (this.psSubscriberState != null) {
                asnOs.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _ID_psSubscriberState);
                int pos = asnOs.StartContentDefiniteLength();
                ((PSSubscriberStateImpl) this.psSubscriberState).encodeAll(asnOs);
                asnOs.FinalizeContent(pos);
            }

            if (this.imei != null)
                ((IMEIImpl) this.imei).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _ID_imei);

            if (this.msClassmark2 != null)
                ((MSClassmark2Impl) this.msClassmark2).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _ID_msclassmark2);

            if (this.gprsMSClass != null)
                ((GPRSMSClassImpl) this.gprsMSClass).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _ID_gprsMSClass);

            if (this.mnpInfoRes != null)
                ((MNPInfoResImpl) this.mnpInfoRes).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _ID_mnpInfoRes);

        } catch (AsnException e) {
            throw new MAPException("AsnException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
        }
    }
92423
public static String encode(byte[] pData) {
        int offset = 0;
        int len;
        StringBuilder buf = new StringBuilder();

        while ((pData.length - offset) > 0) {
            byte a, b, c;
            if ((pData.length - offset) > 2) {
                len = 3;
            }
            else {
                len = pData.length - offset;
            }

            switch (len) {
                case 1:
                    a = pData[offset];
                    b = 0;
                    buf.append(PEM_ARRAY[(a >>> 2) & 0x3F]);
                    buf.append(PEM_ARRAY[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]);
                    buf.append('=');
                    buf.append('=');
                    offset++;
                    break;
                case 2:
                    a = pData[offset];
                    b = pData[offset + 1];
                    c = 0;
                    buf.append(PEM_ARRAY[(a >>> 2) & 0x3F]);
                    buf.append(PEM_ARRAY[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]);
                    buf.append(PEM_ARRAY[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]);
                    buf.append('=');
                    offset += offset + 2; // ???
                    break;
                default:
                    a = pData[offset];
                    b = pData[offset + 1];
                    c = pData[offset + 2];
                    buf.append(PEM_ARRAY[(a >>> 2) & 0x3F]);
                    buf.append(PEM_ARRAY[((a << 4) & 0x30) + ((b >>> 4) & 0xf)]);
                    buf.append(PEM_ARRAY[((b << 2) & 0x3c) + ((c >>> 6) & 0x3)]);
                    buf.append(PEM_ARRAY[c & 0x3F]);
                    offset = offset + 3;
                    break;
            }

        }
        return buf.toString();
    }
787755
@Override
	public ByteArray encodeAsByteArray() throws IOException {
		final int size = messages.size();
		if(size == 0) return ByteArray.EMPTY_BYTE_ARRAY;

		AoByteArrayOutputStream bout = new AoByteArrayOutputStream();
		try {
			try (DataOutputStream out = new DataOutputStream(bout)) {
				out.writeInt(size);
				int count = 0;
				for(Message message : messages) {
					count++;
					ByteArray byteArray = message.encodeAsByteArray();
					final int capacity = byteArray.size;
					out.writeByte(message.getMessageType().getTypeByte());
					out.writeInt(capacity);
					out.write(byteArray.array, 0, capacity);
				}
				if(count != size) throw new ConcurrentModificationException();
			}
		} finally {
			bout.close();
		}
		return new ByteArray(bout.getInternalByteArray(), bout.size());
	}
1153016
public void encodeData(AsnOutputStream asnOs) throws MAPException {
        if (this.targetMS == null) {
            throw new MAPException("Encoding of " + _PrimitiveName
                    + " failed. Manadatory parameter targetMS [0] SubscriberIdentity is not set");
        }

        if (this.lcsLocationInfo == null) {
            throw new MAPException("Encoding of " + _PrimitiveName
                    + " failed. Manadatory parameter lcsLocationInfo [1] LCSLocationInfo is not set");
        }

        try {
            asnOs.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _TAG_TARGET_MS);
            int pos = asnOs.StartContentDefiniteLength();
            ((SubscriberIdentityImpl) this.targetMS).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                    ((SubscriberIdentityImpl) this.targetMS).getTag());
            asnOs.FinalizeContent(pos);
        } catch (AsnException e) {
            throw new MAPException("AsnException while encoding parameter " + _PrimitiveName
                    + ".targetMS [0] SubscriberIdentity");
        }

        ((LCSLocationInfoImpl) this.lcsLocationInfo).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _TAG_LCS_LOCATION_INFO);

        if (this.extensionContainer != null) {
            // extensionContainer [2] ExtensionContainer OPTIONAL,
            ((MAPExtensionContainerImpl) this.extensionContainer).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                    _TAG_EXTENSION_CONTAINER);
        }

        if (this.vgmlcAddress != null) {
            // v-gmlc-Address [3] GSN-Address OPTIONAL,
            ((GSNAddressImpl) this.vgmlcAddress).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _TAG_V_GMLC_ADDRESS);
        }

        if (this.hGmlcAddress != null) {
            // h-gmlc-Address [4] GSN-Address OPTIONAL,
            ((GSNAddressImpl) this.hGmlcAddress).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _TAG_H_GMLC_ADDRESS);
        }

        if (this.pprAddress != null) {
            // ppr-Address [5] GSN-Address OPTIONAL,
            ((GSNAddressImpl) this.pprAddress).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, _TAG_PPR_ADDRESS);
        }

        if (this.additionalVGmlcAddress != null) {
            // additional-v-gmlc-Address [6] GSN-Address OPTIONAL,
            ((GSNAddressImpl) this.additionalVGmlcAddress).encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC,
                    _TAG_ADDITIONAL_V_GMLC_ADDRESS);
        }
    }
857051
public void encodeData(AsnOutputStream asnOs) throws MAPException {

        if (this.ssCode == null)
            throw new MAPException("Error while encoding " + _PrimitiveName + ": ssCode required.");

        if (this.callBarringFeatureList == null)
            throw new MAPException("Error while encoding " + _PrimitiveName + ": callBarringFeatureList required.");

        if (this.callBarringFeatureList.size() < 1 || this.callBarringFeatureList.size() > 32) {
            throw new MAPException("Error while encoding " + _PrimitiveName
                    + ": Parameter callBarringFeatureList size must be from 1 to 32, found: "
                    + this.callBarringFeatureList.size());
        }

        try {

            ((SSCodeImpl) this.ssCode).encodeAll(asnOs);

            asnOs.writeTag(Tag.CLASS_UNIVERSAL, false, Tag.SEQUENCE);
            int pos = asnOs.StartContentDefiniteLength();
            for (ExtCallBarringFeature featureItem : this.callBarringFeatureList) {
                ((ExtCallBarringFeatureImpl) featureItem).encodeAll(asnOs);
            }
            asnOs.FinalizeContent(pos);

            if (this.extensionContainer != null)
                ((MAPExtensionContainerImpl) this.extensionContainer).encodeAll(asnOs);
        } catch (AsnException e) {
            throw new MAPException("AsnException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
        }
    }
818701
function encodeData (data) {
    // json encode data
    data = jsonStableStringify(data)
    // compress if compression in use
    if (this.compression) {
        data = snappy.compressSync(data).toString('base64')
    }
    // return encoded data
    return data
}