// Copyright (C) 2008-2009 Christian M. Zmasek
// Copyright (C) 2008-2009 Burnham Institute for Medical Research
// All rights reserved
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import org.forester.phylogeny.data.Distribution;
import org.forester.phylogeny.data.Event;
import org.forester.phylogeny.data.Identifier;
+import org.forester.phylogeny.data.PhylogenyDataUtil;
import org.forester.phylogeny.data.PropertiesMap;
import org.forester.phylogeny.data.Property;
import org.forester.phylogeny.data.Reference;
import org.forester.phylogeny.data.Sequence;
import org.forester.phylogeny.data.SequenceRelation;
-import org.forester.phylogeny.data.Taxonomy;
import org.forester.phylogeny.data.SequenceRelation.SEQUENCE_RELATION_TYPE;
+import org.forester.phylogeny.data.Taxonomy;
import org.forester.util.FailedConditionCheckException;
import org.forester.util.ForesterConstants;
import org.forester.util.ForesterUtil;
catch ( final PhylogenyParserException ex ) {
throw new SAXException( ex.getMessage() );
}
+ catch ( final PhyloXmlDataFormatException e ) {
+ throw new SAXException( e.getMessage() );
+ }
}
else if ( local_name.equals( PhyloXmlMapping.SEQUENCE_RELATION ) ) {
try {
}
}
}
- catch ( final PhylogenyParserException ex ) {
+ catch ( final PhyloXmlDataFormatException ex ) {
throw new SAXException( ex.getMessage() );
}
}
try {
PhyloXmlHandler.mapElementToPhylogeny( getCurrentXmlElement(), getCurrentPhylogeny() );
}
- catch ( final PhylogenyParserException ex ) {
- throw new SAXException( ex.getMessage() );
+ catch ( final PhylogenyParserException e ) {
+ throw new SAXException( e.getMessage() );
+ }
+ catch ( final PhyloXmlDataFormatException e ) {
+ throw new SAXException( e.getMessage() );
}
finishPhylogeny();
reset();
}
private void mapElementToPhylogenyNode( final XmlElement xml_element, final PhylogenyNode node )
- throws PhylogenyParserException {
+ throws PhylogenyParserException, PhyloXmlDataFormatException {
if ( xml_element.isHasAttribute( PhyloXmlMapping.BRANCH_LENGTH ) ) {
double d = 0;
try {
}
node.setDistanceToParent( d );
}
+ if ( xml_element.isHasAttribute( PhyloXmlMapping.NODE_COLLAPSE ) ) {
+ final String collapse_str = xml_element.getAttribute( PhyloXmlMapping.NODE_COLLAPSE );
+ if ( !ForesterUtil.isEmpty( collapse_str ) && collapse_str.trim().equalsIgnoreCase( "true" ) ) {
+ node.setCollapse( true );
+ }
+ }
for( int i = 0; i < xml_element.getNumberOfChildElements(); ++i ) {
final XmlElement element = xml_element.getChildElement( i );
final String qualified_name = element.getQualifiedName();
if ( qualified_name.equals( PhyloXmlMapping.BRANCH_LENGTH ) ) {
- if ( node.getDistanceToParent() != PhylogenyNode.DISTANCE_DEFAULT ) {
+ if ( node.getDistanceToParent() != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) {
throw new PhylogenyParserException( "ill advised attempt to set distance twice for the same clade (probably via element and via attribute)" );
}
node.setDistanceToParent( element.getValueAsDouble() );
if ( !node.getNodeData().isHasProperties() ) {
node.getNodeData().setProperties( new PropertiesMap() );
}
- node.getNodeData().getProperties().addProperty( ( Property ) PropertyParser.getInstance()
- .parse( element ) );
+ node.getNodeData().getProperties()
+ .addProperty( ( Property ) PropertyParser.getInstance().parse( element ) );
}
}
}
.getAttribute( PhyloXmlMapping.PHYLOGENY_IS_REROOTABLE_ATTR ) ) );
}
if ( element.isHasAttribute( PhyloXmlMapping.PHYLOGENY_BRANCHLENGTH_UNIT_ATTR ) ) {
- getCurrentPhylogeny().setDistanceUnit( element
- .getAttribute( PhyloXmlMapping.PHYLOGENY_BRANCHLENGTH_UNIT_ATTR ) );
+ getCurrentPhylogeny()
+ .setDistanceUnit( element.getAttribute( PhyloXmlMapping.PHYLOGENY_BRANCHLENGTH_UNIT_ATTR ) );
}
if ( element.isHasAttribute( PhyloXmlMapping.PHYLOGENY_IS_ROOTED_ATTR ) ) {
getCurrentPhylogeny().setRooted( Boolean.parseBoolean( element
}
private static void mapElementToPhylogeny( final XmlElement xml_element, final Phylogeny phylogeny )
- throws PhylogenyParserException {
+ throws PhylogenyParserException, PhyloXmlDataFormatException {
for( int i = 0; i < xml_element.getNumberOfChildElements(); ++i ) {
final XmlElement element = xml_element.getChildElement( i );
final String qualified_name = element.getQualifiedName();