/** * @param key the desired parameter's key * @param alternate The alternate value * @return parameter matching the specified key or the * specified alternate String if there is no matching * parameter */ public String getString(String key, String alternate) { String s = getString(key); return (s != null) ? s : alternate; }
/** * Calls the superclass implementation, then looks for a bundle name * and any time units to be skipped. */ protected void configure(ValueParser values) { // do DateTool config super.configure(values); // look for an alternate bundle String bundle = values.getString(BUNDLE_NAME_KEY); if (bundle != null) { this.bundleName = bundle; } this.depth = values.getInt(DEPTH_KEY, 1); // look for time units to be ignored String[] skip = values.getStrings(SKIPPED_UNITS_KEY); if (skip != null) { timeUnits = new LinkedHashMap(TIME_UNITS); for (int i=0; i < skip.length; i++) { timeUnits.remove(skip[i]); } } }
/** * Does the actual configuration. This is protected, so * subclasses may share the same ValueParser and call configure * at any time, while preventing templates from doing so when * configure(Map) is locked. */ protected void configure(ValueParser values) { String altkey = values.getString("key"); if (altkey != null) { setKey(altkey); } }
String listDelim = values.getString(LIST_DELIM_KEY); if (listDelim != null) String listFinalDelim = values.getString(LIST_FINAL_DELIM_KEY); if (listFinalDelim != null) String truncateSuffix = values.getString(TRUNCATE_SUFFIX_KEY); if (truncateSuffix != null) String cellSuffix = values.getString(CELL_SUFFIX_KEY); if (cellSuffix != null) String defaultAlternate = values.getString(DEFAULT_ALTERNATE_KEY); if (defaultAlternate != null)
/** * Does the actual configuration. This is protected, so * subclasses may share the same ValueParser and call configure * at any time, while preventing templates from doing so when * configure(Map) is locked. * @param values configuration values */ protected void configure(ValueParser values) { super.configure(values); String tzId = values.getString(TIMEZONE_KEY); if (tzId != null) { setTimeZone(TimeZone.getTimeZone(tzId)); } }
/** * Does the actual configuration. This is protected, so * subclasses may share the same ValueParser and call configure * at any time, while preventing templates from doing so when * configure(Map) is locked. * @param values configuration values */ protected void configure(ValueParser values) { super.configure(values); String delimiter = values.getString(STRINGS_DELIMITER_FORMAT_KEY); if (delimiter != null) { setStringsDelimiter(delimiter); } String dateFormat = values.getString(DATE_FORMAT_KEY); if (dateFormat != null) { setDateFormat(dateFormat); } String numberFormat = values.getString(NUMBER_FORMAT_KEY); if (numberFormat != null) { setNumberFormat(numberFormat); } }
/** * Does the actual configuration. This is protected, so * subclasses may share the same ValueParser and call configure * at any time, while preventing templates from doing so when * configure(Map) is locked. */ protected void configure(ValueParser values) { super.configure(values); String format = values.getString(FORMAT_KEY); if (format != null) { setFormat(format); } }
/** * Configure this tool * @param values configuration values */ protected void configure(ValueParser values) { this.showDeprecated = values.getBoolean(SHOW_DEPRECATED_KEY, showDeprecated); String classname = values.getString(INSPECT_KEY); if (classname != null) { setType(toClass(classname)); } }
String loggerName = params.getString(LOGGER_NAME_KEY); if (loggerName != null)
String link = props.getString(URI_KEY); if (link != null) String schm = props.getString(SCHEME_KEY); if (schm != null) String info = props.getString(USER_KEY); if (info != null) String hst = props.getString(HOST_KEY); if (hst != null) String pth = props.getString(PATH_KEY); if (pth != null) String params = props.getString(QUERY_KEY); if (params != null) String anchor = props.getString(FRAGMENT_KEY); if (anchor != null) String chrst = props.getString(CHARSET_KEY); if (chrst != null)
/** * Looks for deprecated parse depth and catch.exceptions properties, * as well as any 'forceThreadSafe' setting. */ protected void configure(ValueParser parser) { // look for deprecated parse.depth key Integer depth = parser.getInteger(KEY_PARSE_DEPTH); if (depth != null) { setParseDepth(depth); } // look for deprecated catch.exceptions key Boolean catchEm = parser.getBoolean(KEY_CATCH_EXCEPTIONS); if (catchEm != null) { setCatchExceptions(catchEm); } // check if they want thread-safety manually turned off this.forceThreadSafe = parser.getBoolean(KEY_FORCE_THREAD_SAFE, forceThreadSafe); // if we're request-scoped, then there's no point in forcing the issue if (Scope.REQUEST.equals(parser.getString("scope"))) { this.forceThreadSafe = false; } }
/** * Does the actual configuration. This is protected, so * subclasses may share the same ValueParser and call configure * at any time, while preventing templates from doing so when * configure(Map) is locked. * @param values configuration values */ @Override protected void configure(ValueParser values) { super.configure(values); String delimiter = values.getString(STRINGS_DELIMITER_FORMAT_KEY); if (delimiter != null) { setStringsDelimiter(delimiter); } Boolean trim = values.getBoolean(STRINGS_TRIM_KEY); if (trim != null) { setStringsTrim(trim); } }
/** * Configuration. * @param values configuration values */ protected void configure(ValueParser values) { super.configure(values); initializeImportSupport(values); String resource = values.getString(ImportSupport.RESOURCE_KEY); if (resource != null) { read(resource); } else { String url = values.getString(ImportSupport.URL_KEY); if (url != null) { /* temporary disable safe mode */ boolean safeMode = importSupport.isSafeMode(); importSupport.setSafeMode(false); fetch(url); importSupport.setSafeMode(safeMode); } } }
/** * Looks for the "file" parameter and automatically uses * {@link #initJSON(String)} to parse the file (searched in filesystem current path and classpath) and set the * resulting JSON object as the root node for this instance. * @param values configuration values */ protected void configure(ValueParser values) { super.configure(values); initializeImportSupport(values); String resource = values.getString(ImportSupport.RESOURCE_KEY); if (resource != null) { read(resource); } else { String url = values.getString(ImportSupport.URL_KEY); if (url != null) { /* temporary disable safe mode */ boolean safeMode = importSupport.isSafeMode(); importSupport.setSafeMode(false); fetch(url); importSupport.setSafeMode(safeMode); } } }
/** * Does the actual configuration. This is protected, so * subclasses may share the same ValueParser and call configure * at any time, while preventing templates from doing so when * configure(Map) is locked. * @param values configuration values */ @Override protected void configure(ValueParser values) { super.configure(values); String delimiter = values.getString(STRINGS_DELIMITER_FORMAT_KEY); if (delimiter != null) { setStringsDelimiter(delimiter); } Boolean allow = values.getBoolean(ALLOWSUBKEYS_KEY); if(allow != null) { setAllowSubkeys(allow); } Boolean ro = values.getBoolean(READONLY_KEY); if(ro != null) { setReadOnly(ro); } }