|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.dfki.lt.hog.util.Utility
public class Utility
Utility class with static methods/constants. Created 2003-11-19
Field Summary | |
---|---|
static java.lang.String |
ACID_ATTRIBUTE
|
protected static org.apache.log4j.Logger |
log
A logger for Module s |
static java.lang.String |
METADATA_ELEMENT
|
static java.lang.String |
SESSIONID_ATTRIBUTE
|
Constructor Summary | |
---|---|
Utility()
|
Method Summary | |
---|---|
static java.lang.String |
abstractList2String(java.util.AbstractList list,
java.lang.String prefix,
java.lang.String suffix)
Converts objects of classes implementing Collection
to a String . |
static java.lang.String |
cleanXMLString(java.lang.String dirtyXMLString)
Cleans an XML String by replacing '&', '<', '>' and '"' with '&', '<', '>' and '"', respectively, and by replacing all characters with ASCII code > 127 with the numeric representation. |
static org.w3c.dom.Element |
conf2Element(org.w3c.dom.Document doc,
java.util.Properties props)
Creates a CONF Element from the contents of a given Properties instance. |
static java.lang.String |
conf2Xml(java.util.Properties props)
Creates a CONF XML String from the contents of a given Properties instance. |
static byte[] |
convert(byte[] data,
java.lang.String srcEncoding,
java.lang.String targetEncoding)
|
static java.lang.String |
convert(java.lang.String str,
java.lang.String fromEncoding,
java.lang.String toEncoding)
|
static java.lang.String |
exception2String(java.lang.Exception e)
|
static java.lang.String |
extractHtmlElement(java.lang.String htmlDoc,
java.lang.String tag)
Returns the header part (<HEAD>...</HEAD>) of a given HTML document |
static java.util.ArrayList |
findAllrx(java.lang.String regex,
java.lang.String string)
Uses the given regular expression to find all matching occurences and returns them as an ArrayList of Strings. |
static java.lang.String |
formatDuration(java.util.Date duration)
format duration encoded in Date object as String mm:ss,milliseconds |
static java.lang.String |
formatDuration(long totalMillis)
Format a time span given in milliseconds to a String. |
static java.lang.String |
formatDurationShort(long totalMillis)
Format a time span given in milliseconds to a String. |
static java.lang.String |
formatTime()
format date and time as ISO/RFC string |
static java.lang.String |
getAttributeValue(java.lang.String inputString,
java.lang.String attribute,
int startpos)
|
static java.lang.String |
getComputedAnnotation(MoCoMan mocoman,
java.lang.String inputAnnotation,
java.lang.String seekAnnotationName)
Get computed annotation from MoCoMan, taking sessionID and annotationCollection name from metadata of the input annotation The purpose of this method is to provide (from within a Module implementation) access to annotations other than the previous one. |
static java.lang.String |
getNewLine()
|
static boolean |
isInterpunct(java.lang.String w)
Checks for punctuation, returns true if w is
a puncuation character. |
static java.lang.String |
map2String(java.util.Map map)
Converts a Map to a String . |
static java.lang.String |
map2String(java.util.Map map,
java.lang.String prefix)
Converts a Map to a String . |
static java.lang.String |
map2String(java.util.Map map,
java.lang.String prefix,
java.lang.String suffix)
Converts a Map to a String . |
static java.lang.String |
markSentenceBoundaries(java.lang.String jtokAnno,
java.lang.String marker)
Marks all sentence boundaries of a given text with a given marker. |
static java.lang.String |
node2String(org.w3c.dom.Node node)
Converts any given DOM Node instance to an XML String. |
static java.lang.String |
readStringFromFile(java.lang.String sFilename,
java.lang.String encoding)
read string from file |
static java.lang.String |
rmrsText(java.lang.String text)
Write text to string containing
<text><c>t</c><c>e</c><c>x</c><c>t</c></text>
(for rmrs2html stylesheet). |
static double |
roundTo(int decimals,
double num)
Rounds a number to the specified number of decimal places. |
static java.util.ArrayList |
splitLines(java.lang.String str)
Split a given string into an ArrayList of lines using "\n" as a separator |
static java.util.ArrayList |
splitTabs(java.lang.String str)
Splits a given string into an ArrayList of lines using "\t" as a separator |
static org.w3c.dom.Element |
string2Element(java.lang.String xmlString)
create DOM element from XML String |
static java.lang.String |
unicodeTo7bit(java.lang.String str)
Replaces all non-ascii-7 chars with char-entities. |
static void |
writeStringToFile(java.lang.String sFilename,
java.lang.String sContent)
write string to file |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static org.apache.log4j.Logger log
Module
s
public static final java.lang.String METADATA_ELEMENT
public static final java.lang.String SESSIONID_ATTRIBUTE
public static final java.lang.String ACID_ATTRIBUTE
Constructor Detail |
---|
public Utility()
Method Detail |
---|
public static java.lang.String getNewLine()
public static java.lang.String formatDuration(java.util.Date duration)
duration
-
public static java.lang.String formatDuration(long totalMillis)
totalMillis
- The time span in milliseconds
public static java.lang.String formatDurationShort(long totalMillis)
totalMillis
- The time span in milliseconds
public static java.lang.String formatTime()
public static java.lang.String getComputedAnnotation(MoCoMan mocoman, java.lang.String inputAnnotation, java.lang.String seekAnnotationName)
mocoman
- MoCoMan instanceinputAnnotation
- annotation String that contains the previous annotation with metadataseekAnnotationName
- name of the annotation
public static java.lang.String getAttributeValue(java.lang.String inputString, java.lang.String attribute, int startpos)
public static java.lang.String readStringFromFile(java.lang.String sFilename, java.lang.String encoding)
sFilename
- encoding
-
public static void writeStringToFile(java.lang.String sFilename, java.lang.String sContent)
sFilename
- sContent
- public static java.lang.String map2String(java.util.Map map)
Map
to a String
. Maps can be
AbstractMap, Attributes, HashMap, Hashtable, IdentityHashMap,
RenderingHints, TreeMap or WeakHashMap
map
- The Map to be printed.
public static java.lang.String map2String(java.util.Map map, java.lang.String prefix)
Map
to a String
. Maps can be
AbstractMap, Attributes, HashMap, Hashtable, IdentityHashMap,
RenderingHints, TreeMap or WeakHashMap.
Each line will be followed by a line separator
(e.g. "\n" for Linux).
map
- The Map to be printed.prefix
- A String preceding each line.
public static java.lang.String map2String(java.util.Map map, java.lang.String prefix, java.lang.String suffix)
Map
to a String
. Maps can be
AbstractMap, Attributes, HashMap, Hashtable, IdentityHashMap,
RenderingHints, TreeMap or WeakHashMap. Use prefix
to add a String in front of each line.
map
- The Map to be printed.prefix
- A String preceding each line.suffix
- A String following each line.
public static java.lang.String abstractList2String(java.util.AbstractList list, java.lang.String prefix, java.lang.String suffix)
Converts objects of classes implementing Collection
to a String
. Some known classes implementing interface
Collection
are
LinkedList, ArrayList, Vector, Stack, HashSet, TreeSet, ...
prefix
and suffix
to add a String in front
and at the end of each line respectively.
Note that this method will not care about keys and values, but only
about object entries in the collection and their String representaion
directly.
coll
- The Collection to be printed.prefix
- A String preceding each line.suffix
- A String following each line.
public static final java.lang.String cleanXMLString(java.lang.String dirtyXMLString)
dirtyXMLString
- The XML String to be cleaned
public static java.lang.String unicodeTo7bit(java.lang.String str)
public static java.lang.String node2String(org.w3c.dom.Node node)
node
- The DOM Node to be converted.
public static org.w3c.dom.Element string2Element(java.lang.String xmlString)
xmlString
- String to parse
public static java.lang.String conf2Xml(java.util.Properties props)
props
- The Properties instance to be converted
public static org.w3c.dom.Element conf2Element(org.w3c.dom.Document doc, java.util.Properties props)
doc
- The Document the METADATE will be inserted inprops
- The Properties instance to be converted
public static final java.util.ArrayList splitLines(java.lang.String str)
str
- input String containing newlines
public static final java.util.ArrayList splitTabs(java.lang.String str)
str
- input String containing tabs
public static boolean isInterpunct(java.lang.String w)
true
if w
is
a puncuation character.
w
- input String to tesdt for punctuation
public static java.lang.String rmrsText(java.lang.String text)
text
to string containing
<text><c>t</c><c>e</c><c>x</c><c>t</c></text>
(for rmrs2html stylesheet).
s
- String to convert
public static java.lang.String extractHtmlElement(java.lang.String htmlDoc, java.lang.String tag)
HtmlDoc
-
public static java.lang.String exception2String(java.lang.Exception e)
public static java.util.ArrayList findAllrx(java.lang.String regex, java.lang.String string)
regex
- The regex to be matched.string
- The string to be scanned.
public static java.lang.String convert(java.lang.String str, java.lang.String fromEncoding, java.lang.String toEncoding)
public static byte[] convert(byte[] data, java.lang.String srcEncoding, java.lang.String targetEncoding)
public static java.lang.String markSentenceBoundaries(java.lang.String jtokAnno, java.lang.String marker)
public static double roundTo(int decimals, double num)
decimals
- the number of decimal placesnum
- the number to round
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |