/** * setArgStringValue purpose. * * <p>Stores a human friendly version. * * @param name * @param value * @return */ public boolean addArgStringValue(String name, String value) { PropertyDescriptor pd = getPropertyDescriptor(name); if (pd == null) { return false; } if ((value == null) || value.equals("")) { args.remove(name); return false; } Class cl = pd.getPropertyType(); ArgumentConfig ac = new ArgumentConfig(); ac.setName(name); try { String argType = ArgHelper.getArgumentType(cl); ac.setValue(ArgHelper.getArgumentInstance(argType, value)); } catch (ValidationException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } args.put(name, ac); return true; }
/** * setArgStringValue purpose. * * <p>Stores a human friendly version. If this is a new Argument, then the type is String. * * @param name * @param value * @return */ public boolean setArgStringValue(String name, String value) { ArgumentConfig ac = (ArgumentConfig) args.get(name); if ((value == null) || value.equals("")) { args.remove(name); return true; } if (ac == null) { return addArgStringValue(name, value); } else { if (ac.isFinal()) { throw new IllegalArgumentException("Cannot include final arguments as part of a test."); } StringReader sr = new StringReader(value); try { ac.setValue(ArgHelper.getArgumentInstance(ArgHelper.getArgumentType(ac.getValue()), value)); return true; } catch (Exception e) { e.printStackTrace(); // error, log it return false; } } }
/** * setArgStringValue purpose. * * <p>Stores a human friendly version * * @param name * @param value * @return */ public boolean setArgValue(String name, Object value) { if ((value == null) || value.equals("")) { args.remove(name); return true; } ArgumentConfig ac = (ArgumentConfig) args.get(name); if (ac == null) { ac = new ArgumentConfig(); ac.setName(name); args.put(name, ac); } if (ac.isFinal()) { throw new IllegalArgumentException("Cannot include final arguments as part of a test."); } ac.setValue(value); return true; }