KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.apache.slide.projector.processor.core;
2
3 import java.util.Map JavaDoc;
4 import java.util.logging.Logger JavaDoc;
5
6 import org.apache.slide.projector.Context;
7 import org.apache.slide.projector.Processor;
8 import org.apache.slide.projector.Result;
9 import org.apache.slide.projector.descriptor.AnyValueDescriptor;
10 import org.apache.slide.projector.descriptor.ParameterDescriptor;
11 import org.apache.slide.projector.descriptor.ResultDescriptor;
12 import org.apache.slide.projector.descriptor.StateDescriptor;
13 import org.apache.slide.projector.i18n.DefaultMessage;
14 import org.apache.slide.projector.i18n.ParameterMessage;
15 import org.apache.slide.projector.value.NullValue;
16 import org.apache.slide.projector.value.Value;
17
18 public class Exists implements Processor {
19     private static Logger JavaDoc logger = Logger.getLogger(Exists.class.getName());
20
21     public final static String JavaDoc INPUT = "input";
22
23     public final static String JavaDoc TRUE = "true";
24     public final static String JavaDoc FALSE = "false";
25
26     private final static ResultDescriptor resultDescriptor = new ResultDescriptor(new StateDescriptor[]{
27             new StateDescriptor(TRUE, new DefaultMessage("exists/state/true")),
28             new StateDescriptor(FALSE, new DefaultMessage("exists/state/false"))
29         });
30     private final static ParameterDescriptor[] parameterDescriptor = new ParameterDescriptor[]{ new ParameterDescriptor(INPUT, new ParameterMessage("exists/input"), new AnyValueDescriptor(), NullValue.NULL) };
31  
32     
33     public Result process(Map JavaDoc parameter, Context context) throws Exception JavaDoc {
34         Value input = (Value)parameter.get(INPUT);
35         if ( input instanceof NullValue ) {
36             return new Result(FALSE);
37         }
38         return new Result(TRUE);
39     }
40
41     public ParameterDescriptor[] getParameterDescriptors() {
42         return parameterDescriptor;
43     }
44         
45     public ResultDescriptor getResultDescriptor() {
46         return resultDescriptor;
47     }
48 }
Popular Tags