[MNG-2087] NPE in PluginXdocGenerator

Submitted by: Vincent Siveton


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@379310 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2006-02-21 02:11:43 +00:00
parent 908d6624d4
commit 33e508a29d
1 changed files with 184 additions and 178 deletions

View File

@ -158,65 +158,68 @@ public class PluginXdocGenerator
List mojos = pluginDescriptor.getMojos(); List mojos = pluginDescriptor.getMojos();
for ( Iterator i = mojos.iterator(); i.hasNext(); ) if ( mojos != null )
{ {
MojoDescriptor mojo = (MojoDescriptor) i.next(); for ( Iterator i = mojos.iterator(); i.hasNext(); )
w.startElement( "tr" );
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
String paramName = mojo.getFullGoalName();
w.startElement( "a" );
w.addAttribute( "href", getMojoFilename( mojo, "html" ) );
w.startElement( "code" );
w.writeText( paramName );
w.endElement();
w.endElement();
w.endElement();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
if ( StringUtils.isNotEmpty( mojo.getDescription() ) )
{ {
w.writeMarkup( mojo.getDescription() ); MojoDescriptor mojo = (MojoDescriptor) i.next();
}
else
{
w.writeText( "No description." );
}
String deprecationWarning = mojo.getDeprecated(); w.startElement( "tr" );
if ( deprecationWarning != null )
{ // ----------------------------------------------------------------------
w.writeMarkup( "<br/><b>Deprecated:</b> " ); //
w.writeMarkup( deprecationWarning ); // ----------------------------------------------------------------------
if ( deprecationWarning.length() == 0 )
w.startElement( "td" );
String paramName = mojo.getFullGoalName();
w.startElement( "a" );
w.addAttribute( "href", getMojoFilename( mojo, "html" ) );
w.startElement( "code" );
w.writeText( paramName );
w.endElement();
w.endElement();
w.endElement();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
if ( StringUtils.isNotEmpty( mojo.getDescription() ) )
{ {
w.writeText( "No reason given." ); w.writeMarkup( mojo.getDescription() );
}
else
{
w.writeText( "No description." );
}
String deprecationWarning = mojo.getDeprecated();
if ( deprecationWarning != null )
{
w.writeMarkup( "<br/><b>Deprecated:</b> " );
w.writeMarkup( deprecationWarning );
if ( deprecationWarning.length() == 0 )
{
w.writeText( "No reason given." );
}
w.endElement();
} }
w.endElement(); w.endElement();
w.endElement();
} }
w.endElement();
w.endElement();
} }
w.endElement(); w.endElement();
@ -323,143 +326,146 @@ public class PluginXdocGenerator
List parameters = mojoDescriptor.getParameters(); List parameters = mojoDescriptor.getParameters();
for ( int i = 0; i < parameters.size(); i++ ) if ( parameters != null )
{ {
Parameter parameter = (Parameter) parameters.get( i ); for ( int i = 0; i < parameters.size(); i++ )
w.startElement( "tr" );
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
String paramName = parameter.getAlias();
if ( StringUtils.isEmpty( paramName ) )
{ {
paramName = parameter.getName(); Parameter parameter = (Parameter) parameters.get( i );
}
w.startElement( "code" ); w.startElement( "tr" );
w.writeText( paramName ); // ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.endElement(); // code w.startElement( "td" );
if ( !parameter.isRequired() ) String paramName = parameter.getAlias();
{
w.writeMarkup( " <i>(Optional)</i>" );
}
if ( parameter.getExpression() != null && parameter.getExpression().startsWith( "${component." ) ) if ( StringUtils.isEmpty( paramName ) )
{
w.writeMarkup( " <i>(Discovered)</i>" );
}
else if ( parameter.getRequirement() != null )
{
w.writeMarkup( " <i>(Discovered)</i>" );
}
w.endElement(); // td
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
w.startElement( "code" );
w.addAttribute( "title", parameter.getType() );
int index = parameter.getType().lastIndexOf( "." );
if ( index >= 0 )
{
w.writeText( parameter.getType().substring( index + 1 ) );
}
else
{
w.writeText( parameter.getType() );
}
w.endElement(); // code
w.endElement(); // td
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
w.startElement( "code" );
if ( StringUtils.isNotEmpty( parameter.getExpression() ) &&
!parameter.getExpression().startsWith( "${component." ) )
{
w.writeText( parameter.getExpression() );
}
else
{
w.writeText( "-" );
}
w.endElement(); // code
w.endElement(); // td
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
w.startElement( "code" );
if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) )
{
w.writeText( parameter.getDefaultValue() );
}
else
{
w.writeText( "-" );
}
w.endElement(); // code
w.endElement(); // td
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
if ( StringUtils.isNotEmpty( parameter.getDescription() ) )
{
w.writeMarkup( parameter.getDescription() );
}
else
{
w.writeText( "No description." );
}
String deprecationWarning = parameter.getDeprecated();
if ( deprecationWarning != null )
{
w.writeMarkup( "<br/><b>Deprecated:</b> " );
w.writeMarkup( deprecationWarning );
if ( deprecationWarning.length() == 0 )
{ {
w.writeText( "No reason given." ); paramName = parameter.getName();
} }
w.startElement( "code" );
w.writeText( paramName );
w.endElement(); // code
if ( !parameter.isRequired() )
{
w.writeMarkup( " <i>(Optional)</i>" );
}
if ( parameter.getExpression() != null && parameter.getExpression().startsWith( "${component." ) )
{
w.writeMarkup( " <i>(Discovered)</i>" );
}
else if ( parameter.getRequirement() != null )
{
w.writeMarkup( " <i>(Discovered)</i>" );
}
w.endElement(); // td
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
w.startElement( "code" );
w.addAttribute( "title", parameter.getType() );
int index = parameter.getType().lastIndexOf( "." );
if ( index >= 0 )
{
w.writeText( parameter.getType().substring( index + 1 ) );
}
else
{
w.writeText( parameter.getType() );
}
w.endElement(); // code
w.endElement(); // td
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
w.startElement( "code" );
if ( StringUtils.isNotEmpty( parameter.getExpression() ) &&
!parameter.getExpression().startsWith( "${component." ) )
{
w.writeText( parameter.getExpression() );
}
else
{
w.writeText( "-" );
}
w.endElement(); // code
w.endElement(); // td
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
w.startElement( "code" );
if ( StringUtils.isNotEmpty( parameter.getDefaultValue() ) )
{
w.writeText( parameter.getDefaultValue() );
}
else
{
w.writeText( "-" );
}
w.endElement(); // code
w.endElement(); // td
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
w.startElement( "td" );
if ( StringUtils.isNotEmpty( parameter.getDescription() ) )
{
w.writeMarkup( parameter.getDescription() );
}
else
{
w.writeText( "No description." );
}
String deprecationWarning = parameter.getDeprecated();
if ( deprecationWarning != null )
{
w.writeMarkup( "<br/><b>Deprecated:</b> " );
w.writeMarkup( deprecationWarning );
if ( deprecationWarning.length() == 0 )
{
w.writeText( "No reason given." );
}
}
w.endElement(); // td
w.endElement(); // tr
} }
w.endElement(); // td
w.endElement(); // tr
} }
w.endElement(); // table w.endElement(); // table