KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > projector > descriptor > MessageValueDescriptor


1 package org.apache.slide.projector.descriptor;
2
3 import org.apache.slide.projector.Context;
4 import org.apache.slide.projector.i18n.ErrorMessage;
5 import org.apache.slide.projector.value.MessageValue;
6 import org.apache.slide.projector.value.Value;
7
8 public class MessageValueDescriptor implements ValueDescriptor {
9     public Value valueOf(Object JavaDoc value, Context context) throws ValueCastException {
10         if ( value instanceof MessageValue ) {
11             return (MessageValue)value;
12         } else {
13             try {
14                 return new MessageValue((StringValueDescriptor.ANY.valueOf(value, null).toString()));
15             } catch ( ValueCastException exception ) {
16                 throw new ValueCastException(new ErrorMessage("uncastableMessageValue", new Object JavaDoc[] { value }));
17             }
18         }
19     }
20
21     public void validate(Value value, Context context) throws ValidationException {
22     }
23 }
Popular Tags