01: /*
02: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
07: *
08: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
09: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
10: * the license for the specific language governing your rights and limitations.
11: *
12: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
13: */
14: package org.pentaho.reportdesigner.crm.report.model;
15:
16: import org.gjt.xpp.XmlPullNode;
17: import org.jetbrains.annotations.NotNull;
18: import org.pentaho.reportdesigner.crm.report.PropertyKeys;
19: import org.pentaho.reportdesigner.lib.common.xml.XMLConstants;
20: import org.pentaho.reportdesigner.lib.common.xml.XMLContext;
21: import org.pentaho.reportdesigner.lib.common.xml.XMLExternalizable;
22: import org.pentaho.reportdesigner.lib.common.xml.XMLUtils;
23: import org.pentaho.reportdesigner.lib.common.xml.XMLWriter;
24:
25: import java.io.IOException;
26:
27: /**
28: * User: Martin
29: * Date: 17.01.2007
30: * Time: 18:32:28
31: */
32: public class Formula implements XMLExternalizable {
33: @NotNull
34: private String text;
35:
36: public Formula(@NotNull
37: String text) {
38: this .text = text;
39: }
40:
41: @NotNull
42: public String getText() {
43: return text;
44: }
45:
46: @NotNull
47: public String toString() {
48: return "Formula{" + "text='" + text + '\'' + '}';
49: }
50:
51: public void externalizeObject(@NotNull
52: XMLWriter xmlWriter, @NotNull
53: XMLContext xmlContext) throws IOException {
54: xmlWriter.writeProperty(PropertyKeys.TEXT, text);
55: }
56:
57: public void readObject(@NotNull
58: XmlPullNode node, @NotNull
59: XMLContext xmlContext) throws Exception {
60: while (!node.isFinished()) {
61: Object childNodeList = node.readNextChild();
62: if (childNodeList instanceof XmlPullNode) {
63: XmlPullNode child = (XmlPullNode) childNodeList;
64: if (XMLConstants.PROPERTY.equals(child.getRawName())
65: && PropertyKeys.TEXT
66: .equals(child
67: .getAttributeValueFromRawName(XMLConstants.NAME))) {
68: text = XMLUtils.readProperty(PropertyKeys.TEXT,
69: child);
70: }
71: }
72: }
73: }
74: }
|