use of org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Element in project jaxb-ri by eclipse-ee4j.
the class InlineAnnotationReaderImpl method getAllAnnotations.
/**
* Gets all the annotations on the given declaration.
*/
private Annotation[] getAllAnnotations(Element decl, Locatable srcPos) {
List<Annotation> r = new ArrayList<>();
for (AnnotationMirror m : decl.getAnnotationMirrors()) {
try {
String fullName = ((TypeElement) m.getAnnotationType().asElement()).getQualifiedName().toString();
Class<? extends Annotation> type = SecureLoader.getClassClassLoader(getClass()).loadClass(fullName).asSubclass(Annotation.class);
Annotation annotation = decl.getAnnotation(type);
if (annotation != null)
r.add(LocatableAnnotation.create(annotation, srcPos));
} catch (ClassNotFoundException e) {
// just continue
}
}
return r.toArray(new Annotation[0]);
}
use of org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Element in project jaxb-ri by eclipse-ee4j.
the class StructureLoader method init.
/**
* Completes the initialization.
*
* <p>
* To fix the cyclic reference issue, the main part of the initialization needs to be done
* after a is set to {@link ClassBeanInfoImpl#loader}.
*/
public void init(JAXBContextImpl context, ClassBeanInfoImpl beanInfo, Accessor<?, Map<QName, String>> attWildcard) {
UnmarshallerChain chain = new UnmarshallerChain(context);
for (ClassBeanInfoImpl bi = beanInfo; bi != null; bi = bi.superClazz) {
for (int i = bi.properties.length - 1; i >= 0; i--) {
Property p = bi.properties[i];
switch(p.getKind()) {
case ATTRIBUTE:
if (attUnmarshallers == null)
attUnmarshallers = new QNameMap<>();
AttributeProperty ap = (AttributeProperty) p;
attUnmarshallers.put(ap.attName.toQName(), ap.xacc);
break;
case ELEMENT:
case REFERENCE:
case MAP:
case VALUE:
p.buildChildElementUnmarshallers(chain, childUnmarshallers);
break;
}
}
}
this.frameSize = chain.getScopeSize();
textHandler = childUnmarshallers.get(StructureLoaderBuilder.TEXT_HANDLER);
catchAll = childUnmarshallers.get(StructureLoaderBuilder.CATCH_ALL);
if (attWildcard != null) {
attCatchAll = (Accessor<Object, Map<QName, String>>) attWildcard;
// altogether, so if we have an att wildcard we need to have an empty qname map.
if (attUnmarshallers == null)
attUnmarshallers = EMPTY;
} else {
attCatchAll = null;
}
}
use of org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Element in project jaxb-ri by eclipse-ee4j.
the class SingleElementNodeProperty method buildChildElementUnmarshallers.
@Override
public void buildChildElementUnmarshallers(UnmarshallerChain chain, QNameMap<ChildLoader> handlers) {
JAXBContextImpl context = chain.context;
for (TypeRef<Type, Class> e : prop.getTypes()) {
JaxBeanInfo bi = context.getOrCreate((RuntimeTypeInfo) e.getTarget());
// if the expected Java type is already final, type substitution won't really work anyway.
// this also traps cases like trying to substitute xsd:long element with xsi:type='xsd:int'
Loader l = bi.getLoader(context, !Modifier.isFinal(bi.jaxbType.getModifiers()));
if (e.getDefaultValue() != null)
l = new DefaultValueLoaderDecorator(l, e.getDefaultValue());
if (nillable || chain.context.allNillable)
l = new XsiNilLoader.Single(l, acc);
handlers.put(e.getTagName(), new ChildLoader(l, acc));
}
}
use of org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.Element in project metro-jax-ws by eclipse-ee4j.
the class ServiceArtifactSchemaGenerator method generate.
public void generate(SchemaOutputResolver resolver) {
xsdResolver = resolver;
List<WrapperParameter> wrappers = new ArrayList<>();
for (JavaMethodImpl method : model.getJavaMethods()) {
if (method.getBinding().isRpcLit())
continue;
for (ParameterImpl p : method.getRequestParameters()) {
if (p instanceof WrapperParameter) {
if (WrapperComposite.class.equals((p.getTypeInfo().type))) {
wrappers.add((WrapperParameter) p);
}
}
}
for (ParameterImpl p : method.getResponseParameters()) {
if (p instanceof WrapperParameter) {
if (WrapperComposite.class.equals((p.getTypeInfo().type))) {
wrappers.add((WrapperParameter) p);
}
}
}
}
if (wrappers.isEmpty())
return;
HashMap<String, Schema> xsds = initWrappersSchemaWithImports(wrappers);
postInit(xsds);
for (WrapperParameter wp : wrappers) {
String tns = wp.getName().getNamespaceURI();
Schema xsd = xsds.get(tns);
Element e = xsd._element(Element.class);
e._attribute("name", wp.getName().getLocalPart());
e.type(wp.getName());
ComplexType ct = xsd._element(ComplexType.class);
ct._attribute("name", wp.getName().getLocalPart());
ExplicitGroup sq = ct.sequence();
for (ParameterImpl p : wp.getWrapperChildren()) if (p.getBinding().isBody())
addChild(sq, p);
}
for (Schema xsd : xsds.values()) xsd.commit();
}
Aggregations