1 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 ; 33 import java.util.EventObject ; 34 35 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 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 source, SlideToken token, Namespace namespace, String uri, NodeRevisionDescriptors revisionDescriptors) { 58 this(source, token, namespace, uri, revisionDescriptors, null, null); 59 } 60 61 public ContentEvent(Object source, SlideToken token, Namespace namespace, String uri, NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) { 62 this(source, token, namespace, uri, revisionDescriptors, revisionDescriptor, null); 63 } 64 65 public ContentEvent(Object source, SlideToken token, Namespace namespace, String uri, NodeRevisionDescriptor revisionDescriptor, NodeRevisionContent revisionContent) { 66 this(source, token, namespace, uri, null, revisionDescriptor, revisionContent); 67 } 68 69 public ContentEvent(Object source, SlideToken token, Namespace namespace, String uri, NodeRevisionDescriptor revisionDescriptor) { 70 this(source, token, namespace, uri, null, revisionDescriptor, null); 71 } 72 73 public ContentEvent(Object source, SlideToken token, Namespace namespace, String 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 toString() { 103 StringBuffer buffer = new StringBuffer (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 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 listener, EventObject 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 listener, EventObject 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 listener, EventObject 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 listener, EventObject 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 listener, EventObject 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 listener, EventObject event) throws VetoException { 175 if ( listener instanceof ContentListener ) ((ContentListener)listener).fork((ContentEvent)event); 176 } 177 } 178 } | Popular Tags |