KickJava   Java API By Example, From Geeks To Geeks.

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


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.ProcessException;
8 import org.apache.slide.projector.Processor;
9 import org.apache.slide.projector.Result;
10 import org.apache.slide.projector.Store;
11 import org.apache.slide.projector.descriptor.ParameterDescriptor;
12 import org.apache.slide.projector.descriptor.ResultDescriptor;
13 import org.apache.slide.projector.descriptor.StateDescriptor;
14 import org.apache.slide.projector.descriptor.StringValueDescriptor;
15 import org.apache.slide.projector.i18n.ErrorMessage;
16 import org.apache.slide.projector.i18n.ParameterMessage;
17 import org.apache.slide.projector.util.StoreHelper;
18 import org.apache.slide.projector.value.StringValue;
19
20 public class Dispose implements Processor {
21     private static Logger JavaDoc logger = Logger.getLogger(Dispose.class.getName());
22
23     public final static String JavaDoc STORE = "store";
24     public final static String JavaDoc KEY = "key";
25
26     private final static ParameterDescriptor[] parameterDescriptor = new ParameterDescriptor[]{
27             new ParameterDescriptor(STORE, new ParameterMessage("dispose/parameter/store"), new StringValueDescriptor(Store.stores)),
28             new ParameterDescriptor(KEY, new ParameterMessage("dispose/parameter/key"), new StringValueDescriptor())
29         };
30
31     private final static ResultDescriptor resultDescriptor = new ResultDescriptor(new StateDescriptor[]{ StateDescriptor.OK_DESCRIPTOR });
32
33     public Result process(Map JavaDoc parameter, Context context) throws Exception JavaDoc {
34         String JavaDoc name = ((StringValue)parameter.get(STORE)).toString();
35         String JavaDoc key = ((StringValue)parameter.get(KEY)).toString();
36         Store store = context.getStore(StoreHelper.getStoreByName(name));
37         if ( store == null ) {
38             throw new ProcessException(new ErrorMessage("storeNotAvailable", new String JavaDoc[] {name}));
39         }
40         store.dispose(key);
41         return new Result( StateDescriptor.OK );
42     }
43
44     public ParameterDescriptor[] getParameterDescriptors() {
45         return parameterDescriptor;
46     }
47
48
49     public ResultDescriptor getResultDescriptor() {
50         return resultDescriptor;
51     }
52 }
Popular Tags