|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgov.nih.nci.mageom.util.MAGEUtilities
public class MAGEUtilities
This class defines functions that are useful throughout MAGE.
| Field Summary | |
|---|---|
protected static java.lang.String[] |
_beanPkgNames
|
protected static MAGEUtilities |
_instance
|
protected static java.util.Properties |
_roles
|
protected static java.lang.String[] |
_scPkgNames
|
static int |
URL_FILE
Index for file in parsed URL results. |
static int |
URL_HOST
Index for host in parsed URL results. |
static int |
URL_PASSWORD
Index for password in parsed URL results. |
static int |
URL_PATH
Index for path in parsed URL results. |
static int |
URL_USERNAME
Index for username in parsed URL results. |
| Method Summary | |
|---|---|
static void |
appendOrderBy(java.lang.StringBuffer query,
java.lang.String order)
Appends an ORDER BY to an SQL query. |
static void |
appendWhere(java.lang.StringBuffer where,
java.lang.String exists)
Appends an EXISTS subquery to an SQL WHERE clause. |
static void |
appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.Boolean bool)
Appends an boolean to an SQL WHERE clause using 0/1 paradigm. |
static void |
appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.Long pattern)
Appends an item comparing a column to a pattern to an SQL WHERE clause. |
static void |
appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.Long pattern,
boolean caseInsensitive)
Appends an item comparing a column to a pattern to an SQL WHERE clause. |
static void |
appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.String pattern)
Appends an item comparing a column to a pattern to an SQL WHERE clause. |
static void |
appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.String[] items)
Appends a list of items to an SQL WHERE clause. |
static void |
appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.String pattern,
boolean caseInsensitive)
Appends an item comparing a column to a pattern to an SQL WHERE clause. |
static void |
appendWhere(java.lang.StringBuffer where,
java.lang.String column1,
java.lang.String criteria,
java.lang.String column2)
Appends an item comparing two columns to an SQL WHERE clause. |
static void |
appendWhere(java.lang.StringBuffer where,
java.lang.String column1,
java.lang.String criteria,
java.lang.String column2,
boolean caseInsensitive)
Appends an item comparing two columns to an SQL WHERE clause. |
static void |
appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.String year,
java.lang.String month,
java.lang.String day)
Appends a date to an SQL WHERE clause. |
static java.util.HashMap |
buildParamsMap(java.net.URL url)
|
static boolean |
containsWildcards(java.util.Collection values)
|
static boolean |
containsWildcards(java.lang.String str)
Determines if a string contains wildcards. |
static java.lang.Object |
convert(java.lang.String beanClassName,
java.lang.String attName,
java.lang.Object value)
|
static long |
convertToMilliseconds(int year,
int month,
int day)
Converts a year, month, and day into milliseconds since whenever the time for the Date and Calendar classes start. |
static java.util.Collection |
convertWildcards(java.util.Collection values)
|
static java.lang.String |
convertWildcards(java.lang.String str)
Turns non-SQL wildcards into SQL wildcards: * becomes %, and ? becomes _. |
static java.util.Collection |
escapeApostrophes(java.util.Collection values)
|
static java.lang.String |
escapeApostrophes(java.lang.String str)
Escapes apostrophies. |
static java.lang.reflect.Method |
findMethod(java.lang.Class klass,
java.lang.String match)
|
static java.lang.String |
getAssociatedBeanName(java.lang.String beanDotRole)
|
static java.lang.String |
getBeanClassName(java.lang.String beanName)
|
static java.lang.String |
getBeanName(java.lang.String theName)
|
static java.lang.String |
getBeanNameIgnoreCase(java.lang.String beanName)
|
static java.lang.String |
getBeanPackageName(java.lang.String p_beanName)
|
static java.lang.String |
getHTTPQueryURL(java.lang.String fromBeanName,
java.lang.Object fromObjId,
java.lang.String role,
java.lang.String toBeanName)
|
static java.lang.String |
getReciprocalRole(java.lang.String beanDotRole)
|
static java.lang.String |
getSCClassName(java.lang.String beanName)
|
static java.lang.String |
getSCPackageName(java.lang.String p_beanName)
|
static java.lang.String |
getShortName(java.lang.String theName)
|
static java.lang.String |
HTTPdecode(java.lang.String s)
Deprecated. use HTTPdecode(String s, String enc) |
static java.lang.String |
HTTPdecode(java.lang.String s,
java.lang.String enc)
Decodes a application/x-www-form-urlencoded string using a specific
encoding scheme. |
static java.lang.String |
HTTPencode(java.lang.String s)
Deprecated. use HTTPencode(String s, String enc) |
static java.lang.String |
HTTPencode(java.lang.String s,
java.lang.String enc)
Translates a string into application/x-www-form-urlencoded
format using a specific encoding scheme. |
static java.lang.Object |
invoke(java.lang.Object obj,
java.lang.String methodName,
java.lang.Object[] args)
|
static java.lang.Object |
invoke(java.lang.String className,
java.lang.String methodName,
java.lang.Object[] args)
|
static void |
loadProperties(java.lang.String propertyFile)
|
static java.lang.String[] |
parseURL(java.lang.String sUrl)
Parses a URL into its component pieces. |
static java.util.Collection |
quote(java.util.Collection values)
|
static java.util.HashMap |
readManagerDirectory(java.lang.String dirFileName)
Reads the contents of a MAGE manager directory, returning the contents as a HashMap relating managers to machine addresses. |
static java.util.Properties |
readPropertyFile(java.lang.String fileName)
Reads the contents of a properties file, returning the contents as a Properties object. |
static java.lang.Long |
runGetId(java.lang.Object bean)
|
static java.lang.Object |
runMethod(java.lang.Object bean,
java.lang.String attributeName)
|
static void |
runSetId(java.lang.Object bean,
java.lang.Object theValue)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static java.lang.String[] _beanPkgNames
protected static java.lang.String[] _scPkgNames
protected static java.util.Properties _roles
protected static MAGEUtilities _instance
public static final int URL_USERNAME
public static final int URL_PASSWORD
public static final int URL_HOST
public static final int URL_PATH
public static final int URL_FILE
| Method Detail |
|---|
public static java.lang.String HTTPencode(java.lang.String s)
throws java.io.UnsupportedEncodingException
s - string to encode
java.io.UnsupportedEncodingExceptionHTTPdecode(String)
public static java.lang.String HTTPencode(java.lang.String s,
java.lang.String enc)
throws java.io.UnsupportedEncodingException
application/x-www-form-urlencoded
format using a specific encoding scheme. This method uses the
supplied encoding scheme to obtain the bytes for unsafe
characters.
Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.
s - String to be translated.enc - The name of a supported
character
encoding.
String.
java.io.UnsupportedEncodingException - If the named encoding is not supportedpublic static java.lang.String HTTPdecode(java.lang.String s)
s - string to decode
HTTPencode(String)
public static java.lang.String HTTPdecode(java.lang.String s,
java.lang.String enc)
application/x-www-form-urlencoded string using a specific
encoding scheme.
The supplied encoding is used to determine
what characters are represented by any consecutive sequences of the
form "%xy".
Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.
s - string to decodeenc - The name of a supported
character
encoding.
Stringpublic static java.lang.String[] parseURL(java.lang.String sUrl)
sUrl - a URL as a String
public static long convertToMilliseconds(int year,
int month,
int day)
year - the year to convertmonth - the month to convert, starting from zeroday - the day to convert
Date,
Calendarpublic static java.util.HashMap readManagerDirectory(java.lang.String dirFileName)
The directory should be used to determine which machines in the MAGE system host which managers. The format of the file has each line contain the name of a manager as it it given to RMI and the IP address or DNS name of the machine it should run on, separated by whitespace.
LibraryManager 165.112.113.1 TissueManager 165.112.113.2 ...If one of the lines is formatted wrong, the directory will not include the manager on that line.
The hashtable returned uses the manager names as keys.
dirFileName - name of the file where the directory is stored
public static java.util.Properties readPropertyFile(java.lang.String fileName)
fileName - name of the file where the proteries are stored
public static boolean containsWildcards(java.lang.String str)
str - string to examine
public static java.lang.String convertWildcards(java.lang.String str)
str - string to convert
public static java.lang.String escapeApostrophes(java.lang.String str)
str - string to escape
public static void appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.String pattern)
where - WHERE clause so far, should be blank to startcolumn - name of columnpattern - pattern to compare againstappendWhere(StringBuffer,String,String,boolean)
public static void appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.Long pattern)
where - WHERE clause so far, should be blank to startcolumn - name of columnpattern - pattern to compare againstappendWhere(StringBuffer,String ,String,boolean)
public static void appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.Long pattern,
boolean caseInsensitive)
where - WHERE clause so far, should be blank to startcolumn - name of columnpattern - pattern to compare againstcaseInsensitive - whether to make it case insensitive
public static void appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.String pattern,
boolean caseInsensitive)
where - WHERE clause so far, should be blank to startcolumn - name of columnpattern - pattern to compare againstcaseInsensitive - whether to make it case insensitive
public static void appendWhere(java.lang.StringBuffer where,
java.lang.String column1,
java.lang.String criteria,
java.lang.String column2)
where - WHERE clause so far, should be blank to startcolumn1 - name of the first columncriteria - name of criteria, ie. = or LIKEcolumn2 - name of the second column
public static void appendWhere(java.lang.StringBuffer where,
java.lang.String column1,
java.lang.String criteria,
java.lang.String column2,
boolean caseInsensitive)
where - WHERE clause so far, should be blank to startcolumn1 - name of the first columncriteria - name of criteria, ie. = or LIKEcolumn2 - name of the second columncaseInsensitive - whether to make it case insensitive
public static void appendOrderBy(java.lang.StringBuffer query,
java.lang.String order)
query - query so farorder - the ORDER BY list
public static void appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.String[] items)
where - WHERE clause so far, should be blank to startcolumn - name of columnitems - array of items to look for
public static void appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.String year,
java.lang.String month,
java.lang.String day)
where - WHERE clause so far, should be blank to startcolumn - name of date column to compareyear - String representation of numeric yearmonth - String representation of three-letter monthday - String representation of numeric day
public static void appendWhere(java.lang.StringBuffer where,
java.lang.String exists)
where - WHERE clause so far, should be blank to startexists - the EXISTS subquery
public static void appendWhere(java.lang.StringBuffer where,
java.lang.String column,
java.lang.Boolean bool)
where - WHERE clause so far, should be blank to startcolumn - name of columnbool - the Booleanpublic static java.lang.String getShortName(java.lang.String theName)
public static java.lang.Long runGetId(java.lang.Object bean)
throws java.lang.Exception
java.lang.Exception
public static void runSetId(java.lang.Object bean,
java.lang.Object theValue)
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.String getBeanName(java.lang.String theName)
public static java.lang.Object runMethod(java.lang.Object bean,
java.lang.String attributeName)
throws java.lang.Exception
java.lang.Exceptionpublic static void loadProperties(java.lang.String propertyFile)
public static java.lang.Object invoke(java.lang.String className,
java.lang.String methodName,
java.lang.Object[] args)
throws java.lang.Exception
java.lang.Exception
public static java.lang.Object invoke(java.lang.Object obj,
java.lang.String methodName,
java.lang.Object[] args)
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.String getBeanPackageName(java.lang.String p_beanName)
public static java.lang.String getSCPackageName(java.lang.String p_beanName)
public static boolean containsWildcards(java.util.Collection values)
public static java.util.Collection escapeApostrophes(java.util.Collection values)
public static java.util.Collection convertWildcards(java.util.Collection values)
public static java.util.Collection quote(java.util.Collection values)
public static java.lang.String getAssociatedBeanName(java.lang.String beanDotRole)
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.String getSCClassName(java.lang.String beanName)
public static java.lang.String getBeanClassName(java.lang.String beanName)
public static java.util.HashMap buildParamsMap(java.net.URL url)
public static java.lang.Object convert(java.lang.String beanClassName,
java.lang.String attName,
java.lang.Object value)
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.String getReciprocalRole(java.lang.String beanDotRole)
public static java.lang.String getHTTPQueryURL(java.lang.String fromBeanName,
java.lang.Object fromObjId,
java.lang.String role,
java.lang.String toBeanName)
throws java.lang.Exception
java.lang.Exception
public static java.lang.reflect.Method findMethod(java.lang.Class klass,
java.lang.String match)
throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.String getBeanNameIgnoreCase(java.lang.String beanName)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||