// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
package org.forester.io.parsers.phyloxml;
private StringBuffer _error_messages;
private StringBuffer _warning_messages;
- public PhyloXmlParser() {
+ private PhyloXmlParser() {
init();
reset();
}
final Reader reader = getReaderFromZipFile();
if ( reader == null ) {
throw new PhylogenyParserException( "zip file \"" + getSource()
- + "\" appears not to contain any entries" );
+ + "\" appears not to contain any entries" );
}
xml_reader.parse( new InputSource( reader ) );
}
else if ( getSource() instanceof InputStream ) {
if ( !isZippedInputstream() ) {
final InputStream is = ( InputStream ) getSource();
- final Reader reader = new InputStreamReader( is );
- xml_reader.parse( new InputSource( reader ) );
+ xml_reader.parse( new InputSource( new InputStreamReader( is ) ) );
}
else {
final ZipInputStream zip_is = new ZipInputStream( ( InputStream ) getSource() );
zip_is.getNextEntry();
- final Reader reader = new InputStreamReader( zip_is );
- if ( reader == null ) {
- throw new PhylogenyParserException( "zip input stream \"" + getSource()
- + "\" appears not to contain any (phyloXML) data" );
- }
- xml_reader.parse( new InputSource( reader ) );
+ xml_reader.parse( new InputSource( new InputStreamReader( zip_is ) ) );
}
}
else if ( getSource() instanceof String ) {
}
catch ( final ParserConfigurationException parser_config_exception ) {
throw new PhylogenyParserException( "failed to parse [" + getSource()
- + "]. Problem with XML parser configuration: " + parser_config_exception.getLocalizedMessage() );
+ + "]. Problem with XML parser configuration: " + parser_config_exception.getLocalizedMessage() );
}
catch ( final IOException e ) {
throw new PhylogenyParserException( "problem with input source: " + e.getLocalizedMessage() );
return xml_parser;
}
+ public static PhyloXmlParser createPhyloXmlParser() {
+ final PhyloXmlParser xml_parser = new PhyloXmlParser();
+ return xml_parser;
+ }
+
private class PhyloXmlParserErrorHandler extends DefaultHandler {
@Override
_warning_messages.append( "[line: " + e.getLineNumber() + "] " + e.getMessage() );
}
}
+
+ @Override
+ public String getName() {
+ return "phyloXML Parser";
+ }
}