001: /**
002: * ========================================
003: * JFreeReport : a free Java report library
004: * ========================================
005: *
006: * Project Info: http://reporting.pentaho.org/
007: *
008: * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors.
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
015: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: * See the GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License along with this
019: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020: * Boston, MA 02111-1307, USA.
021: *
022: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
023: * in the United States and other countries.]
024: *
025: * ------------
026: * $Id: Node.java 3048 2007-07-28 18:02:42Z tmorgner $
027: * ------------
028: * (C) Copyright 2000-2005, by Object Refinery Limited.
029: * (C) Copyright 2005-2007, by Pentaho Corporation.
030: */package org.jfree.report.structure;
031:
032: import java.io.Serializable;
033: import java.util.Locale;
034:
035: import org.jfree.report.JFreeReport;
036: import org.jfree.report.expressions.Expression;
037:
038: /**
039: * A node is the most basic unit in a report. It acts as general superclass for
040: * all other elements.
041: *
042: * @author Thomas Morgner
043: */
044: public abstract class Node implements Serializable, Cloneable {
045: private Node parent;
046:
047: protected Node() {
048: }
049:
050: public Node getParent() {
051: return parent;
052: }
053:
054: protected void setParent(final Node parent) {
055: this .parent = parent;
056: }
057:
058: /**
059: * This is an extra method to allow me to track all *illegal* write-accesses
060: * to the parent.
061: *
062: * @param parent
063: */
064: public void updateParent(final Node parent) {
065: this .parent = parent;
066: }
067:
068: public Group getGroup() {
069: Node parent = getParent();
070: while (parent != null) {
071: if (parent instanceof Group) {
072: return (Group) parent;
073: }
074:
075: parent = parent.getParent();
076: }
077: return null;
078: }
079:
080: public ReportDefinition getReport() {
081: Node parent = getParent();
082: while (parent != null) {
083: if (parent instanceof ReportDefinition) {
084: return (ReportDefinition) parent;
085: }
086:
087: parent = parent.getParent();
088: }
089: return null;
090: }
091:
092: public JFreeReport getRootReport() {
093: Node parent = getParent();
094: while (parent != null) {
095: if (parent instanceof JFreeReport) {
096: return (JFreeReport) parent;
097: }
098:
099: parent = parent.getParent();
100: }
101: return null;
102: }
103:
104: public Locale getLocale() {
105: if (parent != null) {
106: return parent.getLocale();
107: }
108: return Locale.getDefault();
109: }
110:
111: public Expression getDisplayCondition() {
112: return null;
113: }
114:
115: public boolean isEnabled() {
116: return true;
117: }
118:
119: public Object clone() throws CloneNotSupportedException {
120: return super.clone();
121: }
122: }
|