Class Helper
- java.lang.Object
-
- org.eclipse.persistence.internal.core.helper.CoreHelper
-
- org.eclipse.persistence.internal.helper.Helper
-
- All Implemented Interfaces:
java.io.Serializable
public class Helper extends CoreHelper implements java.io.Serializable
INTERNAL:Purpose: Define any useful methods that are missing from the base Java.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Queue<java.util.Calendar>calendarCachePERF: Used to cache a set of calendars for conversion/printing purposes.protected static java.lang.StringCRStore CR string, for some reason \n is not platform independent.protected static java.lang.StringCURRENT_WORKING_DIRECTORYPrime the platform-dependent current working directorystatic java.lang.StringDEFAULT_DATABASE_DELIMITERprotected static java.util.TimeZonedefaultTimeZonePERF: Cache default timezone for calendar conversion.protected static java.lang.StringFILE_SEPARATORPrime the platform-dependent file separatorstatic java.lang.StringGET_PROPERTY_METHOD_PREFIXstatic java.lang.StringINDENTstatic java.lang.StringIS_PROPERTY_METHOD_PREFIXstatic booleanisZeroValidPrimaryKeyDeprecated.Instead of setting the flag to true use: session.getProject().setDefaultIdValidation(IdValidation.NULL)static java.lang.StringNLStore newline stringstatic java.lang.ObjectNULL_VALUEUsed to store null values in hashtables, is helper because need to be serializable.protected static java.lang.StringPATH_SEPARATORPrime the platform-dependent path separatorstatic java.lang.StringPERSISTENCE_FIELDNAME_POSTFIXstatic java.lang.StringPERSISTENCE_FIELDNAME_PREFIXstatic java.lang.StringPERSISTENCE_GETstatic java.lang.StringPERSISTENCE_SETstatic intPOSITION_AFTER_GET_PREFIXstatic intPOSITION_AFTER_IS_PREFIXstatic java.lang.StringSET_IS_PROPERTY_METHOD_PREFIXstatic java.lang.StringSET_PROPERTY_METHOD_PREFIXstatic booleanshouldOptimizeDatesUsed to configure JDBC level date optimization.static java.lang.StringSPACEformatting strings for indentingprotected static java.lang.StringTEMP_DIRECTORYPrime the platform-dependent temporary directory
-
Constructor Summary
Constructors Constructor Description Helper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddAllToVector(java.util.Vector theVector, java.util.Vector elementsToAdd)static java.util.ListaddAllUniqueToList(java.util.List objects, java.util.List objectsToAdd)static java.util.VectoraddAllUniqueToVector(java.util.Vector objects, java.util.List objectsToAdd)static java.util.CalendarallocateCalendar()PERF: This is used to optimize Calendar conversion/printing.static booleanareTypesAssignable(java.util.List types1, java.util.List types2)PUBLIC: Compare two vectors of types.static java.lang.Object[]arrayFromVector(java.util.Vector vector)Convert the specified vector into an array.static byte[]buildBytesFromHexString(java.lang.String hex)Convert the HEX string to a byte array.static java.lang.StringbuildHexStringFromBytes(byte[] bytes)Convert the byte array to a HEX string.static java.util.VectorbuildVectorFromMapElements(java.util.Map map)Create a new Vector containing all of the map elements.static java.lang.StringbuildZeroPrefix(int number, int totalDigits)Build a numerical string with leading 0s.static java.lang.StringbuildZeroPrefixAndTruncTrailZeros(int number, int totalDigits)Build a numerical string with leading 0s and truncate trailing zeros.static java.lang.StringbuildZeroPrefixWithoutSign(int number, int totalDigits)Build a numerical string with leading 0s.static java.util.CalendarcalendarFromUtilDate(java.util.Date date)Answer a Calendar from a date.static booleanclassImplementsInterface(java.lang.Class aClass, java.lang.Class anInterface)INTERNAL: Return whether a Class implements a specific interface, either directly or indirectly (through interface or implementation inheritance).static booleanclassIsSubclass(java.lang.Class subClass, java.lang.Class superClass)INTERNAL: Return whether a Class is a subclass of, or the same as, another Class.static voidclose(java.io.Closeable c)Close a closeable object, eating the exceptionstatic booleancompareArrays(java.lang.Object[] array1, java.lang.Object[] array2)static booleancompareBigDecimals(java.math.BigDecimal one, java.math.BigDecimal two)Compare two BigDecimals.static booleancompareByteArrays(byte[] array1, byte[] array2)static booleancompareCharArrays(char[] array1, char[] array2)static booleancompareHashtables(java.util.Hashtable hashtable1, java.util.Hashtable hashtable2)PUBLIC: Compare the elements in 2 hashtables to see if they are equal Added Nov 9, 2000 JED Patch 2.5.1.8static booleancomparePotentialArrays(java.lang.Object firstValue, java.lang.Object secondValue)Compare two potential arrays and return true if they are the same.static intcompareVersions(java.lang.String version1, java.lang.String version2)INTERNAL: Compares two version in num.num.num.num.num*** format.protected static intcompareVersions(java.util.List<java.lang.Integer> list1, java.util.List<java.lang.Integer> list2)INTERNAL: Compares two lists of Integers -1, 0, 1 means the first list is less than, equal, greater than the second list.static java.util.MapconcatenateMaps(java.util.Map first, java.util.Map second)Merge the two Maps into a new HashMap.static java.util.ListconcatenateUniqueLists(java.util.List first, java.util.List second)Return a new List with no duplicated values.static java.util.VectorconcatenateUniqueVectors(java.util.Vector first, java.util.Vector second)Return a new vector with no duplicated values.static java.util.VectorconcatenateVectors(java.util.Vector first, java.util.Vector second)static java.lang.StringconvertLikeToRegex(java.lang.String like)Convert the SQL like pattern to a regex pattern.static boolean[]copyBooleanArray(boolean[] original)Copy an array of boolean to a new arraystatic int[]copyIntArray(int[] original)Copy an array of int to a new arraystatic java.lang.String[]copyStringArray(java.lang.String[] original)Copy an array of strings to a new arraystatic java.util.VectorcopyVector(java.util.List originalVector, int startIndex, int stopIndex)Return a copy of the vector containing a subset starting at startIndex and ending at stopIndex.static intcountOccurrencesOf(java.lang.Object comparisonObject, java.util.List list)Return an integer representing the number of occurrences (using equals()) of the specified object in the specified list.static java.lang.Stringcr()Return a string containing the platform-appropriate characters for carriage return.static java.lang.StringcurrentWorkingDirectory()Return the name of the "current working directory".static java.sql.DatedateFromCalendar(java.util.Calendar calendar)Answer a sql.Date from a Calendar.static java.sql.DatedateFromLong(java.lang.Long longObject)Answer a Date from a long This implementation is based on the java.sql.Date class, not java.util.Date.static java.sql.DatedateFromString(java.lang.String dateString)Answer a Date from a string representation.static java.sql.DatedateFromTimestamp(java.sql.Timestamp timestamp)Answer a Date from a timestamp This implementation is based on the java.sql.Date class, not java.util.Date.static java.sql.DatedateFromYearMonthDate(int year, int month, int day)Answer a Date with the year, month, date.static booleandoesFileExist(java.lang.String fileName)Returns true if the file of this name does indeed existstatic java.lang.StringdoubleSlashes(java.lang.String path)Double up \ to allow printing of directories for source code generation.static java.lang.StringextractJarNameFromURL(java.net.URL url)Extracts the actual path to the jar file.static java.lang.StringfileSeparator()Return a string containing the platform-appropriate characters for separating directory and file names.static java.lang.StringgetAttributeNameFromMethodName(java.lang.String methodName)INTERNAL: Method to convert a getXyz or isXyz method name to an xyz attribute name.static java.util.Queue<java.util.Calendar>getCalendarCache()PERF: Return the calendar cache use to avoid calendar creation for processing java.sql/util.Date/Time/Timestamp objects.static java.lang.ClassgetClassFromClasseName(java.lang.String className, java.lang.ClassLoader classLoader)static java.lang.StringgetComponentTypeNameFromArrayString(java.lang.String aString)static java.lang.reflect.MethodgetDeclaredMethod(java.lang.Class javaClass, java.lang.String methodName)INTERNAL: Returns a Method for the specified Class, method name, and that has no parameters.static java.lang.reflect.MethodgetDeclaredMethod(java.lang.Class javaClass, java.lang.String methodName, java.lang.Class[] methodParameterTypes)INTERNAL: Returns a Method for the specified Class, method name, and formal parameter types.static java.time.format.DateTimeFormattergetDefaultDateTimeFormatter()static java.lang.StringgetDefaultEndDatabaseDelimiter()static java.lang.StringgetDefaultStartDatabaseDelimiter()static java.util.TimeZonegetDefaultTimeZone()PERF: Return the cached default platform.static java.lang.reflect.FieldgetField(java.lang.Class javaClass, java.lang.String fieldName)INTERNAL: Returns a Field for the specified Class and field name.static java.lang.ObjectgetInstanceFromClass(java.lang.Class classFullName)Return the class instance from the classstatic java.lang.ClassgetObjectClass(java.lang.Class javaClass)Returns the object class.static java.lang.StringgetPackageName(java.lang.Class javaClass)return a package name for the specified class.static java.lang.StringgetShortClassName(java.lang.Class javaClass)Answers the unqualified class name for the provided class.static java.lang.StringgetShortClassName(java.lang.Object object)Answers the unqualified class name for the specified object.static java.lang.StringgetShortClassName(java.lang.String javaClassName)Answers the unqualified class name from the specified String.static java.lang.StringgetTabs(int noOfTabs)Return a string containing the specified number of tabs.static java.lang.StringgetWeavedGetMethodName(java.lang.String attributeName)Return the set method name weaved for getting attribute value.static java.lang.StringgetWeavedSetMethodName(java.lang.String attributeName)Return the set method name weaved for setting attribute value.static java.lang.StringgetWeavedValueHolderGetMethodName(java.lang.String attributeName)Return the get method name weaved for a value-holder attribute.static java.lang.StringgetWeavedValueHolderSetMethodName(java.lang.String attributeName)Return the set method name weaved for a value-holder attribute.static booleanhasLob(java.util.Collection<DatabaseField> fields)static intindexOfNullElement(java.util.Vector v, int index)Returns the index of the the firstnullelement found in the specifiedVectorstarting the search at the starting index specified.static java.util.QueueinitCalendarCache()PERF: Init the calendar cache use to avoid calendar creation for processing java.sql/util.Date/Time/Timestamp objects.static java.lang.StringintegerToHexString(java.lang.Integer i)ConvertIntegerto hexadecimalString.static booleanisEquivalentToNull(java.lang.Object value)Check if the value is 0 (int/long) for primitive ids.static booleanisLob(DatabaseField field)static booleanisNumberNegativeOrZero(java.lang.Object value)Returns true if the passed value is Number that is negative or equals to zero.static booleanisPrimitiveWrapper(java.lang.Class classInQuestion)ADVANCED returns true if the class in question is a primitive wrapperstatic booleanisUpperCaseString(java.lang.String s)Returns true if the string given is an all upper case stringstatic booleanisVowel(char c)Returns true if the character given is a vowel.static java.io.File[]listFilesIn(java.io.File directory)Return an array of the files in the specified directory.static java.util.VectormakeVectorFromObject(java.lang.Object theObject)Make a Vector from the passed object.static voidoutputClassFile(java.lang.String className, byte[] classBytes, java.lang.String outputPath)Used by our byte code weaving to enable users who are debugging to output the generated class to a filestatic java.lang.StringpathSeparator()Return a string containing the platform-appropriate characters for separating entries in a path (e.g.static java.lang.StringprintCalendar(java.util.Calendar calendar)Print the Calendar.static java.lang.StringprintCalendar(java.util.Calendar calendar, boolean useLocalTime)Print the Calendar.static java.lang.StringprintCalendarWithoutNanos(java.util.Calendar calendar)Print the Calendar without the nanos portion.static java.lang.StringprintDate(java.sql.Date date)Print the sql.Date.static java.lang.StringprintDate(java.util.Calendar calendar)Print the date part of the calendar.static java.lang.StringprintDate(java.util.Calendar calendar, boolean useLocalTime)Print the date part of the calendar.static java.lang.StringprintStackTraceToString(java.lang.Throwable aThrowable)Return a String containing the printed stacktrace of an exception.static java.lang.StringprintTime(java.sql.Time time)Print the sql.Time.static java.lang.StringprintTime(java.util.Calendar calendar)Print the time part of the calendar.static java.lang.StringprintTime(java.util.Calendar calendar, boolean useLocalTime)Print the time part of the calendar.static java.lang.StringprintTimeFromMilliseconds(long milliseconds)static java.lang.StringprintTimestamp(java.sql.Timestamp timestamp)Print the sql.Timestamp.static java.lang.StringprintTimestampWithoutNanos(java.sql.Timestamp timestamp)Print the sql.Timestamp without the nanos portion.static java.lang.StringprintVector(java.util.Vector vector)Given a Vector, print it, even if there is a null in itstatic java.util.HashtablerehashHashtable(java.util.Hashtable table)static java.util.MaprehashMap(java.util.Map table)static voidreleaseCalendar(java.util.Calendar calendar)PERF: This is used to optimize Calendar conversion/printing.static java.lang.StringremoveAllButAlphaNumericToFit(java.lang.String s1, int maximumStringLength)Returns a String which has had enough non-alphanumeric characters removed to be equal to the maximumStringLength.static java.lang.StringremoveCharacterToFit(java.lang.String s1, char aChar, int maximumStringLength)Returns a String which has had enough of the specified character removed to be equal to the maximumStringLength.static java.lang.StringremoveVowels(java.lang.String s1)Returns a String which has had enough of the specified character removed to be equal to the maximumStringLength.static java.lang.StringreplaceFirstSubString(java.lang.String source, java.lang.String subString, java.lang.String replacement)Replaces the first subString of the source with the replacement.static java.util.VectorreverseVector(java.util.Vector theVector)static java.lang.StringrightTrimString(java.lang.String originalString)Returns a new string with all space characters removed from the rightstatic voidsetDefaultEndDatabaseDelimiter(java.lang.String delimiter)static voidsetDefaultStartDatabaseDelimiter(java.lang.String delimiter)static voidsetShouldOptimizeDates(boolean value)Return if JDBC date access should be optimized.static java.lang.StringshortenStringsByRemovingVowelsToFit(java.lang.String s1, java.lang.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.static booleanshouldOptimizeDates()Return if JDBC date access should be optimized.static java.sql.DatesqlDateFromUtilDate(java.util.Date utilDate)Answer a sql.Date from a timestamp.static voidsystemBug(java.lang.String description)Can be used to mark code if a workaround is added for a JDBC driver or other bug.static java.lang.StringtempDirectory()Return the name of the "temporary directory".static java.sql.TimetimeFromCalendar(java.util.Calendar calendar)Answer a sql.Time from a Calendar.static java.sql.TimetimeFromDate(java.util.Date date)Answer a Time from a Date This implementation is based on the java.sql.Date class, not java.util.Date.static java.sql.TimetimeFromHourMinuteSecond(int hour, int minute, int second)Answer a Time with the hour, minute, second.static java.sql.TimetimeFromLong(java.lang.Long longObject)Answer a Time from a longstatic java.sql.TimetimeFromString(java.lang.String timeString)Answer a Time from a string representation.static java.sql.TimetimeFromTimestamp(java.sql.Timestamp timestamp)Answer a Time from a Timestamp Usus the Hours, Minutes, Seconds instead of getTime() ms value.static java.sql.TimestamptimestampFromCalendar(java.util.Calendar calendar)Answer a Timestamp from a Calendar.static java.sql.TimestamptimestampFromDate(java.util.Date date)Answer a Timestamp from a java.util.Date.static java.sql.TimestamptimestampFromLong(long millis)Answer a Time from a longstatic java.sql.TimestamptimestampFromLong(java.lang.Long millis)Answer a Time from a longstatic java.sql.TimestamptimestampFromString(java.lang.String timestampString)Answer a Timestamp from a string representation.static java.sql.TimestamptimestampFromYearMonthDateHourMinuteSecondNanos(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.static longtimeWithRoundMiliseconds()static voidtoDo(java.lang.String description)Can be used to mark code as need if something strange is seen.static java.lang.StringtoSlashedClassName(java.lang.String dottedClassName)Convert dotted format class name to slashed format class name.static java.net.URItoURI(java.net.URL url)Convert the URL into a URI allowing for special chars.static java.lang.Stringtruncate(java.lang.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.static java.sql.DatetruncateDate(java.sql.Date date)Return a sql.Date with time component zeroed out.static java.sql.DatetruncateDateIgnoreMilliseconds(java.sql.Date date)Return a sql.Date with time component zeroed out (with possible exception of milliseconds).static java.util.DateutilDateFromLong(java.lang.Long longObject)Answer a Date from a long This implementation is based on the java.sql.Date class, not java.util.Date.static java.util.DateutilDateFromSQLDate(java.sql.Date sqlDate)Answer a java.util.Date from a sql.datestatic java.util.DateutilDateFromTime(java.sql.Time time)Answer a java.util.Date from a sql.Timestatic java.util.DateutilDateFromTimestamp(java.sql.Timestamp timestampObject)Answer a java.util.Date from a timestampstatic java.util.VectorvectorFromArray(java.lang.Object[] array)Convert the specified array into a vector.protected static java.util.List<java.lang.Integer>version(java.lang.String version)INTERNAL: Expects version in ***num.num.num.num.num*** format, converts it to a List of Integers.static voidwriteHexString(byte[] bytes, java.io.Writer writer)Convert the byte array to a HEX string.
-
-
-
Field Detail
-
shouldOptimizeDates
public static boolean shouldOptimizeDates
Used to configure JDBC level date optimization.
-
NULL_VALUE
public static final java.lang.Object NULL_VALUE
Used to store null values in hashtables, is helper because need to be serializable.
-
calendarCache
protected static final java.util.Queue<java.util.Calendar> calendarCache
PERF: Used to cache a set of calendars for conversion/printing purposes.
-
defaultTimeZone
protected static final java.util.TimeZone defaultTimeZone
PERF: Cache default timezone for calendar conversion.
-
CR
protected static java.lang.String CR
Store CR string, for some reason \n is not platform independent.
-
SPACE
public static final java.lang.String SPACE
formatting strings for indenting- See Also:
- Constant Field Values
-
INDENT
public static final java.lang.String INDENT
- See Also:
- Constant Field Values
-
NL
public static final java.lang.String NL
Store newline string- See Also:
- Constant Field Values
-
PATH_SEPARATOR
protected static java.lang.String PATH_SEPARATOR
Prime the platform-dependent path separator
-
FILE_SEPARATOR
protected static java.lang.String FILE_SEPARATOR
Prime the platform-dependent file separator
-
CURRENT_WORKING_DIRECTORY
protected static java.lang.String CURRENT_WORKING_DIRECTORY
Prime the platform-dependent current working directory
-
TEMP_DIRECTORY
protected static java.lang.String TEMP_DIRECTORY
Prime the platform-dependent temporary directory
-
isZeroValidPrimaryKey
@Deprecated public static boolean isZeroValidPrimaryKey
Deprecated.Instead of setting the flag to true use: session.getProject().setDefaultIdValidation(IdValidation.NULL)Backdoor to allow 0 to be used in primary keys.
-
IS_PROPERTY_METHOD_PREFIX
public static final java.lang.String IS_PROPERTY_METHOD_PREFIX
- See Also:
- Constant Field Values
-
GET_PROPERTY_METHOD_PREFIX
public static final java.lang.String GET_PROPERTY_METHOD_PREFIX
- See Also:
- Constant Field Values
-
SET_PROPERTY_METHOD_PREFIX
public static final java.lang.String SET_PROPERTY_METHOD_PREFIX
- See Also:
- Constant Field Values
-
SET_IS_PROPERTY_METHOD_PREFIX
public static final java.lang.String SET_IS_PROPERTY_METHOD_PREFIX
- See Also:
- Constant Field Values
-
POSITION_AFTER_IS_PREFIX
public static final int POSITION_AFTER_IS_PREFIX
-
POSITION_AFTER_GET_PREFIX
public static final int POSITION_AFTER_GET_PREFIX
-
DEFAULT_DATABASE_DELIMITER
public static final java.lang.String DEFAULT_DATABASE_DELIMITER
- See Also:
- Constant Field Values
-
PERSISTENCE_SET
public static final java.lang.String PERSISTENCE_SET
- See Also:
- Constant Field Values
-
PERSISTENCE_GET
public static final java.lang.String PERSISTENCE_GET
- See Also:
- Constant Field Values
-
PERSISTENCE_FIELDNAME_PREFIX
public static final java.lang.String PERSISTENCE_FIELDNAME_PREFIX
- See Also:
- Constant Field Values
-
PERSISTENCE_FIELDNAME_POSTFIX
public static final java.lang.String PERSISTENCE_FIELDNAME_POSTFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
shouldOptimizeDates
public static boolean shouldOptimizeDates()
Return if JDBC date access should be optimized.
-
setShouldOptimizeDates
public static void setShouldOptimizeDates(boolean value)
Return if JDBC date access should be optimized.
-
getCalendarCache
public static java.util.Queue<java.util.Calendar> getCalendarCache()
PERF: Return the calendar cache use to avoid calendar creation for processing java.sql/util.Date/Time/Timestamp objects.
-
initCalendarCache
public static java.util.Queue initCalendarCache()
PERF: Init the calendar cache use to avoid calendar creation for processing java.sql/util.Date/Time/Timestamp objects.
-
allocateCalendar
public static java.util.Calendar allocateCalendar()
PERF: This is used to optimize Calendar conversion/printing. This should only be used when a calendar is temporarily required, when finished it must be released back.
-
getDefaultTimeZone
public static java.util.TimeZone getDefaultTimeZone()
PERF: Return the cached default platform. Used for ensuring Calendar are in the local timezone. The JDK method clones the timezone, so cache it locally.
-
getDefaultDateTimeFormatter
public static java.time.format.DateTimeFormatter getDefaultDateTimeFormatter()
-
releaseCalendar
public static void releaseCalendar(java.util.Calendar calendar)
PERF: This is used to optimize Calendar conversion/printing. This should only be used when a calendar is temporarily required, when finished it must be released back.
-
addAllToVector
public static void addAllToVector(java.util.Vector theVector, java.util.Vector elementsToAdd)
-
addAllUniqueToVector
public static java.util.Vector addAllUniqueToVector(java.util.Vector objects, java.util.List objectsToAdd)
-
addAllUniqueToList
public static java.util.List addAllUniqueToList(java.util.List objects, java.util.List objectsToAdd)
-
arrayFromVector
public static java.lang.Object[] arrayFromVector(java.util.Vector vector)
Convert the specified vector into an array.
-
integerToHexString
public static java.lang.String integerToHexString(java.lang.Integer i)
ConvertIntegerto hexadecimalString.- Parameters:
i- AnIntegerto be converted to a hexadecimal string.- Returns:
- The
Stringrepresentation of the unsigned integer value represented by the argument in hexadecimal or"null"if providedIntegerargument isnull.
-
buildBytesFromHexString
public static byte[] buildBytesFromHexString(java.lang.String hex)
Convert the HEX string to a byte array. HEX allows for binary data to be printed.
-
buildHexStringFromBytes
public static java.lang.String buildHexStringFromBytes(byte[] bytes)
Convert the byte array to a HEX string. HEX allows for binary data to be printed.
-
buildVectorFromMapElements
public static java.util.Vector buildVectorFromMapElements(java.util.Map map)
Create a new Vector containing all of the map elements.
-
calendarFromUtilDate
public static java.util.Calendar calendarFromUtilDate(java.util.Date date)
Answer a Calendar from a date.
-
classImplementsInterface
public static boolean classImplementsInterface(java.lang.Class aClass, java.lang.Class anInterface)INTERNAL: Return whether a Class implements a specific interface, either directly or indirectly (through interface or implementation inheritance).- Returns:
- boolean
-
classIsSubclass
public static boolean classIsSubclass(java.lang.Class subClass, java.lang.Class superClass)INTERNAL: Return whether a Class is a subclass of, or the same as, another Class.- Returns:
- boolean
-
compareVersions
public static int compareVersions(java.lang.String version1, java.lang.String version2)INTERNAL: Compares two version in num.num.num.num.num*** format. -1, 0, 1 means the version1 is less than, equal, greater than version2. Example: compareVersions("11.1.0.6.0-Production", "11.1.0.7") == -1 Example: compareVersions("WebLogic Server 10.3.4", "10.3.3.0") == 1
-
version
protected static java.util.List<java.lang.Integer> version(java.lang.String version)
INTERNAL: Expects version in ***num.num.num.num.num*** format, converts it to a List of Integers. Example: "11.1.0.6.0_Production" -> {11, 1, 0, 6, 0} Example: "WebLogic Server 10.3.3.0" -> {10, 3, 3, 0}
-
compareVersions
protected static int compareVersions(java.util.List<java.lang.Integer> list1, java.util.List<java.lang.Integer> list2)INTERNAL: Compares two lists of Integers -1, 0, 1 means the first list is less than, equal, greater than the second list. Example: {11, 1, 0, 6, 0} < {11, 1, 0, 7}
-
getClassFromClasseName
public static java.lang.Class getClassFromClasseName(java.lang.String className, java.lang.ClassLoader classLoader)
-
getComponentTypeNameFromArrayString
public static java.lang.String getComponentTypeNameFromArrayString(java.lang.String aString)
-
compareArrays
public static boolean compareArrays(java.lang.Object[] array1, java.lang.Object[] array2)
-
compareBigDecimals
public static boolean compareBigDecimals(java.math.BigDecimal one, java.math.BigDecimal two)Compare two BigDecimals. This is required because the .equals method of java.math.BigDecimal ensures that the scale of the two numbers are equal. Therefore 0.0 != 0.00.- See Also:
BigDecimal.equals(Object)
-
compareByteArrays
public static boolean compareByteArrays(byte[] array1, byte[] array2)
-
compareCharArrays
public static boolean compareCharArrays(char[] array1, char[] array2)
-
areTypesAssignable
public static boolean areTypesAssignable(java.util.List types1, java.util.List types2)PUBLIC: Compare two vectors of types. Return true if the size of the vectors is the same and each of the types in the first Vector are assignable from the types in the corresponding objects in the second Vector.
-
compareHashtables
public static boolean compareHashtables(java.util.Hashtable hashtable1, java.util.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
-
comparePotentialArrays
public static boolean comparePotentialArrays(java.lang.Object firstValue, java.lang.Object secondValue)Compare two potential arrays and return true if they are the same. Will check for BigDecimals as well.
-
concatenateMaps
public static java.util.Map concatenateMaps(java.util.Map first, java.util.Map second)Merge the two Maps into a new HashMap.
-
concatenateUniqueVectors
public static java.util.Vector concatenateUniqueVectors(java.util.Vector first, java.util.Vector second)Return a new vector with no duplicated values.
-
concatenateUniqueLists
public static java.util.List concatenateUniqueLists(java.util.List first, java.util.List second)Return a new List with no duplicated values.
-
concatenateVectors
public static java.util.Vector concatenateVectors(java.util.Vector first, java.util.Vector second)
-
copyVector
public static java.util.Vector copyVector(java.util.List originalVector, int startIndex, int stopIndex) throws ValidationExceptionReturn a copy of the vector containing a subset starting at startIndex and ending at stopIndex.- Parameters:
originalVector- - original vectorstartIndex- - starting position in vectorstopIndex- - ending position in vector- Throws:
EclipseLinkExceptionValidationException
-
copyStringArray
public static java.lang.String[] copyStringArray(java.lang.String[] original)
Copy an array of strings to a new array- Parameters:
original-- Returns:
-
copyIntArray
public static int[] copyIntArray(int[] original)
Copy an array of int to a new array- Parameters:
original-- Returns:
-
copyBooleanArray
public static boolean[] copyBooleanArray(boolean[] original)
Copy an array of boolean to a new array- Parameters:
original-- Returns:
-
cr
public static java.lang.String cr()
Return a string containing the platform-appropriate characters for carriage return.
-
currentWorkingDirectory
public static java.lang.String currentWorkingDirectory()
Return the name of the "current working directory".
-
tempDirectory
public static java.lang.String tempDirectory()
Return the name of the "temporary directory".
-
dateFromLong
public static java.sql.Date dateFromLong(java.lang.Long longObject)
Answer a Date from a long This implementation is based on the java.sql.Date class, not java.util.Date.- Parameters:
longObject- - milliseconds from the epoch (00:00:00 GMT Jan 1, 1970). Negative values represent dates prior to the epoch.
-
dateFromYearMonthDate
public static java.sql.Date dateFromYearMonthDate(int year, int month, int day)Answer a Date with the year, month, date. This builds a date avoiding the deprecated, inefficient and concurrency bottleneck date constructors. This implementation is based on the java.sql.Date class, not java.util.Date. The year, month, day are the values calendar uses, i.e. year is from 0, month is 0-11, date is 1-31.
-
dateFromString
public static java.sql.Date dateFromString(java.lang.String dateString) throws ConversionExceptionAnswer a Date from a string representation. The string MUST be a valid date and in one of the following formats: YYYY/MM/DD, YYYY-MM-DD, YY/MM/DD, YY-MM-DD. This implementation is based on the java.sql.Date class, not java.util.Date. The Date class contains some minor gotchas that you have to watch out for.- Parameters:
dateString- - string representation of date- Returns:
- - date representation of string
- Throws:
ConversionException
-
dateFromTimestamp
public static java.sql.Date dateFromTimestamp(java.sql.Timestamp timestamp)
Answer a Date from a timestamp This implementation is based on the java.sql.Date class, not java.util.Date.- Parameters:
timestamp- - timestamp representation of date- Returns:
- - date representation of timestampObject
-
doesFileExist
public static boolean doesFileExist(java.lang.String fileName)
Returns true if the file of this name does indeed exist
-
doubleSlashes
public static java.lang.String doubleSlashes(java.lang.String path)
Double up \ to allow printing of directories for source code generation.
-
extractJarNameFromURL
public static java.lang.String extractJarNameFromURL(java.net.URL url)
Extracts the actual path to the jar file.
-
fileSeparator
public static java.lang.String fileSeparator()
Return a string containing the platform-appropriate characters for separating directory and file names.
-
getField
public static java.lang.reflect.Field getField(java.lang.Class javaClass, java.lang.String fieldName) throws java.lang.NoSuchFieldExceptionINTERNAL: Returns a Field for the specified Class and field name. Uses Class.getDeclaredField(String) to find the field. If the field is not found on the specified class the superclass is checked, and so on, recursively. Set accessible to true, so we can access private/package/protected fields.- Throws:
java.lang.NoSuchFieldException
-
getDeclaredMethod
public static java.lang.reflect.Method getDeclaredMethod(java.lang.Class javaClass, java.lang.String methodName) throws java.lang.NoSuchMethodExceptionINTERNAL: Returns a Method for the specified Class, method name, and that has no parameters. Uses Class.getDeclaredMethod(String Class[]) to find the method. If the method is not found on the specified class the superclass is checked, and so on, recursively. Set accessible to true, so we can access private/package/protected methods.- Throws:
java.lang.NoSuchMethodException
-
getDeclaredMethod
public static java.lang.reflect.Method getDeclaredMethod(java.lang.Class javaClass, java.lang.String methodName, java.lang.Class[] methodParameterTypes) throws java.lang.NoSuchMethodExceptionINTERNAL: Returns a Method for the specified Class, method name, and formal parameter types. Uses Class.getDeclaredMethod(String Class[]) to find the method. If the method is not found on the specified class the superclass is checked, and so on, recursively. Set accessible to true, so we can access private/package/protected methods.- Throws:
java.lang.NoSuchMethodException
-
getInstanceFromClass
public static java.lang.Object getInstanceFromClass(java.lang.Class classFullName)
Return the class instance from the class
-
getObjectClass
public static java.lang.Class getObjectClass(java.lang.Class javaClass)
Returns the object class. If a class is primitive return its non primitive class
-
getShortClassName
public static java.lang.String getShortClassName(java.lang.Class javaClass)
Answers the unqualified class name for the provided class.
-
getShortClassName
public static java.lang.String getShortClassName(java.lang.String javaClassName)
Answers the unqualified class name from the specified String.
-
getShortClassName
public static java.lang.String getShortClassName(java.lang.Object object)
Answers the unqualified class name for the specified object.
-
getPackageName
public static java.lang.String getPackageName(java.lang.Class javaClass)
return a package name for the specified class.
-
getTabs
public static java.lang.String getTabs(int noOfTabs)
Return a string containing the specified number of tabs.
-
indexOfNullElement
public static int indexOfNullElement(java.util.Vector v, int index)Returns the index of the the firstnullelement found in the specifiedVectorstarting the search at the starting index specified. Return an int >= 0 and less than size if anullelement was found. Return -1 if anullelement was not found. This is needed in jdk1.1, whereVector.contains(Object)for anullelement will result in aNullPointerException....
-
isPrimitiveWrapper
public static boolean isPrimitiveWrapper(java.lang.Class classInQuestion)
ADVANCED returns true if the class in question is a primitive wrapper
-
isUpperCaseString
public static boolean isUpperCaseString(java.lang.String s)
Returns true if the string given is an all upper case string
-
isVowel
public static boolean isVowel(char c)
Returns true if the character given is a vowel. I.e. one of a,e,i,o,u,A,E,I,O,U.
-
listFilesIn
public static java.io.File[] listFilesIn(java.io.File directory)
Return an array of the files in the specified directory. This allows us to simplify jdk1.1 code a bit.
-
makeVectorFromObject
public static java.util.Vector makeVectorFromObject(java.lang.Object theObject)
Make a Vector from the passed object. If it's a Collection, iterate over the collection and add each item to the Vector. If it's not a collection create a Vector and add the object to it.
-
outputClassFile
public static void outputClassFile(java.lang.String className, byte[] classBytes, java.lang.String outputPath)Used by our byte code weaving to enable users who are debugging to output the generated class to a file- Parameters:
className-classBytes-outputPath-
-
pathSeparator
public static java.lang.String pathSeparator()
Return a string containing the platform-appropriate characters for separating entries in a path (e.g. the classpath)
-
printStackTraceToString
public static java.lang.String printStackTraceToString(java.lang.Throwable aThrowable)
Return a String containing the printed stacktrace of an exception.
-
printTimeFromMilliseconds
public static java.lang.String printTimeFromMilliseconds(long milliseconds)
-
printVector
public static java.lang.String printVector(java.util.Vector vector)
Given a Vector, print it, even if there is a null in it
-
rehashHashtable
public static java.util.Hashtable rehashHashtable(java.util.Hashtable table)
-
rehashMap
public static java.util.Map rehashMap(java.util.Map table)
-
removeAllButAlphaNumericToFit
public static java.lang.String removeAllButAlphaNumericToFit(java.lang.String s1, int maximumStringLength)Returns a String which has had enough non-alphanumeric characters removed to be equal to the maximumStringLength.
-
removeCharacterToFit
public static java.lang.String removeCharacterToFit(java.lang.String s1, char aChar, int maximumStringLength)Returns a String which has had enough of the specified character removed to be equal to the maximumStringLength.
-
removeVowels
public static java.lang.String removeVowels(java.lang.String s1)
Returns a String which has had enough of the specified character removed to be equal to the maximumStringLength.
-
replaceFirstSubString
public static java.lang.String replaceFirstSubString(java.lang.String source, java.lang.String subString, java.lang.String replacement)Replaces the first subString of the source with the replacement.
-
reverseVector
public static java.util.Vector reverseVector(java.util.Vector theVector)
-
rightTrimString
public static java.lang.String rightTrimString(java.lang.String originalString)
Returns a new string with all space characters removed from the right- Parameters:
originalString- - timestamp representation of date- Returns:
- - String
-
shortenStringsByRemovingVowelsToFit
public static java.lang.String shortenStringsByRemovingVowelsToFit(java.lang.String s1, java.lang.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.
-
sqlDateFromUtilDate
public static java.sql.Date sqlDateFromUtilDate(java.util.Date utilDate)
Answer a sql.Date from a timestamp.
-
printDate
public static java.lang.String printDate(java.sql.Date date)
Print the sql.Date.
-
printDate
public static java.lang.String printDate(java.util.Calendar calendar)
Print the date part of the calendar.
-
printDate
public static java.lang.String printDate(java.util.Calendar calendar, boolean useLocalTime)Print the date part of the calendar. Normally the calendar must be printed in the local time, but if the timezone is printed, it must be printing in its timezone.
-
printTime
public static java.lang.String printTime(java.sql.Time time)
Print the sql.Time.
-
printTime
public static java.lang.String printTime(java.util.Calendar calendar)
Print the time part of the calendar.
-
printTime
public static java.lang.String printTime(java.util.Calendar calendar, boolean useLocalTime)Print the time part of the calendar. Normally the calendar must be printed in the local time, but if the timezone is printed, it must be printing in its timezone.
-
printCalendar
public static java.lang.String printCalendar(java.util.Calendar calendar)
Print the Calendar.
-
printCalendar
public static java.lang.String printCalendar(java.util.Calendar calendar, boolean useLocalTime)Print the Calendar. Normally the calendar must be printed in the local time, but if the timezone is printed, it must be printing in its timezone.
-
printTimestamp
public static java.lang.String printTimestamp(java.sql.Timestamp timestamp)
Print the sql.Timestamp.
-
buildZeroPrefix
public static java.lang.String buildZeroPrefix(int number, int totalDigits)Build a numerical string with leading 0s. number is an existing number that the new string will be built on. totalDigits is the number of the required digits of the string.
-
buildZeroPrefixWithoutSign
public static java.lang.String buildZeroPrefixWithoutSign(int number, int totalDigits)Build a numerical string with leading 0s. number is an existing number that the new string will be built on. totalDigits is the number of the required digits of the string.
-
buildZeroPrefixAndTruncTrailZeros
public static java.lang.String buildZeroPrefixAndTruncTrailZeros(int number, int totalDigits)Build a numerical string with leading 0s and truncate trailing zeros. number is an existing number that the new string will be built on. totalDigits is the number of the required digits of the string.
-
printTimestampWithoutNanos
public static java.lang.String printTimestampWithoutNanos(java.sql.Timestamp timestamp)
Print the sql.Timestamp without the nanos portion.
-
printCalendarWithoutNanos
public static java.lang.String printCalendarWithoutNanos(java.util.Calendar calendar)
Print the Calendar without the nanos portion.
-
dateFromCalendar
public static java.sql.Date dateFromCalendar(java.util.Calendar calendar)
Answer a sql.Date from a Calendar.
-
truncateDate
public static java.sql.Date truncateDate(java.sql.Date date)
Return a sql.Date with time component zeroed out. Starting with version 12.1 Oracle jdbc Statement.setDate method no longer zeroes out the time component.
-
truncateDateIgnoreMilliseconds
public static java.sql.Date truncateDateIgnoreMilliseconds(java.sql.Date date)
Return a sql.Date with time component zeroed out (with possible exception of milliseconds). Starting with version 12.1 Oracle jdbc Statement.setDate method no longer zeroes out the whole time component, yet it still zeroes out milliseconds.
-
systemBug
public static void systemBug(java.lang.String description)
Can be used to mark code if a workaround is added for a JDBC driver or other bug.
-
timeFromDate
public static java.sql.Time timeFromDate(java.util.Date date)
Answer a Time from a Date This implementation is based on the java.sql.Date class, not java.util.Date.- Parameters:
date- - time representation of date- Returns:
- - time representation of dateObject
-
timeFromLong
public static java.sql.Time timeFromLong(java.lang.Long longObject)
Answer a Time from a long- Parameters:
longObject- - milliseconds from the epoch (00:00:00 GMT Jan 1, 1970). Negative values represent dates prior to the epoch.
-
timeFromHourMinuteSecond
public static java.sql.Time timeFromHourMinuteSecond(int hour, int minute, int second)Answer a Time with the hour, minute, second. This builds a time avoiding the deprecated, inefficient and concurrency bottleneck date constructors. The hour, minute, second are the values calendar uses, i.e. year is from 0, month is 0-11, date is 1-31.
-
timeFromString
public static java.sql.Time timeFromString(java.lang.String timeString) throws ConversionExceptionAnswer a Time from a string representation. This method will accept times in the following formats: HH-MM-SS, HH:MM:SS- Parameters:
timeString- - string representation of time- Returns:
- - time representation of string
- Throws:
ConversionException
-
timeFromTimestamp
public static java.sql.Time timeFromTimestamp(java.sql.Timestamp timestamp)
Answer a Time from a Timestamp Usus the Hours, Minutes, Seconds instead of getTime() ms value.
-
timeFromCalendar
public static java.sql.Time timeFromCalendar(java.util.Calendar calendar)
Answer a sql.Time from a Calendar.
-
timestampFromCalendar
public static java.sql.Timestamp timestampFromCalendar(java.util.Calendar calendar)
Answer a Timestamp from a Calendar.
-
timestampFromDate
public static java.sql.Timestamp timestampFromDate(java.util.Date date)
Answer a Timestamp from a java.util.Date.
-
timestampFromLong
public static java.sql.Timestamp timestampFromLong(java.lang.Long millis)
Answer a Time from a long- Parameters:
millis- - milliseconds from the epoch (00:00:00 GMT Jan 1, 1970). Negative values represent dates prior to the epoch.
-
timestampFromLong
public static java.sql.Timestamp timestampFromLong(long millis)
Answer a Time from a long- Parameters:
millis- - milliseconds from the epoch (00:00:00 GMT Jan 1, 1970). Negative values represent dates prior to the epoch.
-
timestampFromString
public static java.sql.Timestamp timestampFromString(java.lang.String timestampString) throws ConversionExceptionAnswer a Timestamp from a string representation. This method will accept strings in the following formats: YYYY/MM/DD HH:MM:SS YY/MM/DD HH:MM:SS YYYY-MM-DD HH:MM:SS YY-MM-DD HH:MM:SS YYYY/MM/DD HH:MM:SS.NNNNNNN YYYY/MM/DD HH:MM:SS.NNNNNNN+Z- Parameters:
timestampString- - string representation of timestamp- Returns:
- - timestamp representation of string
- Throws:
ConversionException
-
timestampFromYearMonthDateHourMinuteSecondNanos
public static java.sql.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. The hour, minute, second are the values calendar uses, i.e. year is from 0, month is 0-11, date is 1-31, time is 0-23/59.
-
toDo
public static void toDo(java.lang.String description)
Can be used to mark code as need if something strange is seen.
-
toSlashedClassName
public static java.lang.String toSlashedClassName(java.lang.String dottedClassName)
Convert dotted format class name to slashed format class name.- Parameters:
dottedClassName-- Returns:
- String
-
truncate
public static java.lang.String truncate(java.lang.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. The removal starts backward from the end of original string, and stops if the resulting string size is equal to the passed in size. If the resulting string is still larger than the passed in size after removing all vowels, the end of the resulting string will be truncated.
-
utilDateFromLong
public static java.util.Date utilDateFromLong(java.lang.Long longObject)
Answer a Date from a long This implementation is based on the java.sql.Date class, not java.util.Date.- Parameters:
longObject- - milliseconds from the epoch (00:00:00 GMT Jan 1, 1970). Negative values represent dates prior to the epoch.
-
utilDateFromSQLDate
public static java.util.Date utilDateFromSQLDate(java.sql.Date sqlDate)
Answer a java.util.Date from a sql.date- Parameters:
sqlDate- - sql.date representation of date- Returns:
- - java.util.Date representation of the sql.date
-
utilDateFromTime
public static java.util.Date utilDateFromTime(java.sql.Time time)
Answer a java.util.Date from a sql.Time- Parameters:
time- - time representation of util date- Returns:
- - java.util.Date representation of the time
-
utilDateFromTimestamp
public static java.util.Date utilDateFromTimestamp(java.sql.Timestamp timestampObject)
Answer a java.util.Date from a timestamp- Parameters:
timestampObject- - timestamp representation of date- Returns:
- - java.util.Date representation of timestampObject
-
vectorFromArray
public static java.util.Vector vectorFromArray(java.lang.Object[] array)
Convert the specified array into a vector.
-
writeHexString
public static void writeHexString(byte[] bytes, java.io.Writer writer) throws java.io.IOExceptionConvert the byte array to a HEX string. HEX allows for binary data to be printed.- Throws:
java.io.IOException
-
isEquivalentToNull
public static boolean isEquivalentToNull(java.lang.Object value)
Check if the value is 0 (int/long) for primitive ids.
-
isNumberNegativeOrZero
public static boolean isNumberNegativeOrZero(java.lang.Object value)
Returns true if the passed value is Number that is negative or equals to zero.
-
countOccurrencesOf
public static int countOccurrencesOf(java.lang.Object comparisonObject, java.util.List list)Return an integer representing the number of occurrences (using equals()) of the specified object in the specified list. If the list is null or empty (or both the object and the list is null), 0 is returned.
-
toURI
public static java.net.URI toURI(java.net.URL url) throws java.net.URISyntaxExceptionConvert the URL into a URI allowing for special chars.- Throws:
java.net.URISyntaxException
-
getWeavedValueHolderGetMethodName
public static java.lang.String getWeavedValueHolderGetMethodName(java.lang.String attributeName)
Return the get method name weaved for a value-holder attribute.
-
getWeavedValueHolderSetMethodName
public static java.lang.String getWeavedValueHolderSetMethodName(java.lang.String attributeName)
Return the set method name weaved for a value-holder attribute.
-
getWeavedGetMethodName
public static java.lang.String getWeavedGetMethodName(java.lang.String attributeName)
Return the set method name weaved for getting attribute value. This method is always weaved in field access case. In property access case the method weaved only if attribute name is the same as property name: for instance, the method weaved for "manager" attribute that uses "getManager" / "setManager" access methods, but not for "m_address" attribute that uses "getAddress" / "setAddress" access methods.
-
getWeavedSetMethodName
public static java.lang.String getWeavedSetMethodName(java.lang.String attributeName)
Return the set method name weaved for setting attribute value. This method is always weaved in field access case. In property access case the method weaved only if attribute name is the same as property name: for instance, the method weaved for "manager" attribute that uses "getManager" / "setManager" access methods, but not for "m_address" attribute that uses "getAddress" / "setAddress" access methods.
-
close
public static void close(java.io.Closeable c)
Close a closeable object, eating the exception
-
getAttributeNameFromMethodName
public static java.lang.String getAttributeNameFromMethodName(java.lang.String methodName)
INTERNAL: Method to convert a getXyz or isXyz method name to an xyz attribute name. NOTE: The method name passed it may not actually be a method name, so by default return the name passed in.
-
getDefaultStartDatabaseDelimiter
public static java.lang.String getDefaultStartDatabaseDelimiter()
-
getDefaultEndDatabaseDelimiter
public static java.lang.String getDefaultEndDatabaseDelimiter()
-
setDefaultStartDatabaseDelimiter
public static void setDefaultStartDatabaseDelimiter(java.lang.String delimiter)
-
setDefaultEndDatabaseDelimiter
public static void setDefaultEndDatabaseDelimiter(java.lang.String delimiter)
-
convertLikeToRegex
public static java.lang.String convertLikeToRegex(java.lang.String like)
Convert the SQL like pattern to a regex pattern.
-
isLob
public static boolean isLob(DatabaseField field)
-
hasLob
public static boolean hasLob(java.util.Collection<DatabaseField> fields)
-
timeWithRoundMiliseconds
public static long timeWithRoundMiliseconds()
-
-