nodeDescriptor = new AttributeDescriptor();
} else {
if (log.isTraceEnabled()) {
log.trace( "Adding property as element: " + name );
}
nodeDescriptor = new ElementDescriptor(true);
}
nodeDescriptor.setTextExpression( new MethodExpression( readMethod ) );
if ( writeMethod != null ) {
nodeDescriptor.setUpdater( new MethodUpdater( writeMethod ) );
}
} else if ( isLoopType( type ) ) {
if (log.isTraceEnabled()) {
log.trace("Loop type: " + name);
log.trace("Wrap in collections? " + introspector.isWrapCollectionsInElement());
}
ElementDescriptor loopDescriptor = new ElementDescriptor();
loopDescriptor.setContextExpression(
new IteratorExpression( new MethodExpression( readMethod ) )
);
loopDescriptor.setWrapCollectionsInElement(
introspector.isWrapCollectionsInElement());
// XXX: need to support some kind of 'add' or handle arrays, Lists or indexed properties
//loopDescriptor.setUpdater( new MethodUpdater( writeMethod ) );
if ( Map.class.isAssignableFrom( type ) ) {
loopDescriptor.setQualifiedName( "entry" );
// add elements for reading
loopDescriptor.addElementDescriptor( new ElementDescriptor( "key" ) );
loopDescriptor.addElementDescriptor( new ElementDescriptor( "value" ) );
}
ElementDescriptor elementDescriptor = new ElementDescriptor();
elementDescriptor.setWrapCollectionsInElement(
introspector.isWrapCollectionsInElement());
elementDescriptor.setElementDescriptors( new ElementDescriptor[] { loopDescriptor } );
nodeDescriptor = elementDescriptor;
} else {
if (log.isTraceEnabled()) {
log.trace( "Standard property: " + name);
}
ElementDescriptor elementDescriptor = new ElementDescriptor();
elementDescriptor.setContextExpression( new MethodExpression( readMethod ) );
if ( writeMethod != null ) {
elementDescriptor.setUpdater( new MethodUpdater( writeMethod ) );
}
nodeDescriptor = elementDescriptor;
}