if ( returnType == null || returnType.trim().equals( "" ) ) {
throw new SAXParseException( "<function> requires a 'return-type' attribute",
this.xmlPackageReader.getLocator() );
}
final FunctionDescr functionDescr = new FunctionDescr( name,
returnType );
final Configuration[] parameters = config.getChildren( "parameter" );
for ( int i = 0, length = parameters.length; i < length; i++ ) {
final String identifier = parameters[i].getAttribute( "identifier" );
if ( name == null || identifier.trim().equals( "" ) ) {
throw new SAXParseException( "function's <parameter> requires an 'identifier' attribute",
this.xmlPackageReader.getLocator() );
}
final String type = parameters[i].getAttribute( "type" );
if ( type == null || type.trim().equals( "" ) ) {
throw new SAXParseException( "function's <parameter> requires an 'type' attribute",
this.xmlPackageReader.getLocator() );
}
functionDescr.addParameter( type,
identifier );
}
// we allow empty, "", bodies - but make sure that we atleast have a body element
final Configuration body = config.getChild( "body" );
if ( body == null ) {
throw new SAXParseException( "function must have a <body>",
this.xmlPackageReader.getLocator() );
}
functionDescr.setText( body.getText() );
final PackageDescr packageDescr = this.xmlPackageReader.getPackageDescr();
packageDescr.addFunction( functionDescr );