Class ModelElement


  • public class ModelElement
    extends java.lang.Object
    A w3c Element wrapper with a better API. Author unknown.
    • Constructor Summary

      Constructors 
      Constructor Description
      ModelElement​(org.w3c.dom.Element xml)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double asDouble()  
      Duration asDuration()  
      long asLong()  
      java.lang.String asString()  
      boolean booleanAttribute​(java.lang.String name)  
      boolean booleanAttribute​(java.lang.String name, boolean defaultValue)  
      ModelElement child​(java.lang.String name)
      Returns the child with the given name, or null if none.
      java.lang.Boolean childAsBoolean​(java.lang.String path)  
      java.lang.Double childAsDouble​(java.lang.String path)  
      Duration childAsDuration​(java.lang.String path)  
      java.lang.Integer childAsInteger​(java.lang.String path)  
      java.lang.Long childAsLong​(java.lang.String path)  
      java.lang.String childAsString​(java.lang.String path)  
      ModelElement childByPath​(java.lang.String path)  
      java.util.List<ModelElement> children​(java.lang.String name)
      If not found, return empty list.
      java.lang.Double doubleAttribute​(java.lang.String name)  
      org.w3c.dom.Element getXml()  
      java.lang.Integer integerAttribute​(java.lang.String name)
      Returns the value of this attribute or null if not present
      java.lang.Integer integerAttribute​(java.lang.String name, java.lang.Integer defaultValue)  
      java.lang.Long longAttribute​(java.lang.String name)  
      double requiredDoubleAttribute​(java.lang.String name)
      Returns the given attribute or throws IllegalArgumentException if not present
      int requiredIntegerAttribute​(java.lang.String name)
      Returns the given attribute or throws IllegalArgumentException if not present
      java.lang.String requiredStringAttribute​(java.lang.String name)
      Returns the content of the attribute with the given name or throws IllegalArgumentException if not present
      java.lang.String stringAttribute​(java.lang.String name)
      Returns the content of the attribute with the given name, or null if none
      java.lang.String stringAttribute​(java.lang.String name, java.lang.String defaultValue)
      Returns the content of the attribute with the given name, or the default value if none
      java.util.List<ModelElement> subElements​(java.lang.String name)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ModelElement

        public ModelElement​(org.w3c.dom.Element xml)
    • Method Detail

      • getXml

        public org.w3c.dom.Element getXml()
      • child

        public ModelElement child​(java.lang.String name)
        Returns the child with the given name, or null if none.
      • children

        public java.util.List<ModelElement> children​(java.lang.String name)
        If not found, return empty list.
      • childByPath

        public ModelElement childByPath​(java.lang.String path)
      • childAsString

        public java.lang.String childAsString​(java.lang.String path)
      • asString

        public java.lang.String asString()
      • asDouble

        public double asDouble()
      • asLong

        public long asLong()
      • asDuration

        public Duration asDuration()
      • childAsLong

        public java.lang.Long childAsLong​(java.lang.String path)
      • childAsInteger

        public java.lang.Integer childAsInteger​(java.lang.String path)
      • childAsDouble

        public java.lang.Double childAsDouble​(java.lang.String path)
      • childAsBoolean

        public java.lang.Boolean childAsBoolean​(java.lang.String path)
      • childAsDuration

        public Duration childAsDuration​(java.lang.String path)
      • requiredIntegerAttribute

        public int requiredIntegerAttribute​(java.lang.String name)
        Returns the given attribute or throws IllegalArgumentException if not present
      • integerAttribute

        public java.lang.Integer integerAttribute​(java.lang.String name)
        Returns the value of this attribute or null if not present
      • integerAttribute

        public java.lang.Integer integerAttribute​(java.lang.String name,
                                                  java.lang.Integer defaultValue)
      • booleanAttribute

        public boolean booleanAttribute​(java.lang.String name)
      • booleanAttribute

        public boolean booleanAttribute​(java.lang.String name,
                                        boolean defaultValue)
      • longAttribute

        public java.lang.Long longAttribute​(java.lang.String name)
      • doubleAttribute

        public java.lang.Double doubleAttribute​(java.lang.String name)
      • requiredDoubleAttribute

        public double requiredDoubleAttribute​(java.lang.String name)
        Returns the given attribute or throws IllegalArgumentException if not present
      • stringAttribute

        public java.lang.String stringAttribute​(java.lang.String name)
        Returns the content of the attribute with the given name, or null if none
      • stringAttribute

        public java.lang.String stringAttribute​(java.lang.String name,
                                                java.lang.String defaultValue)
        Returns the content of the attribute with the given name, or the default value if none
      • requiredStringAttribute

        public java.lang.String requiredStringAttribute​(java.lang.String name)
        Returns the content of the attribute with the given name or throws IllegalArgumentException if not present
      • subElements

        public java.util.List<ModelElement> subElements​(java.lang.String name)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object