|
Servoy 3.5.x Public API | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.servoy.j2db.util.Utils
public class Utils
Normal Use: static methods
| Field Summary | |
|---|---|
static double |
DEFAULT_EQUALS_PRECISION
|
static float |
PPI
|
| Method Summary | |
|---|---|
static boolean |
arrayContentEquals(Object[] a,
Object[] a2)
|
static Object[] |
arrayInsert(Object[] src,
Object[] toAdd,
int position,
int n)
Insert an array into another array at a certain position. |
static String |
arrayToString(Object[] array)
|
static String |
calculateMD5Hash(String password)
|
static String |
changeClassNameToFileName(String name)
Change the passed class name to its corresponding file name. |
static String |
changeFileNameToClassName(String name)
Change the passed file name to its corresponding class name. |
static Connection |
closeConnection(Connection connection)
|
static InputStream |
closeInputStream(InputStream is)
|
static OutputStream |
closeOutputStream(OutputStream os)
|
static Reader |
closeReader(Reader r)
|
static ResultSet |
closeResultSet(ResultSet resultSet)
|
static PreparedStatement |
closeStatement(PreparedStatement statement)
|
static Statement |
closeStatement(Statement statement)
|
static Writer |
closeWriter(Writer w)
|
static int |
compare(double d1,
double d2)
|
static int |
compare(String s1,
String s2)
A String.compareTo() wrapper that will not choke on null values. |
static double |
convertPageFormatUnit(int oldUnit,
int newUnit,
double value)
|
static String |
convertToString(Object o)
Convert to string representation, remove trailing '.0' for numbers. |
static int |
countNumbers(String s)
count the numbers in a string |
static PageFormat |
createPageFormat(double width,
double height,
double lm,
double rm,
double tm,
double bm,
int orientation,
int units)
Create a PageFormat object from the dimensions and margins. |
static byte[] |
decodeBASE64(String data)
|
static String |
encodeBASE64(byte[] data)
|
static boolean |
equalObjects(Object oldObj,
Object obj)
|
static boolean |
equalObjects(Object oldObj,
Object obj,
double equalsPrecision)
|
static CharSequence |
escapeMarkup(String s)
Converts a Java String to an HTML markup string, but does not convert normal spaces to non-breaking space entities (<nbsp>). |
static CharSequence |
escapeMarkup(String s,
boolean escapeSpaces)
Converts a Java String to an HTML markup String by replacing illegal characters with HTML entities where appropriate. |
static CharSequence |
escapeMarkup(String s,
boolean escapeSpaces,
boolean convertToHtmlUnicodeEscapes)
Converts a Java String to an HTML markup String by replacing illegal characters with HTML entities where appropriate. |
static String |
findLastNumber(String s)
hardcore try to find the last number in a string |
static String |
findNumber(String s)
hardcore try to find a number in a string |
static String |
firstLetterToUpperCase(String string)
|
static String |
formatNumber(Locale locale,
double param,
int digits)
Format a given number (Visitor (locale) specific) |
static String |
formatNumber(Locale locale,
double param,
String digits)
Format a given number (Visitor (locale) specific) |
static String |
formatNumber(Locale locale,
Object param,
String digits)
Format a given number (Visitor (locale) specific) |
static String |
formatNumber(Locale locale,
String param,
String digits)
Format a given number (Visitor (locale) specific) |
static String |
formatTime(int msec,
String format)
Format a given number of miliseconds in a formatted time Note:if the time (in milliseconds) is smaller than ~month, it is calulated without a timezone) |
static String |
formatTime(long msec,
String format)
Format a given number of miliseconds in a formatted time Note:if the time (in milliseconds) is smaller than ~month, it is calulated without a timezone) |
static boolean |
getAsBoolean(Object o)
Try to parse the given object as a boolean |
static boolean |
getAsBoolean(String s)
Try to parse the given string as a boolean |
static double |
getAsDouble(Object o)
Try to parse the given object as a double |
static double |
getAsDouble(Object o,
boolean throwOnFail)
Try to parse the given object as a double |
static double |
getAsDouble(String s)
Try to parse the given string as a double |
static double |
getAsDouble(String s,
boolean throwOnFail)
Try to parse the given string as a double |
static float |
getAsFloat(Object o)
Try to parse the given object as a float |
static float |
getAsFloat(Object o,
boolean throwOnException)
Try to parse the given object as a float |
static float |
getAsFloat(String s)
Try to parse the given string as a float |
static float |
getAsFloat(String s,
boolean throwOnException)
Try to parse the given string as a float |
static int |
getAsInteger(Object o)
Try to parse the given object as an integer |
static int |
getAsInteger(Object o,
boolean throwOnException)
Try to parse the given object as an integer |
static int |
getAsInteger(String s)
Try to parse the given string as an integer |
static int |
getAsInteger(String s,
boolean throwOnException)
Try to parse the given string as an integer |
static long |
getAsLong(Object o)
Try to parse the given object as a long |
static long |
getAsLong(Object o,
boolean throwOnException)
Try to parse the given object as a long |
static long |
getAsLong(String s)
Try to parse the given string as a long |
static long |
getAsLong(String s,
boolean throwOnException)
Try to parse the given string as a long |
static byte[] |
getFileContent(File f)
|
static String |
getTXTFileContent(File f)
|
static byte[] |
getURLContent(String url)
|
static int |
indexOf(String string,
int ch,
int escape)
|
static int |
indexOf(String string,
int ch,
int escape,
int beginIndex)
|
static void |
invokeLater(com.servoy.j2db.IEventDelegator delegator,
List runnables)
|
static boolean |
isAppleMacOS()
|
static String |
longToHexString(long n,
int digits)
|
static void |
main(String[] args)
|
static Object |
mapToNullIfUnmanageble(Object value)
|
static String |
Matcher_quoteReplacement(String s)
Borrowed from java.util.regex.Matcher (since jre 1.5). |
static Timestamp |
parseDate(String datetime,
String format)
Create a Date (time) from a String, returns null on failure Example: Timestamp t = Utils.parseDate("23-06-1975 6:08 AM", "dd-MM-yyyy hh:mm a"); |
static int |
readerWriterCopy(Reader is,
Writer os)
|
static void |
releaseConnection(Connection connection)
|
static void |
rollback(Connection connection)
|
static String[] |
split(String string,
int separator,
int escape)
|
static int |
streamCopy(InputStream is,
OutputStream os)
|
static int |
streamCopy(InputStream is,
OutputStream os,
ActionListener l,
int actionSize)
|
static boolean |
stringEquals(String left,
String right)
Compares two strings no matter if they are null |
static boolean |
stringIsEmpty(String param)
tells whether a given String is an empty String |
static String |
stringJoin(Iterator iterator,
char separator)
Joins the elements of the provided Iterator into
a single String containing the provided elements. |
static String |
stringJoin(Object[] array,
char separator)
|
static String |
stringReplace(String org,
String source,
String destination)
|
static String |
stringReplace(String org,
String source,
String destination,
int replaceOccurence)
|
static String |
stringReplace(String org,
String source,
String destination,
int replaceOccurence,
boolean mustExact,
boolean caseInsensitiveSearch)
|
static String |
stringReplaceCaseInsensitiveSearch(String org,
String source,
String destination)
|
static String |
stringReplaceExact(String org,
String source,
String destination)
Method for replacing part of a string with a string |
static String |
stringReplaceRecursive(String org,
String source,
String destination)
|
static CharSequence |
toMultilineMarkup(CharSequence s)
Converts a String to multiline HTML markup by replacing newlines with line break entities (<br/>) and multiple occurrences of newline with paragraph break entities (<p>). |
static String |
unescape(String string,
int escape)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final double DEFAULT_EQUALS_PRECISION
public static final float PPI
| Method Detail |
|---|
public static boolean arrayContentEquals(Object[] a,
Object[] a2)
public static Object[] arrayInsert(Object[] src,
Object[] toAdd,
int position,
int n)
src - toAdd - position - n -
public static String arrayToString(Object[] array)
public static String calculateMD5Hash(String password)
public static String changeClassNameToFileName(String name)
name - Class name to be changed.
IllegalArgumentException - If a null name passed.public static String changeFileNameToClassName(String name)
name - Class name to be changed. If this does not represent
a Java class then null is returned.
IllegalArgumentException - If a null name passed.public static Connection closeConnection(Connection connection)
public static InputStream closeInputStream(InputStream is)
public static OutputStream closeOutputStream(OutputStream os)
public static Reader closeReader(Reader r)
public static ResultSet closeResultSet(ResultSet resultSet)
public static PreparedStatement closeStatement(PreparedStatement statement)
public static Statement closeStatement(Statement statement)
public static Writer closeWriter(Writer w)
public static int compare(double d1,
double d2)
public static int compare(String s1,
String s2)
s1 - left strings2 - right string
String.compareTo(java.lang.String)
public static double convertPageFormatUnit(int oldUnit,
int newUnit,
double value)
public static String convertToString(Object o)
public static int countNumbers(String s)
s - the string with the numbers
public static PageFormat createPageFormat(double width,
double height,
double lm,
double rm,
double tm,
double bm,
int orientation,
int units)
width - height - lm - left marginrm - right margintm - top marginbm - bottom marginorientation - units -
public static byte[] decodeBASE64(String data)
public static String encodeBASE64(byte[] data)
public static final boolean equalObjects(Object oldObj,
Object obj)
public static final boolean equalObjects(Object oldObj,
Object obj,
double equalsPrecision)
public static CharSequence escapeMarkup(String s)
s - The string to be escaped
escapeMarkup(String, boolean)
public static CharSequence escapeMarkup(String s,
boolean escapeSpaces)
s - The string to escapeescapeSpaces - True to replace ' ' with nonbreaking space
public static CharSequence escapeMarkup(String s,
boolean escapeSpaces,
boolean convertToHtmlUnicodeEscapes)
s - The string to escapeescapeSpaces - True to replace ' ' with nonbreaking spaceconvertToHtmlUnicodeEscapes - True to convert non-7 bit characters to unicode HTML (...)
public static String findLastNumber(String s)
s - the string with the number
public static String findNumber(String s)
s - the string with the number
public static String firstLetterToUpperCase(String string)
public static String formatNumber(Locale locale,
double param,
int digits)
param - the input numberdigits - number of digits
public static String formatNumber(Locale locale,
double param,
String digits)
param - the input numberdigits - number of digits
public static String formatNumber(Locale locale,
Object param,
String digits)
param - the input numberdigits - number of digits
public static String formatNumber(Locale locale,
String param,
String digits)
param - the input numberdigits - number of digits
public static String formatTime(int msec,
String format)
msec - the miliseconds (current time can be get by 'new java.util.Date().getTime()')format - the display format (format used from java.text.SimpleDateFormat!)
SimpleDateFormat
public static String formatTime(long msec,
String format)
msec - the miliseconds (current time can be get by 'new java.util.Date().getTime()')format - the display format
SimpleDateFormatpublic static boolean getAsBoolean(Object o)
o - the object (Boolean, Number, String, ...) to parse
public static boolean getAsBoolean(String s)
s - the string to parse
public static double getAsDouble(Object o)
o - the object (Number, String, ...) to parse
public static double getAsDouble(Object o,
boolean throwOnFail)
o - the object (Number, String, ...) to parsethrowOnFail - whether or not to throw a RuntimeException on failure
public static double getAsDouble(String s)
s - the string to parse
public static double getAsDouble(String s,
boolean throwOnFail)
s - the string to parsethrowOnFail - whether or not to throw a RuntimeException on failure
public static float getAsFloat(Object o)
o - the object (Number, String, ...) to parse
public static float getAsFloat(Object o,
boolean throwOnException)
o - the object (Number, String, ...) to parsethrowOnException - whether or not to throw a RuntimeException on failure
public static float getAsFloat(String s)
s - the string to parse
public static float getAsFloat(String s,
boolean throwOnException)
s - the string to parsethrowOnException - whether or not to throw a RuntimeException on failure
public static int getAsInteger(Object o)
o - the object (Number, String, ...) to parse
public static int getAsInteger(Object o,
boolean throwOnException)
o - the object (Number, String, ...) to parsethrowOnException - whether to throw an exception if parsing failed
public static int getAsInteger(String s)
s - the string to parse
public static int getAsInteger(String s,
boolean throwOnException)
s - the string to parsethrowOnException - whether or not to throw a RuntimeException on failure
RuntimeException - in case of trouble when throwOnException is truepublic static long getAsLong(Object o)
o - the object (String, Number, ...) to parse
public static long getAsLong(Object o,
boolean throwOnException)
o - the Object (Number, String, ...) to parsethrowOnException - whether or not to throw a RuntimeException on failure
public static long getAsLong(String s)
s - the string to parse
public static long getAsLong(String s,
boolean throwOnException)
s - the string to parsethrowOnException - whether or not to throw a RuntimeException on failure
public static byte[] getFileContent(File f)
public static String getTXTFileContent(File f)
public static byte[] getURLContent(String url)
public static int indexOf(String string,
int ch,
int escape)
public static int indexOf(String string,
int ch,
int escape,
int beginIndex)
public static void invokeLater(com.servoy.j2db.IEventDelegator delegator,
List runnables)
public static boolean isAppleMacOS()
public static String longToHexString(long n,
int digits)
public static void main(String[] args)
public static Object mapToNullIfUnmanageble(Object value)
public static String Matcher_quoteReplacement(String s)
public static Timestamp parseDate(String datetime,
String format)
datetime - the date as formatted stringformat - the format to be used
SimpleDateFormat
public static int readerWriterCopy(Reader is,
Writer os)
throws IOException
IOExceptionpublic static void releaseConnection(Connection connection)
public static void rollback(Connection connection)
public static String[] split(String string,
int separator,
int escape)
public static int streamCopy(InputStream is,
OutputStream os)
throws IOException
IOException
public static int streamCopy(InputStream is,
OutputStream os,
ActionListener l,
int actionSize)
throws IOException
IOException
public static boolean stringEquals(String left,
String right)
left - stringright - string
public static boolean stringIsEmpty(String param)
param -
public static String stringJoin(Iterator iterator,
char separator)
Joins the elements of the provided Iterator into
a single String containing the provided elements.
No delimiter is added before or after the list. Null objects or empty strings within the iteration are represented by empty strings.
iterator - the Iterator of values to join together, may be nullseparator - the separator character to use
null if null iterator input
public static String stringJoin(Object[] array,
char separator)
public static String stringReplace(String org,
String source,
String destination)
public static String stringReplace(String org,
String source,
String destination,
int replaceOccurence)
public static String stringReplace(String org,
String source,
String destination,
int replaceOccurence,
boolean mustExact,
boolean caseInsensitiveSearch)
public static String stringReplaceCaseInsensitiveSearch(String org,
String source,
String destination)
public static String stringReplaceExact(String org,
String source,
String destination)
org - the orginal stringsource - the string to searchdestination - the string to replace
public static String stringReplaceRecursive(String org,
String source,
String destination)
public static CharSequence toMultilineMarkup(CharSequence s)
s - String to transform
public static String unescape(String string,
int escape)
|
Copyright © 2009 Servoy B.V. | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||