+ getNext();
+ }
+
+ public final void setGuessRootedness( final boolean guess_rootedness ) {
+ _guess_rootedness = guess_rootedness;
+ }
+
+ public final void setIgnoreQuotes( final boolean ignore_quotes ) {
+ _ignore_quotes = ignore_quotes;
+ }
+
+ public final void setReplaceUnderscores( final boolean replace_underscores ) {
+ _replace_underscores = replace_underscores;
+ }
+
+ @Override
+ public final void setSource( final Object nhx_source ) throws NHXFormatException, IOException {
+ _source = nhx_source;
+ reset();
+ }
+
+ public final void setTaxonomyExtraction( final TAXONOMY_EXTRACTION taxonomy_extraction ) {
+ _taxonomy_extraction = taxonomy_extraction;
+ }
+
+ private final void determineSourceType( final Object nhx_source ) throws PhylogenyParserException,
+ FileNotFoundException {
+ if ( nhx_source == null ) {
+ throw new PhylogenyParserException( getClass() + ": attempt to parse null object." );
+ }
+ else if ( nhx_source instanceof String ) {
+ _input_type = NHXParser.STRING;
+ _source_length = ( ( String ) nhx_source ).length();
+ _nhx_source = nhx_source;
+ }
+ else if ( nhx_source instanceof StringBuilder ) {
+ _input_type = NHXParser.STRING_BUILDER;
+ _source_length = ( ( StringBuilder ) nhx_source ).length();
+ _nhx_source = nhx_source;
+ }
+ else if ( nhx_source instanceof StringBuffer ) {
+ _input_type = NHXParser.STRING_BUFFER;
+ _source_length = ( ( StringBuffer ) nhx_source ).length();
+ _nhx_source = nhx_source;
+ }
+ else if ( nhx_source instanceof StringBuilder ) {
+ _input_type = NHXParser.STRING_BUILDER;
+ _source_length = ( ( StringBuilder ) nhx_source ).length();
+ _nhx_source = nhx_source;
+ }
+ else if ( nhx_source instanceof char[] ) {
+ _input_type = NHXParser.CHAR_ARRAY;
+ _source_length = ( ( char[] ) nhx_source ).length;
+ _nhx_source = nhx_source;
+ }
+ else if ( nhx_source instanceof File ) {
+ _input_type = NHXParser.BUFFERED_READER;
+ _source_length = 0;
+ final File f = ( File ) nhx_source;
+ final String error = ForesterUtil.isReadableFile( f );
+ if ( !ForesterUtil.isEmpty( error ) ) {
+ throw new PhylogenyParserException( error );
+ }
+ _nhx_source = new BufferedReader( new FileReader( f ) );
+ }
+ else if ( nhx_source instanceof InputStream ) {
+ _input_type = NHXParser.BUFFERED_READER;
+ _source_length = 0;
+ final InputStreamReader isr = new InputStreamReader( ( InputStream ) nhx_source );
+ _nhx_source = new BufferedReader( isr );
+ }
+ else {
+ throw new IllegalArgumentException( getClass() + " can only parse objects of type String,"
+ + " StringBuffer, StringBuilder, char[], File," + " or InputStream "
+ + " [attempt to parse object of " + nhx_source.getClass() + "]." );
+ }
+ }
+
+ private final Phylogeny finishPhylogeny() throws PhylogenyParserException, NHXFormatException,
+ PhyloXmlDataFormatException {
+ if ( _current_phylogeny != null ) {
+ parseNHX( _current_anotation != null ? _current_anotation.toString() : "",
+ _current_phylogeny.getRoot(),
+ getTaxonomyExtraction(),
+ isReplaceUnderscores() );
+ if ( GUESS_IF_SUPPORT_VALUES ) {
+ if ( isBranchLengthsLikeBootstrapValues( _current_phylogeny ) ) {
+ moveBranchLengthsToConfidenceValues( _current_phylogeny );
+ }
+ }
+ if ( isGuessRootedness() ) {
+ final PhylogenyNode root = _current_phylogeny.getRoot();
+ if ( ( root.getDistanceToParent() >= 0.0 ) || !ForesterUtil.isEmpty( root.getName() )
+ || !ForesterUtil.isEmpty( PhylogenyMethods.getSpecies( root ) ) || root.isHasAssignedEvent() ) {
+ _current_phylogeny.setRooted( true );
+ }
+ }
+ return _current_phylogeny;
+ }
+ return null;
+ }
+
+ private final Phylogeny finishSingleNodePhylogeny() throws PhylogenyParserException, NHXFormatException,
+ PhyloXmlDataFormatException {
+ final PhylogenyNode new_node = new PhylogenyNode();
+ parseNHX( _current_anotation.toString(), new_node, getTaxonomyExtraction(), isReplaceUnderscores() );
+ _current_phylogeny = new Phylogeny();
+ _current_phylogeny.setRoot( new_node );
+ return _current_phylogeny;
+ }
+
+ private final void getNext() throws IOException, NHXFormatException {