TextVariableGetElement.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.element.text;

  29. import org.odftoolkit.odfdom.dom.DefaultElementVisitor;
  30. import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
  31. import org.odftoolkit.odfdom.dom.attribute.style.StyleDataStyleNameAttribute;
  32. import org.odftoolkit.odfdom.dom.attribute.text.TextDisplayAttribute;
  33. import org.odftoolkit.odfdom.dom.attribute.text.TextNameAttribute;
  34. import org.odftoolkit.odfdom.pkg.ElementVisitor;
  35. import org.odftoolkit.odfdom.pkg.OdfElement;
  36. import org.odftoolkit.odfdom.pkg.OdfFileDom;
  37. import org.odftoolkit.odfdom.pkg.OdfName;

  38. /** DOM implementation of OpenDocument element {@odf.element text:variable-get}. */
  39. public class TextVariableGetElement extends OdfElement {

  40.   public static final OdfName ELEMENT_NAME =
  41.       OdfName.newName(OdfDocumentNamespace.TEXT, "variable-get");

  42.   /**
  43.    * Create the instance of <code>TextVariableGetElement</code>
  44.    *
  45.    * @param ownerDoc The type is <code>OdfFileDom</code>
  46.    */
  47.   public TextVariableGetElement(OdfFileDom ownerDoc) {
  48.     super(ownerDoc, ELEMENT_NAME);
  49.   }

  50.   /**
  51.    * Get the element name
  52.    *
  53.    * @return return <code>OdfName</code> the name of element {@odf.element text:variable-get}.
  54.    */
  55.   public OdfName getOdfName() {
  56.     return ELEMENT_NAME;
  57.   }

  58.   /**
  59.    * Receives the value of the ODFDOM attribute representation <code>StyleDataStyleNameAttribute
  60.    * </code> , See {@odf.attribute style:data-style-name}
  61.    *
  62.    * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set
  63.    *     and no default value defined.
  64.    */
  65.   public String getStyleDataStyleNameAttribute() {
  66.     StyleDataStyleNameAttribute attr =
  67.         (StyleDataStyleNameAttribute)
  68.             getOdfAttribute(OdfDocumentNamespace.STYLE, "data-style-name");
  69.     if (attr != null) {
  70.       return String.valueOf(attr.getValue());
  71.     }
  72.     return null;
  73.   }

  74.   /**
  75.    * Sets the value of ODFDOM attribute representation <code>StyleDataStyleNameAttribute</code> ,
  76.    * See {@odf.attribute style:data-style-name}
  77.    *
  78.    * @param styleDataStyleNameValue The type is <code>String</code>
  79.    */
  80.   public void setStyleDataStyleNameAttribute(String styleDataStyleNameValue) {
  81.     StyleDataStyleNameAttribute attr =
  82.         new StyleDataStyleNameAttribute((OdfFileDom) this.ownerDocument);
  83.     setOdfAttribute(attr);
  84.     attr.setValue(styleDataStyleNameValue);
  85.   }

  86.   /**
  87.    * Receives the value of the ODFDOM attribute representation <code>TextDisplayAttribute</code> ,
  88.    * See {@odf.attribute text:display}
  89.    *
  90.    * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set
  91.    *     and no default value defined.
  92.    */
  93.   public String getTextDisplayAttribute() {
  94.     TextDisplayAttribute attr =
  95.         (TextDisplayAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "display");
  96.     if (attr != null) {
  97.       return String.valueOf(attr.getValue());
  98.     }
  99.     return null;
  100.   }

  101.   /**
  102.    * Sets the value of ODFDOM attribute representation <code>TextDisplayAttribute</code> , See
  103.    * {@odf.attribute text:display}
  104.    *
  105.    * @param textDisplayValue The type is <code>String</code>
  106.    */
  107.   public void setTextDisplayAttribute(String textDisplayValue) {
  108.     TextDisplayAttribute attr = new TextDisplayAttribute((OdfFileDom) this.ownerDocument);
  109.     setOdfAttribute(attr);
  110.     attr.setValue(textDisplayValue);
  111.   }

  112.   /**
  113.    * Receives the value of the ODFDOM attribute representation <code>TextNameAttribute</code> , See
  114.    * {@odf.attribute text:name}
  115.    *
  116.    * <p>Attribute is mandatory.
  117.    *
  118.    * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set
  119.    *     and no default value defined.
  120.    */
  121.   public String getTextNameAttribute() {
  122.     TextNameAttribute attr = (TextNameAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "name");
  123.     if (attr != null) {
  124.       return String.valueOf(attr.getValue());
  125.     }
  126.     return null;
  127.   }

  128.   /**
  129.    * Sets the value of ODFDOM attribute representation <code>TextNameAttribute</code> , See
  130.    * {@odf.attribute text:name}
  131.    *
  132.    * @param textNameValue The type is <code>String</code>
  133.    */
  134.   public void setTextNameAttribute(String textNameValue) {
  135.     TextNameAttribute attr = new TextNameAttribute((OdfFileDom) this.ownerDocument);
  136.     setOdfAttribute(attr);
  137.     attr.setValue(textNameValue);
  138.   }

  139.   @Override
  140.   public void accept(ElementVisitor visitor) {
  141.     if (visitor instanceof DefaultElementVisitor) {
  142.       DefaultElementVisitor defaultVisitor = (DefaultElementVisitor) visitor;
  143.       defaultVisitor.visit(this);
  144.     } else {
  145.       visitor.visit(this);
  146.     }
  147.   }
  148.   /** Add text content. Only elements which are allowed to have text content offer this method. */
  149.   public void newTextNode(String content) {
  150.     if (content != null && !content.equals("")) {
  151.       this.appendChild(this.getOwnerDocument().createTextNode(content));
  152.     }
  153.   }
  154. }