|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openide.util.Utilities
Otherwise uncategorized useful static methods.
Inner Class Summary | |
static class |
Utilities.UnorderableException
Exception indicating that a given list could not be partially-ordered. |
Field Summary | |
static int |
OS_AIX
Operating system is IBM AIX. |
static int |
OS_DEC
Deprecated. please use OS_TRU64 instead |
static int |
OS_HP
Operating system is HP-UX. |
static int |
OS_IRIX
Operating system is SGI IRIX. |
static int |
OS_LINUX
Operating system is Linux. |
static int |
OS_MAC
Operating system is Mac. |
static int |
OS_OS2
Operating system is OS/2. |
static int |
OS_OTHER
Operating system is unknown. |
static int |
OS_SOLARIS
Operating system is Solaris. |
static int |
OS_SUNOS
Operating system is Sun OS. |
static int |
OS_TRU64
Operating system is Compaq TRU64 Unix |
static int |
OS_UNIX_MASK
A mask for Unix platforms. |
static int |
OS_VMS
Operating system is Compaq OpenVMS |
static int |
OS_WIN_OTHER
Operating system is one of the Windows variants but we don't know which one it is |
static int |
OS_WIN2000
Operating system is Windows 2000. |
static int |
OS_WIN95
Operating system is Windows 95. |
static int |
OS_WIN98
Operating system is Windows 98. |
static int |
OS_WINDOWS_MASK
A mask for Windows platforms. |
static int |
OS_WINNT
Operating system is Windows NT. |
static int |
TYPICAL_WINDOWS_TASKBAR_HEIGHT
A height of the windows's taskbar |
Method Summary | |
static int |
arrayHashCode(Object[] arr)
Compute hash code of array. |
static boolean |
compareObjects(Object o1,
Object o2)
Safe equality check. |
static boolean |
compareObjectsImpl(Object o1,
Object o2,
int checkArraysDepth)
Safe equality check with array recursion. |
static String |
escapeParameters(String[] params)
Complementary method to parseParameters |
static BeanInfo |
getBeanInfo(Class clazz)
Central method for obtaining BeanInfo for potential JavaBean classes. |
static BeanInfo |
getBeanInfo(Class clazz,
Class stopClass)
Central method for obtaining BeanInfo for potential JavaBean classes, with a stop class. |
static String |
getClassName(Class clazz)
Assemble a human-presentable class name for a specified class. |
static Component |
getFocusTraversableComponent(Component c)
Find a focus-traverable component. |
static Class |
getObjectType(Class c)
Get the object type for given primitive type. |
static int |
getOperatingSystem()
Get the operating system on which the IDE is running. |
static Class |
getPrimitiveType(Class c)
Get the primitive type for given object type. |
static Dimension |
getScreenSize()
|
static String |
getShortClassName(Class clazz)
Assemble a human-presentable class name for a specified class (omitting the package). |
static boolean |
isJavaIdentifier(String id)
Test whether a given string is a valid Java identifier. |
static boolean |
isLargeFrameIcons()
Test whether the operating system supports icons on frames (windows). |
static boolean |
isUnix()
Test whether the IDE is running on some variant of Unix. |
static boolean |
isWindows()
Test whether the IDE is running on some variant of Windows. |
static String |
keyToString(KeyStroke stroke)
Converts a Swing key stroke descriptor to a familiar Emacs-like name. |
static Image |
loadImage(String resourceID)
Loads an image from the specified resource ID. |
static Image |
mergeImages(Image image1,
Image image2,
int x,
int y)
This method merges two images into the new one. |
static String[] |
parseParameters(String s)
Parses parameters from a given string in shell-like manner. |
static List |
partialSort(List l,
Comparator c,
boolean stable)
Sort a list according to a specified partial order. |
static String |
pureClassName(String fullName)
Turn full name of an inner class into its pure form. |
static String |
replaceString(String original,
String replaceFrom,
String replaceTo)
Search-and-replace fixed string matches within a string. |
static int |
showJFileChooser(JFileChooser chooser,
Component parent,
String approveButtonText)
Utility method for avoiding of memory leak in JDK 1.3 / JFileChooser.showDialog(...) |
static KeyStroke |
stringToKey(String s)
Construct a new key description from a given universal string description. |
static KeyStroke[] |
stringToKeys(String s)
Convert a space-separated list of user-friendly key binding names to a list of Swing key strokes. |
static Object[] |
toObjectArray(Object array)
Convert an array of primitive types to an array of objects. |
static Object |
toPrimitiveArray(Object[] array)
Convert an array of objects to an array of primitive types. |
static String |
translate(String className)
Handles repackaging whole IDE for runtime compatibility. |
static String |
wrapString(String original,
int width,
boolean wrapWords,
boolean removeNewLines)
Deprecated. Use (String, int, BreakIterator, boolean) as it is friendlier to I18N. |
static String |
wrapString(String original,
int width,
BreakIterator breakIterator,
boolean removeNewLines)
Wrap multi-line strings. |
static String[] |
wrapStringToArray(String original,
int width,
boolean wrapWords,
boolean removeNewLines)
Deprecated. use wrapStringToArray(String, int, BreakIterator, boolean) since it is better for I18N |
static String[] |
wrapStringToArray(String original,
int width,
BreakIterator breakIterator,
boolean removeNewLines)
Wrap multi-line strings (and get the individual lines). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int OS_WINNT
public static final int OS_WIN95
public static final int OS_WIN98
public static final int OS_SOLARIS
public static final int OS_LINUX
public static final int OS_HP
public static final int OS_AIX
public static final int OS_IRIX
public static final int OS_SUNOS
public static final int OS_TRU64
public static final int OS_DEC
public static final int OS_OS2
public static final int OS_MAC
public static final int OS_WIN2000
public static final int OS_VMS
public static final int OS_WIN_OTHER
public static final int OS_OTHER
public static final int OS_WINDOWS_MASK
public static final int OS_UNIX_MASK
public static final int TYPICAL_WINDOWS_TASKBAR_HEIGHT
Method Detail |
public static final int getOperatingSystem()
OS_*
constants (such as OS_WINNT
)public static final boolean isWindows()
true
if Windows, false
if some other manner of operating systempublic static final boolean isUnix()
true
some sort of Unix, false
if some other manner of operating systempublic static final boolean isJavaIdentifier(String id)
id
- string which should be checkedtrue
if a valid identifierpublic static BeanInfo getBeanInfo(Class clazz) throws IntrospectionException
BeanInfo
for potential JavaBean classes.
This implementation provides additional functionality for Swing bean infos.clazz
- class of the bean to provide the BeanInfo
forIntrospectionException
- for the usual reasonsIntrospector.getBeanInfo(Class)
public static BeanInfo getBeanInfo(Class clazz, Class stopClass) throws IntrospectionException
BeanInfo
for potential JavaBean classes, with a stop class.
This implementation provides additional functionality for Swing bean infos.clazz
- class of the bean to provide the BeanInfo
forstopClass
- the stop classIntrospectionException
- for the usual reasonsIntrospector.getBeanInfo(Class, Class)
public static String[] wrapStringToArray(String original, int width, boolean wrapWords, boolean removeNewLines)
wrapStringToArray(String, int, BreakIterator, boolean)
since it is better for I18N
original
- the original string to wrapwidth
- the maximum width of lineswrapWords
- if true
, the lines are wrapped on word boundaries (if possible);
if false
, character boundaries are usedremoveNewLines
- if true
, any newlines in the original string are ignoredpublic static String[] wrapStringToArray(String original, int width, BreakIterator breakIterator, boolean removeNewLines)
original
- the original string to wrapwidth
- the maximum width of linesbreakIterator
- breaks original to chars, words, sentences, depending on what instance you provide.removeNewLines
- if true
, any newlines in the original string are ignoredpublic static String wrapString(String original, int width, BreakIterator breakIterator, boolean removeNewLines)
original
- the original string to wrapwidth
- the maximum width of lineswrapWords
- if true
, the lines are wrapped on word boundaries (if possible);
if false
, character boundaries are usedremoveNewLines
- if true
, any newlines in the original string are ignoredpublic static String wrapString(String original, int width, boolean wrapWords, boolean removeNewLines)
(String, int, BreakIterator, boolean)
as it is friendlier to I18N.
original
- the original string to wrapwidth
- the maximum width of lineswrapWords
- if true
, the lines are wrapped on word boundaries (if possible);
if false
, character boundaries are usedremoveNewLines
- if true
, any newlines in the original string are ignoredpublic static String replaceString(String original, String replaceFrom, String replaceTo)
original
- the original stringreplaceFrom
- the substring to be findreplaceTo
- the substring to replace it withpublic static final String pureClassName(String fullName)
fullName
- e.g. some.pkg.SomeClass$Inner
Inner
public static final boolean isLargeFrameIcons()
true
if it does notpublic static int arrayHashCode(Object[] arr)
arr
- array of objects, can contain null
sObject.hashCode()
public static boolean compareObjects(Object o1, Object o2)
null
Object.equals(java.lang.Object)
null
-safe, so if one of the parameters is true and the second not,
it returns false
.o1
- the first object to compareo2
- the second object to comparetrue
if the objects are equalpublic static boolean compareObjectsImpl(Object o1, Object o2, int checkArraysDepth)
o1
- the first object to compareo2
- the second object to comparecheckArraysDepth
- the depth to which arrays should be compared for equality (negative for infinite depth, zero for no comparison of elements, one for shallow, etc.)true
if the objects are equalcompareObjects(Object, Object)
public static String getClassName(Class clazz)
java.lang.String[]
.clazz
- the class to namepublic static String getShortClassName(Class clazz)
String[]
.clazz
- the class to namepublic static Object toPrimitiveArray(Object[] array)
Integer[]
would be changed to an int[]
.array
- the wrapper arrayIllegalArgumentException
- if the array element type is not a primitive wrapperpublic static Object[] toObjectArray(Object array)
int[]
would be turned into an Integer[]
.array
- the primitive arrayIllegalArgumentException
- if the array element type is not primitivepublic static Class getObjectType(Class c)
c
- primitive type (e.g. int
)Integer
)public static Class getPrimitiveType(Class c)
c
- object type (e.g. Integer
)int
)public static Component getFocusTraversableComponent(Component c)
c
- the component to look innull
Component.isFocusTraversable()
public static String[] parseParameters(String s)
NbProcessDescriptor
you should be able to:
c:\Program Files\jdk\bin\javac
.
-Dname=value
.
"c:\program files\jdk\bin\java" -Dmessage="Hello /\\/\\ there!" -Xmx128m
This example would create the following executable name and arguments:
c:\program files\jdk\bin\java
-Dmessage=Hello /\/\ there!
-Xmx128m
s
- a string to parsepublic static String escapeParameters(String[] params)
parseParameters(java.lang.String)
public static String keyToString(KeyStroke stroke)
stroke
- key descriptionCS-F1
for control-shift-function key one)stringToKey(java.lang.String)
public static KeyStroke stringToKey(String s)
KeyStroke
object used in Swing.
This format has following form:
[C][A][S][M]-identifier
Where:
C
stands for the Control key
A
stands for the Alt key
S
stands for the Shift key
M
stands for the Meta key
KeyEvent
but
without the leading VK_
characters. So KeyEvent.VK_ENTER
is described as
ENTER
.s
- the string with the description of the keynull
if the string does not represent any valid keypublic static KeyStroke[] stringToKeys(String s)
s
- the string with keysnull
if the string description is not validstringToKey(java.lang.String)
public static final Dimension getScreenSize()
public static final int showJFileChooser(JFileChooser chooser, Component parent, String approveButtonText)
parent
- approveButtonText
- public static List partialSort(List l, Comparator c, boolean stable) throws Utilities.UnorderableException
l
- the list to sort (will not be modified)c
- a comparator to impose the partial order; "equal" means that the elements
are not ordered with respect to one another, i.e. may be only a partial orderstable
- whether to attempt a stable sort, meaning that the position of elements
will be disturbed as little as possible; might be slightly slowerUtilities.UnorderableException
- if the specified partial order is inconsistent on this listpublic static String translate(String className)
name
- fully qualified name of a class to translateNullPointerException
- iff name is nullpublic static final Image mergeImages(Image image1, Image image2, int x, int y)
null
, it makes default transparent 16x16 image.image1
- underlying imageimage2
- second imagex
- x position of top-left cornery
- y position of top-left cornerpublic static final Image loadImage(String resourceID)
resourceID
- resource path of the icon
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |