/** * @deprecated As of 1.4.4, minimal JDK version will be 1.7 for next major release */ public static boolean is15() { return isVersion(5); }
/** * @deprecated As of 1.4.4, minimal JDK version will be 1.7 for next major release */ public static boolean is16() { return isVersion(6); }
/** * @since 1.4 * @deprecated As of 1.4.11 use {@link #isVersion(int)}. */ public static boolean is18() { return isVersion(8); }
/** * @since 1.4 * @deprecated As of 1.4.10, minimal JDK version will be 1.7 for next major release */ public static boolean is17() { return isVersion(7); }
/** * @since 1.4.10 * @deprecated As of 1.4.11 use {@link #isVersion(int)} */ public static boolean is9() { return isVersion(9); }
/** * @deprecated As of 1.4.4, minimal JDK version is 1.4 already */ public static boolean is14() { return isVersion(4); }
protected void validateFieldAccess(Field field) { if (Modifier.isFinal(field.getModifiers())) { if (JVM.isVersion(5)) { if (!field.isAccessible()) { field.setAccessible(true); } } else { throw new ObjectAccessException("Invalid final field " + field.getDeclaringClass().getName() + "." + field.getName()); } } }
public ISO8601GregorianCalendarConverter() { SingleValueConverter svConverter = null; final Class type = JVM.loadClassForName(JVM.isVersion(8) ? "com.thoughtworks.xstream.core.util.ISO8601JavaTimeConverter" : "com.thoughtworks.xstream.core.util.ISO8601JodaTimeConverter"); try { svConverter = (SingleValueConverter)type.getDeclaredConstructor(EMPTY_CLASS_ARRAY).newInstance( EMPTY_OBJECT_ARRAY); } catch (final InstantiationException e) { // ignore } catch (final IllegalAccessException e) { // ignore } catch (final InvocationTargetException e) { // ignore } catch (final NoSuchMethodException e) { // ignore } converter = svConverter; }
/** * Get the XMLOutputFactory implementation used normally by the current Java runtime as * standard. * <p> * In contrast to XMLOutputFactory.newFactory() this method will ignore any implementations * provided with the system property <em>javax.xml.stream.XMLOutputFactory</em>, * implementations configured in <em>lib/stax.properties</em> or registered with the Service * API. * </p> * * @return the XMLOutputFactory implementation or null * @throws ClassNotFoundException if the standard class cannot be found * @since 1.4.5 */ public static Class getStaxOutputFactory() throws ClassNotFoundException { if (isVersion(6)) { if (isIBM()) { return Class.forName("com.ibm.xml.xlxp.api.stax.XMLOutputFactoryImpl"); } else { return Class.forName("com.sun.xml.internal.stream.XMLOutputFactoryImpl"); } } return null; }
/** * Get the XMLInputFactory implementation used normally by the current Java runtime as * standard. * <p> * In contrast to XMLInputFactory.newFactory() this method will ignore any implementations * provided with the system property <em>javax.xml.stream.XMLInputFactory</em>, * implementations configured in <em>lib/stax.properties</em> or registered with the Service * API. * </p> * * @return the XMLInputFactory implementation or null * @throws ClassNotFoundException if the standard class cannot be found * @since 1.4.5 */ public static Class getStaxInputFactory() throws ClassNotFoundException { if (isVersion(6)) { if (isIBM()) { return Class.forName("com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl"); } else { return Class.forName("com.sun.xml.internal.stream.XMLInputFactoryImpl"); } } return null; }
/** * Create the DocumentBuilderFactory instance. * * @return the new instance * @since 1.4.9 */ protected DocumentBuilderFactory createDocumentBuilderFactory() { final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); if (JVM.isVersion(5)) { try { Method method = DocumentBuilderFactory.class.getMethod("setFeature", new Class[]{ String.class, boolean.class }); method.invoke(factory, new Object[]{ "http://apache.org/xml/features/disallow-doctype-decl", Boolean.TRUE }); } catch (NoSuchMethodException e) { // Ignore } catch (IllegalAccessException e) { throw new ObjectAccessException("Cannot set feature of DocumentBuilderFactory.", e); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (JVM.isVersion(6) || (cause instanceof ParserConfigurationException && cause.getMessage().indexOf("disallow-doctype-decl") < 0)) { throw new StreamException(cause); } } } factory.setExpandEntityReferences(false); return factory; } }
enumMapper = JVM.isVersion(5) ? UseAttributeForEnumMapper.createEnumMapper(mapper) : null;
this.valueAsAttribute = valueAsAttribute; this.lookup = lookup; enumMapper = JVM.isVersion(5) ? UseAttributeForEnumMapper.createEnumMapper(mapper) : null;
alias("gregorian-calendar", Calendar.class); if (JVM.isVersion(4)) { aliasDynamically("auth-subject", "javax.security.auth.Subject"); alias("linked-hash-map", JVM.loadClassForName("java.util.LinkedHashMap")); if (JVM.isVersion(5)) { aliasDynamically("xml-duration", "javax.xml.datatype.Duration"); alias("concurrent-hash-map", JVM.loadClassForName("java.util.concurrent.ConcurrentHashMap")); if (JVM.isVersion(7)) { aliasType("path", JVM.loadClassForName("java.nio.file.Path")); if (JVM.isVersion(8)) { alias("fixed-clock", JVM.loadClassForName("java.time.Clock$FixedClock")); alias("offset-clock", JVM.loadClassForName("java.time.Clock$OffsetClock"));
attributes = Collections.EMPTY_MAP; if (!JVM.isVersion(6)) { for (Iterator iter = attributes.values().iterator(); iter.hasNext(); ) { if (iter.next() == null) {
types.add(JVM.loadClassForName("java.sql.Date")); if (JVM.isVersion(8)) { xstream.allowTypeHierarchy(JVM.loadClassForName("java.time.Clock")); types.add(JVM.loadClassForName("java.time.Duration"));
registerConverter(new GregorianCalendarConverter(), PRIORITY_NORMAL); if (JVM.isVersion(4)) { if (JVM.isVersion(5)) { PRIORITY_NORMAL, null, null); if (JVM.isVersion(7)) { registerConverterDynamically("com.thoughtworks.xstream.converters.extended.PathConverter", PRIORITY_NORMAL, null, null); if (JVM.isVersion(8)) { registerConverterDynamically("com.thoughtworks.xstream.converters.time.ChronologyConverter", PRIORITY_NORMAL, null, null);
mapper = new DefaultImplementationsMapper(mapper); mapper = new AttributeMapper(mapper, converterLookup, reflectionProvider); if (JVM.isVersion(5)) { mapper = buildMapperDynamically( "com.thoughtworks.xstream.mapper.EnumMapper", new Class[]{Mapper.class}, if (JVM.isVersion(8)) { mapper = buildMapperDynamically("com.thoughtworks.xstream.mapper.LambdaMapper", new Class[]{Mapper.class}, new Object[]{mapper}); if (JVM.isVersion(5)) { mapper = buildMapperDynamically(ANNOTATION_MAPPER_TYPE, new Class[]{ Mapper.class, ConverterRegistry.class, ConverterLookup.class,
addImmutableType(Class.class, false); if (JVM.isVersion(7)) { Class type = JVM.loadClassForName("java.nio.file.Paths"); if (type != null) { if (JVM.isVersion(4)) { if (JVM.isVersion(5)) { addImmutableTypeDynamically("java.util.UUID", true); addImmutableType(Collections.EMPTY_MAP.getClass(), true); if (JVM.isVersion(8)) { addImmutableTypeDynamically("java.time.Duration", false); addImmutableTypeDynamically("java.time.Instant", false);
/** * @since 1.4.10 * @deprecated As of 1.4.11 use {@link #isVersion(int)} */ @Deprecated public static boolean is9() { return isVersion(9); }