001 /* 002 * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 /* $Id: Annotation.java,v bc1d5fde7b73 2009/06/01 14:40:54 maxberger $ */ 018 019 package net.sourceforge.jeuclid.elements.content.semantic; 020 021 import net.sourceforge.jeuclid.elements.AbstractInvisibleJEuclidElement; 022 023 import org.apache.batik.dom.AbstractDocument; 024 import org.w3c.dom.Node; 025 import org.w3c.dom.mathml.MathMLAnnotationElement; 026 027 /** 028 * This class represents a annotation element. 029 * 030 * @version $Revision: bc1d5fde7b73 $ 031 */ 032 public final class Annotation extends AbstractInvisibleJEuclidElement implements 033 MathMLAnnotationElement { 034 035 /** 036 * The XML element from this class. 037 */ 038 public static final String ELEMENT = "annotation"; 039 040 /** The encoding attribute. */ 041 public static final String ATTR_ENCODING = "encoding"; 042 043 private static final long serialVersionUID = 1L; 044 045 /** 046 * Default constructor. Sets MathML Namespace. 047 * 048 * @param qname 049 * Qualified name. 050 * @param odoc 051 * Owner Document. 052 */ 053 public Annotation(final String qname, final AbstractDocument odoc) { 054 super(qname, odoc); 055 } 056 057 /** {@inheritDoc} */ 058 @Override 059 protected Node newNode() { 060 return new Annotation(this.nodeName, this.ownerDocument); 061 } 062 063 /** {@inheritDoc} */ 064 public String getBody() { 065 return this.getText(); 066 } 067 068 /** {@inheritDoc} */ 069 public String getEncoding() { 070 return this.getMathAttribute(Annotation.ATTR_ENCODING); 071 } 072 073 /** {@inheritDoc} */ 074 public void setBody(final String body) { 075 this.setTextContent(body); 076 } 077 078 /** {@inheritDoc} */ 079 public void setEncoding(final String encoding) { 080 this.setAttribute(Annotation.ATTR_ENCODING, encoding); 081 } 082 083 }