下面列出了javax.xml.bind.annotation.XmlNs#com.sun.xml.internal.bind.api.TypeReference 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
*
* @param classes
* @param typeRefs
* @param subclassReplacements
* @param defaultNsUri
* @param c14nSupport
* @param ar
* @param xmlAccessorFactorySupport
* @param allNillable
* @param retainPropertyInfo
* @param improvedXsiTypeHandling
* @return
* @throws JAXBException
* @deprecated use createContext( Class[] classes, Map<String,Object> properties) method instead
*/
@Deprecated
public static JAXBRIContext createContext( Class[] classes,
Collection<TypeReference> typeRefs, Map<Class,Class> subclassReplacements,
String defaultNsUri, boolean c14nSupport, RuntimeAnnotationReader ar,
boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean improvedXsiTypeHandling) throws JAXBException {
JAXBContextImpl.JAXBContextBuilder builder = new JAXBContextImpl.JAXBContextBuilder();
builder.setClasses(classes);
builder.setTypeRefs(typeRefs);
builder.setSubclassReplacements(subclassReplacements);
builder.setDefaultNsUri(defaultNsUri);
builder.setC14NSupport(c14nSupport);
builder.setAnnotationReader(ar);
builder.setXmlAccessorFactorySupport(xmlAccessorFactorySupport);
builder.setAllNillable(allNillable);
builder.setRetainPropertyInfo(retainPropertyInfo);
builder.setImprovedXsiTypeHandling(improvedXsiTypeHandling);
return builder.build();
}
public JAXBContextImpl build() throws JAXBException {
// fool-proof
if (this.defaultNsUri == null) {
this.defaultNsUri = "";
}
if (this.subclassReplacements == null) {
this.subclassReplacements = Collections.emptyMap();
}
if (this.annotationReader == null) {
this.annotationReader = new RuntimeInlineAnnotationReader();
}
if (this.typeRefs == null) {
this.typeRefs = Collections.<TypeReference>emptyList();
}
return new JAXBContextImpl(this);
}
/**
*
* @param classes
* @param typeRefs
* @param subclassReplacements
* @param defaultNsUri
* @param c14nSupport
* @param ar
* @param xmlAccessorFactorySupport
* @param allNillable
* @param retainPropertyInfo
* @param improvedXsiTypeHandling
* @return
* @throws JAXBException
* @deprecated use createContext( Class[] classes, Map<String,Object> properties) method instead
*/
@Deprecated
public static JAXBRIContext createContext( Class[] classes,
Collection<TypeReference> typeRefs, Map<Class,Class> subclassReplacements,
String defaultNsUri, boolean c14nSupport, RuntimeAnnotationReader ar,
boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean improvedXsiTypeHandling) throws JAXBException {
JAXBContextImpl.JAXBContextBuilder builder = new JAXBContextImpl.JAXBContextBuilder();
builder.setClasses(classes);
builder.setTypeRefs(typeRefs);
builder.setSubclassReplacements(subclassReplacements);
builder.setDefaultNsUri(defaultNsUri);
builder.setC14NSupport(c14nSupport);
builder.setAnnotationReader(ar);
builder.setXmlAccessorFactorySupport(xmlAccessorFactorySupport);
builder.setAllNillable(allNillable);
builder.setRetainPropertyInfo(retainPropertyInfo);
builder.setImprovedXsiTypeHandling(improvedXsiTypeHandling);
return builder.build();
}
public JAXBContextImpl build() throws JAXBException {
// fool-proof
if (this.defaultNsUri == null) {
this.defaultNsUri = "";
}
if (this.subclassReplacements == null) {
this.subclassReplacements = Collections.emptyMap();
}
if (this.annotationReader == null) {
this.annotationReader = new RuntimeInlineAnnotationReader();
}
if (this.typeRefs == null) {
this.typeRefs = Collections.<TypeReference>emptyList();
}
return new JAXBContextImpl(this);
}
public JAXBContextImpl build() throws JAXBException {
// fool-proof
if (this.defaultNsUri == null) {
this.defaultNsUri = "";
}
if (this.subclassReplacements == null) {
this.subclassReplacements = Collections.emptyMap();
}
if (this.annotationReader == null) {
this.annotationReader = new RuntimeInlineAnnotationReader();
}
if (this.typeRefs == null) {
this.typeRefs = Collections.<TypeReference>emptyList();
}
return new JAXBContextImpl(this);
}
/**
*
* @param classes
* @param typeRefs
* @param subclassReplacements
* @param defaultNsUri
* @param c14nSupport
* @param ar
* @param xmlAccessorFactorySupport
* @param allNillable
* @param retainPropertyInfo
* @param improvedXsiTypeHandling
* @return
* @throws JAXBException
* @deprecated use createContext( Class[] classes, Map<String,Object> properties) method instead
*/
@Deprecated
public static JAXBRIContext createContext( Class[] classes,
Collection<TypeReference> typeRefs, Map<Class,Class> subclassReplacements,
String defaultNsUri, boolean c14nSupport, RuntimeAnnotationReader ar,
boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean improvedXsiTypeHandling) throws JAXBException {
JAXBContextImpl.JAXBContextBuilder builder = new JAXBContextImpl.JAXBContextBuilder();
builder.setClasses(classes);
builder.setTypeRefs(typeRefs);
builder.setSubclassReplacements(subclassReplacements);
builder.setDefaultNsUri(defaultNsUri);
builder.setC14NSupport(c14nSupport);
builder.setAnnotationReader(ar);
builder.setXmlAccessorFactorySupport(xmlAccessorFactorySupport);
builder.setAllNillable(allNillable);
builder.setRetainPropertyInfo(retainPropertyInfo);
builder.setImprovedXsiTypeHandling(improvedXsiTypeHandling);
return builder.build();
}
private Map<TypeInfo, TypeReference> typeInfoMappings(Collection<TypeInfo> typeInfos) {
Map<TypeInfo, TypeReference> map = new java.util.HashMap<TypeInfo, TypeReference>();
for (TypeInfo ti : typeInfos) {
Type type = WrapperComposite.class.equals(ti.type) ? CompositeStructure.class : ti.type;
TypeReference tr = new TypeReference(ti.tagName, type, ti.annotations);
map.put(ti, tr);
}
return map;
}
private NonElement<Type,Class> getXmlType(RuntimeTypeInfoSet tis, TypeReference tr) {
if(tr==null)
throw new IllegalArgumentException();
XmlJavaTypeAdapter xjta = tr.get(XmlJavaTypeAdapter.class);
XmlList xl = tr.get(XmlList.class);
Ref<Type,Class> ref = new Ref<Type,Class>(annotationReader, tis.getNavigator(), tr.type, xjta, xl );
return tis.getTypeInfo(ref);
}
private NonElement<Type,Class> getXmlType(RuntimeTypeInfoSet tis, TypeReference tr) {
if(tr==null)
throw new IllegalArgumentException();
XmlJavaTypeAdapter xjta = tr.get(XmlJavaTypeAdapter.class);
XmlList xl = tr.get(XmlList.class);
Ref<Type,Class> ref = new Ref<Type,Class>(annotationReader, tis.getNavigator(), tr.type, xjta, xl );
return tis.getTypeInfo(ref);
}
/**
* @deprecated
* @param detailType
* @return Gets the CheckedException corresponding to detailType. Returns
* null if no CheckedExcpetion with the detailType found.
*/
public CheckedExceptionImpl getCheckedException(TypeReference detailType) {
for (CheckedExceptionImpl ce : exceptions) {
TypeInfo actual = ce.getDetailType();
if (actual.tagName.equals(detailType.tagName) && actual.type==detailType.type) {
return ce;
}
}
return null;
}
private Map<TypeInfo, TypeReference> typeInfoMappings(Collection<TypeInfo> typeInfos) {
Map<TypeInfo, TypeReference> map = new java.util.HashMap<TypeInfo, TypeReference>();
for (TypeInfo ti : typeInfos) {
Type type = WrapperComposite.class.equals(ti.type) ? CompositeStructure.class : ti.type;
TypeReference tr = new TypeReference(ti.tagName, type, ti.annotations);
map.put(ti, tr);
}
return map;
}
JAXBRIContextWrapper(JAXBRIContext cxt, Map<TypeInfo, TypeReference> refs) {
context = cxt;
typeRefs = refs;
if (refs != null) {
typeInfos = new java.util.HashMap<TypeReference, TypeInfo>();
for (TypeInfo ti : refs.keySet()) {
typeInfos.put(typeRefs.get(ti), ti);
}
}
}
/**
* Creates {@link UsesJAXBContextFeature}.
* This version allows you to create {@link JAXBRIContext} upfront and uses it.
*/
public UsesJAXBContextFeature(@Nullable final JAXBRIContext context) {
this.factory = new JAXBContextFactory() {
@NotNull
public JAXBRIContext createJAXBContext(@NotNull SEIModel sei, @NotNull List<Class> classesToBind, @NotNull List<TypeReference> typeReferences) throws JAXBException {
return context;
}
};
}
/**
* Creates {@link UsesJAXBContextFeature}.
* This version allows you to create {@link JAXBRIContext} upfront and uses it.
*/
public UsesJAXBContextFeature(@Nullable final JAXBRIContext context) {
this.factory = new JAXBContextFactory() {
@NotNull
public JAXBRIContext createJAXBContext(@NotNull SEIModel sei, @NotNull List<Class> classesToBind, @NotNull List<TypeReference> typeReferences) throws JAXBException {
return context;
}
};
}
public QName getTypeName(TypeReference tr) {
try {
NonElement<Type,Class> xt = getXmlType(getTypeInfoSet(),tr);
if(xt==null) throw new IllegalArgumentException();
return xt.getTypeName();
} catch (IllegalAnnotationsException e) {
// impossible given that JAXBRIContext has been successfully built in the first place
throw new AssertionError(e);
}
}
private XmlSchemaGenerator<Type,Class,Field,Method> createSchemaGenerator() {
RuntimeTypeInfoSet tis;
try {
tis = getTypeInfoSet();
} catch (IllegalAnnotationsException e) {
// this shouldn't happen because we've already
throw new AssertionError(e);
}
XmlSchemaGenerator<Type,Class,Field,Method> xsdgen =
new XmlSchemaGenerator<Type,Class,Field,Method>(tis.getNavigator(),tis);
// JAX-RPC uses Bridge objects that collide with
// @XmlRootElement.
// we will avoid collision here
Set<QName> rootTagNames = new HashSet<QName>();
for (RuntimeElementInfo ei : tis.getAllElements()) {
rootTagNames.add(ei.getElementName());
}
for (RuntimeClassInfo ci : tis.beans().values()) {
if(ci.isElement())
rootTagNames.add(ci.asElement().getElementName());
}
for (TypeReference tr : bridges.keySet()) {
if(rootTagNames.contains(tr.tagName))
continue;
if(tr.type==void.class || tr.type==Void.class) {
xsdgen.add(tr.tagName,false,null);
} else
if(tr.type==CompositeStructure.class) {
// this is a special class we introduced for JAX-WS that we *don't* want in the schema
} else {
NonElement<Type,Class> typeInfo = getXmlType(tis,tr);
xsdgen.add(tr.tagName, !tis.getNavigator().isPrimitive(tr.type),typeInfo);
}
}
return xsdgen;
}
public QName getTypeName(TypeReference tr) {
try {
NonElement<Type,Class> xt = getXmlType(getTypeInfoSet(),tr);
if(xt==null) throw new IllegalArgumentException();
return xt.getTypeName();
} catch (IllegalAnnotationsException e) {
// impossible given that JAXBRIContext has been successfully built in the first place
throw new AssertionError(e);
}
}
@Override
public XMLBridge createBridge(TypeInfo ti) {
TypeReference tr = typeRefs.get(ti);
com.sun.xml.internal.bind.api.Bridge b = context.createBridge(tr);
return WrapperComposite.class.equals(ti.type)
? new WrapperBridge(this, b)
: new BridgeWrapper(this, b);
}
private XmlSchemaGenerator<Type,Class,Field,Method> createSchemaGenerator() {
RuntimeTypeInfoSet tis;
try {
tis = getTypeInfoSet();
} catch (IllegalAnnotationsException e) {
// this shouldn't happen because we've already
throw new AssertionError(e);
}
XmlSchemaGenerator<Type,Class,Field,Method> xsdgen =
new XmlSchemaGenerator<Type,Class,Field,Method>(tis.getNavigator(),tis);
// JAX-RPC uses Bridge objects that collide with
// @XmlRootElement.
// we will avoid collision here
Set<QName> rootTagNames = new HashSet<QName>();
for (RuntimeElementInfo ei : tis.getAllElements()) {
rootTagNames.add(ei.getElementName());
}
for (RuntimeClassInfo ci : tis.beans().values()) {
if(ci.isElement())
rootTagNames.add(ci.asElement().getElementName());
}
for (TypeReference tr : bridges.keySet()) {
if(rootTagNames.contains(tr.tagName))
continue;
if(tr.type==void.class || tr.type==Void.class) {
xsdgen.add(tr.tagName,false,null);
} else
if(tr.type==CompositeStructure.class) {
// this is a special class we introduced for JAX-WS that we *don't* want in the schema
} else {
NonElement<Type,Class> typeInfo = getXmlType(tis,tr);
xsdgen.add(tr.tagName, !tis.getNavigator().isPrimitive(tr.type),typeInfo);
}
}
return xsdgen;
}
public QName getTypeName(TypeReference tr) {
try {
NonElement<Type,Class> xt = getXmlType(getTypeInfoSet(),tr);
if(xt==null) throw new IllegalArgumentException();
return xt.getTypeName();
} catch (IllegalAnnotationsException e) {
// impossible given that JAXBRIContext has been successfully built in the first place
throw new AssertionError(e);
}
}
@Override
public XMLBridge createBridge(TypeInfo ti) {
TypeReference tr = typeRefs.get(ti);
com.sun.xml.internal.bind.api.Bridge b = context.createBridge(tr);
return WrapperComposite.class.equals(ti.type)
? new WrapperBridge(this, b)
: new BridgeWrapper(this, b);
}
@Override
public BindingContext newContext(BindingInfo bi) {
Class[] classes = bi.contentClasses().toArray(new Class[bi.contentClasses().size()]);
for (int i = 0; i < classes.length; i++) {
if (WrapperComposite.class.equals(classes[i])) {
classes[i] = CompositeStructure.class;
}
}
Map<TypeInfo, TypeReference> typeInfoMappings = typeInfoMappings(bi.typeInfos());
Map<Class, Class> subclassReplacements = bi.subclassReplacements();
String defaultNamespaceRemap = bi.getDefaultNamespace();
Boolean c14nSupport = (Boolean) bi.properties().get("c14nSupport");
RuntimeAnnotationReader ar = (RuntimeAnnotationReader) bi.properties().get("com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader");
JAXBContextFactory jaxbContextFactory = (JAXBContextFactory) bi.properties().get(JAXBContextFactory.class.getName());
try {
JAXBRIContext context = (jaxbContextFactory != null)
? jaxbContextFactory.createJAXBContext(
bi.getSEIModel(),
toList(classes),
toList(typeInfoMappings.values()))
: ContextFactory.createContext(
classes, typeInfoMappings.values(),
subclassReplacements, defaultNamespaceRemap,
(c14nSupport != null) ? c14nSupport : false,
ar, false, false, false);
return new JAXBRIContextWrapper(context, typeInfoMappings);
} catch (Exception e) {
throw new DatabindingException(e);
}
}
private Map<TypeInfo, TypeReference> typeInfoMappings(Collection<TypeInfo> typeInfos) {
Map<TypeInfo, TypeReference> map = new java.util.HashMap<TypeInfo, TypeReference>();
for (TypeInfo ti : typeInfos) {
Type type = WrapperComposite.class.equals(ti.type) ? CompositeStructure.class : ti.type;
TypeReference tr = new TypeReference(ti.tagName, type, ti.annotations);
map.put(ti, tr);
}
return map;
}
/**
* @deprecated
* @param detailType
* @return Gets the CheckedException corresponding to detailType. Returns
* null if no CheckedExcpetion with the detailType found.
*/
public CheckedExceptionImpl getCheckedException(TypeReference detailType) {
for (CheckedExceptionImpl ce : exceptions) {
TypeInfo actual = ce.getDetailType();
if (actual.tagName.equals(detailType.tagName) && actual.type==detailType.type) {
return ce;
}
}
return null;
}
private Map<TypeInfo, TypeReference> typeInfoMappings(Collection<TypeInfo> typeInfos) {
Map<TypeInfo, TypeReference> map = new java.util.HashMap<TypeInfo, TypeReference>();
for (TypeInfo ti : typeInfos) {
Type type = WrapperComposite.class.equals(ti.type) ? CompositeStructure.class : ti.type;
TypeReference tr = new TypeReference(ti.tagName, type, ti.annotations);
map.put(ti, tr);
}
return map;
}
private XmlSchemaGenerator<Type,Class,Field,Method> createSchemaGenerator() {
RuntimeTypeInfoSet tis;
try {
tis = getTypeInfoSet();
} catch (IllegalAnnotationsException e) {
// this shouldn't happen because we've already
throw new AssertionError(e);
}
XmlSchemaGenerator<Type,Class,Field,Method> xsdgen =
new XmlSchemaGenerator<Type,Class,Field,Method>(tis.getNavigator(),tis);
// JAX-RPC uses Bridge objects that collide with
// @XmlRootElement.
// we will avoid collision here
Set<QName> rootTagNames = new HashSet<QName>();
for (RuntimeElementInfo ei : tis.getAllElements()) {
rootTagNames.add(ei.getElementName());
}
for (RuntimeClassInfo ci : tis.beans().values()) {
if(ci.isElement())
rootTagNames.add(ci.asElement().getElementName());
}
for (TypeReference tr : bridges.keySet()) {
if(rootTagNames.contains(tr.tagName))
continue;
if(tr.type==void.class || tr.type==Void.class) {
xsdgen.add(tr.tagName,false,null);
} else
if(tr.type==CompositeStructure.class) {
// this is a special class we introduced for JAX-WS that we *don't* want in the schema
} else {
NonElement<Type,Class> typeInfo = getXmlType(tis,tr);
xsdgen.add(tr.tagName, !tis.getNavigator().isPrimitive(tr.type),typeInfo);
}
}
return xsdgen;
}
private Map<TypeInfo, TypeReference> typeInfoMappings(Collection<TypeInfo> typeInfos) {
Map<TypeInfo, TypeReference> map = new java.util.HashMap<TypeInfo, TypeReference>();
for (TypeInfo ti : typeInfos) {
Type type = WrapperComposite.class.equals(ti.type) ? CompositeStructure.class : ti.type;
TypeReference tr = new TypeReference(ti.tagName, type, ti.annotations);
map.put(ti, tr);
}
return map;
}
@Override
public XMLBridge createBridge(TypeInfo ti) {
TypeReference tr = typeRefs.get(ti);
com.sun.xml.internal.bind.api.Bridge b = context.createBridge(tr);
return WrapperComposite.class.equals(ti.type)
? new WrapperBridge(this, b)
: new BridgeWrapper(this, b);
}
private XmlSchemaGenerator<Type,Class,Field,Method> createSchemaGenerator() {
RuntimeTypeInfoSet tis;
try {
tis = getTypeInfoSet();
} catch (IllegalAnnotationsException e) {
// this shouldn't happen because we've already
throw new AssertionError(e);
}
XmlSchemaGenerator<Type,Class,Field,Method> xsdgen =
new XmlSchemaGenerator<Type,Class,Field,Method>(tis.getNavigator(),tis);
// JAX-RPC uses Bridge objects that collide with
// @XmlRootElement.
// we will avoid collision here
Set<QName> rootTagNames = new HashSet<QName>();
for (RuntimeElementInfo ei : tis.getAllElements()) {
rootTagNames.add(ei.getElementName());
}
for (RuntimeClassInfo ci : tis.beans().values()) {
if(ci.isElement())
rootTagNames.add(ci.asElement().getElementName());
}
for (TypeReference tr : bridges.keySet()) {
if(rootTagNames.contains(tr.tagName))
continue;
if(tr.type==void.class || tr.type==Void.class) {
xsdgen.add(tr.tagName,false,null);
} else
if(tr.type==CompositeStructure.class) {
// this is a special class we introduced for JAX-WS that we *don't* want in the schema
} else {
NonElement<Type,Class> typeInfo = getXmlType(tis,tr);
xsdgen.add(tr.tagName, !tis.getNavigator().isPrimitive(tr.type),typeInfo);
}
}
return xsdgen;
}
public BridgeImpl(JAXBContextImpl context, Name tagName, JaxBeanInfo<T> bi,TypeReference typeRef) {
super(context);
this.tagName = tagName;
this.bi = bi;
this.typeRef = typeRef;
}