|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.core.pool.RecyclableSupport org.norther.tammi.core.pool.PoolableSupport org.norther.tammi.spray.engine.tool.GlobalTool org.norther.tammi.spray.engine.tool.TypeTool
public class TypeTool
A global context tool for type conversions.
Constructor Summary | |
---|---|
TypeTool()
Constructs a new tool. |
Method Summary | ||
---|---|---|
Object |
append(Object array,
Object element)
Appends an element to an array. |
|
Object |
asArray(Object object)
Returns an object in an array. |
|
|
asList(Object... object)
Returns a collection, array or objects as a list. |
|
|
asOrderedSet(Object... object)
Returns a collection, array or object as an ordered set. |
|
|
asSet(Object... object)
Returns a collection, array or objects as a set. |
|
String |
cite(Object obj)
Returns an object within apostrophes. |
|
Object |
clone(Object array)
Clones an array and its elements. |
|
String |
concat(String... str)
Concatenates strings. |
|
Object |
copy(Object array)
Copies an array but not its elements. |
|
Collection<Boolean> |
counter()
Returns an endless counter. |
|
Collection<Boolean> |
counter(int size)
Returns a counter. |
|
String |
cut(String str,
int max)
Returns a string cut to the specified size. |
|
String |
cut(String str,
int max,
String tail)
Returns a string cut to the specified size. |
|
String |
digest(String algorithm,
String string)
Computes a digest hash. |
|
String |
digest(String algorithm,
String string,
String encoding)
Computes a digest hash applying the specified encoding. |
|
String |
digest(String algorithm,
String salt,
String string,
String encoding)
Computes a digest hash using the given salt and applying the specified encoding. |
|
boolean |
equals(Object object1,
Object object2)
Checks whether two objects are equal. |
|
String |
escape(CharSequence sequence)
Excapes the specified sequence. |
|
String |
escape(CharSequence sequence,
int limit,
String additions)
Escapes the specified sequence with additions. |
|
String |
fromXML(Object object)
Converts an XML encoded object to a text string. |
|
String |
get(String str,
String delim,
int index)
Gets an indexed element from a string. |
|
int |
indexOf(Object source,
Object object,
int... limits)
Gets the index of the specified object within the source. |
|
Object |
insert(Object array,
int index,
Object element)
Inserts an element to an array. |
|
boolean |
isArray(Object object)
Checks whether an object is an array. |
|
boolean |
isBoolean(Object object)
Checks whether an object is a boolean. |
|
boolean |
isBooleanType(String className,
Class<?>... loaded)
Checks whether the named class is boolean. |
|
boolean |
isByte(Object object)
Checks whether an object is a byte. |
|
boolean |
isChar(String str,
int c)
Checks whether a string represents the specified char. |
|
boolean |
isCharacter(Object object)
Checks whether an object is a character. |
|
boolean |
isCharSequence(Object object)
Checks whether an object is a char sequence. |
|
boolean |
isCharSequenceType(String className,
Class<?>... loaded)
Checks whether the named class is character based. |
|
boolean |
isDateType(String className,
Class<?>... loaded)
Checks whether the named class is date based. |
|
boolean |
isDouble(Object object)
Checks whether an object is a doouble. |
|
boolean |
isFloat(Object object)
Checks whether an object is a float. |
|
boolean |
isInstance(Object object,
String className)
Checks whether the specified object is an instance of the named class. |
|
boolean |
isInteger(Object object)
Checks whether an object is an integer. |
|
boolean |
isLOBType(String className,
Class<?>... loaded)
Checks whether the named class is a large object. |
|
boolean |
isLocationType(String className,
Class<?>... loaded)
Checks whether the named class is location based. |
|
boolean |
isLong(Object object)
Checks whether an object is a long. |
|
boolean |
isNull(Object object)
Checks whether an object is null. |
|
boolean |
isNumber(Object object)
Checks whether an object is a number. |
|
boolean |
isNumericType(String className,
Class<?>... loaded)
Checks whether the named class is numeric. |
|
boolean |
isPrimitiveType(String className)
Checks whether the specified class name is primitive. |
|
boolean |
isShort(Object object)
Checks whether an object is a short. |
|
boolean |
isString(Object object)
Checks whether an object is a string. |
|
boolean |
isStringType(String className,
Class<?>... loaded)
Checks whether the named class is string based. |
|
String |
join(Object array,
String delims)
Joins an array to delimited items to a string. |
|
Object |
newArray(int length)
Returns an array of the specified size. |
|
StringBuffer |
newBuffer()
Returns an empty buffer. |
|
StringBuffer |
newBuffer(Object object)
Returns an initialized buffer. |
|
OutputStream |
newByteStream()
Returns a byte stream. |
|
File |
newFile(Object obj)
Returns a new file. |
|
|
newList()
Returns an empty list. |
|
|
newList(int size)
Returns a sized list. |
|
Locale |
newLocale(Object obj)
Returns a new locale. |
|
|
newMap()
Returns an empty map. |
|
|
newOrderedMap()
Returns an empty ordered map. |
|
|
newOrderedSet()
Returns an empty ordered set. |
|
|
newSet()
Returns an empty set. |
|
ZipEntry |
newZipEntry(String path)
Returns a zip entry. |
|
OutputStream |
newZipStream(OutputStream out)
Returns a zip stream. |
|
Object |
none()
Returns a null. |
|
Date |
now()
Returns the current date. |
|
|
prefix(String prefix,
Map<? super String,V> map)
Returns a map that is a prefixed subset of the given one. |
|
|
prefix(String prefix,
String delims,
Map<? super String,V> map)
Returns a map that is a prefixed subset of the given one. |
|
String |
printStackTrace(Throwable error)
Prints the stack trace of a throwable. |
|
String |
quote(Object obj)
Returns an object within quotation. |
|
String |
replace(String source,
String from,
String to)
Replaces occurancies of the specified substring in a string to another substring. |
|
Object |
sort(Object source)
Sorts the specified source into ascending order. |
|
Object |
sort(Object source,
Comparator<?> comp)
Sorts the specified source to the order induced by the specified comparator. |
|
Object |
sort(Object array,
int fromIndex,
int toIndex)
Sorts the specified range of the specified array into ascending order. |
|
Object |
sort(Object source,
String className)
Sorts the specified source to the order induced by the specified comparator class. |
|
String[] |
split(String items,
String delims)
Splits the delimited items of a string to an array. |
|
|
suffix(String suffix,
Map<? super String,V> map)
Returns a map that is a suffixed subset of the given one. |
|
|
suffix(String suffix,
String delims,
Map<? super String,V> map)
Returns a map that is a suffixed subset of the given one. |
|
String |
tab(int depth)
Returns a tab of the specified depth. |
|
boolean |
toBoolean(Object obj)
Converts a string into a boolean. |
|
byte |
toByte(Object object)
Converts an object to a byte. |
|
byte[] |
toBytes(Object object,
String... encoding)
Converts an object to bytes. |
|
char |
toChar(Object obj)
Converts an object to a char. |
|
Class<?> |
toClass(String className,
boolean... options)
Returns the class instance of the named class. |
|
Comparator<Object> |
toComparator(List<String> attributes)
Returns an attribute comparator for the specified attributes. |
|
double |
toDouble(Object obj)
Converts a string into a double. |
|
float |
toFloat(Object obj)
Converts a string into a float. |
|
int |
toInt(Object obj)
Converts a string into an int. |
|
long |
toLong(Object obj)
Converts a string into a long. |
|
Object |
toObject(String className,
Object object)
Converts objects. |
|
Object |
toObject(String className,
Object object,
String pattern)
Converts objects by applying a pattern. |
|
|
toObjects(Map<?,?> classNames,
Map<K,?> objects)
Converts a map of objects. |
|
|
toObjects(Map<?,?> classNames,
Map<K,?> objects,
String pattern)
Converts a map of objects by applying a pattern. |
|
Paint |
toPaint(String color)
Converts a named color to a paint. |
|
int |
toPermissionMask(String actions)
Converts permitted actions to a permission mask. |
|
String |
toPermittedActions(int permission)
Converts a permission mask to permitted actions. |
|
String |
toPlainType(Class<?> clazz)
Converts a class to its plain type. |
|
String |
toPlainType(String className)
Converts a qualified class name to its plain type. |
|
short |
toShort(Object obj)
Converts a string into a short. |
|
String |
toString(Object object)
Converts an object to a string. |
|
String |
toString(Object object,
String pattern)
Converts an object to a string by applying a pattern. |
|
String |
toString(String className,
Object object)
Converts an object of the named class to a string. |
|
String |
toString(String className,
Object object,
String pattern)
Converts an object of the named class to a string by applying a pattern. |
|
StringDate |
toStringDate(Date date)
Converts a date to a string date. |
|
StringDate |
toStringDate(Object obj)
Converts a string to a string date. |
|
String[] |
toStrings(Object object)
Converts objects to a strings. |
|
String[] |
toStrings(String className,
Object object)
Converts objects of the named class to strings. |
|
String[] |
toStrings(String className,
Object object,
String pattern)
Converts objects of the named class to strings by applying a pattern. |
|
Stroke |
toStroke(String pattern)
Converts a pattern to a stroke. |
|
String |
toXML(Object object)
Converts an object to an XML encoded string. |
|
String |
toXML(String className,
Object object)
Converts an object to an XML encoded string. |
|
String |
toXML(String className,
Object object,
String pattern)
Converts an object to an XML encoded string applying a pattern. |
|
String |
unescape(CharSequence sequence)
Unescapes the specified sequence. |
|
String |
unescape(CharSequence sequence,
int limit,
String exceptions)
Unescapes the specified sequence with exceptions. |
|
String |
wrap(String str)
Returns a string wrapped by linefeeds. |
Methods inherited from class org.norther.tammi.spray.engine.tool.GlobalTool |
---|
clone, dispose, getContext, getContextToolFilter, getMBeanServer, isBound, nop, toString, valueBound, valueUnbound |
Methods inherited from class org.norther.tammi.core.pool.PoolableSupport |
---|
disposed, recycled |
Methods inherited from class org.norther.tammi.core.pool.RecyclableSupport |
---|
isDisposed, recycle |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.norther.tammi.core.pool.Recyclable |
---|
isDisposed, recycle |
Constructor Detail |
---|
public TypeTool()
Method Detail |
---|
public int indexOf(Object source, Object object, int... limits)
source
- the source.object
- the object.limits
- inclusive start and exclusive end indices.
public Object copy(Object array)
array
- the array.
public Object clone(Object array)
array
- the array.
public String get(String str, String delim, int index)
str
- the string.delim
- the delimiter.index
- the index.
public String concat(String... str)
str
- the strings.
public <V> Map<String,V> prefix(String prefix, Map<? super String,V> map)
V
- the subset value type.prefix
- a key prefix.map
- the source map.
public <V> Map<String,V> prefix(String prefix, String delims, Map<? super String,V> map)
V
- the subset value type.prefix
- a key prefix.delims
- key delimiters.map
- the source map.
public <V> Map<String,V> suffix(String suffix, Map<? super String,V> map)
V
- the subset value type.suffix
- a key suffix.map
- the source map.
public <V> Map<String,V> suffix(String suffix, String delims, Map<? super String,V> map)
V
- the subset value type.suffix
- a key suffix.delims
- key delimiters.map
- the source map.
public String replace(String source, String from, String to)
source
- the source string.from
- the substring to replace from.to
- the substring to replace to.
public boolean isBooleanType(String className, Class<?>... loaded)
className
- the class name to check.loaded
- an optionally loaded class.
public boolean isNumericType(String className, Class<?>... loaded)
className
- the class name to check.loaded
- an optionally loaded class.
public boolean isStringType(String className, Class<?>... loaded)
className
- the class name to check.loaded
- an optionally loaded class.
public boolean isCharSequenceType(String className, Class<?>... loaded)
className
- the class name to check.loaded
- an optionally loaded class.
public boolean isDateType(String className, Class<?>... loaded)
className
- the class name to check.loaded
- an optionally loaded class.
public boolean isLocationType(String className, Class<?>... loaded)
className
- the class name to check.loaded
- an optionally loaded class.
public boolean isLOBType(String className, Class<?>... loaded)
className
- the class name to check.loaded
- an optionally loaded class.
public boolean isPrimitiveType(String className)
className
- the class name to check.
public boolean isArray(Object object)
object
- an object.
public boolean isNumber(Object object)
object
- an object.
public boolean isByte(Object object)
object
- an object.
public boolean isCharacter(Object object)
object
- an object.
public boolean isShort(Object object)
object
- an object.
public boolean isInteger(Object object)
object
- an object.
public boolean isLong(Object object)
object
- an object.
public boolean isFloat(Object object)
object
- an object.
public boolean isDouble(Object object)
object
- an object.
public boolean isBoolean(Object object)
object
- an object.
public boolean isString(Object object)
object
- an object.
public boolean isCharSequence(Object object)
object
- an object.
public boolean isNull(Object object)
object
- an object.
public boolean isInstance(Object object, String className)
object
- an object.className
- the class name.
public boolean isChar(String str, int c)
str
- the string.c
- the char.
public boolean equals(Object object1, Object object2)
object1
- the first object.object2
- the second object.
public Object none()
public byte[] toBytes(Object object, String... encoding)
object
- the object.encoding
- the encoding.
public byte toByte(Object object)
object
- the object.
public char toChar(Object obj)
obj
- the object.
public short toShort(Object obj)
obj
- the object.
public int toInt(Object obj)
obj
- the object.
public long toLong(Object obj)
obj
- the object.
public float toFloat(Object obj)
obj
- the object.
public double toDouble(Object obj)
obj
- the object.
public boolean toBoolean(Object obj)
obj
- the object.
public StringDate toStringDate(Object obj)
obj
- the object.
public StringDate toStringDate(Date date)
date
- the date.
public String toString(Object object)
object
- the object to convert.
public String toString(Object object, String pattern)
object
- the object to convert.pattern
- the conversion pattern.
public String toString(String className, Object object)
className
- the source class name.object
- the object to convert.
public String toString(String className, Object object, String pattern)
className
- the source class name.object
- the object to convert.pattern
- the conversion pattern.
public String[] toStrings(Object object)
object
- the object to convert.
public String[] toStrings(String className, Object object)
className
- the source class name.object
- the object to convert.
public String[] toStrings(String className, Object object, String pattern)
className
- the source class name.object
- the object to convert.pattern
- the conversion pattern.
public Object toObject(String className, Object object)
className
- the target class name.object
- the object to convert.
public Object toObject(String className, Object object, String pattern)
className
- the target class name.object
- the object to convert.pattern
- the conversion pattern.
public <K> Map<K,Object> toObjects(Map<?,?> classNames, Map<K,?> objects)
K
- the key type.classNames
- a map of class names.objects
- a map of objects to convert.
public <K> Map<K,Object> toObjects(Map<?,?> classNames, Map<K,?> objects, String pattern)
K
- the key type.classNames
- a map of class names.objects
- a map of objects to convert.pattern
- the conversion pattern.
public String toPermittedActions(int permission)
permission
- the permission to convert.
public String toPlainType(Class<?> clazz)
clazz
- the class.
public String toPlainType(String className)
className
- the qualified class name.
public int toPermissionMask(String actions)
actions
- the actions to convert.
public Collection<Boolean> counter()
public Collection<Boolean> counter(int size)
size
- the size of the counter.
public Object sort(Object source)
source
- the source to sort.
public Object sort(Object source, Comparator<?> comp)
source
- the source to sort.comp
- the comparator.
public Object sort(Object source, String className)
source
- the source to sort.className
- the class name of the comparator.
public Object sort(Object array, int fromIndex, int toIndex)
array
- the array to sort.fromIndex
- the indext to start from.toIndex
- the index to end to.
public Comparator<Object> toComparator(List<String> attributes)
attributes
- a list of attributes.
public Date now()
public File newFile(Object obj)
obj
- the object.
public Locale newLocale(Object obj)
obj
- the object.
public <K,V> OrderedMap<K,V> newOrderedMap()
K
- the key type.V
- the value type.
public <E> OrderedSet<E> newOrderedSet()
E
- the element type.
public <E> Set<E> asOrderedSet(Object... object)
E
- the element type.object
- the object.
public <K,V> Map<K,V> newMap()
K
- the key type.V
- the value type.
public <E> Set<E> newSet()
E
- the element type.
public <E> Set<E> asSet(Object... object)
E
- the element type.object
- the object.
public <E> List<E> newList()
E
- the element type.
public <E> List<E> newList(int size)
E
- the element type.size
- the size.
public <E> List<E> asList(Object... object)
E
- the element type.object
- the object.
public StringBuffer newBuffer()
public StringBuffer newBuffer(Object object)
object
- the initial object.
public OutputStream newByteStream()
public OutputStream newZipStream(OutputStream out)
out
- the output stream.
public ZipEntry newZipEntry(String path)
path
- the entry path.
public Object newArray(int length)
length
- the length.
public Object asArray(Object object)
object
- the object.
public Object append(Object array, Object element)
array
- the array or first element.element
- the element(s).
public Object insert(Object array, int index, Object element)
array
- the array or first element.index
- the index (-1 = append).element
- the element(s).
public Class<?> toClass(String className, boolean... options)
className
- the class name to load.options
- to disgard array dimensions and to prefer object classes.
public String toXML(Object object)
object
- the object to convert.
public String toXML(String className, Object object)
className
- the source class name.object
- the object to convert.
public String toXML(String className, Object object, String pattern)
className
- the source class name.object
- the object to convert.pattern
- the conversion pattern.
public String fromXML(Object object)
object
- the object to convert.
public Paint toPaint(String color)
color
- the name of the color.
public Stroke toStroke(String pattern)
pattern
- the stroke pattern.
public String cut(String str, int max)
str
- the string.max
- the max length.
public String cut(String str, int max, String tail)
str
- the string.max
- the max length.tail
- an optional tail.
public String wrap(String str)
str
- the string.
public String cite(Object obj)
obj
- the object.
public String quote(Object obj)
obj
- the object.
public String tab(int depth)
depth
- the depth.
public String[] split(String items, String delims)
items
- the items to convert.delims
- the delimiters to apply.
public String join(Object array, String delims)
array
- the array to join.delims
- the delimiters to apply.
public String escape(CharSequence sequence)
sequence
- the sequence.
public String escape(CharSequence sequence, int limit, String additions)
sequence
- the sequence.limit
- the escaping limit (-1 = unlimited).additions
- a list of additions.
public String unescape(CharSequence sequence)
sequence
- the sequence.
public String unescape(CharSequence sequence, int limit, String exceptions)
sequence
- the sequence.limit
- the escaping limit (-1 = unlimited).exceptions
- a list of exceptions.
public String digest(String algorithm, String string)
algorithm
- the digest algorithm.string
- the string to use.
public String digest(String algorithm, String string, String encoding)
algorithm
- the digest algorithm.string
- the string to use.encoding
- the character encoding.
public String digest(String algorithm, String salt, String string, String encoding)
algorithm
- the digest algorithm.salt
- the salt to use.string
- the string to use.encoding
- the character encoding.
public String printStackTrace(Throwable error)
error
- the throwable.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |