Package pal.xml

Class 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
    • 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.
      • 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
      • 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.