protected AbstractTypeCreator createRootTypeCreator() { AbstractTypeCreator creator = new XMLTypeCreator(); creator.setConfiguration(getTypeCreationOptions()); return creator; }
@Override public AegisType createCollectionType(TypeClassInfo info) { /* If it is a parameterized type, then we already know * the parameter(s) and we don't need to fish them out of the XML. */ if (info.getType() instanceof Class) { return createCollectionTypeFromGeneric(info); } return nextCreator.createCollectionType(info); }
private AegisType createTypeFromGeneric(Object cType) { if (cType instanceof TypeClassInfo) { return createTypeForClass((TypeClassInfo)cType); } else if (cType instanceof Class) { return createType((Class<?>)cType); } else { return null; } }
Element top = findMapping(clazz); if (top != null) { mappings.add(top); for (int i = 0; i < interfaces.length; i++) { Class<?> interfaze = interfaces[i]; List<Element> interfaceMappings = findMappings(interfaze); mappings.addAll(interfaceMappings); Element mapping = findMapping(sup); if (mapping != null) { mappings.add(mapping);
@Override public AegisType createDefaultType(TypeClassInfo info) { Element mapping = findMapping(info.getType()); List<Element> mappings = findMappings(info.getType()); Class<?> relatedClass = TypeUtil.getTypeRelatedClass(info.getType()); btinfo.setTypeMapping(getTypeMapping()); btinfo.setDefaultMinOccurs(getConfiguration().getDefaultMinOccurs()); btinfo.setDefaultNillable(getConfiguration().isDefaultNillable()); btinfo.setExtensibleElements(getConfiguration().isDefaultExtensibleElements()); 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); name = createQName(relatedClass); type.setTypeMapping(getTypeMapping());
protected void readMetadata(TypeClassInfo info, Element mapping, Element parameter) { info.setTypeName(createQName(parameter, DOMUtils.getAttributeValueEmptyNull(parameter, "typeName"))); info.setMappedName(createQName(parameter, DOMUtils.getAttributeValueEmptyNull(parameter, "mappedName"))); Class<?> relatedClass = TypeUtil.getTypeRelatedClass(info.getType()); Type componentType = getComponentType(mapping, parameter); if (componentType != null) { // there is actually XML config. Type fullType = ParameterizedTypeFactory.createParameterizedType(relatedClass, Type keyType = getKeyType(mapping, parameter); if (keyType != null) { info.setKeyType(keyType); Type valueType = getValueType(mapping, parameter); if (valueType != null) { info.setValueType(valueType); setType(info, parameter);
@Override public TypeClassInfo createClassInfo(Method m, int index) { Element mapping = findMapping(m.getDeclaringClass()); List<Element> nodes = getMatches(mapping, "./method[@name='" + m.getName() + "']/parameter[@index='" + index + "']/parent::*"); if (nodes.isEmpty()) { Element bestMatch = getBestMatch(mapping, m, nodes); Element parameter = getMatch(bestMatch, "parameter[@index='" + index + "']"); readMetadata(info, mapping, parameter); } else { List<Element> nodes = getMatches(mapping, "./method[@name='" + m.getName() + "']/return-type/parent::*"); if (nodes.isEmpty()) { return info; Element bestMatch = getBestMatch(mapping, m, nodes); if (bestMatch == null) { readMetadata(info, mapping, rtElement);
@Override public TypeClassInfo createClassInfo(PropertyDescriptor pd) { Element mapping = findMapping(pd.getReadMethod().getDeclaringClass()); if (mapping == null) { return nextCreator.createClassInfo(pd); } Element propertyEl = getMatch(mapping, "./property[@name='" + pd.getName() + "']"); if (propertyEl == null) { return nextCreator.createClassInfo(pd); } TypeClassInfo info = new TypeClassInfo(); Type returnType = pd.getReadMethod().getGenericReturnType(); info.setType(returnType); info.setDescription("property " + pd.getDisplayName()); readMetadata(info, mapping, propertyEl); return info; }
@Override protected AegisType getOrCreateMapKeyType(TypeClassInfo info) { AegisType type = null; if (info.getKeyType() != null) { type = createTypeFromGeneric(info.getKeyType()); } if (type == null) { type = super.getOrCreateMapKeyType(info); } return type; }
@Override protected boolean isEnum(Class<?> javaType) { Element mapping = findMapping(javaType); if (mapping != null) { return super.isEnum(javaType); } return nextCreator.isEnum(javaType); }
@Override public AegisType createDefaultType(TypeClassInfo info) { Element mapping = findMapping(info.getType()); List<Element> mappings = findMappings(info.getType()); Class<?> relatedClass = TypeUtil.getTypeRelatedClass(info.getType()); btinfo.setTypeMapping(getTypeMapping()); btinfo.setDefaultMinOccurs(getConfiguration().getDefaultMinOccurs()); btinfo.setDefaultNillable(getConfiguration().isDefaultNillable()); btinfo.setExtensibleElements(getConfiguration().isDefaultExtensibleElements()); 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); name = createQName(relatedClass); type.setTypeMapping(getTypeMapping());
protected void readMetadata(TypeClassInfo info, Element mapping, Element parameter) { info.setTypeName(createQName(parameter, DOMUtils.getAttributeValueEmptyNull(parameter, "typeName"))); info.setMappedName(createQName(parameter, DOMUtils.getAttributeValueEmptyNull(parameter, "mappedName"))); Class<?> relatedClass = TypeUtil.getTypeRelatedClass(info.getType()); Type componentType = getComponentType(mapping, parameter); if (componentType != null) { // there is actually XML config. Type fullType = ParameterizedTypeFactory.createParameterizedType(relatedClass, Type keyType = getKeyType(mapping, parameter); if (keyType != null) { info.setKeyType(keyType); Type valueType = getValueType(mapping, parameter); if (valueType != null) { info.setValueType(valueType); setType(info, parameter);
@Override public TypeClassInfo createClassInfo(Method m, int index) { Element mapping = findMapping(m.getDeclaringClass()); List<Element> nodes = getMatches(mapping, "./method[@name='" + m.getName() + "']/parameter[@index='" + index + "']/parent::*"); if (nodes.isEmpty()) { Element bestMatch = getBestMatch(mapping, m, nodes); Element parameter = getMatch(bestMatch, "parameter[@index='" + index + "']"); readMetadata(info, mapping, parameter); } else { List<Element> nodes = getMatches(mapping, "./method[@name='" + m.getName() + "']/return-type/parent::*"); if (nodes.isEmpty()) { return info; Element bestMatch = getBestMatch(mapping, m, nodes); if (bestMatch == null) { readMetadata(info, mapping, rtElement);
@Override public TypeClassInfo createClassInfo(PropertyDescriptor pd) { Element mapping = findMapping(pd.getReadMethod().getDeclaringClass()); if (mapping == null) { return nextCreator.createClassInfo(pd); } Element propertyEl = getMatch(mapping, "./property[@name='" + pd.getName() + "']"); if (propertyEl == null) { return nextCreator.createClassInfo(pd); } TypeClassInfo info = new TypeClassInfo(); Type returnType = pd.getReadMethod().getGenericReturnType(); info.setType(returnType); info.setDescription("property " + pd.getDisplayName()); readMetadata(info, mapping, propertyEl); return info; }
Element top = findMapping(clazz); if (top != null) { mappings.add(top); for (int i = 0; i < interfaces.length; i++) { Class<?> interfaze = interfaces[i]; List<Element> interfaceMappings = findMappings(interfaze); mappings.addAll(interfaceMappings); Element mapping = findMapping(sup); if (mapping != null) { mappings.add(mapping);
@Override protected AegisType getOrCreateGenericType(TypeClassInfo info) { AegisType type = null; if (info.getType() instanceof ParameterizedType) { type = createTypeFromGeneric(info.getType()); } if (type == null) { type = super.getOrCreateGenericType(info); } return type; }
@Override protected boolean isEnum(Class<?> javaType) { Element mapping = findMapping(javaType); if (mapping != null) { return super.isEnum(javaType); } return nextCreator.isEnum(javaType); }
private AegisType createTypeFromGeneric(Object cType) { if (cType instanceof TypeClassInfo) { return createTypeForClass((TypeClassInfo)cType); } else if (cType instanceof Class) { return createType((Class<?>)cType); } else { return null; } }
@Override protected AegisType getOrCreateGenericType(TypeClassInfo info) { AegisType type = null; if (info.getType() instanceof ParameterizedType) { type = createTypeFromGeneric(info.getType()); } if (type == null) { type = super.getOrCreateGenericType(info); } return type; }
@Override public AegisType createEnumType(TypeClassInfo info) { Element mapping = findMapping(info.getType()); if (mapping != null) { return super.createEnumType(info); } return nextCreator.createEnumType(info); }