1 /*
2 * Copyright (C) 2002 Carsten Krebs (Team-Konzept GmbH & Co.KG)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 package com.teamkonzept.dom4jb.dom;
19
20 import com.teamkonzept.dom4jb.schema.CDATADescriptor;
21
22 public class CDATA extends CharacterData
23 implements org.w3c.dom.CDATASection {
24
25 private final CDATADescriptor descriptor;
26 private final Object bean;
27 private String data;
28 private boolean isInitialized;
29
30 /*** Creates new CDATA */
31 public CDATA(
32 final Document document,
33 final CDATADescriptor descriptor,
34 final Object bean) {
35 super(document);
36 this.descriptor = descriptor;
37 this.bean = bean;
38 this.isInitialized = false;
39 }
40
41 public final short getNodeType() {
42 return CDATA.CDATA_SECTION_NODE;
43 }
44
45 public String getNodeName() {
46 return "#cdata-section";
47 }
48
49 public String getData() {
50 if (!isInitialized) {
51 data = descriptor.getValue(bean);
52 isInitialized = true;
53 }
54 return data;
55 }
56
57 /***
58 * Breaks this node into two nodes at the specified <code>offset</code>,
59 * keeping both in the tree as siblings. After being split, this node
60 * will contain all the content up to the <code>offset</code> point. A
61 * new node of the same type, which contains all the content at and
62 * after the <code>offset</code> point, is returned. If the original
63 * node had a parent node, the new node is inserted as the next sibling
64 * of the original node. When the <code>offset</code> is equal to the
65 * length of this node, the new node has no data.
66 * @param offset The 16-bit unit offset at which to split, starting from
67 * <code>0</code>.
68 * @return The new node, of the same type as this node.
69 */
70 public org.w3c.dom.Text splitText(final int offset) {
71 throw new UnsupportedOperationException(
72 "Method splitText(int) not yet implemented.");
73 }
74
75 /***
76 * @see com.teamkonzept.dom4jb.dom.Node#accept(Filter)
77 */
78 public boolean accept(final Filter filter) {
79 return filter.match((CDATA) this);
80 }
81 }
This page was automatically generated by Maven