private ConfigurationProperty getProperty(String parameterList, StringTokenizer st) throws InterpreterPropertyException { String switchProperty = st.nextToken(); ConfigurationProperty property = getProperty(switchProperty); if (property == null ) { throw new InterpreterPropertyException("Unsupported parameter " + parameterList); } return property; } }
private void checkValues(ConfigurationProperty p, List<String> values) throws InterpreterPropertyException { Pattern pattern = Pattern.compile(p.getValidatingExpression()); for (String value : values) { Matcher m = pattern.matcher(value); if ( ! m.matches()) { throw new InterpreterPropertyException( "Could not parse the value for interpreter property " + p + " expected to be in the form " + p.getExample() ); } } }
private void checkValueCount(ConfigurationProperty p, List<String> values) throws InterpreterPropertyException { if ( values.size() < p.getMinValueCount()) { throw new InterpreterPropertyException("At least " + p.getMinValueCount() + " value(s) must be supplied for the property " + p); } else if ( values.size() > p.getMaxValueCount()) { throw new InterpreterPropertyException("At most " + p.getMaxValueCount() + " value(s) must be supplied for the property " + p); } }
private void addPropertyValues(Map<ConfigurationProperty, List<String>> propertyMap, StringTokenizer st, ConfigurationProperty property) throws InterpreterPropertyException { List<String> l = getOrCreatePropertyList(propertyMap, property); if ( ! st.hasMoreTokens() ) { if (isBooleanSwitchProperty(property)) { l.add("true"); } else { throw new InterpreterPropertyException( String.format("No value was given for switch -%s (-%s), and Chorus cannot provide a default", property.getSwitchShortName(), property.getSwitchName() ) ); } } else { while(st.hasMoreTokens()) { l.add(st.nextToken()); } } }
throw new InterpreterPropertyException("arguments must start with a switch, e.g. -f");
private void checkIfMandatory(Map<ConfigurationProperty, List<String>> results, ConfigurationProperty p) throws InterpreterPropertyException { if ( p.isMandatory() && ! results.containsKey(p)) { throw new InterpreterPropertyException( "Mandatory property " + p + " was not set. " + "You can set this property with the -" + p.getSwitchName() + " switch, " + "the -" + p.getSwitchShortName() + " switch or the " + p.getSystemProperty() + " system property" ); } } }