KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.apache.slide.projector.processor.core;
2
3 import org.apache.slide.projector.ContentType;
4 import org.apache.slide.projector.Context;
5 import org.apache.slide.projector.HttpContext;
6 import org.apache.slide.projector.ProcessException;
7 import org.apache.slide.projector.descriptor.ParameterDescriptor;
8 import org.apache.slide.projector.descriptor.ResultEntryDescriptor;
9 import org.apache.slide.projector.descriptor.StringValueDescriptor;
10 import org.apache.slide.projector.i18n.DefaultMessage;
11 import org.apache.slide.projector.i18n.ErrorMessage;
12 import org.apache.slide.projector.i18n.ParameterMessage;
13 import org.apache.slide.projector.processor.SimpleProcessor;
14 import org.apache.slide.projector.value.StringValue;
15 import org.apache.slide.projector.value.Value;
16
17 public class URL extends SimpleProcessor {
18     public Value process(Value input, Context context) throws Exception JavaDoc {
19         Value output;
20         if ( context instanceof HttpContext ) {
21             output = new StringValue(((HttpContext)context).getContextPath() + "/" + ((StringValue)input).toString());
22         } else {
23             throw new ProcessException(new ErrorMessage("httpContextRequired"));
24         }
25         return output;
26     }
27
28     public ParameterDescriptor getParameterDescriptor() {
29         return new ParameterDescriptor(INPUT, new ParameterMessage("url/parameter/input"), new StringValueDescriptor());
30     }
31
32     public ResultEntryDescriptor getResultEntryDescriptor() {
33         return new ResultEntryDescriptor(OUTPUT, new DefaultMessage("url/result/output"), ContentType.DYNAMIC, true);
34     }
35 }
Popular Tags