forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
60 lines
1.3 KiB
package siprp.higiene.relatorio.print;
|
|
|
|
import java.util.Vector;
|
|
|
|
import org.jdom.Element;
|
|
|
|
public class AreaToPrint
|
|
implements PrintableInterface, Comparable
|
|
{
|
|
protected String designacao;
|
|
protected Vector<PostoToPrint> postos;
|
|
protected Integer ordem;
|
|
protected boolean temGenerico;
|
|
|
|
public AreaToPrint( String designacao, Vector<PostoToPrint> postos, Integer ordem, boolean temGenerico )
|
|
{
|
|
super();
|
|
this.designacao = designacao;
|
|
this.postos = postos;
|
|
this.ordem = ordem;
|
|
this.temGenerico = temGenerico;
|
|
}
|
|
|
|
@Override
|
|
public Element toJdomElement() throws Exception
|
|
{
|
|
Element areaElement = new Element( "area" );
|
|
Element designacaoElement = new Element( "designacao" );
|
|
designacaoElement.setText( designacao );
|
|
areaElement.addContent( designacaoElement );
|
|
for( PostoToPrint posto : postos )
|
|
{
|
|
areaElement.addContent( posto.toJdomElement() );
|
|
}
|
|
return areaElement;
|
|
}
|
|
|
|
@Override
|
|
public int compareTo(Object o)
|
|
{
|
|
if( o instanceof AreaToPrint )
|
|
{
|
|
if( temGenerico && !( ( AreaToPrint ) o ).temGenerico )
|
|
{
|
|
return -1;
|
|
}
|
|
else if( !temGenerico && ( ( AreaToPrint ) o ).temGenerico )
|
|
{
|
|
return 1;
|
|
}
|
|
if( ordem != null )
|
|
{
|
|
return ( ( ( AreaToPrint ) o ).ordem == null ) ? -1 : ordem.compareTo( ( ( AreaToPrint ) o ).ordem );
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
}
|