TextDateElement.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.TextDateAdjustAttribute;
  33. import org.odftoolkit.odfdom.dom.attribute.text.TextDateValueAttribute;
  34. import org.odftoolkit.odfdom.dom.attribute.text.TextFixedAttribute;
  35. import org.odftoolkit.odfdom.pkg.ElementVisitor;
  36. import org.odftoolkit.odfdom.pkg.OdfElement;
  37. import org.odftoolkit.odfdom.pkg.OdfFileDom;
  38. import org.odftoolkit.odfdom.pkg.OdfName;

  39. /** DOM implementation of OpenDocument element {@odf.element text:date}. */
  40. public class TextDateElement extends OdfElement {

  41.   public static final OdfName ELEMENT_NAME = OdfName.newName(OdfDocumentNamespace.TEXT, "date");

  42.   /**
  43.    * Create the instance of <code>TextDateElement</code>
  44.    *
  45.    * @param ownerDoc The type is <code>OdfFileDom</code>
  46.    */
  47.   public TextDateElement(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:date}.
  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>TextDateAdjustAttribute</code>
  88.    * , See {@odf.attribute text:date-adjust}
  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 getTextDateAdjustAttribute() {
  94.     TextDateAdjustAttribute attr =
  95.         (TextDateAdjustAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "date-adjust");
  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>TextDateAdjustAttribute</code> , See
  103.    * {@odf.attribute text:date-adjust}
  104.    *
  105.    * @param textDateAdjustValue The type is <code>String</code>
  106.    */
  107.   public void setTextDateAdjustAttribute(String textDateAdjustValue) {
  108.     TextDateAdjustAttribute attr = new TextDateAdjustAttribute((OdfFileDom) this.ownerDocument);
  109.     setOdfAttribute(attr);
  110.     attr.setValue(textDateAdjustValue);
  111.   }

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

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

  138.   /**
  139.    * Receives the value of the ODFDOM attribute representation <code>TextFixedAttribute</code> , See
  140.    * {@odf.attribute text:fixed}
  141.    *
  142.    * @return - the <code>Boolean</code> , the value or <code>null</code>, if the attribute is not
  143.    *     set and no default value defined.
  144.    */
  145.   public Boolean getTextFixedAttribute() {
  146.     TextFixedAttribute attr =
  147.         (TextFixedAttribute) getOdfAttribute(OdfDocumentNamespace.TEXT, "fixed");
  148.     if (attr != null) {
  149.       return Boolean.valueOf(attr.booleanValue());
  150.     }
  151.     return null;
  152.   }

  153.   /**
  154.    * Sets the value of ODFDOM attribute representation <code>TextFixedAttribute</code> , See
  155.    * {@odf.attribute text:fixed}
  156.    *
  157.    * @param textFixedValue The type is <code>Boolean</code>
  158.    */
  159.   public void setTextFixedAttribute(Boolean textFixedValue) {
  160.     TextFixedAttribute attr = new TextFixedAttribute((OdfFileDom) this.ownerDocument);
  161.     setOdfAttribute(attr);
  162.     attr.setBooleanValue(textFixedValue.booleanValue());
  163.   }

  164.   @Override
  165.   public void accept(ElementVisitor visitor) {
  166.     if (visitor instanceof DefaultElementVisitor) {
  167.       DefaultElementVisitor defaultVisitor = (DefaultElementVisitor) visitor;
  168.       defaultVisitor.visit(this);
  169.     } else {
  170.       visitor.visit(this);
  171.     }
  172.   }
  173.   /** Add text content. Only elements which are allowed to have text content offer this method. */
  174.   public void newTextNode(String content) {
  175.     if (content != null && !content.equals("")) {
  176.       this.appendChild(this.getOwnerDocument().createTextNode(content));
  177.     }
  178.   }
  179. }