Top Description Fields Constructors Methods
org.eclipse.persistence.internal.helper

public Class Helper

extends CoreHelper
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Closeable, .File, .FileNotFoundException, .FileOutputStream, .FileReader, .IOException, .PrintWriter, .Serializable, .StringWriter, .Writer, java.lang.reflect.Field, .Method, java.math.BigDecimal, .BigInteger, java.net.URI, .URISyntaxException, java.sql.Timestamp, java.util.ArrayList, .Calendar, .Collection, .Date, .Enumeration, .HashMap, .Hashtable, .Iterator, .List, .Map, .Queue, .StringTokenizer, .TimeZone, .Vector, java.util.concurrent.ConcurrentLinkedQueue, org.eclipse.persistence.config.SystemProperties, org.eclipse.persistence.exceptions.ConversionException, .ValidationException, org.eclipse.persistence.internal.core.helper.CoreHelper, org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor, org.eclipse.persistence.internal.security.PrivilegedAccessHelper, org.eclipse.persistence.logging.AbstractSessionLog, .SessionLog

INTERNAL:

Purpose: Define any useful methods that are missing from the base Java.

Field Summary

Modifier and TypeField and Description
protected static final Queue<Calendar>
calendarCache

PERF: Used to cache a set of calendars for conversion/printing purposes.

protected static String
CR

Hides org.eclipse.persistence.internal.core.helper.CoreHelper.CR.

Store CR string, for some reason \n is not platform independent.
protected static String
CURRENT_WORKING_DIRECTORY

Prime the platform-dependent current working directory

private static DateTimeFormatter
public static final String
private static String
private static String
protected static final TimeZone
defaultTimeZone

PERF: Cache default timezone for calendar conversion.

protected static String
FILE_SEPARATOR

Prime the platform-dependent file separator

public static final String
public static final String
public static final String
public static boolean
isZeroValidPrimaryKey

Backdoor to allow 0 to be used in primary keys.

public static final String
NL

Store newline string

private static final String
NULL_STRING

Used to convert null value to String.

public static final Object
NULL_VALUE

Used to store null values in hashtables, is helper because need to be serializable.

protected static String
PATH_SEPARATOR

Prime the platform-dependent path separator

public static final String
public static final String
public static final String
public static final String
public static final int
public static final int
public static final String
public static final String
public static boolean
shouldOptimizeDates

Used to configure JDBC level date optimization.

public static final String
SPACE

formatting strings for indenting

protected static String
TEMP_DIRECTORY

Prime the platform-dependent temporary directory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <E> void
addAllToVector(Vector<E> theVector, Vector<? extends E> elementsToAdd)

public static <T> List<T>
addAllUniqueToList(List<T> objects, List<T> objectsToAdd)

public static <T> Vector<T>
addAllUniqueToVector(Vector<T> objects, List<T> objectsToAdd)

public static Calendar
allocateCalendar()

PERF: This is used to optimize Calendar conversion/printing.

public static boolean
areTypesAssignable(List<Class<?>> types1, List<Class<?>> types2)

PUBLIC: Compare two vectors of types.

public static Object[]
arrayFromVector(Vector<?> vector)

Convert the specified vector into an array.

public static byte[]
buildBytesFromHexString(String hex)

Convert the HEX string to a byte array.

public static String
buildHexStringFromBytes(byte[] bytes)

Convert the byte array to a HEX string.

public static <T> Vector<T>
buildVectorFromMapElements(Map<?, T> map)

Create a new Vector containing all of the map elements.

public static String
buildZeroPrefix(int number, int totalDigits)

Build a numerical string with leading 0s.

public static String
buildZeroPrefixAndTruncTrailZeros(int number, int totalDigits)

Build a numerical string with leading 0s and truncate trailing zeros.

public static String
buildZeroPrefixWithoutSign(int number, int totalDigits)

Build a numerical string with leading 0s.

public static Calendar
calendarFromUtilDate(Date date)

Answer a Calendar from a date.

public static <T> boolean

Returns:

boolean
classImplementsInterface
(Class<T> aClass, Class<?> anInterface)

INTERNAL: Return whether a Class implements a specific interface, either directly or indirectly (through interface or implementation inheritance).

public static boolean

Returns:

boolean
classIsSubclass
(Class<?> subClass, Class<?> superClass)

INTERNAL: Return whether a Class is a subclass of, or the same as, another Class.

public static void
close(Closeable c)

Close a closeable object, eating the exception

public static boolean
compareArrays(Object[] array1, Object[] array2)

public static boolean
compareBigDecimals(BigDecimal one, BigDecimal two)

Compare two BigDecimals.

