001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.uml.core.eventframework;
043:
044: import org.dom4j.Node;
045:
046: public class EventContext implements IEventContext {
047: private IEventFilter m_eventFilter = null;
048: private Object m_data = null;
049: private String m_name = null;
050: private Node m_node = null;
051: private org.dom4j.Node m_4Jnode = null;
052:
053: public EventContext() {
054: }
055:
056: /**
057: * Sets / Gets the EventFilter for this Context.
058: */
059: public IEventFilter getFilter() {
060: if (m_eventFilter == null) {
061: m_eventFilter = new EventFilter();
062: }
063: return m_eventFilter;
064: }
065:
066: /**
067: * Sets / Gets the EventFilter for this Context.
068: */
069: public void setFilter(IEventFilter value) {
070: if (value != null)
071: m_eventFilter = value;
072: }
073:
074: /**
075: * Sets / Gets the XML node this context represents.
076: */
077: public Node getNode() {
078: if (m_node == null) {
079: //create it.
080: }
081: return m_node;
082: }
083:
084: public org.dom4j.Node getDom4JNode() {
085: if (m_4Jnode == null) {
086: //create it.
087: }
088: return m_4Jnode;
089: }
090:
091: /**
092: * Sets / Gets the XML node this context represents.
093: */
094: public void setNode(Node value) {
095: if (value != null)
096: m_node = value;
097: }
098:
099: public void setDom4JNode(org.dom4j.Node value) {
100: if (value != null)
101: m_4Jnode = value;
102: }
103:
104: /**
105: * Validates the trigger and payload about to be dispatched.
106: */
107: public boolean validateEvent(String triggerName, Object payLoad) {
108: if (triggerName != null && triggerName.length() > 0) {
109: return getFilter().validateEvent(triggerName, payLoad);
110: }
111: return false;
112: }
113:
114: /**
115: * The name of this EventContext.
116: */
117: public String getName() {
118: if (m_name.equals("")) {
119: //set the name
120: }
121: return m_name;
122: }
123:
124: /**
125: * The name of this EventContext.
126: */
127: public void setName(String value) {
128: m_name = value;
129: }
130:
131: /**
132: * User-defined data associated with this Context.
133: */
134: public Object getData() {
135: if (m_data == null) {
136: //create it.
137: }
138: return m_data;
139: }
140:
141: /**
142: * User-defined data associated with this Context.
143: */
144: public void setData(Object value) {
145: if (value != null)
146: m_data = value;
147: }
148:
149: public static final String CLSID = "{C77F3863-A2D3-4832-B28B-A2E86CC32FEA}";
150:
151: }
|