Exemple #1
0
  public static byte[] makeBytes() throws Exception {

    setLenTotal();

    byte[] bytes = new byte[lenTotal];

    if (!flag) {
      for (int i = 0; i < lenTotal; i++) {
        bytes[i] = (byte) ' ';
      }
    }

    if (flag) {
      for (PacketHeader fld : PacketHeader.values()) {
        fld.setVal(bytes, fld.getDefVal());
      }
    }

    if (flag) {
      TR_LEN.setVal(bytes, String.valueOf(lenTotal));
      TR_CODE.setVal(bytes, "");
      TR_DATE.setVal(bytes, new SimpleDateFormat("yyyyMMdd", Locale.KOREA).format(new Date()));
      TR_TIME.setVal(bytes, new SimpleDateFormat("HHmmss", Locale.KOREA).format(new Date()));
      TR_USER.setVal(bytes, "QWERT12345");
      TR_PASS.setVal(bytes, "1Q2WER4RKD");
      KEY_CODE.setVal(bytes, "FK39SXK3M3");
      RET_CODE.setVal(bytes, "");
      DATA_LEN.setVal(bytes, String.valueOf(0));
      FILLER.setVal(bytes, "");
    }

    return bytes;
  }
Exemple #2
0
  public static void print() throws Exception {

    if (flag) {
      String name = new Object() {}.getClass().getEnclosingClass().getName();

      int len = 0;
      int off = 0;
      for (PacketHeader fld : PacketHeader.values()) {
        len = fld.getLen();

        if (flag)
          log.debug(
              String.format(
                  "[%s] [%s] [%3d:%3d] [%3d:%3d] [%20s] [%s] [%s]",
                  name,
                  fld.getType(),
                  off,
                  fld.getOff(),
                  len,
                  fld.getLen(),
                  fld.getName(),
                  fld.getDesc(),
                  fld.getDefVal()));

        off += fld.getLen();
      }

      if (flag) log.debug("Total Length = " + off);
    }
  }
Exemple #3
0
  private static int setLenTotal() throws Exception {

    if (lenTotal < 0) {

      int off = 0;

      for (PacketHeader fld : PacketHeader.values()) {
        off += fld.getLen();
      }

      lenTotal = off;
    }

    return lenTotal;
  }
Exemple #4
0
  private static void test01(String[] args) throws Exception {

    if (flag) {
      /*
       * USAGE 1
       */

      PacketHeader.print();
    }
  }