KickJava   Java API By Example, From Geeks To Geeks.

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


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