|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vmm.core.Util
public class Util
Provides several static utility funtions that can be used in various places.
Constructor Summary | |
---|---|
Util()
|
Method Summary | |
---|---|
static long |
availableMemory()
Tries to compute the amount of memory that is available and not yet used. |
static java.awt.Cursor |
createCursorFromResource(java.lang.String imageResourceFileName,
int activeX,
int activeY)
A method that creates a cursor from an image file. |
static java.lang.String[] |
explode(java.lang.String str,
java.lang.String separators)
A convenience method that breaks up a string into tokens, where the tokens are substrings seprated by specified delimiters. |
static java.lang.Object |
externalStringToValue(java.lang.String str,
java.lang.Class valueType)
Tries to convert a string to a value of a specified type. |
static javax.swing.KeyStroke |
getAccelerator(java.lang.String description)
Returns a KeyStroke, typically for use as the accelerator for a menu command. |
static java.awt.geom.Point2D |
getPoint2DFromUser(java.awt.Component parent,
java.lang.String prompt)
|
static java.awt.geom.Point2D |
getPoint2DFromUser(java.awt.Component parent,
java.lang.String prompt,
double initialX,
double initialY)
|
static java.awt.geom.Point2D |
getPoint2DFromUser(java.awt.Component parent,
java.lang.String prompt,
double initialX,
double initialY,
java.lang.String nameForX,
java.lang.String nameForY)
|
static boolean |
isMacOS()
Test whether the program is running on Mac OS. |
static ComplexExpression |
parseComplexConstantExpression(java.lang.String expressionAsString)
Parses a string to produce a constant ComplexExpression. |
static Expression |
parseConstantExpression(java.lang.String expressionAsString)
Parses a string to produce a constant Expression. |
static java.lang.String |
toExternalString(java.lang.Object value)
Converts any value to a string -- hopefull a string that can be parsed by externalStringToValue(String, Class) to recover the original
value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static Expression parseConstantExpression(java.lang.String expressionAsString) throws ParseError
Parser
is
used to do the parsing.
expressionAsString
- The constant expression, represented as a string. A ParseError
is thrown if this is not a legal real-valued expression.
ParseError
public static ComplexExpression parseComplexConstantExpression(java.lang.String expressionAsString) throws ParseError
Parser
is
used to do the parsing.
expressionAsString
- The constant expression, represented as a string. A ParseError
is thrown if this is not a legal complex expression.
ParseError
public static java.awt.Cursor createCursorFromResource(java.lang.String imageResourceFileName, int activeX, int activeY)
getResource
method
of the Toolkit class. If the resource is not found or if any
other error occurs, then the return value of the method will
be null. The second and third parameters specify the
active point of the cursor -- the point that determines the
(x,y) position of the cursor in mouse events.
public static boolean isMacOS()
public static javax.swing.KeyStroke getAccelerator(java.lang.String description)
public static long availableMemory()
public static java.awt.geom.Point2D getPoint2DFromUser(java.awt.Component parent, java.lang.String prompt)
public static java.awt.geom.Point2D getPoint2DFromUser(java.awt.Component parent, java.lang.String prompt, double initialX, double initialY)
public static java.awt.geom.Point2D getPoint2DFromUser(java.awt.Component parent, java.lang.String prompt, double initialX, double initialY, java.lang.String nameForX, java.lang.String nameForY)
public static java.lang.String[] explode(java.lang.String str, java.lang.String separators)
str
- the string that is to be exploded; if null, then the return
value is nullseparators
- characters in this string are separatos between tokens
in the string that is being exploded. If this is null, then the
return value will be an array of length one containing str as its
only element.public static java.lang.String toExternalString(java.lang.Object value)
externalStringToValue(String, Class)
to recover the original
value. This method definitely works for: the wrapper types such as Double, Complex,
Color, Point2D, Vector3D, double[], int[]. For other types, this method
returns value.toString(), which might work. In no case does it throw an exception.
Note that a null value is converted to the string "##NULL##". For double and
float numbers, the special strings NaN, +INF, -INF, and EPSILON are used
to represent the special values Not-a-number, positive infinity, negative
infinity, and min_value (the smallest positive value). This method is
used in SaveAndRestore
and in other places where conversion of
an object to a string is needed.
public static java.lang.Object externalStringToValue(java.lang.String str, java.lang.Class valueType) throws java.lang.IllegalArgumentException
toExternalString(Object)
for at least the following
types: the wrapper types, Color, Point2D, Complex, Vector3D, double[], and int[].
The special string "##NULL##" is converted to the value null (except in the case
of primitive types.) The method will work for primitive types such as Double.TYPE.
Note that for the type Double.TYPE, the return value is of type Double (just as it
would be for Double.class). Aside from these built-in types, the method will try
to find a static method in the class named "fromString" and with one parameter of
type String. If such a method is found, it will be called and its return value
will be the return value of this mthod. If no such method is found, an attempt
is made to find a constructor in the class with one parameter of type String.
If such a constructor is found, it is invoked to produce the return value.
An exception of type IllegalArgumentException will be thrown if none of this succeeds in producing an object of the specified type. No other type of exception will be thrown.
java.lang.IllegalArgumentException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |