示例#1
0
 /**
  * Unset a field referenced by a fpath if it exists, otherwise ignore.
  *
  * @param fpath dot-separated field path (i.e. 63.2)
  * @throws ISOException
  */
 public void unset(String fpath) throws ISOException {
   StringTokenizer st = new StringTokenizer(fpath, ".");
   ISOMsg m = this;
   ISOMsg lastm = m;
   int fldno = -1;
   int lastfldno;
   for (; ; ) {
     lastfldno = fldno;
     fldno = Integer.parseInt(st.nextToken());
     if (st.hasMoreTokens()) {
       Object obj = m.getValue(fldno);
       if (obj instanceof ISOMsg) {
         lastm = m;
         m = (ISOMsg) obj;
       } else {
         // No real way of unset further subfield, exit.  Perhaps should be ISOException?
         break;
       }
     } else {
       m.unset(fldno);
       if (m.hasFields() == false && (lastfldno != -1)) {
         lastm.unset(lastfldno);
       }
       break;
     }
   }
 }