|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javatools.datatypes.StringModifier
public abstract class StringModifier
This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools). It is licensed under the Creative Commons Attribution License (see http://creativecommons.org/licenses/by/3.0) by the YAGO-NAGA team (see http://mpii.de/yago-naga). This class is a collection of additional string modification methods. For instance, it provides methods to generate a string from an array, separating array elements by a given delimiter; String array[]={"cat", "mouse", "cheese"}; String imploded=StringModifier.implode(array," eats "); System.out.println(imploded); -> cat eats mouse eats cheese; imploded=StringModifier.implode(array,","); System.out.println(imploded); -> cat,mouse,cheese; This is helpfull for instance to generate a list of values for database insertion; note that there is also a version of that functionality that makes sure the array strings are all formated for database insertion/queries (e.g. put in quotations).
Constructor Summary | |
---|---|
StringModifier()
|
Method Summary | ||
---|---|---|
static boolean |
areEqual(java.lang.String s1,
java.lang.String s2)
checks for equality between two potential strings |
|
static java.lang.String |
implode(java.util.Collection<?> col,
java.lang.String delim)
|
|
static java.lang.String |
implode(java.lang.String[] array,
java.lang.String delim)
|
|
static java.lang.String |
implodeForDB(java.util.Collection<?> col,
java.lang.String delim,
Database database)
|
|
static java.lang.String |
implodeForDB(java.util.Iterator<?> it,
java.lang.String delim,
Database database)
|
|
static
|
implodeForDB(java.util.Iterator<java.util.Map.Entry<T,K>> it,
java.lang.String keyValueDelim,
java.lang.String pairDelim,
Database database,
boolean formatKey,
boolean formatValue)
Concatenates key value pairs of a Map.Entry iterator into a combined String, separating each key from its value by a key-value delimeter and each key-value pair by pair delimeter while optionally applying the database.format function to each key/value |
|
static java.lang.String |
implodeForDB(java.util.Map<?,?> map,
java.lang.String keyValueDelim,
java.lang.String pairDelim,
Database database,
boolean formatKey,
boolean formatValue)
Concatenates key value pairs of a Map into a combined String, separating each key from its value by a key-value delimeter and each key-value pair by pair delimeter while optionally applying the database.format function to each key/value |
|
static
|
implodeForDB(T[] col,
java.lang.String delim,
Database database)
|
|
static java.lang.String |
implodeForDBAsConditions(java.util.Map<?,?> map,
Database database)
Concatenates key value pairs of a Map into a combined String representing the pairs as independent column conditions for a database query, applying the database.format function to each value |
|
static java.lang.String |
limitLength(java.lang.String s,
int length)
limits the length of a String to the given size ie applies s.substring(0,length) for given length iff length | |
static java.util.Set<java.lang.String> |
lowercase(java.lang.String... ar)
applies lowercase to all Strings in an array, returns them as a set |
|
static void |
main(java.lang.String[] argv)
Test method |
|
static java.util.Set<java.lang.String> |
toNGram(java.lang.String original,
int n)
produces an n-gram set from the string |
|
static java.util.Map<java.lang.String,java.lang.Double> |
toWeighedNGram(java.lang.String original,
int n)
produces a weighed n-gram set from the string |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringModifier()
Method Detail |
---|
public static java.lang.String implode(java.lang.String[] array, java.lang.String delim)
public static java.lang.String implode(java.util.Collection<?> col, java.lang.String delim)
public static java.lang.String implodeForDB(java.util.Collection<?> col, java.lang.String delim, Database database)
public static java.lang.String implodeForDB(java.util.Iterator<?> it, java.lang.String delim, Database database)
public static <T> java.lang.String implodeForDB(T[] col, java.lang.String delim, Database database)
public static java.lang.String implodeForDBAsConditions(java.util.Map<?,?> map, Database database)
map
- the Map to be implodeddatabase
- the Database instance for which the pairs shall be formattedpublic static java.lang.String implodeForDB(java.util.Map<?,?> map, java.lang.String keyValueDelim, java.lang.String pairDelim, Database database, boolean formatKey, boolean formatValue)
map
- the Map to be implodedkeyValueDelimeter
- delimeter inserted between each key and its valuepairDelimeter
- delimeter inserted between key-value pairsdatabase
- the Database instance for which the pairs shall be formattedformatKey
- flag indicating whether to format the keys with database.formatformatValue
- flag indicating whether to format the values with database.formatpublic static <T,K> java.lang.String implodeForDB(java.util.Iterator<java.util.Map.Entry<T,K>> it, java.lang.String keyValueDelim, java.lang.String pairDelim, Database database, boolean formatKey, boolean formatValue)
it
- the Map.Entry iteratorkeyValueDelimeter
- delimeter inserted between each key and its valuepairDelimeter
- delimeter inserted between key-value pairsdatabase
- the Database instance for which the pairs shall be formattedformatKey
- flag indicating whether to format the keys with database.formatformatValue
- flag indicating whether to format the values with database.formatpublic static java.lang.String limitLength(java.lang.String s, int length)
public static java.util.Set<java.lang.String> toNGram(java.lang.String original, int n)
original
- the String to be split into n-grams of size nn
- size of the n-grams
public static java.util.Map<java.lang.String,java.lang.Double> toWeighedNGram(java.lang.String original, int n)
original
- the String to be split into n-grams of size nn
- size of the n-grams
public static final java.util.Set<java.lang.String> lowercase(java.lang.String... ar)
public static final boolean areEqual(java.lang.String s1, java.lang.String s2)
public static void main(java.lang.String[] argv) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |