| java.lang.Object com.flexive.shared.FxSharedUtils
FxSharedUtils | final public class FxSharedUtils (Code) | | Flexive shared utility functions.
author: Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at) |
Inner Class :public static interface ParameterMapper extends Serializable | |
Inner Class :final public static class ProcessResult | |
Inner Class :final static class AsyncStreamBuffer extends Thread | |
Method Summary | |
public static void | checkParameterEmpty(Object value, String parameterName) Check if the given value is empty (empty string or null for String objects, empty collection,
null for other objects) and throw an exception if empty. | public static void | checkParameterNull(Object value, String parameterName) Check if the given value is empty (empty string or null for String objects, empty collection,
null for other objects) and throw an exception if empty. | public static String | decodeXPath(String escapedXPath) Decodes a previously escaped XPath. | public static String | escapePath(String path) | public static String | escapeXPath(String xpath) Escapes the given XPath for use in a public URI. | public static ProcessResult | executeCommand(String command, String... arguments) | public static String | formatResultValue(Object value, ContentLinkFormatter linkFormatter, String linkFormat, String itemLinkFormat) Formats the value as returned from a flexive search query. | public static V | get(Map<K, V> map, K key, V defaultValue) Returns map.get(key) if key exists, defaultValue otherwise. | public static String | getBuildDate() | public static String | getBuildNumber() | public static String | getBuildUser() | public static String | getBundledGroovyVersion() | public static byte[] | getBytes(String s) Returns the UTF-8 byte representation of the given string. | public static Collator | getCollator() Returns a collator for the calling user's locale. | public static int | getColumnIndex(String[] columnNames, String name) Return the index of the given column name. | public static int | getColumnIndex(List<String> columnNames, String name) Return the index of the given column name. | public static synchronized List<String> | getDrops() | public static String | getEmptyResultMessage() | public static FxString | getEnumLabel(Enum> value, Object... args) Returns the localized label for the given enum value. | public static String | getFlexiveEdition() | public static String | getFlexiveEditionFull() | public static String | getFlexiveVersion() | public static String | getHeader() | public static String | getLocalizedMessage(String resourceBundle, long localeId, String localeIso, String key, Object... args) | public static Map<K, V> | getMappedFunction(ParameterMapper<K, V> mapper) Projects a single-parameter function on a hashmap. | public static FxString | getMessage(String resourceBundle, String key, Object... args) Returns a multilingual FxString with all translations for the given property key. | public static List<StepDefinition> | getUsedStepDefinitions(List<? extends Step> steps, List<? extends StepDefinition> stepDefinitions) | public static synchronized String | hashPassword(long accountId, String password) Compute the hash of the given flexive password. | public static boolean | isGroovyScript(String name) | public static boolean | isQuoted(String value, char quoteChar) Returns true if the given string value is quoted with the given character (e.g. | public static String | loadFile(File file) Load the contents of a file, returning it as a String. | public static String | loadFromInputStream(InputStream in, int length) | public static String | lookupResource(String resourceBundle, String key, String localeIso) | public static String | sha1Hash(byte[] bytes) Creates a SHA-1 hash for the given data and returns it
in hexadecimal string encoding. | public static String[] | splitLiterals(String text, char[] stringDelims, char separator) Splits the given text using separator. | public static String[] | splitLiterals(String text) Splits the given comma-separated text. | public static boolean | storeFile(String contents, File file) | public static String | stripQuotes(String value, char quoteChar) Strips the quotes from the given string if it is quoted, otherwise it returns
the input value itself. | public static void | writeResultValue(Writer out, Object value, ContentLinkFormatter linkFormatter, String linkFormat, String itemLinkFormat) Renders the value as returned from a flexive search query to the
given output writer. |
COOKIE_FORCE_TEST_DIVISION | final public static String COOKIE_FORCE_TEST_DIVISION(Code) | | Browser tests set this cookie to force using the test division instead of the actual division
defined by the URL domain.
TODO: security?
|
SHARED_BUNDLE | final public static String SHARED_BUNDLE(Code) | | Shared message resources bundle
|
USE_JDK6_EXTENSION | final public static boolean USE_JDK6_EXTENSION(Code) | | Are JDK 6+ extensions allowed to be run on the current VM?
|
WINDOWS | final public static boolean WINDOWS(Code) | | |
XPATH_ENCODEDSLASH | final public static String XPATH_ENCODEDSLASH(Code) | | The character(s) representing a "xpath slash" (/) in a public URL.
|
checkParameterEmpty | public static void checkParameterEmpty(Object value, String parameterName)(Code) | | Check if the given value is empty (empty string or null for String objects, empty collection,
null for other objects) and throw an exception if empty.
Parameters: value - value to check Parameters: parameterName - name of the value (for the exception) |
checkParameterNull | public static void checkParameterNull(Object value, String parameterName)(Code) | | Check if the given value is empty (empty string or null for String objects, empty collection,
null for other objects) and throw an exception if empty.
Parameters: value - value to check Parameters: parameterName - name of the value (for the exception) |
escapePath | public static String escapePath(String path)(Code) | | Escape a path for usage on the current operating systems shell
Parameters: path - path to escape escaped path |
executeCommand | public static ProcessResult executeCommand(String command, String... arguments)(Code) | | Execute a command on the operating system
Parameters: command - name of the command Parameters: arguments - arguments to pass to the command (one argument per String!) result |
formatResultValue | public static String formatResultValue(Object value, ContentLinkFormatter linkFormatter, String linkFormat, String itemLinkFormat)(Code) | | Formats the value as returned from a flexive search query.
Parameters: value - the value to be formatted the formatted string value |
get | public static V get(Map<K, V> map, K key, V defaultValue)(Code) | | Returns map.get(key) if key exists, defaultValue otherwise.
Parameters: map - a map Parameters: key - the required key Parameters: defaultValue - the default value to be returned if key does not exist in map map.get(key) if key exists, defaultValue otherwise. |
getBuildDate | public static String getBuildDate()(Code) | | Get the date flexive was compiled
compile date |
getBuildNumber | public static String getBuildNumber()(Code) | | Get the subversion build number
subversion build number |
getBuildUser | public static String getBuildUser()(Code) | | Get the name of the user that built flexive
build user |
getBundledGroovyVersion | public static String getBundledGroovyVersion()(Code) | | Get the version of the bundled groovy runtime
version of the bundled groovy runtime |
getBytes | public static byte[] getBytes(String s)(Code) | | Returns the UTF-8 byte representation of the given string. Use this instead of
String.getBytes , since the latter will fail if the system locale is not UTF-8.
Parameters: s - the string to be processed the UTF-8 byte representation of the given string |
getCollator | public static Collator getCollator()(Code) | | Returns a collator for the calling user's locale.
a collator for the calling user's locale. |
getColumnIndex | public static int getColumnIndex(String[] columnNames, String name)(Code) | | Return the index of the given column name. If name has no
prefix (e.g. "co."), then only a suffix match is performed (e.g.
"name" matches "co.name" or "abc.name", whichever comes first.)
Parameters: columnNames - all column names to be searched Parameters: name - the requested column name the 1-based index of the given column, or -1 if it does not exist |
getColumnIndex | public static int getColumnIndex(List<String> columnNames, String name)(Code) | | Return the index of the given column name. If name has no
prefix (e.g. "co."), then only a suffix match is performed (e.g.
"name" matches "co.name" or "abc.name", whichever comes first.)
Parameters: columnNames - all column names to be searched Parameters: name - the requested column name the 1-based index of the given column, or -1 if it does not exist |
getDrops | public static synchronized List<String> getDrops()(Code) | | Get a list of all installed and deployed drops
list of all installed and deployed drops |
getEmptyResultMessage | public static String getEmptyResultMessage()(Code) | | Returns the localized "empty" message for empty result fields
the localized "empty" message for empty result fields |
getEnumLabel | public static FxString getEnumLabel(Enum> value, Object... args)(Code) | | Returns the localized label for the given enum value. The enum translations are
stored in FxSharedMessages.properties and are standardized as
FQCN.value ,
e.g.
com.flexive.shared.search.query.ValueComparator.LIKE .
Parameters: value - the enum value to be translated Parameters: args - optional arguments to be replaced in the localized messages the localized label for the given enum value |
getFlexiveEdition | public static String getFlexiveEdition()(Code) | | Get the name of this flexive edition
flexive edition |
getFlexiveEditionFull | public static String getFlexiveEditionFull()(Code) | | Get the name of this flexive edition with the product name
flexive edition with product name |
getFlexiveVersion | public static String getFlexiveVersion()(Code) | | Get the flexive version
flexive version |
getHeader | public static String getHeader()(Code) | | Get the default html header title
html header title |
getLocalizedMessage | public static String getLocalizedMessage(String resourceBundle, long localeId, String localeIso, String key, Object... args)(Code) | | Get the localized message for a given language code and ISO
Parameters: resourceBundle - the resource bundle to use Parameters: localeId - used locale if args contain FxString instances Parameters: localeIso - ISO code of the requested locale Parameters: key - the key in the resource bundle Parameters: args - arguments to replace in the message ({n}) localized message |
getMappedFunction | public static Map<K, V> getMappedFunction(ParameterMapper<K, V> mapper)(Code) | | Projects a single-parameter function on a hashmap.
Useful for calling parameterized functions from JSF-EL.
Parameters: mapper - the parameter mapper wrapping the function to be called a hashmap projected on the given parameter mapper |
getMessage | public static FxString getMessage(String resourceBundle, String key, Object... args)(Code) | | Returns a multilingual FxString with all translations for the given property key.
Parameters: resourceBundle - the resource bundle to be used Parameters: key - the message key Parameters: args - optional parameters to be replaced in the property translations a multilingual FxString with all translations for the given property key. |
getUsedStepDefinitions | public static List<StepDefinition> getUsedStepDefinitions(List<? extends Step> steps, List<? extends StepDefinition> stepDefinitions)(Code) | | Returns a list of all used step definitions for the given steps
Parameters: steps - list of steps to be examined Parameters: stepDefinitions - all defined step definitions a list of all used step definitions for this workflow |
hashPassword | public static synchronized String hashPassword(long accountId, String password)(Code) | | Compute the hash of the given flexive password.
Parameters: accountId - the user account ID Parameters: password - the cleartext password a hashed password |
isGroovyScript | public static boolean isGroovyScript(String name)(Code) | | Is the script (most likely) a groovy script?
Parameters: name - script name to check if this script could be a groovy script |
isQuoted | public static boolean isQuoted(String value, char quoteChar)(Code) | | Returns true if the given string value is quoted with the given character (e.g. 'value').
Parameters: value - the string value to be checked Parameters: quoteChar - the quote character, for example ' true if the given string value is quoted with the given character (e.g. 'value'). |
loadFile | public static String loadFile(File file)(Code) | | Load the contents of a file, returning it as a String.
This method should only be used when really necessary since no real error handling is performed!!!
Parameters: file - the File to load file contents |
loadFromInputStream | public static String loadFromInputStream(InputStream in, int length)(Code) | | Load a String from an InputStream (until end of stream)
Parameters: in - InputStream Parameters: length - length of the string if > -1 (NOT number of bytes to read!) String |
lookupResource | public static String lookupResource(String resourceBundle, String key, String localeIso)(Code) | | Try to find a localized resource messages
Parameters: resourceBundle - the name of the resource bundle to retrieve the message from Parameters: key - resource key Parameters: localeIso - locale of the resource bundle resource from a localized bundle |
splitLiterals | public static String[] splitLiterals(String text, char[] stringDelims, char separator)(Code) | | Splits the given text using separator. String literals are supported, e.g.
abc,def yields two elements, but 'abc,def' yields one (stringDelims = ['\''], separator = ',').
Parameters: text - the text to be splitted Parameters: stringDelims - delimiters for literal string values, usually ' and " Parameters: separator - separator between tokens split string |
splitLiterals | public static String[] splitLiterals(String text)(Code) | | Splits the given comma-separated text. String literals are supported, e.g.
abc,def yields two elements, but 'abc,def' yields one.
Parameters: text - the text to be splitted split string |
storeFile | public static boolean storeFile(String contents, File file)(Code) | | Rather primitive "write String to file" helper, returns false if failed
Parameters: contents - the String to store Parameters: file - the file, if existing it will be overwritten if successful |
stripQuotes | public static String stripQuotes(String value, char quoteChar)(Code) | | Strips the quotes from the given string if it is quoted, otherwise it returns
the input value itself.
Parameters: value - the value to be "unquoted" Parameters: quoteChar - the quote character, for example ' the unquoted string, or value , if it was not quoted |
writeResultValue | public static void writeResultValue(Writer out, Object value, ContentLinkFormatter linkFormatter, String linkFormat, String itemLinkFormat) throws IOException(Code) | | Renders the value as returned from a flexive search query to the
given output writer.
Parameters: out - the output writer Parameters: value - the value to be formatted throws: IOException - if the value could not be written |
|
|