public void load(TypedProperties properties, String key, Class<?> type, String value) {
    Matcher m = MAP_PATTERN.matcher(key);
    if (m.matches()) {
      String mainKey = m.group(1);
      TypedProperties subProperties = properties.get(mainKey, (TypedProperties) null);
      if (subProperties == null) {
        subProperties = new TypedProperties(properties, mainKey);
      }

      String subKey = m.group(2);
      if (!m.group(3).equals("")) {
        // FIXME, assumed it is {}{}
        load(subProperties, subKey + m.group(3), type, value);
      } else {
        PropertyConverter<?> converter = converters.get(type);
        if (converter == null) {
          System.err.println(
              "TypedProperties.load: No Converter defined for '" + type + "' of '" + subKey + "'");
        } else {
          try {
            converter.load(subProperties, subKey, type, value);
          } catch (Exception e) {
            System.err.println(
                "TypedProperties.load: Could not load property '"
                    + subKey
                    + "' with type '"
                    + type
                    + "'");
          }
        }
      }
    }
  }
Пример #2
0
 /**
  * Generates a custom name containing numbers and an underscore ex. 282818_00023. The name
  * contains current seconds and a random number component.
  *
  * @return custom name
  */
 public static String generateCustomName() {
   Random random = new Random();
   StringBuilder sb = new StringBuilder();
   sb.append(PropertyConverter.getCurrentTimeSeconds());
   sb.append('_');
   int i = random.nextInt(99999);
   if (i < 10) {
     sb.append("0000");
   } else if (i < 100) {
     sb.append("000");
   } else if (i < 1000) {
     sb.append("00");
   } else if (i < 10000) {
     sb.append('0');
   }
   sb.append(i);
   return sb.toString();
 }
Пример #3
0
 public boolean isValid(Object value) {
   return validator.isValid(converter.parse((FIELD_DATA_TYPE) value));
 }
Пример #4
0
 public void validate(Object value) throws InvalidValueException {
   validator.validate(converter.parse((FIELD_DATA_TYPE) value));
 }