blob: 7ebd0f5b375af5458709f2c2c175c43477b121fb [file] [log] [blame]
##################################################################
##
## 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.
##
##################################################################
## Template to create the Java class representing an ODF element.
##
## Documentation of template development can be found in local file
## TemplateHelp.html.
##
#set ($base = $javamodel.getBaseclass($context))
#set ($baseElement = ${model.getElement($base.getQName())})
#set($classname = "${model.camelCase($base)}ElementBase")
##
## Set Superclass
#if (${base.isStylable()})
#set ($stylable = true)
#set ($superclass = "OdfStylableElement")
#if ($baseElement)
#set ($elementStyleFamily=${odfmodel.getStyleFamilies($baseElement)})
#set ($useOdfStyleableShapeElement = false)
#foreach($f in $elementStyleFamily)
#if (${f.getQName()}=="draw:graphic" || ${f.getQName()}=="presentation:presentation")
#set ($useOdfStyleableShapeElement = true)
#end
#end
#end
#else
#set ($superclass = 'OdfElement')
#end
#if ($context== "text:list-level-style")
#set ($superclass = 'OdfStyleBase')
#end
#if ($useOdfStyleableShapeElement || $classname=="DrawShapeElementBase")
#set ($superclass = "OdfStyleableShapeElement")
#end
##
## Begin Code
#include('copyright.txt')
/*
* This file is automatically generated.
* Don't edit manually.
*/
package org.odftoolkit.odfdom.dom.element.${base.getNamespace()};
##
## ---------------------------------------------------
## Imports
## ---------------------------------------------------
##
import org.odftoolkit.odfdom.pkg.OdfFileDom;
import org.odftoolkit.odfdom.pkg.OdfName;
import org.odftoolkit.odfdom.dom.OdfDocumentNamespace;
import org.odftoolkit.odfdom.pkg.OdfElement;
import org.odftoolkit.odfdom.dom.element.OdfStyleBase;
import org.odftoolkit.odfdom.dom.element.OdfStylableElement;
import org.odftoolkit.odfdom.dom.style.OdfStyleFamily;
import org.odftoolkit.odfdom.dom.element.OdfStyleableShapeElement;
#foreach ($attribute in ${base.getBaseAttributes().withoutMultiples()})
#if ($attribute == "*")
#set ($anyattribute = true)
#else
import org.odftoolkit.odfdom.dom.attribute.${attribute.getNamespace()}.${model.camelCase($attribute)}Attribute;
#end
#end
##
## ---------------------------------------------------
## Class
## ---------------------------------------------------
##
/**
* DOM implementation of OpenDocument base element
*
#if ($anyattribute)
* This class can have any org.w3c.dom.Attribute attribute.
#end
*/
public abstract class $classname extends $superclass {
/**
* Create the instance of <code>$classname</code>
*
* @param ownerDoc The type is <code>OdfFileDom</code>
*/
#if (${base.isStylable()}&& ($useOdfStyleableShapeElement == false) || $classname=="TextParagraphElementBase")
public $classname(OdfFileDom ownerDoc, OdfName elementName, OdfStyleFamily styleFamily, OdfName styleAttrName) {
super(ownerDoc, elementName, styleFamily, styleAttrName);
}
#else
public $classname(OdfFileDom ownerDoc, OdfName elementName) {
super(ownerDoc, elementName);
}
#end
##
## ---------------------------------------------------
## Attribute getters and setters
## ---------------------------------------------------
##
#foreach ($attr in ${base.getBaseAttributes().withoutMultiples()})
#set ($valueObject = "String")
#set ($simpleValue = "")
#set ($dataTypes = ${attr.getDatatypes().withoutMultiples()})
#set ($valueTypes = ${javamodel.getValuetypes($dataTypes)})
#foreach ($valueType in $valueTypes)
#set ($valueObject = $valueType)
#end
#set($values = ${attr.getValues().withoutMultiples()})
#if ($values.size() ==2)
#set ($trueFlag = false)
#set ($falseFlag = false)
#foreach ($value in $values)
#if ($value==true)
#set ($trueFlag = true)
#end
#if ($value==false)
#set ($falseFlag = true)
#end
#end
#if ($trueFlag and $falseFlag)
#set ($hasdatatype = true)
#set ($valueObject = "Boolean")
#end
#end
#if ($valueObject != "String" && $valueObject != "Double" && $valueObject != "Integer" && $valueObject != "Boolean")
#set ($valueObject = "String")
#end
#if ($valueObject != "String")
#set ($simpleValue = ${javamodel.getPrimitiveType($valueObject)})
#end
#if ($attr != "*")
#set ($attribute = ${attr.withMultiples()})
#set ($aNS = ${attribute.getNamespace()})
#set ($aClassname = "${model.camelCase($attribute)}Attribute")
#set ($aParam = "${model.javaCase($attribute)}Value")
/**
* Receives the value of the ODFDOM attribute representation <code>$aClassname</code> , See {@odf.attribute ${attribute.getQName()}}
*
* @return - the <code>$valueObject</code> , the value or <code>null</code>, if the attribute is not set and no default value defined.
*/
public $valueObject get${aClassname}() {
$aClassname attr = ($aClassname) getOdfAttribute(OdfDocumentNamespace.${aNS.toUpperCase()}, "${attribute.getLocalName()}");
if (attr != null) {
#if ($simpleValue!="")
return ${valueObject}.valueOf(attr.${simpleValue}Value());
#else
return ${valueObject}.valueOf(attr.getValue());
#end
}
#if ($odfmodel.getDefaultAttributeValue($attr, $base))
#set ($defaultValue = ${model.escapeLiteral($odfmodel.getDefaultAttributeValue($attr, $base))})
#set ($defaultValueSet = $odfmodel.getDefaultAttributeValues($attr))
#if ($defaultValueSet.size()>1)
#set ($constant = $model.constantCase($defaultValue))
#if ($valueObject == "String")
return ${aClassname}.DEFAULT_VALUE_${model.escapeKeyword($constant)};
#else
return ${valueObject}.valueOf(${aClassname}.DEFAULT_VALUE_${model.escapeKeyword($constant)});
#end
#else
#if ($valueObject == "String")
return ${aClassname}.DEFAULT_VALUE;
#else
return ${valueObject}.valueOf(${aClassname}.DEFAULT_VALUE);
#end
#end
#else
return null;
#end
}
/**
* Sets the value of ODFDOM attribute representation <code>$aClassname</code> , See {@odf.attribute ${attribute.getQName()}}
*
* @param $aParam The type is <code>$valueObject</code>
*/
public void set${aClassname}($valueObject $aParam) {
$aClassname attr = new ${aClassname}((OdfFileDom) this.ownerDocument);
setOdfAttribute(attr);
#if ($valueObject == "String")
attr.setValue($aParam);
#else
attr.set${model.camelCase($simpleValue)}Value($aParam.${simpleValue}Value());
#end
}
#end
#end
}