本文整理汇总了Java中javax.xml.bind.annotation.XmlSchema.location方法的典型用法代码示例。如果您正苦于以下问题:Java XmlSchema.location方法的具体用法?Java XmlSchema.location怎么用?Java XmlSchema.location使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.annotation.XmlSchema
的用法示例。
在下文中一共展示了XmlSchema.location方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import javax.xml.bind.annotation.XmlSchema; //导入方法依赖的package包/类
public void write(OutputStream stream, T object) {
try {
JAXBContext context = JAXBContext.newInstance(object.getClass());
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
XmlSchema schemaAnnotation = object.getClass().getPackage().getAnnotation(XmlSchema.class);
if (schemaAnnotation != null && schemaAnnotation.location() != null) {
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, schemaAnnotation.location());
// TODO: May just this ArtifactoryConfigVersion.getCurrent().getXsdLocation());
}
marshaller.marshal(object, stream);
} catch (Exception e) {
throw new RuntimeException("Failed to write object to stream.", e);
} finally {
IOUtils.closeQuietly(stream);
}
}
示例2: getSchemaLocations
import javax.xml.bind.annotation.XmlSchema; //导入方法依赖的package包/类
public Map<String,String> getSchemaLocations() {
Map<String, String> r = new HashMap<String,String>();
for (ClassInfoImpl<T, C, F, M> ci : beans().values()) {
XmlSchema xs = reader.getPackageAnnotation( XmlSchema.class, ci.getClazz(), null );
if(xs==null)
continue;
String loc = xs.location();
if(loc.equals(XmlSchema.NO_LOCATION))
continue; // unspecified
r.put(xs.namespace(),loc);
}
return r;
}