KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > event > ContentEvent


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/event/ContentEvent.java,v 1.4 2004/07/28 09:36:28 ib Exp $
3  * $Revision: 1.4 $
4  * $Date: 2004/07/28 09:36:28 $
5  *
6  * ====================================================================
7  *
8  * Copyright 2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.event;
25
26 import org.apache.slide.common.SlideToken;
27 import org.apache.slide.common.Namespace;
28 import org.apache.slide.content.NodeRevisionContent;
29 import org.apache.slide.content.NodeRevisionDescriptor;
30 import org.apache.slide.content.NodeRevisionDescriptors;
31
32 import java.util.EventListener JavaDoc;
33 import java.util.EventObject JavaDoc;
34
35 /**
36  * Content event class
37  *
38  * @version $Revision: 1.4 $
39  */

40 public class ContentEvent extends ResourceEvent {
41     public final static Create CREATE = new Create();
42     public final static Remove REMOVE = new Remove();
43     public final static Retrieve RETRIEVE = new Retrieve();
44     public final static Store STORE = new Store();
45     public final static Fork FORK = new Fork();
46     public final static Merge MERGE = new Merge();
47
48     public final static String JavaDoc GROUP = "content";
49     public final static AbstractEventMethod[] methods = new AbstractEventMethod[] { CREATE, REMOVE, RETRIEVE, STORE, FORK, MERGE };
50
51     private SlideToken token;
52     private Namespace namespace;
53     private NodeRevisionDescriptors revisionDescriptors;
54     private NodeRevisionDescriptor revisionDescriptor;
55     private NodeRevisionContent revisionContent;
56
57     public ContentEvent(Object JavaDoc source, SlideToken token, Namespace namespace, String JavaDoc uri, NodeRevisionDescriptors revisionDescriptors) {
58         this(source, token, namespace, uri, revisionDescriptors, null, null);
59     }
60
61     public ContentEvent(Object JavaDoc source, SlideToken token, Namespace namespace, String JavaDoc uri, NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) {
62         this(source, token, namespace, uri, revisionDescriptors, revisionDescriptor, null);
63     }
64
65     public ContentEvent(Object JavaDoc source, SlideToken token, Namespace namespace, String JavaDoc uri, NodeRevisionDescriptor revisionDescriptor, NodeRevisionContent revisionContent) {
66         this(source, token, namespace, uri, null, revisionDescriptor, revisionContent);
67     }
68
69     public ContentEvent(Object JavaDoc source, SlideToken token, Namespace namespace, String JavaDoc uri, NodeRevisionDescriptor revisionDescriptor) {
70         this(source, token, namespace, uri, null, revisionDescriptor, null);
71     }
72
73     public ContentEvent(Object JavaDoc source, SlideToken token, Namespace namespace, String JavaDoc uri, NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, NodeRevisionContent revisionContent) {
74         super(source, uri);
75         this.token = token;
76         this.namespace = namespace;
77         this.revisionDescriptors = revisionDescriptors;
78         this.revisionDescriptor = revisionDescriptor;
79         this.revisionContent = revisionContent;
80     }
81
82     public SlideToken getToken() {
83         return token;
84     }
85
86     public NodeRevisionDescriptors getRevisionDescriptors() {
87         return revisionDescriptors;
88     }
89
90     public NodeRevisionDescriptor getRevisionDescriptor() {
91         return revisionDescriptor;
92     }
93
94     public NodeRevisionContent getRevisionContent() {
95         return revisionContent;
96     }
97
98     public Namespace getNamespace() {
99         return namespace;
100     }
101
102     public String JavaDoc toString() {
103         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(256);
104         buffer.append(getClass().getName()).append("[content");
105         if ( revisionDescriptors != null ) buffer.append(" uri=").append(revisionDescriptors.getUri());
106         if ( revisionDescriptor != null ) buffer.append(" contentType=").append(revisionDescriptor.getContentType());
107         buffer.append("]");
108         return buffer.toString();
109     }
110
111     public static AbstractEventMethod[] getMethods() {
112         return methods;
113     }
114
115     public static String JavaDoc getGroup() {
116         return GROUP;
117     }
118
119     public final static class Create extends VetoableEventMethod {
120         public Create() {
121             super(GROUP, "create");
122         }
123
124         public void fireVetaoableEvent(EventListener JavaDoc listener, EventObject JavaDoc event) throws VetoException {
125             if ( listener instanceof ContentListener ) ((ContentListener)listener).create((ContentEvent)event);
126         }
127     }
128
129     public final static class Remove extends VetoableEventMethod {
130         public Remove() {
131             super(GROUP, "remove");
132         }
133
134         public void fireVetaoableEvent(EventListener JavaDoc listener, EventObject JavaDoc event) throws VetoException {
135             if ( listener instanceof ContentListener ) ((ContentListener)listener).remove((ContentEvent)event);
136         }
137     }
138
139     public final static class Store extends VetoableEventMethod {
140         public Store() {
141             super(GROUP, "store");
142         }
143
144         public void fireVetaoableEvent(EventListener JavaDoc listener, EventObject JavaDoc event) throws VetoException {
145             if ( listener instanceof ContentListener ) ((ContentListener)listener).store((ContentEvent)event);
146         }
147     }
148
149     public final static class Retrieve extends VetoableEventMethod {
150         public Retrieve() {
151             super(GROUP, "retrieve");
152         }
153
154         public void fireVetaoableEvent(EventListener JavaDoc listener, EventObject JavaDoc event) throws VetoException {
155             if ( listener instanceof ContentListener ) ((ContentListener)listener).retrieve((ContentEvent)event);
156         }
157     }
158
159     public final static class Merge extends VetoableEventMethod {
160         public Merge() {
161             super(GROUP, "merge");
162         }
163
164         public void fireVetaoableEvent(EventListener JavaDoc listener, EventObject JavaDoc event) throws VetoException {
165             if ( listener instanceof ContentListener ) ((ContentListener)listener).merge((ContentEvent)event);
166         }
167     }
168
169     public final static class Fork extends VetoableEventMethod {
170         public Fork() {
171             super(GROUP, "fork");
172         }
173
174         public void fireVetaoableEvent(EventListener JavaDoc listener, EventObject JavaDoc event) throws VetoException {
175             if ( listener instanceof ContentListener ) ((ContentListener)listener).fork((ContentEvent)event);
176         }
177     }
178 }
Popular Tags