/** * Answer the type of the EclipseLink session this MBean represents. * Types include: "ServerSession", "DatabaseSession", "SessionBroker" */ public String getSessionType() { return Helper.getShortClassName(getSession().getClass()); }
public XDKPlatform() { super(); try { Class[] argTypes = { URL.class }; buildSchemaMethod = Helper.getDeclaredMethod(XSDBuilder.class, "build", argTypes); } catch (NoSuchMethodException e) { } }
/** * Print the sql.Timestamp without the nanos portion. */ public static String printTimestampWithoutNanos(java.sql.Timestamp timestamp) { // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString. Calendar calendar = allocateCalendar(); calendar.setTime(timestamp); String string = printCalendarWithoutNanos(calendar); releaseCalendar(calendar); return string; }
/** * 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 */ public static int compareVersions(String version1, String version2) { return compareVersions(version(version1), version(version2)); }
/** * Print the sql.Time. */ public static String printTime(java.sql.Time time) { // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString. Calendar calendar = allocateCalendar(); calendar.setTime(time); String string = printTime(calendar); releaseCalendar(calendar); return string; }
/** * Print the sql.Date. */ public static String printDate(java.sql.Date date) { // PERF: Avoid deprecated get methods, that are now very inefficient and used from toString. Calendar calendar = allocateCalendar(); calendar.setTime(date); String string = printDate(calendar); releaseCalendar(calendar); return string; }
/** * Answer a sql.Date from a timestamp. */ public static java.sql.Date sqlDateFromUtilDate(java.util.Date utilDate) { // PERF: Avoid deprecated get methods, that are now very inefficient. Calendar calendar = allocateCalendar(); calendar.setTime(utilDate); java.sql.Date date = dateFromCalendar(calendar); releaseCalendar(calendar); return date; }
/** * INTERNAL: * Convert all the class-name-based settings in this SortedCollectionContainerPolicy to actual class-based * settings. This method is used when converting a project that has been built * with class names to a project with classes. * @param classLoader */ public void convertClassNamesToClasses(ClassLoader classLoader){ super.convertClassNamesToClasses(classLoader); if(m_comparator==null){ if(comparatorClass==null){ if(comparatorClassName!=null){ Class comparatorClass = Helper.getClassFromClasseName(comparatorClassName, classLoader); if(Helper.classImplementsInterface(comparatorClass, java.util.Comparator.class)){ m_comparator=(Comparator)Helper.getInstanceFromClass(comparatorClass); }else{ throw ValidationException.invalidComparatorClass(comparatorClassName); } } }else{ if(Helper.classImplementsInterface(comparatorClass, java.util.Comparator.class)){ m_comparator=(Comparator)Helper.getInstanceFromClass(comparatorClass); }else{ throw ValidationException.invalidComparatorClass(comparatorClass.getName()); } } } }
/** * INTERNAL: * Return whether a map key this container policy represents is an attribute. */ @Override public boolean isMapKeyAttribute() { if (elementDescriptor != null && keyName != null){ DatabaseMapping mapping = elementDescriptor.getMappingForAttributeName(Helper.getAttributeNameFromMethodName(keyName)); if (mapping != null) { return mapping.isDirectToFieldMapping(); } } initializeKey(); if (keyField != null){ if (keyField.getClass().isPrimitive()){ return true; } } else if (keyMethod != null) { if (keyMethod.getClass().isPrimitive()) { return true; } } return false; }
/** * Answer a sql.Time from a Calendar. */ public static java.sql.Time timeFromCalendar(Calendar calendar) { if (!defaultTimeZone.equals(calendar.getTimeZone())) { // Must convert the calendar to the local timezone if different, as dates have no timezone (always local). Calendar localCalendar = allocateCalendar(); localCalendar.setTimeInMillis(calendar.getTimeInMillis()); java.sql.Time date = timeFromHourMinuteSecond(localCalendar.get(Calendar.HOUR_OF_DAY), localCalendar.get(Calendar.MINUTE), localCalendar.get(Calendar.SECOND)); releaseCalendar(localCalendar); return date; } return timeFromHourMinuteSecond(calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND)); }
/** * Convert the byte array to a HEX string. * HEX allows for binary data to be printed. */ public static void writeHexString(byte[] bytes, Writer writer) throws IOException { writer.write(buildHexStringFromBytes(bytes)); }
/** * INTERNAL: * Convenience method - return a platform-specific line-feed. */ protected static String cr() { return org.eclipse.persistence.internal.helper.Helper.cr(); }
/** * Override to avoid exceptions due to lack of get method. */ public void initializeAttributes(Class theJavaClass) throws DescriptorException { if (getAttributeName() == null) { throw DescriptorException.attributeNameNotSpecified(); } try { if (!isWriteOnly()) { Class[] parameterTypes = new Class[1]; parameterTypes[0] = Helper.getClassFromClasseName(parameterTypeAsString, loader); attributeClassification = parameterTypes[0]; setSetMethod(Helper.getDeclaredMethod(theJavaClass, setMethodName, parameterTypes)); } } catch (NoSuchMethodException ex) { DescriptorException descriptorException = DescriptorException.noSuchMethodWhileInitializingAttributesInMethodAccessor(getSetMethodName(), getGetMethodName(), theJavaClass.getName()); descriptorException.setInternalException(ex); throw descriptorException; } }
@Override public void initializeConnectionData(Connection connection) throws SQLException { if (this.isConnectionDataInitialized) { return; } DatabaseMetaData dmd = connection.getMetaData(); String databaseVersion = dmd.getDatabaseProductVersion(); this.isFractionalTimeSupported = Helper.compareVersions(databaseVersion, "5.6.4") >= 0; // Driver 5.1 supports NVARCHAR this.driverSupportsNationalCharacterVarying = Helper.compareVersions(dmd.getDriverVersion(), "5.1.0") >= 0; this.isConnectionDataInitialized = true; }
/** * INTERNAL: * Set the keyMethod or keyField based on the keyName */ protected void initializeKey(){ // Should only run through this once ... if (keyName != null && keyMethod == null && keyField == null) { try { keyMethod = Helper.getDeclaredMethod(elementClass, keyName, (Class[]) null); } catch (NoSuchMethodException ex) { try { keyField = Helper.getField(elementClass, keyName); } catch (NoSuchFieldException e) { throw ValidationException.mapKeyNotDeclaredInItemClass(keyName, elementClass); } } } }
} else if(type.isPrimitive()) { return false; } else if(type.isArray() && (String.class.equals(type.getComponentType()) || type.getComponentType().isPrimitive() || Helper.isPrimitiveWrapper(type.getComponentType()))) { return true; } else if(type.isArray() && (type.getComponentType().isArray() || type.getComponentType().isPrimitive() || type.getComponentType().getPackage().getName().startsWith("java."))) { if (String.class.equals(domainClass) || domainClass.isPrimitive() || Helper.isPrimitiveWrapper(domainClass)) { return true;
return org.eclipse.persistence.internal.helper.Helper.getClassFromClasseName(javaClass.getQualifiedName(), loader);
/** * Extract TimeZone from TIMESTAMPTZ. */ public static TimeZone extractTimeZone(byte[] bytes) { String regionName = null; if ((bytes[11] & -128) != 0) { int regionCode = (bytes[11] & 127) << 6; regionCode += ((bytes[12] & 252) >> 2); regionName = new String(ZONEIDMAP.getRegion(regionCode)); } else { int hourOffset = bytes[11] - 20; int minuteOffset = bytes[12] - 60; String offset = Helper.buildZeroPrefix(hourOffset, 2) + ":" + Helper.buildZeroPrefixWithoutSign(minuteOffset, 2); regionName = "GMT" + offset; } return TimeZone.getTimeZone(regionName); } }
/** * 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. */ public static String buildZeroPrefix(int number, int totalDigits) { String numbString = buildZeroPrefixWithoutSign(number, totalDigits); if (number < 0) { numbString = "-" + numbString; } else { numbString = "+" + numbString; } return numbString; }
/** * Answer a sql.Date from a timestamp. */ public static java.sql.Date sqlDateFromUtilDate(java.util.Date utilDate) { // PERF: Avoid deprecated get methods, that are now very inefficient. Calendar calendar = allocateCalendar(); calendar.setTime(utilDate); java.sql.Date date = dateFromCalendar(calendar); releaseCalendar(calendar); return date; }