01: /* TextInfo.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Sat Sep 1 01:14:10 2007, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zk.ui.metainfo;
20:
21: import org.zkoss.zk.ui.Component;
22: import org.zkoss.zk.ui.Page;
23: import org.zkoss.zk.xel.ExValue;
24: import org.zkoss.zk.xel.impl.EvaluatorRef;
25:
26: /**
27: * Represents a text.
28: *
29: * @author tomyeh
30: * @since 3.0.0
31: */
32: public class TextInfo extends EvalRefStub implements
33: java.io.Serializable {
34: private final ExValue _text;
35:
36: /**
37: * @param evalr the evaluator reference. It cannot be null.
38: * Retrieve it from {@link LanguageDefinition#getEvaluatorRef}
39: * or {@link PageDefinition#getEvaluatorRef}, depending which it
40: * belongs.
41: */
42: public TextInfo(EvaluatorRef evalr, String text) {
43: if (evalr == null)
44: throw new IllegalArgumentException();
45: _evalr = evalr;
46: _text = text != null ? new ExValue(text, String.class) : null;
47: }
48:
49: /** Returns the raw value (text).
50: */
51: public String getRawValue() {
52: return _text.getRawValue();
53: }
54:
55: /** Returns the value after evaluation.
56: */
57: public String getValue(Page page) {
58: return _text != null ? (String) _text.getValue(_evalr, page)
59: : null;
60: }
61:
62: /** Returns the value after evaluation.
63: */
64: public String getValue(Component comp) {
65: return _text != null ? (String) _text.getValue(_evalr, comp)
66: : null;
67: }
68: }
|