KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.apache.slide.projector.processor.core;
2
3 import org.apache.slide.projector.Context;
4 import org.apache.slide.projector.descriptor.ArrayValueDescriptor;
5 import org.apache.slide.projector.descriptor.ParameterDescriptor;
6 import org.apache.slide.projector.descriptor.ResultEntryDescriptor;
7 import org.apache.slide.projector.descriptor.StringValueDescriptor;
8 import org.apache.slide.projector.i18n.DefaultMessage;
9 import org.apache.slide.projector.i18n.ParameterMessage;
10 import org.apache.slide.projector.processor.SimpleProcessor;
11 import org.apache.slide.projector.value.ArrayValue;
12 import org.apache.slide.projector.value.PrintableValue;
13 import org.apache.slide.projector.value.StringValue;
14 import org.apache.slide.projector.value.Value;
15
16 public class StringArrayRenderer extends SimpleProcessor {
17     public Value process(Value input, Context context) throws Exception JavaDoc {
18         Value []array = ((ArrayValue)input).getArray();
19         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(1024);
20         for ( int i = 0; i < array.length; i++ ) {
21             if ( array[i] instanceof PrintableValue ) {
22                 ((PrintableValue)array[i]).print(buffer);
23             }
24         }
25         return new StringValue(buffer.toString());
26     }
27
28     public ParameterDescriptor getParameterDescriptor() {
29         return new ParameterDescriptor(INPUT, new ParameterMessage("arrayRenderer/input"), new ArrayValueDescriptor(new StringValueDescriptor()));
30     }
31
32     public ResultEntryDescriptor getResultEntryDescriptor() {
33         return new ResultEntryDescriptor(OUTPUT, new DefaultMessage("arrayRenderer/output"), "*", true);
34     }
35 }
Popular Tags