View Javadoc

1   /*
2    * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  /* $Id: Annotation.java,v bc1d5fde7b73 2009/06/01 14:40:54 maxberger $ */
18  
19  package net.sourceforge.jeuclid.elements.content.semantic;
20  
21  import net.sourceforge.jeuclid.elements.AbstractInvisibleJEuclidElement;
22  
23  import org.apache.batik.dom.AbstractDocument;
24  import org.w3c.dom.Node;
25  import org.w3c.dom.mathml.MathMLAnnotationElement;
26  
27  /**
28   * This class represents a annotation element.
29   * 
30   * @version $Revision: bc1d5fde7b73 $
31   */
32  public final class Annotation extends AbstractInvisibleJEuclidElement implements
33          MathMLAnnotationElement {
34  
35      /**
36       * The XML element from this class.
37       */
38      public static final String ELEMENT = "annotation";
39  
40      /** The encoding attribute. */
41      public static final String ATTR_ENCODING = "encoding";
42  
43      private static final long serialVersionUID = 1L;
44  
45      /**
46       * Default constructor. Sets MathML Namespace.
47       * 
48       * @param qname
49       *            Qualified name.
50       * @param odoc
51       *            Owner Document.
52       */
53      public Annotation(final String qname, final AbstractDocument odoc) {
54          super(qname, odoc);
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      protected Node newNode() {
60          return new Annotation(this.nodeName, this.ownerDocument);
61      }
62  
63      /** {@inheritDoc} */
64      public String getBody() {
65          return this.getText();
66      }
67  
68      /** {@inheritDoc} */
69      public String getEncoding() {
70          return this.getMathAttribute(Annotation.ATTR_ENCODING);
71      }
72  
73      /** {@inheritDoc} */
74      public void setBody(final String body) {
75          this.setTextContent(body);
76      }
77  
78      /** {@inheritDoc} */
79      public void setEncoding(final String encoding) {
80          this.setAttribute(Annotation.ATTR_ENCODING, encoding);
81      }
82  
83  }