|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.biomoby.shared.Utils
public abstract class Utils
This is a set of several utility methods which may be useful for writing both registry and client code. Some methods are specific for Apache Axis framework.
Constructor Summary | |
---|---|
Utils()
|
Method Summary | |
---|---|
static String |
checkOrCreateArticleName(String articleName,
String className)
Check or create an article name. |
static void |
createFile(File file,
String contents)
Create a file and fill it with given contents. |
static void |
createFile(File file,
StringBuffer contents)
Create a file and fill it with given contents. |
static String |
format(Object objectToBeFormatted,
int indent)
|
static InputStream |
getInputStream(URL url)
Gets an InputStream on a URL |
static URL |
getResourceURL(String path,
Class c)
Work in progress. |
static String |
javaEscape(String value)
Make 'value' a valid Java identifier by trimming it and by replacing "unwanted" characters by underscores. |
static String |
mobyEscape(String value)
Make sure that an article name does not collide with the member names in the top-level MobyObject. |
static String |
ms2Human(long millis)
Give back an elapsed time (given in milllis) in a human readable form. |
static String |
pureName(String lsid)
Return just the last part of the LSID identifier. |
static String |
readResource(String path,
Class c)
Work in progress. |
static String |
readResource(String filename,
Object resourceOwner)
Find the resource with the given 'filename', read it and return it. |
static String |
simpleClassName(String className)
Return just the last part of a Java class name (after the last dot). |
static String |
stackTraceIfSerious(Throwable e)
Return a stringified version of the given exception, containing - for more serious errors, such as NullPointerException - also a stack trace. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static String format(Object objectToBeFormatted, int indent)
public static void createFile(File file, String contents) throws MobyException
file
- to be createdcontents
- what to put in the created file
MobyException
- if something goes wrongpublic static void createFile(File file, StringBuffer contents) throws MobyException
file
- to be createdcontents
- what to put in the created file
MobyException
- if something goes wrongpublic static String ms2Human(long millis)
millis
- is a time interval in milliseconds
public static String pureName(String lsid)
lsid
- is an input
public static String readResource(String filename, Object resourceOwner) throws MobyException
filename
- of a resource is a '/'-separated path name that
identifies the resourceresourceOwner
- is any object whose class loader is used
to find and get the resource; typically one would put here
"this" when calling this method
MobyException
- if resource was found but an error
occured during its reading (IO problem, memory problem etc.)public static String readResource(String path, Class c) throws IOException
Slightly richer version of readResource(String,Object)
. It reads the resource using
platform default encoding (which may be not what you
want... something to be done better (TBD).
IOException
- if resource was found but an error
occured during its reading (IO problem, memory problem etc.)public static URL getResourceURL(String path, Class c)
Similar to readResource(String,Class)
but return just
an URL of a resource, not the resource itself.
public static String stackTraceIfSerious(Throwable e)
e
- to be reportedpublic static String simpleClassName(String className)
className
- whose last part is being looked for
public static String checkOrCreateArticleName(String articleName, String className)
This method checks if the given 'articleName' is not empty - and if it is then it replaces it with the given 'className' (each Biomoby object always has a class name).
It also trims the article name (removes starting and ending whitespaces).
articleName
- will be checked, or created if it is emptyclassName
- will be used to create an article name (if
necessary)
public static String mobyEscape(String value)
I must admit that this replacement is not full-proof: if a data type will have both article names 'value' and 'the_value' then this arrangement breaks...
This method is used at least from two places now (an XML Moby Parser and a MoSeS code generator) - that's why it ended up here in general utilities.
value
- will be checked (already expected not to be empty)
public static String javaEscape(String value)
value
- will be checked
public static InputStream getInputStream(URL url) throws MobyException
MobyException
|
Version: 1.1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |