类javax.xml.bind.annotation.XmlSchema源码实例Demo

下面列出了怎么用javax.xml.bind.annotation.XmlSchema的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: cxf   文件: JaxWsServiceFactoryBean.java
protected final void initConfiguration(JaxWsImplementorInfo ii) {
    if (ii.isWebServiceProvider()) {
        jaxWsConfiguration = new WebServiceProviderConfiguration();
        jaxWsConfiguration.setServiceFactory(this);
        getServiceConfigurations().add(0, jaxWsConfiguration);
        setWrapped(false);
        setDataBinding(new SourceDataBinding());
        setMethodDispatcher(new JAXWSProviderMethodDispatcher(implInfo));
    } else {
        jaxWsConfiguration = new JaxWsServiceConfiguration();
        jaxWsConfiguration.setServiceFactory(this);
        getServiceConfigurations().add(0, jaxWsConfiguration);

        Class<?> seiClass = ii.getEndpointClass();
        if (seiClass != null && seiClass.getPackage() != null) {
            XmlSchema schema = seiClass.getPackage().getAnnotation(XmlSchema.class);
            if (schema != null && XmlNsForm.QUALIFIED.equals(schema.elementFormDefault())) {
                setQualifyWrapperSchema(true);
            }
        }
        setMethodDispatcher(new JAXWSMethodDispatcher(implInfo));
    }
    loadWSFeatureAnnotation(ii.getSEIClass(), ii.getImplementorClass());
}
 
源代码2 项目: TencentKona-8   文件: ElementInfoImpl.java
final QName parseElementName(XmlElementDecl e) {
    String local = e.name();
    String nsUri = e.namespace();
    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,
            nav().getDeclaringClassForMethod(method),this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
源代码3 项目: jaxb2-basics   文件: XmlTypeUtils.java
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;
}
 
源代码4 项目: jaxb2-basics   文件: XmlTypeUtils.java
private static String getNamespace(final Package targetPackage) {
	String namespaceURI;
	if (targetPackage == null) {
		namespaceURI = "";
	} else {
		final XmlSchema xmlSchemaAnnotation = targetPackage
				.getAnnotation(XmlSchema.class);
		if (xmlSchemaAnnotation == null) {
			namespaceURI = "";
		} else {
			final String packageNamespace = xmlSchemaAnnotation.namespace();
			if (packageNamespace == null || "".equals(packageNamespace)) {
				namespaceURI = "";
			} else {
				namespaceURI = packageNamespace;
			}
		}
	}
	return namespaceURI;
}
 
源代码5 项目: jdk8u60   文件: TypeInfoSetImpl.java
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();
}
 
源代码6 项目: jdk8u60   文件: TypeInfoImpl.java
/**
 * Parses an {@link XmlRootElement} annotation on a class
 * and determine the element name.
 *
 * @return null
 *      if none was found.
 */
protected final QName parseElementName(ClassDeclT clazz) {
    XmlRootElement e = reader().getClassAnnotation(XmlRootElement.class,clazz,this);
    if(e==null)
        return null;

    String local = e.name();
    if(local.equals("##default")) {
        // if defaulted...
        local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz));
    }
    String nsUri = e.namespace();
    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
源代码7 项目: hottub   文件: TypeInfoImpl.java
/**
 * Parses an {@link XmlRootElement} annotation on a class
 * and determine the element name.
 *
 * @return null
 *      if none was found.
 */
protected final QName parseElementName(ClassDeclT clazz) {
    XmlRootElement e = reader().getClassAnnotation(XmlRootElement.class,clazz,this);
    if(e==null)
        return null;

    String local = e.name();
    if(local.equals("##default")) {
        // if defaulted...
        local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz));
    }
    String nsUri = e.namespace();
    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
源代码8 项目: openjdk-jdk8u   文件: TypeInfoSetImpl.java
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();
}
 
源代码9 项目: openjdk-8-source   文件: ElementInfoImpl.java
final QName parseElementName(XmlElementDecl e) {
    String local = e.name();
    String nsUri = e.namespace();
    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,
            nav().getDeclaringClassForMethod(method),this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: ElementInfoImpl.java
final QName parseElementName(XmlElementDecl e) {
    String local = e.name();
    String nsUri = e.namespace();
    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,
            nav().getDeclaringClassForMethod(method),this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
源代码11 项目: openjdk-8   文件: TypeInfoSetImpl.java
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();
}
 
源代码12 项目: openjdk-jdk9   文件: TypeInfoSetImpl.java
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();
}
 
源代码13 项目: openjdk-8-source   文件: TypeInfoImpl.java
/**
 * Parses an {@link XmlRootElement} annotation on a class
 * and determine the element name.
 *
 * @return null
 *      if none was found.
 */
protected final QName parseElementName(ClassDeclT clazz) {
    XmlRootElement e = reader().getClassAnnotation(XmlRootElement.class,clazz,this);
    if(e==null)
        return null;

    String local = e.name();
    if(local.equals("##default")) {
        // if defaulted...
        local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz));
    }
    String nsUri = e.namespace();
    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
源代码14 项目: openjdk-jdk9   文件: TypeInfoImpl.java
/**
 * Parses an {@link XmlRootElement} annotation on a class
 * and determine the element name.
 *
 * @return null
 *      if none was found.
 */
protected final QName parseElementName(ClassDeclT clazz) {
    XmlRootElement e = reader().getClassAnnotation(XmlRootElement.class,clazz,this);
    if(e==null)
        return null;

    String local = e.name();
    if(local.equals("##default")) {
        // if defaulted...
        local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz));
    }
    String nsUri = e.namespace();
    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
源代码15 项目: openjdk-8-source   文件: TypeInfoSetImpl.java
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();
}
 
源代码16 项目: TencentKona-8   文件: ReferencePropertyInfoImpl.java
private String getEffectiveNamespaceFor(XmlElementRef r) {
    String nsUri = r.namespace();

    XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
    if(xs!=null && xs.attributeFormDefault()== XmlNsForm.QUALIFIED) {
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(nsUri.length()==0)
            nsUri = parent.builder.defaultNsUri;
    }

    return nsUri;
}
 
源代码17 项目: openjdk-8   文件: PropertyInfoImpl.java
private QName calcXmlName(String uri,String local) {
    // compute the default
    TODO.checkSpec();
    if(local.length()==0 || local.equals("##default"))
        local = seed.getName();
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.elementFormDefault()) {
            case QUALIFIED:
                QName typeName = parent.getTypeName();
                if(typeName!=null)
                    uri = typeName.getNamespaceURI();
                else
                    uri = xs.namespace();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else {
            uri = "";
        }
    }
    return new QName(uri.intern(),local.intern());
}
 
源代码18 项目: TencentKona-8   文件: TypeInfoSetImpl.java
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;
}
 
源代码19 项目: TencentKona-8   文件: TypeInfoSetImpl.java
public final XmlNsForm getElementFormDefault(String nsUri) {
    for (ClassInfoImpl<T, C, F, M> ci : beans().values()) {
        XmlSchema xs = reader.getPackageAnnotation( XmlSchema.class, ci.getClazz(), null );
        if(xs==null)
            continue;

        if(!xs.namespace().equals(nsUri))
            continue;

        XmlNsForm xnf = xs.elementFormDefault();
        if(xnf!=XmlNsForm.UNSET)
            return xnf;
    }
    return XmlNsForm.UNSET;
}
 
源代码20 项目: TencentKona-8   文件: TypeInfoImpl.java
/**
 * Parses a (potentially-null) {@link XmlType} annotation on a class
 * and determine the actual value.
 *
 * @param clazz
 *      The class on which the XmlType annotation is checked.
 * @param t
 *      The {@link XmlType} annotation on the clazz. This value
 *      is taken as a parameter to improve the performance for the case where
 *      't' is pre-computed.
 */
protected final QName parseTypeName(ClassDeclT clazz, XmlType t) {
    String nsUri="##default";
    String local="##default";
    if(t!=null) {
        nsUri = t.namespace();
        local = t.name();
    }

    if(local.length()==0)
        return null; // anonymous


    if(local.equals("##default"))
        // if defaulted ...
        local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz));

    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
源代码21 项目: TencentKona-8   文件: AttributePropertyInfoImpl.java
private QName calcXmlName(XmlAttribute att) {
    String uri;
    String local;

    uri = att.namespace();
    local = att.name();

    // compute the default
    if(local.equals("##default"))
        local = NameConverter.standard.toVariableName(getName());
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.attributeFormDefault()) {
            case QUALIFIED:
                uri = parent.getTypeName().getNamespaceURI();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else
            uri = "";
    }

    return new QName(uri.intern(),local.intern());
}
 
源代码22 项目: freehealth-connector   文件: MarshallerHelper.java
private static QName translate(Class<?> clazz) {
   Annotation[] arr$ = clazz.getPackage().getAnnotations();
   int len$ = arr$.length;

   for(int i$ = 0; i$ < len$; ++i$) {
      Annotation annotation = arr$[i$];
      if (annotation instanceof XmlSchema) {
         XmlSchema schema = (XmlSchema)annotation;
         return new QName(schema.namespace(), clazz.getSimpleName());
      }
   }

   LOG.debug("Unable to determine QName for class:" + clazz + " using package as namespace.");
   return new QName(clazz.getPackage().getName(), clazz.getSimpleName());
}
 
