ConfigConfigItemElement.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.config;

  29. import org.odftoolkit.odfdom.dom.DefaultElementVisitor;
  30. import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
  31. import org.odftoolkit.odfdom.dom.attribute.config.ConfigNameAttribute;
  32. import org.odftoolkit.odfdom.dom.attribute.config.ConfigTypeAttribute;
  33. import org.odftoolkit.odfdom.pkg.ElementVisitor;
  34. import org.odftoolkit.odfdom.pkg.OdfElement;
  35. import org.odftoolkit.odfdom.pkg.OdfFileDom;
  36. import org.odftoolkit.odfdom.pkg.OdfName;

  37. /** DOM implementation of OpenDocument element {@odf.element config:config-item}. */
  38. public class ConfigConfigItemElement extends OdfElement {

  39.   public static final OdfName ELEMENT_NAME =
  40.       OdfName.newName(OdfDocumentNamespace.CONFIG, "config-item");

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

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

  57.   /**
  58.    * Receives the value of the ODFDOM attribute representation <code>ConfigNameAttribute</code> ,
  59.    * See {@odf.attribute config:name}
  60.    *
  61.    * <p>Attribute is mandatory.
  62.    *
  63.    * @return - the <code>String</code> , the value or <code>null</code>, if the attribute is not set
  64.    *     and no default value defined.
  65.    */
  66.   public String getConfigNameAttribute() {
  67.     ConfigNameAttribute attr =
  68.         (ConfigNameAttribute) getOdfAttribute(OdfDocumentNamespace.CONFIG, "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>ConfigNameAttribute</code> , See
  76.    * {@odf.attribute config:name}
  77.    *
  78.    * @param configNameValue The type is <code>String</code>
  79.    */
  80.   public void setConfigNameAttribute(String configNameValue) {
  81.     ConfigNameAttribute attr = new ConfigNameAttribute((OdfFileDom) this.ownerDocument);
  82.     setOdfAttribute(attr);
  83.     attr.setValue(configNameValue);
  84.   }

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

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

  113.   @Override
  114.   public void accept(ElementVisitor visitor) {
  115.     if (visitor instanceof DefaultElementVisitor) {
  116.       DefaultElementVisitor defaultVisitor = (DefaultElementVisitor) visitor;
  117.       defaultVisitor.visit(this);
  118.     } else {
  119.       visitor.visit(this);
  120.     }
  121.   }
  122.   /** Add text content. Only elements which are allowed to have text content offer this method. */
  123.   public void newTextNode(String content) {
  124.     if (content != null && !content.equals("")) {
  125.       this.appendChild(this.getOwnerDocument().createTextNode(content));
  126.     }
  127.   }
  128. }