Esempio n. 1
0
 /**
  * Creates an ISOField associated with fldno within this ISOMsg
  *
  * @param fpath dot-separated field path (i.e. 63.2)
  * @param c component
  */
 public void set(String fpath, ISOComponent c) throws ISOException {
   StringTokenizer st = new StringTokenizer(fpath, ".");
   ISOMsg m = this;
   for (; ; ) {
     int fldno = Integer.parseInt(st.nextToken());
     if (st.hasMoreTokens()) {
       Object obj = m.getValue(fldno);
       if (obj instanceof ISOMsg) m = (ISOMsg) obj;
       else
       /*
        * we need to go deeper, however, if the value == null then
        * there is nothing to do (unset) at the lower levels, so break now and save some processing.
        */
       if (c == null) {
         break;
       } else {
         // We have a value to set, so adding a level to hold it is sensible.
         m.set(m = new ISOMsg(fldno));
       }
     } else {
       m.set(c);
       break;
     }
   }
 }
Esempio n. 2
0
 /**
  * Creates an ISOField associated with fldno within this ISOMsg
  *
  * @param fpath dot-separated field path (i.e. 63.2)
  * @param value binary field value
  */
 public void set(String fpath, byte[] value) throws ISOException {
   StringTokenizer st = new StringTokenizer(fpath, ".");
   ISOMsg m = this;
   for (; ; ) {
     int fldno = Integer.parseInt(st.nextToken());
     if (st.hasMoreTokens()) {
       Object obj = m.getValue(fldno);
       if (obj instanceof ISOMsg) m = (ISOMsg) obj;
       else m.set(m = new ISOMsg(fldno));
     } else {
       m.set(fldno, value);
       break;
     }
   }
 }
Esempio n. 3
0
 /**
  * Partially clone an ISOMsg
  *
  * @param fields int array of fields to go
  * @return new ISOMsg instance
  */
 public Object clone(int[] fields) {
   try {
     ISOMsg m = (ISOMsg) super.clone();
     m.fields = new TreeMap();
     for (int i = 0; i < fields.length; i++) {
       if (hasField(fields[i])) {
         try {
           m.set(getComponent(fields[i]));
         } catch (ISOException e) {
           // it should never happen
         }
       }
     }
     return m;
   } catch (CloneNotSupportedException e) {
     throw new InternalError();
   }
 }