コード例 #1
0
ファイル: NAEACICImpl.java プロジェクト: nacerix/jss7
  public String getCarrierCode() {

    if (this.data == null || this.data.length == 0) return null;

    try {
      ByteArrayInputStream stm = new ByteArrayInputStream(this.data);
      stm.read();
      String address = TbcdString.decodeString(stm, this.data.length - 1);
      if (address.length() == 4
          && this.getNetworkIdentificationPlanValue()
              .equals(NetworkIdentificationPlanValue.threeDigitCarrierIdentification)) {
        return address.substring(0, 3);
      }
      return address;
    } catch (MAPParsingComponentException e) {
      return null;
    } catch (IOException e) {
      return null;
    }
  }
コード例 #2
0
ファイル: NAEACICImpl.java プロジェクト: nacerix/jss7
  private void setParameters(
      String carrierCode,
      NetworkIdentificationPlanValue networkIdentificationPlanValue,
      NetworkIdentificationTypeValue networkIdentificationTypeValue)
      throws MAPException {

    if (carrierCode == null
        || networkIdentificationPlanValue == null
        || networkIdentificationTypeValue == null)
      throw new MAPException(
          "Error when encoding "
              + _PrimitiveName
              + ": carrierCode, networkIdentificationPlanValue or networkIdentificationTypeValue is empty");

    if (!(carrierCode.length() == 3 || carrierCode.length() == 4))
      throw new MAPException(
          "Error when encoding " + _PrimitiveName + ": carrierCode lenght should be 3 or 4");

    ByteArrayOutputStream stm = new ByteArrayOutputStream();

    int octOne = 0;
    octOne = octOne | (networkIdentificationTypeValue.getCode() << 4);
    octOne = octOne | networkIdentificationPlanValue.getCode();

    stm.write(octOne);

    try {
      TbcdString.encodeString(stm, carrierCode);
    } catch (MAPException e) {
      throw new MAPException(e);
    }

    this.data = stm.toByteArray();

    if (carrierCode.length() == 3) {
      this.data[2] = (byte) (this.data[2] & THREE_OCTET_CARRIER_CODE_MASK);
    }
  }