XlinkActuateAttribute.java

  1. /**
  2.  * **********************************************************************
  3.  *
  4.  * <p>DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
  5.  *
  6.  * <p>Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
  7.  *
  8.  * <p>Use is subject to license terms.
  9.  *
  10.  * <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  11.  * except in compliance with the License. You may obtain a copy of the License at
  12.  * http://www.apache.org/licenses/LICENSE-2.0. You can also obtain a copy of the License at
  13.  * http://odftoolkit.org/docs/license.txt
  14.  *
  15.  * <p>Unless required by applicable law or agreed to in writing, software distributed under the
  16.  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  17.  * express or implied.
  18.  *
  19.  * <p>See the License for the specific language governing permissions and limitations under the
  20.  * License.
  21.  *
  22.  * <p>**********************************************************************
  23.  */

  24. /*
  25.  * This file is automatically generated.
  26.  * Don't edit manually.
  27.  */
  28. package org.odftoolkit.odfdom.dom.attribute.xlink;

  29. import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
  30. import org.odftoolkit.odfdom.dom.element.db.DbConnectionResourceElement;
  31. import org.odftoolkit.odfdom.dom.element.draw.DrawAElement;
  32. import org.odftoolkit.odfdom.dom.element.draw.DrawAppletElement;
  33. import org.odftoolkit.odfdom.dom.element.draw.DrawFillImageElement;
  34. import org.odftoolkit.odfdom.dom.element.draw.DrawFloatingFrameElement;
  35. import org.odftoolkit.odfdom.dom.element.draw.DrawImageElement;
  36. import org.odftoolkit.odfdom.dom.element.draw.DrawObjectElement;
  37. import org.odftoolkit.odfdom.dom.element.draw.DrawObjectOleElement;
  38. import org.odftoolkit.odfdom.dom.element.draw.DrawPluginElement;
  39. import org.odftoolkit.odfdom.dom.element.form.FormFormElement;
  40. import org.odftoolkit.odfdom.dom.element.meta.MetaAutoReloadElement;
  41. import org.odftoolkit.odfdom.dom.element.meta.MetaTemplateElement;
  42. import org.odftoolkit.odfdom.dom.element.presentation.PresentationEventListenerElement;
  43. import org.odftoolkit.odfdom.dom.element.presentation.PresentationSoundElement;
  44. import org.odftoolkit.odfdom.dom.element.script.ScriptEventListenerElement;
  45. import org.odftoolkit.odfdom.dom.element.style.StyleBackgroundImageElement;
  46. import org.odftoolkit.odfdom.dom.element.svg.SvgDefinitionSrcElement;
  47. import org.odftoolkit.odfdom.dom.element.svg.SvgFontFaceUriElement;
  48. import org.odftoolkit.odfdom.dom.element.table.TableCellRangeSourceElement;
  49. import org.odftoolkit.odfdom.dom.element.table.TableTableSourceElement;
  50. import org.odftoolkit.odfdom.dom.element.text.TextAElement;
  51. import org.odftoolkit.odfdom.dom.element.text.TextListLevelStyleImageElement;
  52. import org.odftoolkit.odfdom.pkg.OdfAttribute;
  53. import org.odftoolkit.odfdom.pkg.OdfElement;
  54. import org.odftoolkit.odfdom.pkg.OdfFileDom;
  55. import org.odftoolkit.odfdom.pkg.OdfName;

  56. /** DOM implementation of OpenDocument attribute {@odf.attribute xlink:actuate}. */
  57. public class XlinkActuateAttribute extends OdfAttribute {

  58.   public static final OdfName ATTRIBUTE_NAME =
  59.       OdfName.newName(OdfDocumentNamespace.XLINK, "actuate");
  60.   public static final String DEFAULT_VALUE_ONLOAD = Value.ONLOAD.toString();
  61.   public static final String DEFAULT_VALUE_ONREQUEST = Value.ONREQUEST.toString();

  62.   /**
  63.    * Create the instance of OpenDocument attribute {@odf.attribute xlink:actuate}.
  64.    *
  65.    * @param ownerDocument The type is <code>OdfFileDom</code>
  66.    */
  67.   public XlinkActuateAttribute(OdfFileDom ownerDocument) {
  68.     super(ownerDocument, ATTRIBUTE_NAME);
  69.   }

  70.   /**
  71.    * Returns the attribute name.
  72.    *
  73.    * @return the <code>OdfName</code> for {@odf.attribute xlink:actuate}.
  74.    */
  75.   @Override
  76.   public OdfName getOdfName() {
  77.     return ATTRIBUTE_NAME;
  78.   }

  79.   /** @return Returns the name of this attribute. */
  80.   @Override
  81.   public String getName() {
  82.     return ATTRIBUTE_NAME.getLocalName();
  83.   }

  84.   /** The value set of {@odf.attribute xlink:actuate}. */
  85.   public enum Value {
  86.     ONLOAD("onLoad"),
  87.     ONREQUEST("onRequest");

  88.     private String mValue;

  89.     Value(String value) {
  90.       mValue = value;
  91.     }

  92.     @Override
  93.     public String toString() {
  94.       return mValue;
  95.     }

  96.     public static Value enumValueOf(String value) {
  97.       for (Value aIter : values()) {
  98.         if (value.equals(aIter.toString())) {
  99.           return aIter;
  100.         }
  101.       }
  102.       return null;
  103.     }
  104.   }

  105.   /** @param attrValue The <code>Enum</code> value of the attribute. */
  106.   public void setEnumValue(Value attrValue) {
  107.     setValue(attrValue.toString());
  108.   }

  109.   /** @return Returns the <code>Enum</code> value of the attribute */
  110.   public Value getEnumValue() {
  111.     return Value.enumValueOf(this.getValue());
  112.   }

  113.   /**
  114.    * Returns the default value of {@odf.attribute xlink:actuate}.
  115.    *
  116.    * @return the default value as <code>String</code> dependent of its element name return <code>
  117.    *     null</code> if the default value does not exist
  118.    */
  119.   @Override
  120.   public String getDefault() {
  121.     OdfElement parentElement = (OdfElement) getOwnerElement();
  122.     String defaultValue = null;
  123.     if (parentElement != null) {
  124.       if (parentElement instanceof DbConnectionResourceElement) {
  125.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  126.       }
  127.       if (parentElement instanceof DrawAElement) {
  128.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  129.       }
  130.       if (parentElement instanceof DrawAppletElement) {
  131.         defaultValue = DEFAULT_VALUE_ONLOAD;
  132.       }
  133.       if (parentElement instanceof DrawFillImageElement) {
  134.         defaultValue = DEFAULT_VALUE_ONLOAD;
  135.       }
  136.       if (parentElement instanceof DrawFloatingFrameElement) {
  137.         defaultValue = DEFAULT_VALUE_ONLOAD;
  138.       }
  139.       if (parentElement instanceof DrawImageElement) {
  140.         defaultValue = DEFAULT_VALUE_ONLOAD;
  141.       }
  142.       if (parentElement instanceof DrawObjectElement) {
  143.         defaultValue = DEFAULT_VALUE_ONLOAD;
  144.       }
  145.       if (parentElement instanceof DrawObjectOleElement) {
  146.         defaultValue = DEFAULT_VALUE_ONLOAD;
  147.       }
  148.       if (parentElement instanceof DrawPluginElement) {
  149.         defaultValue = DEFAULT_VALUE_ONLOAD;
  150.       }
  151.       if (parentElement instanceof FormFormElement) {
  152.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  153.       }
  154.       if (parentElement instanceof MetaAutoReloadElement) {
  155.         defaultValue = DEFAULT_VALUE_ONLOAD;
  156.       }
  157.       if (parentElement instanceof MetaTemplateElement) {
  158.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  159.       }
  160.       if (parentElement instanceof PresentationEventListenerElement) {
  161.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  162.       }
  163.       if (parentElement instanceof PresentationSoundElement) {
  164.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  165.       }
  166.       if (parentElement instanceof ScriptEventListenerElement) {
  167.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  168.       }
  169.       if (parentElement instanceof StyleBackgroundImageElement) {
  170.         defaultValue = DEFAULT_VALUE_ONLOAD;
  171.       }
  172.       if (parentElement instanceof SvgDefinitionSrcElement) {
  173.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  174.       }
  175.       if (parentElement instanceof SvgFontFaceUriElement) {
  176.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  177.       }
  178.       if (parentElement instanceof TableCellRangeSourceElement) {
  179.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  180.       }
  181.       if (parentElement instanceof TableTableSourceElement) {
  182.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  183.       }
  184.       if (parentElement instanceof TextAElement) {
  185.         defaultValue = DEFAULT_VALUE_ONREQUEST;
  186.       }
  187.       if (parentElement instanceof TextListLevelStyleImageElement) {
  188.         defaultValue = DEFAULT_VALUE_ONLOAD;
  189.       }
  190.     }
  191.     return defaultValue;
  192.   }

  193.   /**
  194.    * Default value indicator. As the attribute default value is dependent from its element, the
  195.    * attribute has only a default, when a parent element exists.
  196.    *
  197.    * @return <code>true</code> if {@odf.attribute xlink:actuate} has an element parent otherwise
  198.    *     return <code>false</code> as undefined.
  199.    */
  200.   @Override
  201.   public boolean hasDefault() {
  202.     return getOwnerElement() == null ? false : true;
  203.   }

  204.   /** @return Returns whether this attribute is known to be of type ID (i.e. xml:id ?) */
  205.   @Override
  206.   public boolean isId() {
  207.     return false;
  208.   }
  209. }