use of org.apache.cxf.aegis.type.basic.BeanType in project cxf by apache.
the class XMLTypeCreator method createDefaultType.
@Override
public AegisType createDefaultType(TypeClassInfo info) {
Element mapping = findMapping(info.getType());
List<Element> mappings = findMappings(info.getType());
Class<?> relatedClass = TypeUtil.getTypeRelatedClass(info.getType());
if (mapping != null || !mappings.isEmpty()) {
String typeNameAtt = null;
if (mapping != null) {
typeNameAtt = DOMUtils.getAttributeValueEmptyNull(mapping, "name");
}
String extensibleElements = null;
if (mapping != null) {
extensibleElements = mapping.getAttribute("extensibleElements");
}
String extensibleAttributes = null;
if (mapping != null) {
extensibleAttributes = mapping.getAttribute("extensibleAttributes");
}
String defaultNS = NamespaceHelper.makeNamespaceFromClassName(relatedClass.getName(), "http");
QName name = null;
if (typeNameAtt != null) {
name = NamespaceHelper.createQName(mapping, typeNameAtt, defaultNS);
defaultNS = name.getNamespaceURI();
}
// We do not deal with Generic beans at this point.
XMLBeanTypeInfo btinfo = new XMLBeanTypeInfo(relatedClass, mappings, defaultNS);
btinfo.setTypeMapping(getTypeMapping());
btinfo.setDefaultMinOccurs(getConfiguration().getDefaultMinOccurs());
btinfo.setDefaultNillable(getConfiguration().isDefaultNillable());
if (extensibleElements != null) {
btinfo.setExtensibleElements(Boolean.valueOf(extensibleElements).booleanValue());
} else {
btinfo.setExtensibleElements(getConfiguration().isDefaultExtensibleElements());
}
if (extensibleAttributes != null) {
btinfo.setExtensibleAttributes(Boolean.valueOf(extensibleAttributes).booleanValue());
} else {
btinfo.setExtensibleAttributes(getConfiguration().isDefaultExtensibleAttributes());
}
btinfo.setQualifyAttributes(this.getConfiguration().isQualifyAttributes());
btinfo.setQualifyElements(this.getConfiguration().isQualifyElements());
BeanType type = new BeanType(btinfo);
if (name == null) {
name = createQName(relatedClass);
}
type.setSchemaType(name);
type.setTypeClass(info.getType());
type.setTypeMapping(getTypeMapping());
return type;
}
return nextCreator.createDefaultType(info);
}
use of org.apache.cxf.aegis.type.basic.BeanType in project cxf by apache.
the class AnnotatedTypeTest method testAegisType.
/**
* Test if attributeProperty is correctly mapped to attProp by
* applying the xml mapping file <className>.aegis.xml
*/
@Test
public void testAegisType() {
BeanType type = (BeanType) tm.getTypeCreator().createType(AnnotatedBean3.class);
assertEquals(0, type.getTypeInfo().getAttributes().size());
Iterator<QName> itr = type.getTypeInfo().getElements().iterator();
assertTrue(itr.hasNext());
QName q = itr.next();
assertEquals("attProp", q.getLocalPart());
}
use of org.apache.cxf.aegis.type.basic.BeanType in project cxf by apache.
the class ConfigurationTest method testExtensibleDefaultFalse.
@Test
public void testExtensibleDefaultFalse() throws Exception {
config.setDefaultExtensibleElements(false);
config.setDefaultExtensibleAttributes(false);
AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
BeanTypeInfo info = ((BeanType) type).getTypeInfo();
assertFalse(info.isExtensibleElements());
assertFalse(info.isExtensibleAttributes());
}
use of org.apache.cxf.aegis.type.basic.BeanType in project cxf by apache.
the class ConfigurationTest method testMinOccursDefault0.
@Test
public void testMinOccursDefault0() throws Exception {
config.setDefaultMinOccurs(0);
AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
BeanTypeInfo info = ((BeanType) type).getTypeInfo();
assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(), "bogusProperty")), 0);
}
use of org.apache.cxf.aegis.type.basic.BeanType in project cxf by apache.
the class ConfigurationTest method testNillableDefaultFalse.
@Test
public void testNillableDefaultFalse() throws Exception {
config.setDefaultNillable(false);
AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
BeanTypeInfo info = ((BeanType) type).getTypeInfo();
assertFalse(info.isNillable(new QName(info.getDefaultNamespace(), "bogusProperty")));
}
Aggregations