Java Code Examples for javax.xml.bind.annotation.XmlSchema#xmlns()
The following examples show how to use
javax.xml.bind.annotation.XmlSchema#xmlns() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeInfoSetImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); }
Example 2
Source File: TypeInfoSetImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
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(); }
Example 3
Source File: TypeInfoSetImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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(); }
Example 4
Source File: TypeInfoSetImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
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(); }
Example 5
Source File: TypeInfoSetImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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(); }
Example 6
Source File: TypeInfoSetImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
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(); }
Example 7
Source File: TypeInfoSetImpl.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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(); }
Example 8
Source File: TypeInfoSetImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
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(); }
Example 9
Source File: XmlTypeUtils.java From jaxb2-basics with BSD 2-Clause "Simplified" License | 6 votes |
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; }
Example 10
Source File: EppInput.java From nomulus with Apache License 2.0 | 5 votes |
/** * Returns the EPP resource type ("domain", "contact", or "host") for commands that operate on * EPP resources, otherwise absent. */ public Optional<String> getResourceType() { ResourceCommand resourceCommand = getResourceCommand(); if (resourceCommand != null) { XmlSchema xmlSchemaAnnotation = resourceCommand.getClass().getPackage().getAnnotation(XmlSchema.class); if (xmlSchemaAnnotation != null && xmlSchemaAnnotation.xmlns().length > 0) { return Optional.of(xmlSchemaAnnotation.xmlns()[0].prefix()); } } return Optional.empty(); }
Example 11
Source File: AnnotationConsistencyCheck.java From sis with Apache License 2.0 | 4 votes |
/** * Replaces {@value #DEFAULT} value by the {@link XmlSchema} namespace if needed, * then performs validity check on the resulting namespace. This method checks that: * * <ul> * <li>The namespace is not redundant with the package-level {@link XmlSchema} namespace.</li> * <li>The namespace is declared in a package-level {@link XmlNs} annotation.</li> * <li>The namespace starts with the {@linkplain #getExpectedNamespaceStart expected namespace}.</li> * </ul> * * @param namespace the namespace given by the {@code @XmlRootElement} or {@code @XmlElement} annotation. * @param impl the implementation or wrapper class from which to get the package namespace. * @param uml the {@code @UML} annotation, or {@code null} if none. * @return the actual namespace (same as {@code namespace} if it was not {@value #DEFAULT}). */ private String assertExpectedNamespace(String namespace, final Class<?> impl, final UML uml) { assertNotNull("Missing namespace.", namespace); assertFalse("Missing namespace.", namespace.trim().isEmpty()); /* * Get the namespace declared at the package level, and ensure the the * given namespace is not redundant with that package-level namespace. */ final XmlSchema schema = impl.getPackage().getAnnotation(XmlSchema.class); assertNotNull("Missing @XmlSchema annotation in package-info.", schema); final String schemaNamespace = schema.namespace(); // May be XMLConstants.NULL_NS_URI assertFalse("Namespace declaration is redundant with package-info @XmlSchema.", namespace.equals(schemaNamespace)); /* * Resolve the namespace given in argument: using the class-level namespace if needed, * or the package-level namespace if the class-level one is not defined. */ if (DEFAULT.equals(namespace)) { final XmlType type = impl.getAnnotation(XmlType.class); if (type == null || DEFAULT.equals(namespace = type.namespace())) { namespace = schemaNamespace; } assertFalse("No namespace defined.", XMLConstants.NULL_NS_URI.equals(namespace)); } /* * Check that the namespace is declared in the package-level @XmlNs annotation. * We do not verify the validity of those @XmlNs annotations, since this is the * purpose of the 'testPackageAnnotations()' method. */ boolean found = false; for (final XmlNs ns : schema.xmlns()) { if (namespace.equals(ns.namespaceURI())) { found = true; break; } } if (!found) { fail("Namespace for " + impl + " is not declared in the package @XmlSchema.xmlns()."); } /* * Check that the namespace is one of the namespaces controlled by the specification. * We check only the namespace start, since some specifications define many namespaces * under a common root (e.g. "http://standards.iso.org/iso/19115/-3/"). */ if (uml != null && false) { // This verification is available only on development branches. final String expected = getExpectedNamespaceStart(impl, uml); if (!namespace.startsWith(expected)) { fail("Expected " + expected + "… namespace for that ISO specification but got " + namespace); } } return namespace; }