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

    if (this.maxTransferredVolume == -1 && this.maxElapsedTime == -1
        || this.maxTransferredVolume != -1 && this.maxElapsedTime != -1) {
      throw new CAPException(
          "Error while decoding " + _PrimitiveName + ": One and only one choice must be selected");
    }

    try {
      if (this.maxTransferredVolume != -1) {
        asnOs.writeIntegerData(this.maxTransferredVolume);
      } else {
        asnOs.writeIntegerData(this.maxElapsedTime);
      }
    } catch (IOException e) {
      throw new CAPException(
          "IOException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
    }
  }
Esempio n. 2
0
  @Override
  public void encodeData(AsnOutputStream asnOs) throws CAPException {
    if (this.volumeIfNoTariffSwitch == null && this.volumeIfTariffSwitch == null
        || this.volumeIfNoTariffSwitch != null && this.volumeIfTariffSwitch != null) {
      throw new CAPException(
          "Error while decoding " + _PrimitiveName + ": One and only one choice must be selected");
    }

    try {
      if (this.volumeIfNoTariffSwitch != null) {
        asnOs.writeIntegerData(volumeIfNoTariffSwitch.longValue());
      } else {
        ((VolumeIfTariffSwitchImpl) this.volumeIfTariffSwitch).encodeData(asnOs);
      }
    } catch (IOException e) {
      throw new CAPException(
          "MAPException when encoding " + _PrimitiveName + ": " + e.getMessage(), e);
    }
  }