01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.event;
17:
18: /**
19: *
20: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/event/GTNoteImpl.java $
21: */
22: public class GTNoteImpl implements GTNote {
23: GTComponent notificationParent = GTRoot.NO_PARENT;
24: protected String notificationName = "";
25: protected int notificationPosition = GTDelta.NO_INDEX;
26:
27: public GTNoteImpl() {
28: }
29:
30: public GTNoteImpl(String notificationName, int notificationPosition) {
31: this .notificationName = notificationName;
32: this .notificationPosition = notificationPosition;
33: }
34:
35: public GTNoteImpl(GTComponent parent, String notificationName,
36: int notificationPosition) {
37: this .notificationParent = parent;
38: this .notificationName = notificationName;
39: this .notificationPosition = notificationPosition;
40: }
41:
42: public GTComponent getParent() {
43: return notificationParent;
44: }
45:
46: public void setParent(GTComponent newParent) {
47: if (newParent == null) {
48: newParent = GTRoot.NO_PARENT;
49: }
50:
51: if (notificationParent != GTRoot.NO_PARENT) {
52: throw new IllegalStateException(
53: "Please remove from existing parent first");
54: }
55:
56: notificationParent = newParent;
57: }
58:
59: public void setNotificationName(String name) {
60: notificationName = name;
61: }
62:
63: public String getNotificationName() {
64: return notificationName;
65: }
66:
67: public void setNotificationPosition(int index) {
68: notificationPosition = index;
69: }
70:
71: public int getNotificationPosition() {
72: return notificationPosition;
73: }
74:
75: public String toString() {
76: StringBuffer buf = new StringBuffer();
77: buf.append(notificationParent.getNote());
78: if (notificationName != null && notificationName.length() != 0) {
79: buf.append(".");
80: buf.append(notificationName);
81: if (notificationPosition != GTDelta.NO_INDEX) {
82: buf.append("[");
83: buf.append(notificationPosition);
84: buf.append("]");
85: }
86: }
87: return buf.toString();
88: }
89: }
|