// 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.io.parsers.phyloxml.PhyloXmlMapping;
import org.forester.util.ForesterUtil;
-public class Accession implements PhylogenyData {
+public final class Accession implements PhylogenyData {
- final String _value;
- final String _source;
+ final private String _value;
+ final private String _source;
+ final private String _value_source;
public Accession( final String value, final String source ) {
_value = value;
_source = source;
+ if ( source != null ) {
+ _value_source = value + source;
+ }
+ else {
+ _value_source = value;
+ }
}
+ @Override
public StringBuffer asSimpleText() {
return new StringBuffer( getValue() );
}
+ @Override
public StringBuffer asText() {
final StringBuffer sb = new StringBuffer();
if ( !ForesterUtil.isEmpty( getSource() ) ) {
return sb;
}
+ @Override
public PhylogenyData copy() {
- return new Accession( new String( getValue() ), new String( getSource() ) );
+ return new Accession( getValue() , getSource() );
}
@Override
@Override
public int hashCode() {
- if ( getSource() != null ) {
- return ( getSource() + getValue() ).hashCode();
- }
- return getValue().hashCode();
+ //if ( getSource() != null ) {
+ // return ( getSource() + getValue() ).hashCode();
+ // }
+ return _value_source.hashCode();
}
+ @Override
public boolean isEqual( final PhylogenyData data ) {
if ( this == data ) {
return true;
return ( a.getValue().equals( getValue() ) );
}
+ @Override
public StringBuffer toNHX() {
final StringBuffer sb = new StringBuffer();
sb.append( ":" );
return sb;
}
+ @Override
public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException {
if ( ForesterUtil.isEmpty( getSource() ) ) {
PhylogenyDataUtil.appendElement( writer,