本文整理匯總了Java中javax.xml.bind.annotation.XmlNs類的典型用法代碼示例。如果您正苦於以下問題:Java XmlNs類的具體用法?Java XmlNs怎麽用?Java XmlNs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
XmlNs類屬於javax.xml.bind.annotation包,在下文中一共展示了XmlNs類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getXmlNs
import javax.xml.bind.annotation.XmlNs; //導入依賴的package包/類
public Map<String,String> getXmlNs(String namespaceUri) {
if(xmlNsCache==null) {
xmlNsCache = new HashMap<String,Map<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 uri = xs.namespace();
Map<String,String> m = xmlNsCache.get(uri);
if(m==null)
xmlNsCache.put(uri,m=new HashMap<String, String>());
for( XmlNs xns : xs.xmlns() ) {
m.put(xns.prefix(),xns.namespaceURI());
}
}
}
Map<String,String> r = xmlNsCache.get(namespaceUri);
if(r!=null) return r;
else return Collections.emptyMap();
}
示例2: getPrefix
import javax.xml.bind.annotation.XmlNs; //導入依賴的package包/類
private static String getPrefix(final Package targetPackage,
String namespaceURI) {
String prefix;
final Map<String, String> namespacePrefixes = new HashMap<String, String>();
if (targetPackage != null) {
final XmlSchema xmlSchemaAnnotation = targetPackage
.getAnnotation(XmlSchema.class);
if (xmlSchemaAnnotation != null) {
for (XmlNs xmlns : xmlSchemaAnnotation.xmlns()) {
namespacePrefixes.put(xmlns.namespaceURI(), xmlns.prefix());
}
}
}
prefix = namespacePrefixes.get(namespaceURI);
return prefix;
}
示例3: run
import javax.xml.bind.annotation.XmlNs; //導入依賴的package包/類
@Override
public boolean run(final Outline outline, final Options options, final ErrorHandler errorHandler) {
final JClass xmlNsClass = outline.getCodeModel().ref(XmlNs.class);
final JClass xmlSchemaClass = outline.getCodeModel().ref(XmlSchema.class);
for (PackageOutline packageOutline : outline.getAllPackageContexts()) {
final JPackage p = packageOutline._package();
// get the target namespaces of all schemas that bind to the current package
final Set<String> packageNamespaces = getPackageNamespace(packageOutline);
// is there any prefix binding defined for the current package ?
final Model packageModel = getPackageModel((PackageOutlineImpl) packageOutline);
final List<Pair> list = getPrefixBinding(packageModel, packageNamespaces);
acknowledgePrefixAnnotations(packageModel);
if (list == null || list.isEmpty()) {
// no prefix binding, nothing to do
continue;
}
// add XML namespace prefix annotations
final JAnnotationUse xmlSchemaAnnotation = getOrAddXmlSchemaAnnotation(p, xmlSchemaClass);
if (xmlSchemaAnnotation == null) {
throw new RuntimeException("Unable to get/add 'XmlSchema' annotation to package [" + p.name() + "]");
}
final JAnnotationArrayMember members = xmlSchemaAnnotation.paramArray("xmlns");
for (Pair pair : list) {
addNamespacePrefix(xmlNsClass, members, pair.getNamespace(), pair.getPrefix());
}
}
return true;
}
示例4: xmlns
import javax.xml.bind.annotation.XmlNs; //導入依賴的package包/類
public XmlNs[] xmlns() {
return core.xmlns();
}
示例5: getXmlNsSet
import javax.xml.bind.annotation.XmlNs; //導入依賴的package包/類
/**
* Returns declared XmlNs annotations (from package-level annotation XmlSchema
*
* @return set of all present XmlNs annotations
*/
public Set<XmlNs> getXmlNsSet() {
return xmlNsSet;
}