public static boolean
compareByteArrays(byte[] array1, byte[] array2)

public static boolean
compareCharArrays(char[] array1, char[] array2)

public static boolean
compareHashtables(Hashtable<?, ?> hashtable1, Hashtable<?, ?> hashtable2)

PUBLIC: Compare the elements in 2 hashtables to see if they are equal Added Nov 9, 2000 JED Patch 2.5.1.8

public static boolean
comparePotentialArrays(Object firstValue, Object secondValue)

Compare two potential arrays and return true if they are the same.

public static int
compareVersions(String version1, String version2)

INTERNAL: Compares two version in num.num.num.num.num*** format.

protected static int
compareVersions(List<Integer> list1, List<Integer> list2)

INTERNAL: Compares two lists of Integers -1, 0, 1 means the first list is less than, equal, greater than the second list.

public static <K, V> Map<K, V>
concatenateMaps(Map<? extends K, ? extends V> first, Map<? extends K, ? extends V> second)

Merge the two Maps into a new HashMap.

public static <E> List<E>
concatenateUniqueLists(List<? extends E> first, List<? extends E> second)

Return a new List with no duplicated values.

public static <E> Vector<E>
concatenateUniqueVectors(Vector<? extends E> first, Vector<? extends E> second)

Return a new vector with no duplicated values.

public static <E> Vector<E>
concatenateVectors(Vector<? extends E> first, Vector<? extends E> second)

public static String
convertLikeToRegex(String like)

Convert the SQL like pattern to a regex pattern.

public static boolean[]
copyBooleanArray(boolean[] original)

Copy an array of boolean to a new array

public static int[]
copyIntArray(int[] original)

Copy an array of int to a new array

public static String[]
copyStringArray(String[] original)

Copy an array of strings to a new array

public static <E> Vector<E>
copyVector(List<E>
- original vector
originalVector
,
int
- starting position in vector
startIndex
,
int
- ending position in vector
stopIndex
)

Return a copy of the vector containing a subset starting at startIndex and ending at stopIndex.

public static int
countOccurrencesOf(Object comparisonObject, List<?> list)

Return an integer representing the number of occurrences (using equals()) of the specified object in the specified list.

public static String
cr()

Hides org.eclipse.persistence.internal.core.helper.CoreHelper.cr.

Return a string containing the platform-appropriate characters for carriage return.
public static String
currentWorkingDirectory()

Return the name of the "current working directory".

public static Date
dateFromCalendar(Calendar calendar)

Answer a sql.Date from a Calendar.

public static Date
dateFromLong(Long
- milliseconds from the epoch (00:00:00 GMT Jan 1, 1970). Negative values represent dates prior to the epoch.
longObject
)

Answer a Date from a long This implementation is based on the java.sql.Date class, not java.util.Date.

public static Date

Returns:

- date representation of string
dateFromString
(String
- string representation of date
dateString
)

Answer a Date from a string representation.

public static Date

Returns:

- date representation of timestampObject
dateFromTimestamp
(Timestamp
- timestamp representation of date
timestamp
)

Answer a Date from a timestamp This implementation is based on the java.sql.Date class, not java.util.Date.

public static Date
dateFromYearMonthDate(int year, int month, int day)

Answer a Date with the year, month, date.

public static boolean
doesFileExist(String fileName)

Returns true if the file of this name does indeed exist

public static String
doubleSlashes(String path)

Double up \ to allow printing of directories for source code generation.

public static String
extractJarNameFromURL(URL url)

Extracts the actual path to the jar file.

public static String
fileSeparator()

Return a string containing the platform-appropriate characters for separating directory and file names.

public static String
getAttributeNameFromMethodName(String methodName)

INTERNAL: Method to convert a getXyz or isXyz method name to an xyz attribute name.

public static Queue<Calendar>
getCalendarCache()

PERF: Return the calendar cache use to avoid calendar creation for processing java.sql/util.Date/Time/Timestamp objects.

public static <T> Class<T>
getClassFromClasseName(final String className, final ClassLoader classLoader)

public static String
public static Method
getDeclaredMethod(Class<?> javaClass, String methodName)

INTERNAL: Returns a Method for the specified Class, method name, and that has no parameters.

public static Method
getDeclaredMethod(final Class<?> javaClass, final String methodName, final Class<?>[] methodParameterTypes)

INTERNAL: Returns a Method for the specified Class, method name, and formal parameter types.

public static DateTimeFormatter
public static String
public static String
public static TimeZone
getDefaultTimeZone()

PERF: Return the cached default platform.

public static Field
getField(final Class<?> javaClass, final String fieldName)

INTERNAL: Returns a Field for the specified Class and field name.

