pal.xml
Class ElementParser

java.lang.Object
  extended by pal.xml.ElementParser
All Implemented Interfaces:
XMLConstants

public class ElementParser
extends java.lang.Object
implements XMLConstants

This class provides static methods for parsing PAL objects from DOM Elements. Methods are ordered in public, protected, private and alphabetic within each group.

Version:
$Id: ElementParser.java,v 1.14 2003/08/02 01:15:14 matt Exp $
Author:
Alexei Drummond

Field Summary
 
Fields inherited from interface pal.util.XMLConstants
A_TO_C, A_TO_G, A_TO_T, ALIGNMENT, ALPHA, ANCESTRAL_MU_RATE, ANCESTRAL_POP_SIZE, ATTRIBUTE, BACKWARDS, BLOSUM62, C_TO_G, C_TO_T, COALESCENT, CONST_EXP_CONST, CONST_EXP_GROWTH, CONSTANT_MUTATION_RATE, CONSTANT_POPULATION, CPREV, CURRENT_POP_SIZE_DURATION, DATA_TYPE, DATA_TYPE_ID, DAYHOFF, DAYS, DEMOGRAPHIC_MODEL, DIRECTION, EDGE, EXPANDING_POPULATION, EXPONENTIAL_GROWTH, F81, F84, FREQUENCIES, G_TO_T, GAMMA_ALPHA, GAMMA_DISTRIBUTION, GENERATIONS, GROWTH_PHASE_DURATION, GROWTH_RATE, GTR, HEIGHT, HKY, ID, JC, JTT, KAPPA, LENGTH, MISSING, MODEL, MONTHS, MTREV24, MU_STEP_TIME, MUTATION_RATE, MUTATION_RATE_MODEL, MUTATIONS, NAME, NODE, NUMBER_CATEGORIES, OMEGA, ORIGIN, PARAMETER, POPULATION_SIZE, PYRIMIDINE_PURINE_RATIO, RATE_DISTRIBUTION, RATE_MATRIX, SEQUENCE, SPACES_PER_LEVEL, STEPPED_MUTATION_RATE, TIME, TIME_DATA, TN, TREE, TS_TV_RATIO, TWO_STATE, TYPE, UNIFORM, UNIFORM_RATE_DISTRIBUTION, UNITS, UNKNOWN, VALUE, VT, WAG, YANG_CODON_MODEL, YEARS
 
Constructor Summary
ElementParser()
           
 
Method Summary
protected static double getDoubleValue(org.w3c.dom.Element e)
           
static org.w3c.dom.Element getFirstByName(org.w3c.dom.Element parent, java.lang.String name)
           
protected static int getIntegerValue(org.w3c.dom.Element e)
           
protected static java.lang.String getNameAttr(org.w3c.dom.Element e)
           
protected static int getUnitsAttr(org.w3c.dom.Element e)
           
protected static boolean hasAttribute(org.w3c.dom.Element e, java.lang.String name)
          This method allows the removeal of e.hasAttribute which is DOM Level 2.
static Alignment parseAlignmentElement(org.w3c.dom.Element e)
          Parses an alignment element and returns an alignment object.
static Attribute parseAttributeElement(org.w3c.dom.Element e)
          parses an attribute element.
static DemographicModel parseDemographicModel(org.w3c.dom.Element e)
          Parses an element from an DOM document into a DemographicModel.
static Node parseEdgeNodeElement(org.w3c.dom.Element e)
           
static double[] parseFrequencies(org.w3c.dom.Element element)
          reads XML format of frequencies.
static MutationRateModel parseMutationRateModel(org.w3c.dom.Element e)
          Reads a mutation rate model from a DOM Document element.
static Node parseNodeElement(org.w3c.dom.Element e)
           
static RateDistribution parseRateDistribution(org.w3c.dom.Element e)
           
static RateMatrix parseRateMatrix(org.w3c.dom.Element e)
          Reads a rate matrix from a DOM Document element.
protected static RateMatrix parseRateMatrix(org.w3c.dom.Element e, Alignment a)
          Reads a rate matrix from a DOM Document element.
