/**
* Returns the schema namespace URI for the specified JAXB type. The URI
* can then be used to create a {@link QName} instance that is necessary
* to instantiate a {@link JAXBElement}.
*
* @param type a JAXB generated type.
* @return the namespace URI.
*/
@SuppressWarnings("unchecked")
public static String getNamespaceUriForType( Class<?> type )
{
String pkgInfoFqcn = type.getPackage().getName() + ".package-info";
try
{
/*
* package-info.class is a special class generated by JAXB - it contains the schema namespace
* URI for all generated classes.
*/
Class<?> pkgInfo = Class.forName( pkgInfoFqcn );
XmlSchema schema = pkgInfo.getAnnotation( XmlSchema.class );
return schema.namespace();
}
catch ( ClassNotFoundException e )
{
return null;
}
}
JaxbHelper.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:quartzdesk-executor
作者:
评论列表
文章目录