1 63 64 package org.apache.slide.projector.processor; 65 66 import java.util.Map ; 67 68 import org.apache.slide.projector.Context; 69 import org.apache.slide.projector.Processor; 70 import org.apache.slide.projector.Result; 71 import org.apache.slide.projector.descriptor.ParameterDescriptor; 72 import org.apache.slide.projector.descriptor.ResultDescriptor; 73 import org.apache.slide.projector.descriptor.ResultEntryDescriptor; 74 import org.apache.slide.projector.descriptor.StateDescriptor; 75 import org.apache.slide.projector.value.Value; 76 77 80 81 public abstract class SimpleProcessor implements Processor { 82 public final static String INPUT = "input"; 83 public final static String OUTPUT = "output"; 84 85 public abstract Value process(Value input, Context context) throws Exception ; 86 87 public abstract ParameterDescriptor getParameterDescriptor(); 88 89 public abstract ResultEntryDescriptor getResultEntryDescriptor(); 90 91 public Result process(Map parameter, Context context) throws Exception { 92 Value input = (Value)parameter.get(INPUT); 93 Value output = process(input, context); 94 return new Result(StateDescriptor.OK, OUTPUT, output); 95 } 96 97 public ParameterDescriptor[] getParameterDescriptors() { 98 return new ParameterDescriptor[] { getParameterDescriptor() }; 99 } 100 101 public ResultDescriptor getResultDescriptor() { 102 return new ResultDescriptor( 103 new StateDescriptor[] { StateDescriptor.OK_DESCRIPTOR }, 104 new ResultEntryDescriptor[] { 105 getResultEntryDescriptor() 106 }); 107 } 108 } | Popular Tags |