public static Object
getInstanceFromClass(final Class<?> classFullName)

Return the class instance from the class

public static Class<?>
getObjectClass(Class<?> javaClass)

Returns the object class.

public static String
getPackageName(Class<?> javaClass)

return a package name for the specified class.

public static String
getShortClassName(Class<?> javaClass)

Answers the unqualified class name for the provided class.

public static String
getShortClassName(String javaClassName)

Answers the unqualified class name from the specified String.

public static String
getShortClassName(Object object)

Answers the unqualified class name for the specified object.

public static String
getTabs(int noOfTabs)

Return a string containing the specified number of tabs.

public static String
getWeavedGetMethodName(String attributeName)

Return the set method name weaved for getting attribute value.

public static String
getWeavedSetMethodName(String attributeName)

Return the set method name weaved for setting attribute value.

public static String
getWeavedValueHolderGetMethodName(String attributeName)

Return the get method name weaved for a value-holder attribute.

public static String
getWeavedValueHolderSetMethodName(String attributeName)

Return the set method name weaved for a value-holder attribute.

public static boolean
public static int
indexOfNullElement(Vector<?> v, int index)

Returns the index of the the first null element found in the specified Vector starting the search at the starting index specified.

public static Queue<Calendar>
initCalendarCache()

PERF: Init the calendar cache use to avoid calendar creation for processing java.sql/util.Date/Time/Timestamp objects.

public static String

Returns:

The String representation of the unsigned integer value represented by the argument in hexadecimal or "null" if provided Integer argument is null.
integerToHexString
(final Integer
An Integer to be converted to a hexadecimal string.
i
)

Convert Integer to hexadecimal String.

public static boolean
isEquivalentToNull(Object value)

Check if the value is 0 (int/long) for primitive ids.

public static boolean
public static boolean
isNumberNegativeOrZero(Object value)

Returns true if the passed value is Number that is negative or equals to zero.

public static boolean
isPrimitiveWrapper(Class<?> classInQuestion)

ADVANCED returns true if the class in question is a primitive wrapper

public static boolean
isUpperCaseString(String s)

Returns true if the string given is an all upper case string

public static boolean
isVowel(char c)

Returns true if the character given is a vowel.

public static File[]
listFilesIn(File directory)

Return an array of the files in the specified directory.

public static <T> Vector<T>
makeVectorFromObject(Object theObject)

Make a Vector from the passed object.

public static void
outputClassFile(String className, byte[] classBytes, String outputPath)

Used by our byte code weaving to enable users who are debugging to output the generated class to a file

public static String
pathSeparator()

Return a string containing the platform-appropriate characters for separating entries in a path (e.g. the classpath)

public static String
printCalendar(Calendar calendar)

Print the Calendar.

public static String
printCalendar(Calendar calendar, boolean useLocalTime)

Print the Calendar.

public static String
printCalendarWithoutNanos(Calendar calendar)

Print the Calendar without the nanos portion.

public static String
printDate(Date date)

Print the sql.Date.

public static String
printDate(Calendar calendar)

Print the date part of the calendar.

public static String
printDate(Calendar calendar, boolean useLocalTime)

Print the date part of the calendar.

public static String
printStackTraceToString(Throwable aThrowable)

Return a String containing the printed stacktrace of an exception.

public static String
printTime(Time time)

Print the sql.Time.

public static String
printTime(Calendar calendar)

Print the time part of the calendar.

public static String
printTime(Calendar calendar, boolean useLocalTime)

Print the time part of the calendar.

public static String
printTimeFromMilliseconds(long milliseconds)

public static String
printTimestamp(Timestamp timestamp)

Print the sql.Timestamp.

public static String
printTimestampWithoutNanos(Timestamp timestamp)

Print the sql.Timestamp without the nanos portion.

public static String
printVector(Vector<?> vector)

Given a Vector, print it, even if there is a null in it

public static <K, V> Hashtable<K, V>
public static <K, V> Map<K, V>
rehashMap(Map<K, V> table)

public static void
releaseCalendar(Calendar calendar)

PERF: This is used to optimize Calendar conversion/printing.

public static String
removeAllButAlphaNumericToFit(String s1, int maximumStringLength)

Returns a String which has had enough non-alphanumeric characters removed to be equal to the maximumStringLength.

public static String
removeCharacterToFit(String s1, char aChar, int maximumStringLength)

Returns a String which has had enough of the specified character removed to be equal to the maximumStringLength.

public static String
removeVowels(String s1)

Returns a String which has had enough of the specified character removed to be equal to the maximumStringLength.

public static String
replaceFirstSubString(String source, String subString, String replacement)

Replaces the first subString of the source with the replacement.

