KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > projector > processor > core > Event


1 /*
2  * $Header: /home/cvs/jakarta-slide/projector/src/java/org/apache/slide/projector/processor/core/Event.java,v 1.4 2004/08/03 14:29:55 dflorey Exp $
3  * $Revision: 1.4 $
4  * $Date: 2004/08/03 14:29:55 $
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.projector.processor.core;
25
26 import java.util.Map JavaDoc;
27
28 import org.apache.slide.projector.Context;
29 import org.apache.slide.projector.Processor;
30 import org.apache.slide.projector.Projector;
31 import org.apache.slide.projector.Result;
32 import org.apache.slide.projector.descriptor.BooleanValueDescriptor;
33 import org.apache.slide.projector.descriptor.MapValueDescriptor;
34 import org.apache.slide.projector.descriptor.ParameterDescriptor;
35 import org.apache.slide.projector.descriptor.ResultDescriptor;
36 import org.apache.slide.projector.descriptor.StateDescriptor;
37 import org.apache.slide.projector.i18n.ParameterMessage;
38 import org.apache.slide.projector.value.BooleanValue;
39 import org.apache.slide.projector.value.MapValue;
40
41 /**
42  * The Event class
43  *
44  */

45 public class Event implements Processor {
46     public final static String JavaDoc INFORMATION = "information";
47     public final static String JavaDoc VETOABLE = "vetoable";
48
49     private final static ParameterDescriptor[] parameterDescriptors = new ParameterDescriptor[] {
50         new ParameterDescriptor(INFORMATION, new ParameterMessage("event/information"), MapValueDescriptor.ANY),
51         new ParameterDescriptor(VETOABLE, new ParameterMessage("event/vetoable"), new BooleanValueDescriptor(), new BooleanValue(false))
52     };
53     private final static ResultDescriptor resultDescriptor = new ResultDescriptor(new StateDescriptor[] { StateDescriptor.OK_DESCRIPTOR });
54
55     public Result process(Map JavaDoc parameter, Context context) throws Exception JavaDoc {
56         Map JavaDoc information = ((MapValue)parameter.get(INFORMATION)).getMap();
57         boolean vetoable = ((BooleanValue)parameter.get(VETOABLE)).booleanValue();
58         if ( vetoable ) {
59             Projector.getRepository().fireVetoableEvent(information, context.getCredentials());
60         } else {
61             Projector.getRepository().fireEvent(information, context.getCredentials());
62         }
63         return new Result(StateDescriptor.OK);
64     }
65
66     public ParameterDescriptor[] getParameterDescriptors() {
67         return parameterDescriptors;
68     }
69
70     public ResultDescriptor getResultDescriptor() {
71         return resultDescriptor;
72     }
73 }
74
Popular Tags