当前位置: 首页>>代码示例>>Java>>正文


Java JdkVersion类代码示例

本文整理汇总了Java中org.springframework.core.JdkVersion的典型用法代码示例。如果您正苦于以下问题:Java JdkVersion类的具体用法?Java JdkVersion怎么用?Java JdkVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JdkVersion类属于org.springframework.core包,在下文中一共展示了JdkVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGetBundle

import org.springframework.core.JdkVersion; //导入依赖的package包/类
/**
 * Obtain the resource bundle for the given basename and Locale.
 * @param basename the basename to look for
 * @param locale the Locale to look for
 * @return the corresponding ResourceBundle
 * @throws MissingResourceException if no matching bundle could be found
 * @see java.util.ResourceBundle#getBundle(String, java.util.Locale, ClassLoader)
 * @see #getBundleClassLoader()
 */
protected ResourceBundle doGetBundle(String basename, Locale locale) throws MissingResourceException {
	if ((this.defaultEncoding != null && !"ISO-8859-1".equals(this.defaultEncoding)) ||
			!this.fallbackToSystemLocale || this.cacheMillis >= 0) {
		// Custom Control required...
		if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
			throw new IllegalStateException("Cannot use 'defaultEncoding', 'fallbackToSystemLocale' and " +
					"'cacheSeconds' on the standard ResourceBundleMessageSource when running on Java 5. " +
					"Consider using ReloadableResourceBundleMessageSource instead.");
		}
		return new ControlBasedResourceBundleFactory().getBundle(basename, locale);
	}
	else {
		// Good old standard call...
		return ResourceBundle.getBundle(basename, locale, getBundleClassLoader());
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:ResourceBundleMessageSource.java

示例2: testResourceBundleMessageSourceWithInappropriateDefaultCharset

import org.springframework.core.JdkVersion; //导入依赖的package包/类
public void testResourceBundleMessageSourceWithInappropriateDefaultCharset() {
	if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
		return;
	}
	ResourceBundleMessageSource ms = new ResourceBundleMessageSource();
	ms.setBasename("org/springframework/context/support/messages");
	ms.setDefaultEncoding("argh");
	ms.setFallbackToSystemLocale(false);
	try {
		ms.getMessage("code1", null, Locale.ENGLISH);
		fail("Should have thrown NoSuchMessageException");
	}
	catch (NoSuchMessageException ex) {
		// expected
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:ResourceBundleMessageSourceTests.java

示例3: assertHtmlOutput

import org.springframework.core.JdkVersion; //导入依赖的package包/类
private void assertHtmlOutput(String output) throws Exception {
	if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
		// TODO: find out why the SAXReader.read call fails on JDK 1.4 and 1.3
		return;
	}

	SAXReader reader = new SAXReader();
	Document document = reader.read(new StringReader(output));
	List nodes = document.getRootElement().selectNodes("/html/body/table/tr");

	Element tr1 = (Element) nodes.get(0);
	assertRowElement(tr1, "1", "Whatsit", "12.99");
	Element tr2 = (Element) nodes.get(1);
	assertRowElement(tr2, "2", "Thingy", "13.99");
	Element tr3 = (Element) nodes.get(2);
	assertRowElement(tr3, "3", "Gizmo", "14.99");
	Element tr4 = (Element) nodes.get(3);
	assertRowElement(tr4, "4", "Cranktoggle", "11.99");
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:XsltViewTests.java

示例4: getMapValue

import org.springframework.core.JdkVersion; //导入依赖的package包/类
private Object getMapValue(Map map, Object key) {
	if (map.containsKey(key)) {
		return map.get(key);
	}
	else {
		if (!JdkVersion.isAtLeastJava15()) {
			// we don't know the type of the keys, so we fall back to
			// comparing toString()
			for (Iterator i = map.entrySet().iterator(); i.hasNext();) {
				Map.Entry entry = (Map.Entry) i.next();
				if (entry.getKey() == key
						|| (entry.getKey() != null && key != null && entry.getKey().toString().equals(
								key.toString()))) {
					return entry.getValue();
				}
			}
		}
		return null;
	}
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:21,代码来源:DefaultMemberPropertyAccessor.java

示例5: createNotReadablePropertyException

import org.springframework.core.JdkVersion; //导入依赖的package包/类
protected NotReadablePropertyException createNotReadablePropertyException(String propertyName, Exception e) {
	if (JdkVersion.isAtLeastJava14()) {
		NotReadablePropertyException beanException = new NotReadablePropertyException(getTargetClass(),
				propertyName);
		beanException.initCause(e);
		return beanException;
	}
	else {
		ByteArrayOutputStream stackTrace = new ByteArrayOutputStream();
		PrintWriter stackTraceWriter = new PrintWriter(stackTrace);
		e.printStackTrace(stackTraceWriter);
		stackTraceWriter.close();
		return new NotReadablePropertyException(getTargetClass(), propertyName,
				new String(stackTrace.toByteArray()));
	}
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:17,代码来源:AbstractMemberPropertyAccessor.java

示例6: computeSecurityAttribute

import org.springframework.core.JdkVersion; //导入依赖的package包/类
private SecurityAttribute computeSecurityAttribute(Method method, Class<?> targetClass)
{
	// The method may be on an interface, but we need attributes from the
	// target class.
	// If the target class is null, the method will be unchanged.
	Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
	// If we are dealing with method with generic parameters, find the
	// original method.
	if( JdkVersion.isAtLeastJava15() )
	{
		specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
	}

	// First try is the method in the target class.
	SecurityAttribute txAtt = findSecurityAttribute(specificMethod, targetClass);
	if( txAtt != null )
	{
		return txAtt;
	}

	if( !specificMethod.equals(method) )
	{
		// Fallback is to look at the original method.
		txAtt = findSecurityAttribute(method, targetClass);
		if( txAtt != null )
		{
			return txAtt;
		}
	}
	return null;
}
 
开发者ID:equella,项目名称:Equella,代码行数:32,代码来源:SecurityAttributeSource.java

示例7: setUp

import org.springframework.core.JdkVersion; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    host = System.getProperty("Z3950ClientTest.host");
    port = System.getProperty("Z3950ClientTest.port");
    base = System.getProperty("Z3950ClientTest.base");
    Assume.assumeNotNull(host, port, base);
    assertEquals(JdkVersion.JAVA_17, JdkVersion.getMajorJavaVersion());
}
 
开发者ID:proarc,项目名称:proarc,代码行数:9,代码来源:Z3950ClientTest.java

示例8: testLocatePlatformMBeanServer

import org.springframework.core.JdkVersion; //导入依赖的package包/类
public void testLocatePlatformMBeanServer() {
	if(JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
		return;
	}

	MBeanServer server = null;
	try {
		server = JmxUtils.locateMBeanServer();
	}
	finally {
		if (server != null) {
			MBeanServerFactory.releaseMBeanServer(server);
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:16,代码来源:JmxUtilsTests.java

示例9: testNotMXBean

import org.springframework.core.JdkVersion; //导入依赖的package包/类
public void testNotMXBean() throws Exception {
	if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
		return;
	}
	FooNotX foo = new FooNotX();
	assertFalse("MXBean annotation not detected correctly", JmxUtils.isMBean(foo.getClass()));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:8,代码来源:JmxUtilsAnnotationTests.java

示例10: testAnnotatedMXBean

import org.springframework.core.JdkVersion; //导入依赖的package包/类
public void testAnnotatedMXBean() throws Exception {
	if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
		return;
	}
	FooX foo = new FooX();
	assertTrue("MXBean annotation not detected correctly", JmxUtils.isMBean(foo.getClass()));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:8,代码来源:JmxUtilsAnnotationTests.java

示例11: testParseLocalizedBigDecimalNumber1

import org.springframework.core.JdkVersion; //导入依赖的package包/类
public void testParseLocalizedBigDecimalNumber1() {
	if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
		return;
	}
	String bigDecimalAsString = "0.10";
	NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH);
	Number bigDecimal = NumberUtils.parseNumber(bigDecimalAsString, BigDecimal.class, numberFormat);
	assertEquals(new BigDecimal(bigDecimalAsString), bigDecimal);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:NumberUtilsTests.java

示例12: testParseLocalizedBigDecimalNumber2

import org.springframework.core.JdkVersion; //导入依赖的package包/类
public void testParseLocalizedBigDecimalNumber2() {
	if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
		return;
	}
	String bigDecimalAsString = "0.001";
	NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH);
	Number bigDecimal = NumberUtils.parseNumber(bigDecimalAsString, BigDecimal.class, numberFormat);
	assertEquals(new BigDecimal(bigDecimalAsString), bigDecimal);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:NumberUtilsTests.java

示例13: testParseLocalizedBigDecimalNumber3

import org.springframework.core.JdkVersion; //导入依赖的package包/类
public void testParseLocalizedBigDecimalNumber3() {
	if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
		return;
	}
	String bigDecimalAsString = "3.14159265358979323846";
	NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH);
	Number bigDecimal = NumberUtils.parseNumber(bigDecimalAsString, BigDecimal.class, numberFormat);
	assertEquals(new BigDecimal(bigDecimalAsString), bigDecimal);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:NumberUtilsTests.java

示例14: SQLErrorCodeSQLExceptionTranslator

import org.springframework.core.JdkVersion; //导入依赖的package包/类
/**
 * Constructor for use as a JavaBean.
 * The SqlErrorCodes or DataSource property must be set.
 */
public SQLErrorCodeSQLExceptionTranslator() {
	if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_16) {
		setFallbackTranslator(new SQLExceptionSubclassTranslator());
	}
	else {
		setFallbackTranslator(new SQLStateSQLExceptionTranslator());
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:13,代码来源:SQLErrorCodeSQLExceptionTranslator.java

示例15: supports

import org.springframework.core.JdkVersion; //导入依赖的package包/类
public boolean supports(Type genericType) {
	if (genericType instanceof ParameterizedType) {
		ParameterizedType parameterizedType = (ParameterizedType) genericType;
		if (JAXBElement.class.equals(parameterizedType.getRawType()) &&
				parameterizedType.getActualTypeArguments().length == 1) {
			Type typeArgument = parameterizedType.getActualTypeArguments()[0];
			if (typeArgument instanceof Class) {
				Class<?> classArgument = (Class<?>) typeArgument;
				if (JdkVersion.getMajorJavaVersion() >= JdkVersion.JAVA_17 && classArgument.isArray()) {
					return classArgument.getComponentType().equals(Byte.TYPE);
				}
				else {
					return (isPrimitiveWrapper(classArgument) || isStandardClass(classArgument) ||
							supportsInternal(classArgument, false));
				}
			}
			else if (JdkVersion.getMajorJavaVersion() <= JdkVersion.JAVA_16 &&
					typeArgument instanceof GenericArrayType) {
				// see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5041784
				GenericArrayType arrayType = (GenericArrayType) typeArgument;
				return arrayType.getGenericComponentType().equals(Byte.TYPE);
			}
		}
	}
	else if (genericType instanceof Class) {
		Class<?> clazz = (Class<?>) genericType;
		return supportsInternal(clazz, this.checkForXmlRootElement);
	}
	return false;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:31,代码来源:Jaxb2Marshaller.java


注:本文中的org.springframework.core.JdkVersion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。