static TimeOrderCharacterData parseTimeDataElement(org.w3c.dom.Element e)
           
static Tree parseTreeElement(org.w3c.dom.Element e)
           
static void validateTagName(org.w3c.dom.Element e, java.lang.String name)
          Throws a runtime exception if the element does not have the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementParser

public ElementParser()
Method Detail

getFirstByName

public static org.w3c.dom.Element getFirstByName(org.w3c.dom.Element parent,
                                                 java.lang.String name)
Returns:
the first child element of the given name.

parseAlignmentElement

public static Alignment parseAlignmentElement(org.w3c.dom.Element e)
                                       throws XmlParseException
Parses an alignment element and returns an alignment object.

Throws:
XmlParseException

parseAttributeElement

public static Attribute parseAttributeElement(org.w3c.dom.Element e)
                                       throws XmlParseException
parses an attribute element.

Throws:
XmlParseException

parseDemographicModel

public static DemographicModel parseDemographicModel(org.w3c.dom.Element e)
                                              throws XmlParseException
Parses an element from an DOM document into a DemographicModel. Recognises ConstantPopulation, ExponentialGrowth, ConstExpGrowth.

Throws:
XmlParseException

parseEdgeNodeElement

public static Node parseEdgeNodeElement(org.w3c.dom.Element e)
                                 throws XmlParseException
Returns:
a tree node parsed from an XML element.
Throws:
XmlParseException

parseFrequencies

public static final double[] parseFrequencies(org.w3c.dom.Element element)
                                       throws XmlParseException
reads XML format of frequencies.
e.g <frequencies>0.19 0.31 0.16 0.34 </frequencies>.

Throws:
XmlParseException

parseMutationRateModel

public static MutationRateModel parseMutationRateModel(org.w3c.dom.Element e)
                                                throws XmlParseException
Reads a mutation rate model from a DOM Document element.

Throws:
XmlParseException

parseNodeElement

public static Node parseNodeElement(org.w3c.dom.Element e)
                             throws XmlParseException
Returns:
a tree node parsed from an XML element.
Throws:
XmlParseException

parseRateMatrix

public static RateMatrix parseRateMatrix(org.w3c.dom.Element e)
                                  throws XmlParseException
Reads a rate matrix from a DOM Document element. Reads JC, F81, HKY, GTR

Throws:
XmlParseException

parseRateDistribution

public static RateDistribution parseRateDistribution(org.w3c.dom.Element e)
                                              throws XmlParseException
Throws:
XmlParseException

parseRateMatrix

protected static RateMatrix parseRateMatrix(org.w3c.dom.Element e,
                                            Alignment a)
                                     throws XmlParseException
Reads a rate matrix from a DOM Document element. Reads JC, F81, HKY, GTR

Throws:
XmlParseException

parseTimeDataElement

public static TimeOrderCharacterData parseTimeDataElement(org.w3c.dom.Element e)
                                                   throws XmlParseException
Returns:
a time data object based on the given XML element.
Throws:
XmlParseException

parseTreeElement

public static Tree parseTreeElement(org.w3c.dom.Element e)
                             throws XmlParseException
Returns:
a tree object based on the XML element it was passed.
Throws:
XmlParseException

validateTagName

public static void validateTagName(org.w3c.dom.Element e,
                                   java.lang.String name)
                            throws XmlParseException
Throws a runtime exception if the element does not have the given name.

Throws:
XmlParseException

getDoubleValue

protected static double getDoubleValue(org.w3c.dom.Element e)

getIntegerValue

protected static int getIntegerValue(org.w3c.dom.Element e)

getNameAttr

protected static java.lang.String getNameAttr(org.w3c.dom.Element e)

getUnitsAttr

protected static int getUnitsAttr(org.w3c.dom.Element e)

hasAttribute

protected static final boolean hasAttribute(org.w3c.dom.Element e,
                                            java.lang.String name)
This method allows the removeal of e.hasAttribute which is DOM Level 2. I am trying to keep compliant with DOM level 1 for now.