예제 #1
0
 private static Subtype checkSubtype(Type type, String subtypeName, String valueName)
     throws Exception {
   Subtype subtype = FieldValueDefinition.getEnum(Subtype.class, subtypeName);
   if (null == subtype) {
     throw new Exception("Subtype \"" + subtypeName + "\" not supported");
   }
   if (!type.isValidSubtype(subtype)) {
     throw new Exception(
         "Subtype \"" + subtypeName + "\" not supported " + "for type " + type.toString());
   }
   return subtype;
 }
예제 #2
0
  private static void checkProperty(String typeName, String subtypeName, String valueName)
      throws Exception {
    Type type = FieldValueDefinition.getEnum(Type.class, typeName);
    if (null == type) {
      throw new Exception("Type \"" + typeName + "\" not supported");
    }

    switch (type) {
      case TEXT:
        checkString(subtypeName, valueName);
        break;
      case NUMERIC:
        checkNumeric(subtypeName, valueName);
        break;
      case DATE:
        checkDate(subtypeName, valueName);
        break;
    }
  }
예제 #3
0
 private static Mode checkValue(Type type, Subtype subtype, String valueName, boolean variation)
     throws Exception {
   Mode value = FieldValueDefinition.getEnum(Mode.class, valueName);
   if (null == value) {
     throw new Exception(
         (variation ? "Variation" : "Value") + " \"" + valueName + "\" not supported");
   }
   if (!variation && !subtype.isValidInitialMode(value)
       || variation && !subtype.isValidVariationMode(value)) {
     throw new Exception(
         (variation ? "Variation" : "Value")
             + " \""
             + valueName
             + "\" not supported "
             + "for subtype "
             + subtype.toString()
             + " and type "
             + type.toString());
   }
   return value;
 }