gt:         protected Element getElement() {
context: /*
  
     Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed with
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License, Version 2.0
     (the "License"); you may not use this file except in compliance with
     the License.  You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  
   */
  package org.apache.batik.anim.dom;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  
  import org.w3c.dom.Attr;
  import org.w3c.dom.DOMException;
  import org.w3c.dom.Element;
  import org.w3c.dom.svg.SVGAnimatedLengthList;
  import org.w3c.dom.svg.SVGException;
  import org.w3c.dom.svg.SVGLength;
  import org.w3c.dom.svg.SVGLengthList;
  
  import org.apache.batik.anim.values.AnimatableLengthListValue;
  import org.apache.batik.anim.values.AnimatableValue;
  import org.apache.batik.dom.svg.ListBuilder;
  import org.apache.batik.dom.svg.LiveAttributeException;
  import org.apache.batik.dom.svg.SVGItem;
  import org.apache.batik.parser.ParseException;
  
  /**
   * This class is the implementation of the {@link SVGAnimatedLengthList}
   * interface.
   *
   * @author <a href="mailto:nicolas.socheleau@bitflash.com">Nicolas Socheleau</a>
   * @version $Id$
   */
  public class SVGOMAnimatedLengthList
      extends AbstractSVGAnimatedValue
      implements SVGAnimatedLengthList {
  
      /**
       * The base value.
       */
      protected BaseSVGLengthList baseVal;
  
      /**
       * The animated value.
       */
      protected AnimSVGLengthList animVal;
  
      /**
       * Whether the list is changing.
       */
      protected boolean changing;
  
      /**
       * Default value for the length list.
       */
      protected String defaultValue;
  
      /**
       * Whether empty length lists are allowed.
       */
      protected boolean emptyAllowed;
  
      /**
       * The direction of the lengths in this list.
       */
      protected short direction;
  
      /**
       * Creates a new SVGOMAnimatedLengthList.
       * @param elt The associated element.
       * @param ns The attribute's namespace URI.
       * @param ln The attribute's local name.
       * @param defaultValue The default value if the attribute is not specified.
       * @param emptyAllowed Whether a list with no items is allowed.
       * @param direction The direction of the lengths in the list.
       */
      public SVGOMAnimatedLengthList(AbstractElement elt,
                                     String ns,
                                     String ln,
                                     String defaultValue,
                                     boolean emptyAllowed,
                                     short direction) {
          super(elt, ns, ln);
          this.defaultValue = defaultValue;
          this.emptyAllowed = emptyAllowed;
          this.direction = direction;
      }
  
      /**
       * <b>DOM</b>: Implements {@link SVGAnimatedLengthList#getBaseVal()}.
       */
      public SVGLengthList getBaseVal() {
          if (baseVal == null) {
              baseVal = new BaseSVGLengthList();
          }
          return baseVal;
      }
  
      /**
       * <b>DOM</b>: Implements {@link SVGAnimatedLengthList#getAnimVal()}.
       */
      public SVGLengthList getAnimVal() {
          if (animVal == null) {
              animVal = new AnimSVGLengthList();
          }
          return animVal;
      }
  
      /**
       * Throws an exception if the length list value is malformed.
       */
      public void check() {
          if (!hasAnimVal) {
              if (baseVal == null) {
                  baseVal = new BaseSVGLengthList();
              }
              baseVal.revalidate();
              if (baseVal.missing) {
                  throw new LiveAttributeException
                      (element, localName,
                       LiveAttributeException.ERR_ATTRIBUTE_MISSING, null);
              }
              if (baseVal.malformed) {
                  throw new LiveAttributeException
                      (element, localName,
                       LiveAttributeException.ERR_ATTRIBUTE_MALFORMED,
                       baseVal.getValueAsString());
              }
          }
      }
  
      /**
       * Returns the base value of the attribute as an {@link AnimatableValue}.
       */
      public AnimatableValue getUnderlyingValue(AnimationTarget target) {
          SVGLengthList ll = getBaseVal();
          int n = ll.getNumberOfItems();
          short[] types = new short[n];
          float[] values = new float[n];
          for (int i = 0; i < n; i++) {
              SVGLength l = ll.getItem(i);
              types[i] = l.getUnitType();
              values[i] = l.getValueInSpecifiedUnits();
          }
          return new AnimatableLengthListValue
              (target, types, values,
               target.getPercentageInterpretation
                   (getNamespaceURI(), getLocalName(), false));
      }
  
      /**
       * Updates the animated value with the given {@link AnimatableValue}.
       */
      protected void updateAnimatedValue(AnimatableValue val) {
          if (val == null) {
              hasAnimVal = false;
          } else {
              hasAnimVal = true;
              AnimatableLengthListValue animLengths =
                  (AnimatableLengthListValue) val;
              if (animVal == null) {
                  animVal = new AnimSVGLengthList();
              }
              animVal.setAnimatedValue(animLengths.getLengthTypes(),
                                       animLengths.getLengthValues());
          }
          fireAnimatedAttributeListeners();
      }
  
      /**
       * Called when an Attr node has been added.
       */
      public void attrAdded(Attr node, String newv) {
          if (!changing && baseVal != null) {
              baseVal.invalidate();
          }
          fireBaseAttributeListeners();
          if (!hasAnimVal) {
              fireAnimatedAttributeListeners();
          }
      }
  
      /**
       * Called when an Attr node has been modified.
       */
      public void attrModified(Attr node, String oldv, String newv) {
          if (!changing && baseVal != null) {
              baseVal.invalidate();
          }
          fireBaseAttributeListeners();
          if (!hasAnimVal) {
              fireAnimatedAttributeListeners();
          }
      }
  
      /**
       * Called when an Attr node has been removed.
       */
      public void attrRemoved(Attr node, String oldv) {
          if (!changing && baseVal != null) {
              baseVal.invalidate();
          }
          fireBaseAttributeListeners();
          if (!hasAnimVal) {
              fireAnimatedAttributeListeners();
          }
      }
  
      /**
       * {@link SVGLengthList} implementation for the base length list value.
       */
      public class BaseSVGLengthList extends AbstractSVGLengthList {
  
          /**
           * Whether the value is missing.
           */
          protected boolean missing;
  
          /**
           * Whether the value is malformed.
           */
          protected boolean malformed;
  
          /**
           * Creates a new BaseSVGLengthList.
           */
          public BaseSVGLengthList() {
              super(SVGOMAnimatedLengthList.this.direction);
          }
  
          /**
           * Create a DOMException.
           */
          protected DOMException createDOMException(short type, String key,
                                                    Object[] args) {
              return element.createDOMException(type, key, args);
          }
  
          /**
           * Create a SVGException.
           */
          protected SVGException createSVGException(short type, String key,
                                                    Object[] args) {
  
              return ((SVGOMElement)element).createSVGException(type, key, args);
          }
  
          /**
           * Returns the element owning the attribute with which this length
           * list is associated.
           */
  