源代码23 项目: freehealth-connector   文件: MarshallerHelper.java
private static QName translate(Class<?> clazz) {
   Annotation[] arr$ = clazz.getPackage().getAnnotations();
   int len$ = arr$.length;

   for(int i$ = 0; i$ < len$; ++i$) {
      Annotation annotation = arr$[i$];
      if (annotation instanceof XmlSchema) {
         XmlSchema schema = (XmlSchema)annotation;
         return new QName(schema.namespace(), clazz.getSimpleName());
      }
   }

   LOG.debug("Unable to determine QName for class:" + clazz + " using package as namespace.");
   return new QName(clazz.getPackage().getName(), clazz.getSimpleName());
}
 
源代码24 项目: hottub   文件: PropertyInfoImpl.java
private QName calcXmlName(String uri,String local) {
    // compute the default
    TODO.checkSpec();
    if(local.length()==0 || local.equals("##default"))
        local = seed.getName();
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.elementFormDefault()) {
            case QUALIFIED:
                QName typeName = parent.getTypeName();
                if(typeName!=null)
                    uri = typeName.getNamespaceURI();
                else
                    uri = xs.namespace();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else {
            uri = "";
        }
    }
    return new QName(uri.intern(),local.intern());
}
 
源代码25 项目: freehealth-connector   文件: MarshallerHelper.java
private static QName translate(Class<?> clazz) {
   Annotation[] arr$ = clazz.getPackage().getAnnotations();
   int len$ = arr$.length;

   for(int i$ = 0; i$ < len$; ++i$) {
      Annotation annotation = arr$[i$];
      if (annotation instanceof XmlSchema) {
         XmlSchema schema = (XmlSchema)annotation;
         return new QName(schema.namespace(), clazz.getSimpleName());
      }
   }

   LOG.debug("Unable to determine QName for class:" + clazz + " using package as namespace.");
   return new QName(clazz.getPackage().getName(), clazz.getSimpleName());
}
 
源代码26 项目: hottub   文件: AttributePropertyInfoImpl.java
private QName calcXmlName(XmlAttribute att) {
    String uri;
    String local;

    uri = att.namespace();
    local = att.name();

    // compute the default
    if(local.equals("##default"))
        local = NameConverter.standard.toVariableName(getName());
    if(uri.equals("##default")) {
        XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(xs!=null) {
            switch(xs.attributeFormDefault()) {
            case QUALIFIED:
                uri = parent.getTypeName().getNamespaceURI();
                if(uri.length()==0)
                    uri = parent.builder.defaultNsUri;
                break;
            case UNQUALIFIED:
            case UNSET:
                uri = "";
            }
        } else
            uri = "";
    }

    return new QName(uri.intern(),local.intern());
}
 
源代码27 项目: jdk8u60   文件: TypeInfoSetImpl.java
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;
}
 
源代码28 项目: jdk8u60   文件: TypeInfoSetImpl.java
public final XmlNsForm getElementFormDefault(String nsUri) {
    for (ClassInfoImpl<T, C, F, M> ci : beans().values()) {
        XmlSchema xs = reader.getPackageAnnotation( XmlSchema.class, ci.getClazz(), null );
        if(xs==null)
            continue;

        if(!xs.namespace().equals(nsUri))
            continue;

        XmlNsForm xnf = xs.elementFormDefault();
        if(xnf!=XmlNsForm.UNSET)
            return xnf;
    }
    return XmlNsForm.UNSET;
}
 
private String getEffectiveNamespaceFor(XmlElementRef r) {
    String nsUri = r.namespace();

    XmlSchema xs = reader().getPackageAnnotation( XmlSchema.class, parent.getClazz(), this );
    if(xs!=null && xs.attributeFormDefault()== XmlNsForm.QUALIFIED) {
        // JAX-RPC doesn't want the default namespace URI swapping to take effect to
        // local "unqualified" elements. UGLY.
        if(nsUri.length()==0)
            nsUri = parent.builder.defaultNsUri;
    }

    return nsUri;
}
 
源代码30 项目: jdk8u60   文件: TypeInfoImpl.java
/**
 * Parses a (potentially-null) {@link XmlType} annotation on a class
 * and determine the actual value.
 *
 * @param clazz
 *      The class on which the XmlType annotation is checked.
 * @param t
 *      The {@link XmlType} annotation on the clazz. This value
 *      is taken as a parameter to improve the performance for the case where
 *      't' is pre-computed.
 */
protected final QName parseTypeName(ClassDeclT clazz, XmlType t) {
    String nsUri="##default";
    String local="##default";
    if(t!=null) {
        nsUri = t.namespace();
        local = t.name();
    }

    if(local.length()==0)
        return null; // anonymous


    if(local.equals("##default"))
        // if defaulted ...
        local = NameConverter.standard.toVariableName(nav().getClassShortName(clazz));

    if(nsUri.equals("##default")) {
        // if defaulted ...
        XmlSchema xs = reader().getPackageAnnotation(XmlSchema.class,clazz,this);
        if(xs!=null)
            nsUri = xs.namespace();
        else {
            nsUri = builder.defaultNsUri;
        }
    }

    return new QName(nsUri.intern(),local.intern());
}
 
 同包方法