/** * Helper method. */ private void setLanguage(boolean excludeMode, String language) { if (Util.isEmpty(language)) return; if (excludeMode) excludeLanguage(language); else includeLanguage(language); }
/** * Allows the locales which language matches any of the languages from a given array. * @param languages the given array of languages. * @return this locale filter. */ public LocaleFilter includeLanguage(String ... languages) { if (Util.isEmpty(languages)) return this; for (String language : languages) includeLanguage(language); return this; }
/** * Disallows the locales from a given array of locales. * @param localeIds the given array of locales. * @return this locale filter. */ public LocaleFilter exclude(LocaleId ... localeIds) { if (Util.isEmpty(localeIds)) return this; for (LocaleId localeId : localeIds) exclude(localeId); return this; }
/** * Creates a new StringParameters object with a null path and an empty buffer. */ public StringParameters () { super(); buffer = new ParametersString(); reset(); // Set default values }
/** * Helper method. */ private void setRegion(boolean excludeMode, String region) { if (Util.isEmpty(region)) return; if (excludeMode) excludeRegion(region); else includeRegion(region); }
/** * Helper method. */ private void setUserPart(boolean excludeMode, String userPart) { if (Util.isEmpty(userPart)) return; if (excludeMode) excludeUserPart(userPart); else includeUserPart(userPart); }
/** * Helper method. */ private void setPattern(boolean excludeMode, String pattern, int flags) { if (Util.isEmpty(pattern)) return; if (excludeMode) excludePattern(pattern, flags); else includePattern(pattern, flags); }
/** * Disallows the locales which language matches any of the languages from a given array. * @param languages the given array of languages. * @return this locale filter. */ public LocaleFilter excludeLanguage(String ... languages) { if (Util.isEmpty(languages)) return this; for (String language : languages) excludeLanguage(language); return this; }
/** * Disallows the locales which user part matches any of the user parts from a given array. * @param userParts the given array of user parts. * @return this locale filter. */ public LocaleFilter excludeUserPart(String ... userParts) { if (Util.isEmpty(userParts)) return this; for (String userPart : userParts) excludeUserPart(userPart); return this; }
/** * Allows the locales which user part matches any of the user parts from a given array. * @param userParts the given array of user parts. * @return this locale filter. */ public LocaleFilter includeUserPart(String ... userParts) { if (Util.isEmpty(userParts)) return this; for (String userPart : userParts) includeUserPart(userPart); return this; }
@Override public String toString () { // Plus two *write-only* parameters: always set to true and 0 // This is used by the encoder to know how it needs to escape the quotes // It must not be 0 if one of the data part to extract is an attribute // here we can use 0 because all extracted text comes from elements. buffer.setBoolean(QUOTEMODEDEFINED, true); buffer.setInteger(QUOTEMODE, 0); return super.toString(); }
/** * Creates a new StringParameters object with a null path the specified * initial parameter data * @param data the string holding the parameters. See {@link IParameters#fromString}. */ public StringParameters (String data) { super(); buffer = new ParametersString(); fromString(data); }
/** * Gets the string value for a given parameter after decoding it if necessary. * @param name the name of the parameter. * @param defaultValue the default (not encoded) value to use. * @return the string value of the given parameter, decoded if necessary. */ public String getEncodedString (String name, String defaultValue) { return Base64.decodePassword(getString(name, defaultValue)); }
/** * Writes a string. The text is automatically escaped. * @param text the text to output. */ public void writeString (String text) { closeStartTag(); appendRawXML(Util.escapeToXML(text, 0, false, null)); }
/** * Writes an attribute and its associated value. You must use * {@link #writeStartElement(String)} just before. * @param name the name of the attribute. * @param value the value of the attribute. */ public void writeAttributeString (String name, String value) { write(" " + name + "=\"" + Util.escapeToXML(value, 3, false, null) + "\""); }
public static String[] split(String string, String delimRegex, int group) { String delimPlaceholder = "<delimiter>"; string = RegexUtil.replaceAll(string, delimRegex, group, delimPlaceholder); return ListUtil.stringAsArray(string, delimPlaceholder); }
/** * Load the {@link IParameters} from the give {@link InputStream} * @param stream - stream of the parameter file. */ public void loadParametersFromStream(InputStream stream) { // stream parameters always overrides any other source parametersLocation = null; this.parameters.fromString(StreamUtil.streamUtf8AsString(stream)); } }
/** * Helper method. */ private void setLocale(boolean excludeMode, String language, String region, String userPart) { if (Util.isEmpty(language)) return; if (Util.isEmpty(region)) return; if (Util.isEmpty(userPart)) return; if (excludeMode) exclude(new LocaleId(language, region, userPart)); else include(new LocaleId(language, region, userPart)); }