KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > xml > types > A_CmsXmlValueCdataBase


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/xml/types/A_CmsXmlValueCdataBase.java,v $
3  * Date : $Date: 2005/06/23 11:11:23 $
4  * Version: $Revision: 1.10 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.xml.types;
33
34 import org.opencms.file.CmsObject;
35 import org.opencms.main.CmsIllegalArgumentException;
36 import org.opencms.main.CmsRuntimeException;
37 import org.opencms.util.CmsStringUtil;
38 import org.opencms.xml.I_CmsXmlDocument;
39
40 import java.util.Locale JavaDoc;
41
42 import org.dom4j.Element;
43
44 /**
45  * Base class for XML content value implementations that require only a simple XML cdata text node.<p>
46  *
47  * @author Alexander Kandzior
48  *
49  * @version $Revision: 1.10 $
50  *
51  * @since 6.0.0
52  */

53 public abstract class A_CmsXmlValueCdataBase extends A_CmsXmlContentValue {
54
55     /** The String value of the element node. */
56     protected String JavaDoc m_stringValue;
57
58     /**
59      * Default constructor for a xml content type
60      * that initializes some internal values.<p>
61      */

62     protected A_CmsXmlValueCdataBase() {
63
64         super();
65     }
66
67     /**
68      * Initializes the required members for this XML content value.<p>
69      *
70      * @param document the XML content instance this value belongs to
71      * @param element the XML element that contains this value
72      * @param locale the locale this value is created for
73      * @param type the type instance to create the value for
74      */

75     protected A_CmsXmlValueCdataBase(I_CmsXmlDocument document, Element element, Locale JavaDoc locale, I_CmsXmlSchemaType type) {
76
77         super(document, element, locale, type);
78         m_stringValue = element.getText();
79     }
80
81     /**
82      * Initializes the schema type descriptor values for this type descriptor.<p>
83      *
84      * @param name the name of the XML node containing the value according to the XML schema
85      * @param minOccurs minimum number of occurences of this type according to the XML schema
86      * @param maxOccurs maximum number of occurences of this type according to the XML schema
87      */

88     protected A_CmsXmlValueCdataBase(String JavaDoc name, String JavaDoc minOccurs, String JavaDoc maxOccurs) {
89
90         super(name, minOccurs, maxOccurs);
91     }
92
93     /**
94      * @see org.opencms.xml.types.I_CmsXmlContentValue#getPlainText(org.opencms.file.CmsObject)
95      */

96     public String JavaDoc getPlainText(CmsObject cms) {
97
98         return getStringValue(cms);
99     }
100
101     /**
102      * @see org.opencms.xml.types.I_CmsXmlContentValue#getStringValue(CmsObject)
103      */

104     public String JavaDoc getStringValue(CmsObject cms) throws CmsRuntimeException {
105
106         return m_stringValue;
107     }
108
109     /**
110      * @see org.opencms.xml.types.I_CmsXmlContentValue#setStringValue(org.opencms.file.CmsObject, java.lang.String)
111      */

112     public void setStringValue(CmsObject cms, String JavaDoc value) throws CmsIllegalArgumentException {
113
114         m_element.clearContent();
115         if (CmsStringUtil.isNotEmpty(value)) {
116             m_element.addCDATA(value);
117         }
118         m_stringValue = value;
119     }
120 }
Popular Tags