* @param reader the reader from which to read the file
*/
public void read( String key, Reader reader )
{
try {
XmlElement regRoot = XmlSource.read( reader );
Vector componentNodes = regRoot.getChildren();
int numComponents = componentNodes.size();
for ( int i = 0; i < numComponents; i++ ) {
XmlElement componentNode = ( XmlElement )componentNodes.elementAt( i );
try {
String componentName = componentNode.getAttribute( "name" );
String iconName = componentNode.getAttribute( "icon" );
String reflect = componentNode.getAttribute( "reflect" );
String tag = componentNode.getName().toLowerCase();
if ( !tag.equals( "component" ))
continue;
ComponentAdapter oldCa = (ComponentAdapter)propertiesRegister.get( componentName );
ComponentAdapter ca = oldCa;
if ( oldCa == null ) {
if (( reflect != null ) && reflect.equals( "true" )) {
ca = addReflectionAdapter( key, componentName, iconName, componentNode.getAttribute( "class" ), componentNode.getAttribute( "ui" ));
// Make sure there aren't duplicates of this property.
propertiesRegister.remove( componentName );
propertiesRegister.put( componentName, ca );
continue;
}
ca = addComponentAdapter( key, componentName, iconName, componentNode.getAttribute( "class" ), componentNode.getAttribute( "ui" ));
}
Vector propertyNodes = componentNode.getChildren();
int numProperties = propertyNodes.size();
for ( int j = 0; j < numProperties; j++ ) {
XmlElement propertyNode = componentNode.elementAt( j );
String type = propertyNode.getAttribute( "type" );
String name = propertyNode.getAttribute( "name" );
String method = propertyNode.getAttribute( "method" );
String attribStr = propertyNode.getAttribute( "attrib" );
boolean attributed = (( attribStr != null ) && ( attribStr.equals( "true" )));
String paramType = "String";
if ( type == null )
type = "both";
if(( name != null ) && ( method != null )){
if ( type.equals( "get" ) || type.equals( "both" )) {
String getMethod = method;
if (( getMethod == null ) || ( getMethod.length() == 0 ))
getMethod = "get" + name.substring( 0, 1 ).toUpperCase() + name.substring( 1 );
else if ( type.equals( "both" ))
getMethod = "get" + method.substring( 0, 1 ).toUpperCase() + method.substring( 1 );
Vector params = propertyNode.getChildren();
if ( params.size() > 0 )
paramType = ((XmlElement)params.elementAt( 0 )).getAttribute( "type" );
ca.addProperty( "get", name, getMethod, paramType, attributed, true, null );
}
if ( type.equals( "set" ) || type.equals( "both" )) {
String setMethod = method;
if (( setMethod == null ) || ( setMethod.length() == 0 ))
setMethod = "set" + name.substring( 0, 1 ).toUpperCase() + name.substring( 1 );
else if ( type.equals( "both" ))
setMethod = "set" + method.substring( 0, 1 ).toUpperCase() + method.substring( 1 );
Vector params = propertyNode.getChildren();
if ( params.size() > 0 )
paramType = ((XmlElement)params.elementAt( 0 )).getAttribute( "type" );
ca.addProperty( "set", name, setMethod, paramType, attributed, true, null );
}