|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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 | |
|---|---|
String |
cite(String str)
Returns a string within apostrophes. |
Collection |
counter()
Returns an endless counter. |
Collection |
counter(int size)
Returns a counter. |
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 |
fromXML(Object object)
Converts an XML encoded object to a text string. |
Object |
get(Object array,
int index)
Gets an indexed element. |
boolean |
isArray(Object object)
Checks whether an object is an array. |
boolean |
isBoolean(Object object)
Checks whether an object is a 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 |
isDate(String className)
Checks whether the specified class name 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 |
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 |
isNumeric(String className)
Checks whether the specified class name is numeric. |
boolean |
isPrimitive(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 |
isString(String className)
Checks whether the specified class name is character based. |
int |
length(Object object)
Gets the length of an object. |
Object |
none()
Returns a null. |
Map |
prefix(String prefix,
Map map)
Returns a map that is a prefixed subset of the given one. |
Map |
prefix(String prefix,
String delims,
Map 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(String str)
Returns a string within quotation. |
String |
replace(String source,
String from,
String to)
Replaces occurancies of the specified substring in a string to another substring. |
void |
set(Object array,
int index,
Object value)
Sets an indexed element. |
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. |
Map |
suffix(String suffix,
Map map)
Returns a map that is a suffixed subset of the given one. |
Map |
suffix(String suffix,
String delims,
Map map)
Returns a map that is a suffixed subset of the given one. |
String |
toActions(int permission)
Converts a permission mask into actions. |
Object |
toArray(Object object)
Returns an object in an array. |
Object |
toArray(Object first,
Object second)
Returns two objects in an array. |
boolean |
toBoolean(Object obj)
Converts a string into a boolean. |
StringBuffer |
toBuffer()
Returns an empty buffer. |
StringBuffer |
toBuffer(Object object)
Returns an initialized buffer. |
byte |
toByte(Object obj)
Converts an object into a byte. |
char |
toChar(Object obj)
Converts a string into a char. |
protected Class |
toClass(String className)
Returns the class instance of the named class. |
Comparator |
toComparator(List 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. |
List |
toList()
Returns an empty list. |
List |
toList(int size)
Returns a sized list. |
List |
toList(Object object)
Returns a collection, array or object as a list. |
long |
toLong(Object obj)
Converts a string into a long. |
Map |
toMap()
Returns an empty map. |
Object |
toObject(String className,
String string)
Converts a string into an object. |
Object |
toObject(String className,
String string,
String pattern)
Converts a string into an object. |
OrderedMap |
toOrderedMap()
Returns an empty ordered map. |
OrderedSet |
toOrderedSet()
Returns an empty ordered set. |
Set |
toOrderedSet(Object object)
Returns a collection, array or object as an ordered set. |
Paint |
toPaint(String color)
Converts a named color to a paint. |
int |
toPermission(String actions)
Converts an action string into a permission mask. |
String |
toPlainType(Class clazz)
Converts a class to its plain type. |
String |
toPlainType(String className)
Converts a qualified class name to its plain type. |
Set |
toSet()
Returns an empty set. |
Set |
toSet(Object object)
Returns a collection, array or object as a set. |
short |
toShort(Object obj)
Converts a string into a short. |
OutputStream |
toStream()
Returns a byte stream. |
String |
toString(Object object)
Converts an object into a string. |
String |
toString(String className,
Object object)
Converts an object of the named class into a string. |
String |
toString(String className,
Object object,
String pattern)
Converts an object of the named class into a string 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. |
OutputStream |
toZipStream(OutputStream out)
Returns a zip stream. |
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, getName, 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 Object get(Object array,
int index)
array - the array or list.index - the index.
public void set(Object array,
int index,
Object value)
array - the array or list.index - the index.value - the value.public int length(Object object)
object - the object.
public Map prefix(String prefix,
Map map)
prefix - a key prefix.map - the source map.
public Map prefix(String prefix,
String delims,
Map map)
prefix - a key prefix.delims - key delimiters.map - the source map.
public Map suffix(String suffix,
Map map)
suffix - a key suffix.map - the source map.
public Map suffix(String suffix,
String delims,
Map map)
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 isDate(String className)
className - the class name to check.
public boolean isNumeric(String className)
className - the class name to check.
public boolean isString(String className)
className - the class name to check.
public boolean isPrimitive(String className)
className - the class name to check.
public boolean isArray(Object object)
object - an object.
public boolean isString(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 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 toByte(Object obj)
obj - 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 String toString(Object object)
object - the object to convert.
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 Object toObject(String className,
String string)
className - the target class name.string - the string to convert.
public Object toObject(String className,
String string,
String pattern)
className - the target class name.string - the string to convert.pattern - the conversion pattern.
public String toActions(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 toPermission(String actions)
actions - the actions to convert.
public Collection counter()
public Collection 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 toComparator(List attributes)
attributes - a list of attributes.
public OrderedMap toOrderedMap()
public OrderedSet toOrderedSet()
public Set toOrderedSet(Object object)
object - the object.
public Map toMap()
public Set toSet()
public Set toSet(Object object)
object - the object.
public List toList()
public List toList(int size)
size - the size.
public List toList(Object object)
object - the object.
public StringBuffer toBuffer()
public StringBuffer toBuffer(Object object)
object - the initial object.
public OutputStream toStream()
public OutputStream toZipStream(OutputStream out)
out - the output stream.
public Object toArray(Object object)
object - the object.
public Object toArray(Object first,
Object second)
first - the first object.second - the second object.
protected Class toClass(String className)
className - the class name to load.
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 cite(String str)
str - the string.
public String quote(String str)
str - the string.
public String wrap(String str)
str - the string.
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 | |||||||||