예제 #1
0
 /**
  * @param cfg
  *     <ul>
  *       <li>sequencer - a sequencer used to store counters
  *       <li>unset - space delimited list of fields to be unset
  *       <li>valid - space delimited list of valid fields
  *       <li>comma delimited list of fields to be unset when applying filter
  *       <li>xzy - property named "xyz"
  *     </ul>
  */
 public void setConfiguration(Configuration cfg) throws ConfigurationException {
   this.cfg = cfg;
   try {
     String seqName = cfg.get("sequencer", null);
     unsetFields = ISOUtil.toIntArray(cfg.get("unset", ""));
     validFields = ISOUtil.toIntArray(cfg.get("valid", ""));
     if (seqName != null) {
       seq = (Sequencer) NameRegistrar.get("sequencer." + cfg.get("sequencer"));
     } else if (seq == null) {
       seq = new VolatileSequencer();
     }
   } catch (NameRegistrar.NotFoundException e) {
     throw new ConfigurationException(e);
   }
 }
예제 #2
0
 private void applyProps(ISOMsg m) throws ISOException {
   int maxField = m.getMaxField();
   for (int i = 0; i <= maxField; i++) {
     Object o = null;
     if (m.hasField(i)) o = m.getValue(i);
     if (o instanceof String) {
       String value = (String) o;
       if (value.length() == 0) continue;
       if (value.equalsIgnoreCase("$date"))
         m.set(new ISOField(i, ISODate.getDateTime(new Date())));
       else if ((value.toLowerCase().startsWith("$date")) && value.contains("GMT")) {
         String zoneID = value.substring(value.indexOf("GMT"));
         m.set(new ISOField(i, ISODate.getDateTime(new Date(), TimeZone.getTimeZone(zoneID))));
       } else if (value.charAt(0) == '#')
         m.set(new ISOField(i, ISOUtil.zeropad(Integer.toString(seq.get(value.substring(1))), 6)));
       else if (value.charAt(0) == '$') {
         String p = cfg.get(value.substring(1), null);
         if (p != null) m.set(new ISOField(i, p));
       }
     }
   }
 }