Esempio n. 1
0
  /**
   * Initializing object from a BER encoding. This method is for internal use only. You should use
   * the constructor that takes a BEREncoding.
   *
   * @param ber the BER to decode.
   * @param check_tag if the tag should be checked.
   * @throws ASN1Exception if the BER encoding is bad.
   */
  public void ber_decode(BEREncoding ber, boolean check_tag) throws ASN1Exception {
    // Costs_otherCharges should be encoded by a constructed BER

    BERConstructed ber_cons;
    try {
      ber_cons = (BERConstructed) ber;
    } catch (ClassCastException e) {
      throw new ASN1EncodingException("Zebulun Costs_otherCharges: bad BER form\n");
    }

    // Prepare to decode the components

    int num_parts = ber_cons.number_components();
    int part = 0;
    BEREncoding p;

    // Decoding: forWhat [1] IMPLICIT HumanString

    if (num_parts <= part) {
      // End of record, but still more elements to get
      throw new ASN1Exception("Zebulun Costs_otherCharges: incomplete");
    }
    p = ber_cons.elementAt(part);

    if (p.tag_get() != 1 || p.tag_type_get() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
      throw new ASN1EncodingException("Zebulun Costs_otherCharges: bad tag in s_forWhat\n");
    }

    s_forWhat = new HumanString(p, false);
    part++;

    // Decoding: charge [2] IMPLICIT Charge

    if (num_parts <= part) {
      // End of record, but still more elements to get
      throw new ASN1Exception("Zebulun Costs_otherCharges: incomplete");
    }
    p = ber_cons.elementAt(part);

    if (p.tag_get() != 2 || p.tag_type_get() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
      throw new ASN1EncodingException("Zebulun Costs_otherCharges: bad tag in s_charge\n");
    }

    s_charge = new Charge(p, false);
    part++;

    // Should not be any more parts

    if (part < num_parts) {
      throw new ASN1Exception(
          "Zebulun Costs_otherCharges: bad BER: extra data "
              + part
              + "/"
              + num_parts
              + " processed");
    }
  }
Esempio n. 2
0
  /**
   * Initializing object from a BER encoding. This method is for internal use only. You should use
   * the constructor that takes a BEREncoding.
   *
   * @param ber the BER to decode.
   * @param check_tag if the tag should be checked.
   * @throws ASN1Exception if the BER encoding is bad.
   */
  public void ber_decode(BEREncoding ber, boolean check_tag) throws ASN1Exception {
    BERConstructed tagwrapper;

    // Null out all choices

    c_generic = null;
    c_datbaseSpecific = null;

    // Try choice generic
    if (ber.tag_get() == 1 && ber.tag_type_get() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
      try {
        tagwrapper = (BERConstructed) ber;
      } catch (ClassCastException e) {
        throw new ASN1EncodingException("Zebulun SortElement: bad BER form\n");
      }
      if (tagwrapper.number_components() != 1) {
        throw new ASN1EncodingException("Zebulun SortElement: bad BER form\n");
      }
      c_generic = new SortKey(tagwrapper.elementAt(0), true);
      return;
    }

    // Try choice datbaseSpecific
    if (ber.tag_get() == 2 && ber.tag_type_get() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
      BEREncoding ber_data;
      ber_data = ber;
      BERConstructed ber_cons;
      try {
        ber_cons = (BERConstructed) ber_data;
      } catch (ClassCastException e) {
        throw new ASN1EncodingException("Zebulun SortElement: bad BER form\n");
      }

      int num_parts = ber_cons.number_components();
      int p;

      c_datbaseSpecific = new SortElement_datbaseSpecific[num_parts];

      for (p = 0; p < num_parts; p++) {
        c_datbaseSpecific[p] = new SortElement_datbaseSpecific(ber_cons.elementAt(p), true);
      }
      return;
    }

    throw new ASN1Exception("Zebulun SortElement: bad BER encoding: choice not matched");
  }
Esempio n. 3
0
  /**
   * Initializing object from a BER encoding. This method is for internal use only. You should use
   * the constructor that takes a BEREncoding.
   *
   * @param ber the BER to decode.
   * @param check_tag if the tag should be checked.
   * @throws ASN1Exception if the BER encoding is bad.
   */
  public void ber_decode(BEREncoding ber, boolean check_tag) throws ASN1Exception {
    // UnitType should be encoded by a constructed BER

    BERConstructed ber_cons;
    try {
      ber_cons = (BERConstructed) ber;
    } catch (ClassCastException e) {
      throw new ASN1EncodingException("Zebulun UnitType: bad BER form\n");
    }

    // Prepare to decode the components

    int num_parts = ber_cons.number_components();
    int part = 0;
    BEREncoding p;
    BERConstructed tagged;

    // Decoding: name [0] IMPLICIT InternationalString OPTIONAL

    if (num_parts <= part) {
      // End of record, but still more elements to get
      throw new ASN1Exception("Zebulun UnitType: incomplete");
    }
    p = ber_cons.elementAt(part);

    if (p.tag_get() == 0 && p.tag_type_get() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
      s_name = new InternationalString(p, false);
      part++;
    }

    // Decoding: description [1] IMPLICIT HumanString OPTIONAL

    if (num_parts <= part) {
      // End of record, but still more elements to get
      throw new ASN1Exception("Zebulun UnitType: incomplete");
    }
    p = ber_cons.elementAt(part);

    if (p.tag_get() == 1 && p.tag_type_get() == BEREncoding.CONTEXT_SPECIFIC_TAG) {
      s_description = new HumanString(p, false);
      part++;
    }

    // Decoding: unitType [2] EXPLICIT StringOrNumeric

    if (num_parts <= part) {
      // End of record, but still more elements to get
      throw new ASN1Exception("Zebulun UnitType: incomplete");
    }
    p = ber_cons.elementAt(part);

    if (p.tag_get() != 2 || p.tag_type_get() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
      throw new ASN1EncodingException("Zebulun UnitType: bad tag in s_unitType\n");
    }

    try {
      tagged = (BERConstructed) p;
    } catch (ClassCastException e) {
      throw new ASN1EncodingException("Zebulun UnitType: bad BER encoding: s_unitType tag bad\n");
    }
    if (tagged.number_components() != 1) {
      throw new ASN1EncodingException("Zebulun UnitType: bad BER encoding: s_unitType tag bad\n");
    }

    s_unitType = new StringOrNumeric(tagged.elementAt(0), true);
    part++;

    // Decoding: units [3] IMPLICIT SEQUENCE OF Units

    if (num_parts <= part) {
      // End of record, but still more elements to get
      throw new ASN1Exception("Zebulun UnitType: incomplete");
    }
    p = ber_cons.elementAt(part);

    if (p.tag_get() != 3 || p.tag_type_get() != BEREncoding.CONTEXT_SPECIFIC_TAG) {
      throw new ASN1EncodingException("Zebulun UnitType: bad tag in s_units\n");
    }

    try {
      BERConstructed cons = (BERConstructed) p;
      int parts = cons.number_components();
      s_units = new Units[parts];
      int n;
      for (n = 0; n < parts; n++) {
        s_units[n] = new Units(cons.elementAt(n), true);
      }
    } catch (ClassCastException e) {
      throw new ASN1EncodingException("Bad BER");
    }
    part++;

    // Should not be any more parts

    if (part < num_parts) {
      throw new ASN1Exception(
          "Zebulun UnitType: bad BER: extra data " + part + "/" + num_parts + " processed");
    }
  }