@Override protected Map<String, String> parse(List<String> arguments) throws Exception { checkArgumentCountMin(1); Map<String, String> keyValueMap = new HashMap<>(); for (String argument : arguments) { if (!argument.contains(AbstractJPMap.KEY_VALUE_SEPARATOR)) { throw new JPParsingException("KeyValueSeparator[" + AbstractJPMap.KEY_VALUE_SEPARATOR + "] is missing for Argument[" + argument + "]."); } String[] split = argument.split(AbstractJPMap.KEY_VALUE_SEPARATOR); if (split.length != 2) { throw new JPParsingException("Argument[" + argument + "] does not contain a valid key value mapping!"); } keyValueMap.put(split[0], split[1]); } return keyValueMap; } }
protected final void parseArguments() throws JPParsingException { try { valueType = ValueType.CommandLine; parsedValue = parse(Collections.unmodifiableList(arguments)); } catch (Exception ex) { logger.error("Could not parse argument[" + identifier + "]!"); logger.info("The valid syntax would be: " + getSyntax() + "\n"); throw new JPParsingException("Could not parse argument[" + identifier + "]!", ex); } parsed = true; }
/** * {@inheritDoc} * * @param arguments {@inheritDoc} * @return {@inheritDoc} * @throws Exception {@inheritDoc} */ @Override protected Map<Scope, File> parse(List<String> arguments) throws Exception { if (arguments.stream().anyMatch(s -> !s.matches(FULL_REGEX))) { throw new JPParsingException("Every argument of " + COMMAND_IDENTIFIERS[1] + " has to be of type " + ARGUMENT_IDENTIFIERS[0] + " and thus match \"" + FULL_REGEX + "\"."); } Map<Scope, File> result = arguments.stream().map(s -> { Matcher m = PATTERN.matcher(s); m.matches(); return new AbstractMap.SimpleEntry<>((m.group(2) != null) ? new Scope(m.group(2)) : new Scope("/"), new File(m.group(3))); }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return result; }
throw new JPParsingException("invalid system property syntax: " + arg); throw new JPParsingException("unknown property: " + arg); throw new JPParsingException("= bad property: " + arg);