public TranslationHashMap put(String key, String val) { String existing = map.put(toLowerCase(key), val); if (existing != null) throw new IllegalStateException("Cannot overwrite key " + key + " with " + val + ", was: " + existing); return this; }
/** * Replaces all characters which are not numbers, characters or underscores with underscores */ public static String weightingToFileName(Weighting w) { return toLowerCase(w.toString()).replaceAll("\\|", "_"); }
public synchronized String get(String key) { if (!key.equals(toLowerCase(key))) throw new IllegalArgumentException("Do not use upper case keys (" + key + ") for StorableProperties since 0.7"); String ret = map.get(key); if (ret == null) return ""; return ret; }
public Directory put(String name, DAType type) { if (!name.equals(toLowerCase(name))) throw new IllegalArgumentException("Since 0.7 DataAccess objects does no longer accept upper case names"); types.put(name, type); return this; }
/** * Before it saves this value it creates a string out of it. */ public synchronized StorableProperties put(String key, Object val) { if (!key.equals(toLowerCase(key))) throw new IllegalArgumentException("Do not use upper case keys (" + key + ") for StorableProperties since 0.7"); map.put(key, val.toString()); return this; }
public static double stringToTons(String value) { value = toLowerCase(value).replaceAll(" ", "").replaceAll("(tons|ton)", "t"); value = value.replace("mgw", "").trim(); double factor = 1; if (value.endsWith("t")) { value = value.substring(0, value.length() - 1); } else if (value.endsWith("lbs")) { value = value.substring(0, value.length() - 3); factor = 0.00045359237; } return Double.parseDouble(value) * factor; }
@Override public String tr(String key, Object... params) { String val = map.get(toLowerCase(key)); if (isEmpty(val)) return key; return String.format(Locale.ROOT, val, params); }
public String getVehicle() { return toLowerCase(super.get("vehicle", "")); }
public String getWeighting() { return toLowerCase(super.get("weighting", "")); }
/** * This method creates a CmdArgs object from the specified string array (a list of key=value pairs). */ public static CmdArgs read(String[] args) { Map<String, String> map = new LinkedHashMap<>(); for (String arg : args) { int index = arg.indexOf("="); if (index <= 0) { continue; } String key = arg.substring(0, index); if (key.startsWith("-")) { key = key.substring(1); } if (key.startsWith("-")) { key = key.substring(1); } String value = arg.substring(index + 1); String old = map.put(toLowerCase(key), value); if (old != null) throw new IllegalArgumentException("Pair '" + toLowerCase(key) + "'='" + value + "' not possible to " + "add to the CmdArgs-object as the key already exists with '" + old + "'"); } return new CmdArgs(map); }
/** * Enables the use of contraction hierarchies to reduce query times. Enabled by default. * * @param weightingList A list containing multiple weightings like: "fastest", "shortest" or * your own weight-calculation type. */ public CHAlgoFactoryDecorator setWeightingsAsStrings(List<String> weightingList) { if (weightingList.isEmpty()) throw new IllegalArgumentException("It is not allowed to pass an emtpy weightingList"); weightingsAsStrings.clear(); for (String strWeighting : weightingList) { strWeighting = toLowerCase(strWeighting); strWeighting = strWeighting.trim(); addWeighting(strWeighting); } return this; }
/** * Enables the use of contraction hierarchies to reduce query times. Enabled by default. * * @param weightingList A list containing multiple weightings like: "fastest", "shortest" or * your own weight-calculation type. */ public LMAlgoFactoryDecorator setWeightingsAsStrings(List<String> weightingList) { if (weightingList.isEmpty()) throw new IllegalArgumentException("It is not allowed to pass an emtpy weightingList"); weightingsAsStrings.clear(); for (String strWeighting : weightingList) { strWeighting = toLowerCase(strWeighting); strWeighting = strWeighting.trim(); addWeighting(strWeighting); } return this; }
/** * Removes any characters in the String that we don't care about in the matching procedure * TODO Currently limited to certain 'western' languages */ private String prepareName(String name) { // \s = A whitespace character: [ \t\n\x0B\f\r] String[] arr = name.split("\\s"); List<String> list = new ArrayList<>(arr.length); for (int i = 0; i < arr.length; i++) { String rewrite = NON_WORD_CHAR.matcher(toLowerCase(arr[i])).replaceAll(""); String tmp = rewriteMap.get(rewrite); if (tmp != null) rewrite = tmp; // Ignore matching short frases like de, la, ... if (!rewrite.isEmpty() && rewrite.length() > 2) { list.add(rewrite); } } return listToString(list); }
public static double stringToMeter(String value) { value = toLowerCase(value).replaceAll(" ", "").replaceAll("(meters|meter|mtrs|mtr|mt|m\\.)", "m"); double factor = 1; double offset = 0;
static List<FlagEncoder> parseEncoderString(FlagEncoderFactory factory, String encoderList) { if (encoderList.contains(":")) throw new IllegalArgumentException("EncodingManager does no longer use reflection instantiate encoders directly."); if (!encoderList.equals(toLowerCase(encoderList))) throw new IllegalArgumentException("Since 0.7 EncodingManager does no longer accept upper case profiles: " + encoderList); String[] entries = encoderList.split(","); List<FlagEncoder> resultEncoders = new ArrayList<>(); for (String entry : entries) { entry = toLowerCase(entry.trim()); if (entry.isEmpty()) continue; String entryVal = ""; if (entry.contains("|")) { entryVal = entry; entry = entry.split("\\|")[0]; } PMap configuration = new PMap(entryVal); FlagEncoder fe = factory.createFlagEncoder(entry, configuration); if (configuration.has("version") && fe.getVersion() != configuration.getInt("version", -1)) throw new IllegalArgumentException("Encoder " + entry + " was used in version " + configuration.getLong("version", -1) + ", but current version is " + fe.getVersion()); resultEncoders.add(fe); } return resultEncoders; }
String id = jsonIdField.isEmpty() || toLowerCase(jsonIdField).equals("id") ? jsonFeature.getId() : (String) jsonFeature.getProperty(jsonIdField); if (id == null || id.isEmpty()) throw new IllegalArgumentException("ID cannot be empty but was for JsonFeature " + jsonFeatureIdx);
String getFileName(double lat, double lon) { int lonInt = getMinLonForTile(lon); int latInt = getMinLatForTile(lat); return toLowerCase(getLatString(latInt) + getNorthString(latInt) + getLonString(lonInt) + getEastString(lonInt) + FILE_NAME_END); }
String getFileName(double lat, double lon) { int lonInt = getMinLonForTile(lon); int latInt = getMinLatForTile(lat); return toLowerCase(getNorthString(latInt) + getLatString(latInt) + getEastString(lonInt) + getLonString(lonInt)); }
@Override public DataAccess find(String name, DAType type) { if (!name.equals(toLowerCase(name))) throw new IllegalArgumentException("Since 0.7 DataAccess objects does no longer accept upper case names"); DataAccess da = map.get(name); if (da != null) { if (!type.equals(da.getType())) throw new IllegalStateException("Found existing DataAccess object '" + name + "' but types did not match. Requested:" + type + ", was:" + da.getType()); return da; } if (type.isInMemory()) { if (type.isInteg()) { if (type.isStoring()) da = new RAMIntDataAccess(name, location, true, byteOrder); else da = new RAMIntDataAccess(name, location, false, byteOrder); } else if (type.isStoring()) da = new RAMDataAccess(name, location, true, byteOrder); else da = new RAMDataAccess(name, location, false, byteOrder); } else if (type.isMMap()) { da = new MMapDataAccess(name, location, byteOrder, type.isAllowWrites()); } else { da = new UnsafeDataAccess(name, location, byteOrder); } map.put(name, da); return da; }
String weightingStr = toLowerCase(hintsMap.getWeighting()); Weighting weighting = null;