/** Sets the encoding which was used in the received query string */ public void setEncoding(String encoding) { this.encoding = toLowerCase(encoding); }
/** * Return a lowercased version of the given string. Since this is language * independent, this is more of a case normalization operation than * lowercasing. Vespa code should <i>never</i> do lowercasing with implicit * locale. * * @param in * a string to lowercase * @return a string containing only lowercase character */ public static String toLowerCase(String in) { // def is picked from http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#toLowerCase%28%29 String lower = toLowerCasePrintableAsciiOnly(in); return (lower == null) ? in.toLowerCase(Locale.ENGLISH) : lower; } public static String toUpperCase(String in) {
/** "HTTP://a" → "http://a" */ private void lowCaseHost() { host = toLowerCase(host); }
/** * <p>The lower casing method to use in Vespa when doing language independent processing of natural language data. * It is placed in a single place to ensure symmetry between e.g. query processing and indexing.</p> * <p>Return a lowercased version of the given string. Since this is language independent, this is more of a case * normalization operation than lowercasing.</p> * * @param in The string to lowercase. * @return A string containing only lowercase character. */ public static String toLowerCase(String in) { // def is picked from http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#toLowerCase%28%29 // Also, at the time of writing, English is the default language for queries return Lowercase.toLowerCase(in); }
/** Parses a day of week name in english to an int, where 0 is sunday, 6 saturday. */ public static int getDayOfWeek(String day) { return ConfigModelUtils.day2int.get(toLowerCase(day)); }
@Override public String toInstanceDescription() { return toLowerCase(primitiveClass.getSimpleName()); }
@Override public String stringValue() { return toLowerCase(primitiveClass.getSimpleName()); }
public static Type fromString(String name) { for (Type type : Type.values()) { if (toLowerCase(name).equals(toLowerCase(type.name))) { return type; } } return NONE; } }
/** Returns the field name of an alias or field name */ public String unalias(String aliasOrField) { if (aliases == null || aliases.isEmpty()) return aliasOrField; String field = aliases.get(toLowerCase(aliasOrField)); if (field != null) return field; return aliasOrField; }
public static IoType fromString(String name) { for (IoType type : IoType.values()) { if (toLowerCase(name).equals(toLowerCase(type.name))) { return type; } } return NORMAL; } }
public static double valueOf(String valueString) { Matcher matcher = pattern.matcher(valueString); if (!matcher.matches()) { throw new IllegalArgumentException("Value '" + valueString + "' does not match the pattern for binary unit"); } double value = Double.valueOf(matcher.group(1)); String unit = matcher.group(3); if (unit != null) { value *= unitToValue(toLowerCase(unit).charAt(0)); } return value; }
static private String getMediaType(HttpRequest request) { String header = request.getHeader(com.yahoo.jdisc.http.HttpHeaders.Names.CONTENT_TYPE); if (header == null) { return ""; } int semi = header.indexOf(';'); if (semi != -1) { header = header.substring(0, semi); } return com.yahoo.text.Lowercase.toLowerCase(header.trim()); }
/** * Returns the language from an encoding, or {@link #UNKNOWN} if it cannot be determined. * * @param encoding The name of the encoding to derive the <code>Language</code> from. * @return the language given by the encoding, or {@link #UNKNOWN} if not determined. */ public static Language fromEncoding(String encoding) { if (encoding == null) return UNKNOWN; return fromLowerCasedEncoding(Lowercase.toLowerCase(encoding)); }
private void addAlias(String alias, String field) { ensureNotFrozen(); if (aliases == null) aliases = new HashMap<>(); aliases.put(toLowerCase(alias), field); }
/** * Returns the type of service. This is the class name without the * package prefix by default. */ public String getServiceType() { return toLowerCase(getShortClassName()); }
public Freshness(String dateTime) { parse(toLowerCase(dateTime)); // Set reference time }
/** * Computes an md5 hash of the contents of the application package * * @return an md5sum of the application package */ private static String computeCheckSum(File appDir) { MessageDigest md5; try { md5 = MessageDigest.getInstance("MD5"); for (File file : appDir.listFiles((dir, name) -> !name.equals(ApplicationPackage.EXT_DIR) && !name.startsWith("."))) { addPathToDigest(file, "", md5, true, false); } return toLowerCase(HexDump.toHexString(md5.digest())); } catch (Exception e) { throw new RuntimeException(e); } }
public void addAlias(String alias, String indexName) { Index old = indices.get(alias); if (old != null) { if (old.getName().equals(indexName)) return; throw new IllegalArgumentException("Tried adding the alias '" + alias + "' for the index name '" + indexName + "' when the name '" + alias + "' already maps to '" + old.getName() + "'"); } Index index = indices.get(indexName); if (index == null) throw new IllegalArgumentException("Failed adding alias '" + alias + "' for the index name '" + indexName + "' as there is no index with that name available."); indices.put(alias, index); index.addAlias(alias); String lca = toLowerCase(alias); if (lowerCase.get(lca) == null) lowerCase.put(lca, index); }
public void addIndex(Index index) { indices.put(index.getName(), index); lowerCase.put(toLowerCase(index.getName()), index); if (index.isDefaultPosition()) { defaultPosition = index.getName(); } }
private String getCanonicNameFromDocumentTypes(String indexName, List<String> documentTypes) { if (!isInitialized()) return indexName; if (documentTypes.isEmpty()) { Index index = unionSearchDefinition.getIndexByLowerCase(toLowerCase(indexName)); return index == null ? indexName : index.getName(); } DocumentTypeListOffset sd = chooseSearchDefinition(documentTypes, 0); while (sd != null) { Index index = sd.searchDefinition.getIndexByLowerCase(toLowerCase(indexName)); if (index != null) return index.getName(); sd = chooseSearchDefinition(documentTypes, sd.offset); } return indexName; }