public static <T> Vector<T>
reverseVector(Vector<T> theVector)

public static String

Returns:

- String
rightTrimString
(String
- timestamp representation of date
originalString
)

Returns a new string with all space characters removed from the right

public static void
public static void
public static void
setShouldOptimizeDates(boolean value)

Return if JDBC date access should be optimized.

public static String
shortenStringsByRemovingVowelsToFit(String s1, String s2, int maximumStringLength)

Returns a String which is a concatenation of two string which have had enough vowels removed from them so that the sum of the sized of the two strings is less than or equal to the specified size.

public static boolean
shouldOptimizeDates()

Return if JDBC date access should be optimized.

public static Date
sqlDateFromUtilDate(Date utilDate)

Answer a sql.Date from a timestamp.

public static void
systemBug(String description)

Can be used to mark code if a workaround is added for a JDBC driver or other bug.

public static String
tempDirectory()

Return the name of the "temporary directory".

public static Time
timeFromCalendar(Calendar calendar)

Answer a sql.Time from a Calendar.

public static Time

Returns:

- time representation of dateObject
timeFromDate
(Date
- time representation of date
date
)

Answer a Time from a Date This implementation is based on the java.sql.Date class, not java.util.Date.

public static Time
timeFromHourMinuteSecond(int hour, int minute, int second)

Answer a Time with the hour, minute, second.

public static Time
timeFromLong(Long
- milliseconds from the epoch (00:00:00 GMT Jan 1, 1970). Negative values represent dates prior to the epoch.
longObject
)

Answer a Time from a long

public static Time

Returns:

- time representation of string
timeFromString
(String
- string representation of time
timeString
)

Answer a Time from a string representation.

public static Time
timeFromTimestamp(Timestamp timestamp)

Answer a Time from a Timestamp Usus the Hours, Minutes, Seconds instead of getTime() ms value.

public static Timestamp
timestampFromCalendar(Calendar calendar)

Answer a Timestamp from a Calendar.

public static Timestamp
timestampFromDate(Date date)

Answer a Timestamp from a java.util.Date.

public static Timestamp
timestampFromLong(Long
- milliseconds from the epoch (00:00:00 GMT Jan 1, 1970). Negative values represent dates prior to the epoch.
millis
)

Answer a Time from a long

public static Timestamp
timestampFromLong(long
- milliseconds from the epoch (00:00:00 GMT Jan 1, 1970). Negative values represent dates prior to the epoch.
millis
)

Answer a Time from a long

public static Timestamp

Returns:

- timestamp representation of string
timestampFromString
(String
- string representation of timestamp
timestampString
)

Answer a Timestamp from a string representation.

public static Timestamp
timestampFromYearMonthDateHourMinuteSecondNanos(int year, int month, int date, int hour, int minute, int second, int nanos)

Answer a Timestamp with the year, month, day, hour, minute, second.

public static long
public static void
toDo(String description)

Can be used to mark code as need if something strange is seen.

public static String

Returns:

String
toSlashedClassName
(String dottedClassName)

Convert dotted format class name to slashed format class name.

public static URI
toURI(URL url)

Convert the URL into a URI allowing for special chars.

public static String
truncate(String originalString, int size)

If the size of the original string is larger than the passed in size, this method will remove the vowels from the original string.

public static Date
truncateDate(Date date)

Return a sql.Date with time component zeroed out.

public static Date
truncateDateIgnoreMilliseconds(Date date)

Return a sql.Date with time component zeroed out (with possible exception of milliseconds).

public static Date
utilDateFromLong(Long
- milliseconds from the epoch (00:00:00 GMT Jan 1, 1970). Negative values represent dates prior to the epoch.
longObject
)

Answer a Date from a long This implementation is based on the java.sql.Date class, not java.util.Date.

public static Date

Returns:

- java.util.Date representation of the sql.date
utilDateFromSQLDate
(Date
- sql.date representation of date
sqlDate
)

Answer a java.util.Date from a sql.date

public static Date

Returns:

- java.util.Date representation of the time
utilDateFromTime
(Time
- time representation of util date
time
)

Answer a java.util.Date from a sql.Time

public static Date

Returns:

- java.util.Date representation of timestampObject
utilDateFromTimestamp
(Timestamp
- timestamp representation of date
timestampObject
)

Answer a java.util.Date from a timestamp

public static <T> Vector<T>
vectorFromArray(T[] array)

Convert the specified array into a vector.

protected static List<Integer>
version(String version)

INTERNAL: Expects version in ***num.num.num.num.num*** format, converts it to a List of Integers.

public static void
writeHexString(byte[] bytes, Writer writer)

Convert the byte array to a HEX string.