import java.util.TreeSet;
import java.util.regex.Pattern;
+import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.Distribution;
+import org.forester.phylogeny.data.Sequence;
+import org.forester.phylogeny.data.Taxonomy;
+
public final class ForesterUtil {
public final static String FILE_SEPARATOR = System.getProperty( "file.separator" );
private ForesterUtil() {
}
+ public static void ensurePresenceOfTaxonomy( final PhylogenyNode node ) {
+ if ( !node.getNodeData().isHasTaxonomy() ) {
+ node.getNodeData().setTaxonomy( new Taxonomy() );
+ }
+ }
+
+ public static void ensurePresenceOfSequence( final PhylogenyNode node ) {
+ if ( !node.getNodeData().isHasSequence() ) {
+ node.getNodeData().setSequence( new Sequence() );
+ }
+ }
+
+ final public static void ensurePresenceOfDistribution( final PhylogenyNode node ) {
+ if ( !node.getNodeData().isHasDistribution() ) {
+ node.getNodeData().setDistribution( new Distribution( "" ) );
+ }
+ }
+
+ final public static void ensurePresenceOfDate( final PhylogenyNode node ) {
+ if ( !node.getNodeData().isHasDate() ) {
+ node.getNodeData().setDate( new org.forester.phylogeny.data.Date() );
+ }
+ }
+
final public static void appendSeparatorIfNotEmpty( final StringBuffer sb, final char separator ) {
if ( sb.length() > 0 ) {
sb.append( separator );
}
final public static void printErrorMessage( final String prg_name, final String message ) {
- System.out.println( "[" + prg_name + "] > error: " + message );
+ System.err.println( "[" + prg_name + "] > error: " + message );
}
final public static void printProgramInformation( final String prg_name, final String prg_version, final String date ) {
final public static void unexpectedFatalError( final String prg_name, final Exception e ) {
System.err.println();
System.err.println( "[" + prg_name
- + "] > unexpected error (Should not have occured! Please contact program author(s).)" );
+ + "] > Unexpected error. Should not have occured! Please contact program author(s)." );
e.printStackTrace( System.err );
System.err.println();
System.exit( -1 );
final public static void unexpectedFatalError( final String prg_name, final String message ) {
System.err.println();
System.err.println( "[" + prg_name
- + "] > unexpected error. Should not have occured! Please contact program author(s)." );
+ + "] > Unexpected error. Should not have occured! Please contact program author(s)." );
System.err.println( message );
System.err.println();
System.exit( -1 );
final public static void unexpectedFatalError( final String prg_name, final String message, final Exception e ) {
System.err.println();
System.err.println( "[" + prg_name
- + "] > unexpected error. Should not have occured! Please contact program author(s)." );
+ + "] > Unexpected error. Should not have occured! Please contact program author(s)." );
System.err.println( message );
e.printStackTrace( System.err );
System.err.println();