this.def = def;
}
public final void write()
{
final ListProperty extTypeListProperty = (ListProperty) SapphireExtensionDef.TYPE.property( this.def.getExtensionType().text() );
final ElementType extType = extTypeListProperty.getType();
final List<Element> extElements = new ArrayList<Element>();
if( this.filter == null )
{
for( SapphireExtensionDef extension : this.extensions )
{
extElements.addAll( extension.property( extTypeListProperty ) );
}
}
else
{
for( SapphireExtensionDef extension : this.extensions )
{
for( Element extElement : extension.property( extTypeListProperty ) )
{
if( this.filter.allows( extElement ) )
{
extElements.add( extElement );
}
}
}
}
if( ! extElements.isEmpty() )
{
// Sort extensions.
sort( extElements );
// Write section header.
if( this.def.getIncludeSectionHeader().content() )
{
final ExtensionSummaryExportOp op = this.def.nearest( ExtensionSummaryExportOp.class );
final String sectionHeaderLevel
= ( ( op.getCreateFinishedDocument().content() == false || op.getDocumentBodyTitle().content() == null ) ? "h1" : "h2" );
this.out.println();
this.out.print( "<a name=\"" );
this.out.print( extTypeListProperty.name() );
this.out.print( "\"><" );
this.out.print( sectionHeaderLevel );
this.out.print( '>' );
this.out.print( extTypeListProperty.getLabel( true, CapitalizationType.TITLE_STYLE, false ) );
this.out.print( "</" );
this.out.print( sectionHeaderLevel );
this.out.print( "></a>" );
this.out.println();
}
// Determine columns.
final List<PropertyDef> columns = new ArrayList<PropertyDef>();
for( ExtensionSummarySectionColumnDef cdef : this.def.getColumns() )
{
final PropertyDef cprop = extType.property( cdef.getName().text() );
if( cprop != null )
{
columns.add( cprop );
}
}
if( columns.isEmpty() )
{
columns.addAll( getDefaultColumns() );
}
for( Iterator<PropertyDef> itr = columns.iterator(); itr.hasNext(); )
{
final PropertyDef cprop = itr.next();
boolean empty = true;
if( cprop instanceof ValueProperty )
{
final ValueProperty cvprop = (ValueProperty) cprop;
for( Element element : extElements )
{
if( element.property( cvprop ).text() != null )
{
empty = false;
break;
}
}
}
else if( cprop instanceof ListProperty )
{
final ListProperty clprop = (ListProperty) cprop;
for( Element element : extElements )
{
if( ! element.property( clprop ).empty() )
{