role = role.substring( 0, posRoleHintSeparator );
}
// TODO: remove deprecated expression
requirements.put( parameter.getName(), new Requirement( role, roleHint ) );
}
else if ( parameter.getRequirement() != null )
{
requirements.put( parameter.getName(), parameter.getRequirement() );
}
else if ( !helpDescriptor || parameter.isEditable() ) // don't show readonly parameters in help
{
// treat it as a normal parameter.
w.startElement( "parameter" );
GeneratorUtils.element( w, "name", parameter.getName() );
if ( parameter.getAlias() != null )
{
GeneratorUtils.element( w, "alias", parameter.getAlias() );
}
GeneratorUtils.element( w, "type", parameter.getType() );
if ( parameter.getSince() != null )
{
w.startElement( "since" );
if ( StringUtils.isEmpty( parameter.getSince() ) )
{
w.writeText( "No version given" );
}
else
{
w.writeText( parameter.getSince() );
}
w.endElement();
}
if ( parameter.getDeprecated() != null )
{
if ( StringUtils.isEmpty( parameter.getDeprecated() ) )
{
GeneratorUtils.element( w, "deprecated", "No reason given" );
}
else
{
GeneratorUtils.element( w, "deprecated", parameter.getDeprecated() );
}
}
if ( parameter.getImplementation() != null )
{
GeneratorUtils.element( w, "implementation", parameter.getImplementation() );
}
GeneratorUtils.element( w, "required", Boolean.toString( parameter.isRequired() ) );
GeneratorUtils.element( w, "editable", Boolean.toString( parameter.isEditable() ) );
GeneratorUtils.element( w, "description", parameter.getDescription(), helpDescriptor );
if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) || StringUtils.isNotEmpty(
parameter.getExpression() ) )
{
configuration.add( parameter );
}
w.endElement();
}
}
}
w.endElement();
// ----------------------------------------------------------------------
// Configuration
// ----------------------------------------------------------------------
if ( !configuration.isEmpty() )
{
w.startElement( "configuration" );
for ( Parameter parameter : configuration )
{
if ( helpDescriptor && !parameter.isEditable() )
{
// don't show readonly parameters in help
continue;
}
w.startElement( parameter.getName() );
String type = parameter.getType();
if ( StringUtils.isNotEmpty( type ) )
{
w.addAttribute( "implementation", type );
}
if ( parameter.getDefaultValue() != null )
{
w.addAttribute( "default-value", parameter.getDefaultValue() );
}
if ( StringUtils.isNotEmpty( parameter.getExpression() ) )
{
w.writeText( parameter.getExpression() );
}
w.endElement();
}
w.endElement();
}
// ----------------------------------------------------------------------
// Requirements
// ----------------------------------------------------------------------
if ( !requirements.isEmpty() && !helpDescriptor )
{
w.startElement( "requirements" );
for ( Map.Entry<String, Requirement> entry : requirements.entrySet() )
{
String key = entry.getKey();
Requirement requirement = entry.getValue();
w.startElement( "requirement" );
GeneratorUtils.element( w, "role", requirement.getRole() );
if ( StringUtils.isNotEmpty( requirement.getRoleHint() ) )
{
GeneratorUtils.element( w, "role-hint", requirement.getRoleHint() );
}
GeneratorUtils.element( w, "field-name", key );
w.endElement();