if (currStepDescriptor == null) {
// need to take the non easy way, may be the instance has a
// value for this step with a different name, of a derived
// type of the one declared in the parent type
String prefixedStepName = currStep.toString();
PropertyName name = FF.property(prefixedStepName);
Attribute child = (Attribute) name.evaluate(parent);
if (child != null) {
currStepDescriptor = child.getDescriptor();
}
}
} else {
AttributeDescriptor actualDescriptor;
if (null == attributeName.getNamespaceURI()) {
actualDescriptor = (AttributeDescriptor) Types.findDescriptor(parentType, attributeName.getLocalPart());
} else {
actualDescriptor = (AttributeDescriptor) Types.findDescriptor(parentType, attributeName);
}
if (actualDescriptor != null) {
int minOccurs = actualDescriptor.getMinOccurs();
int maxOccurs = actualDescriptor.getMaxOccurs();
boolean nillable = actualDescriptor.isNillable();
if (actualDescriptor instanceof GeometryDescriptor) {
// important to maintain CRS information encoding
if (Geometry.class.isAssignableFrom(targetNodeType.getBinding())) {
if (!(targetNodeType instanceof GeometryType)) {
targetNodeType = new GeometryTypeImpl(targetNodeType.getName(),
targetNodeType.getBinding(), crs != null ? crs
: ((GeometryDescriptor) actualDescriptor)
.getCoordinateReferenceSystem(),
targetNodeType.isIdentified(), targetNodeType
.isAbstract(),
targetNodeType.getRestrictions(), targetNodeType
.getSuper(), targetNodeType.getDescription());
}
currStepDescriptor = descriptorFactory.createGeometryDescriptor(
(GeometryType) targetNodeType, attributeName, minOccurs,
maxOccurs, nillable, null);
} else {
throw new IllegalArgumentException("Can't set targetNodeType: "
+ targetNodeType.toString() + " for attribute mapping: "
+ attributeName + " as it is not a Geometry type!");
}
} else {
currStepDescriptor = descriptorFactory.createAttributeDescriptor(
targetNodeType, attributeName, minOccurs, maxOccurs, nillable,
null);
}
}
}
if (currStepDescriptor == null) {
StringBuffer parentAtts = new StringBuffer();
Collection properties = parentType.getDescriptors();
for (Iterator it = properties.iterator(); it.hasNext();) {
PropertyDescriptor desc = (PropertyDescriptor) it.next();
Name name = desc.getName();
parentAtts.append(name.getNamespaceURI());
parentAtts.append("#");
parentAtts.append(name.getLocalPart());
if (it.hasNext()) {
parentAtts.append(", ");
}
}
throw new IllegalArgumentException(currStep