KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > text > template > xhtml > Text


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.text.template.xhtml;
6
7 import java.io.IOException JavaDoc;
8 import java.io.Writer JavaDoc;
9 import java.util.ResourceBundle JavaDoc;
10 import org.exoplatform.commons.utils.ExpressionUtil;
11 import org.exoplatform.text.template.*;
12
13 /**
14  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
15  * @since Feb 1, 2005
16  * @version $Id$
17  */

18 public class Text extends Element {
19   protected Value data_ ;
20   
21   public Text(String JavaDoc value) {
22     if(value == null ) return ;
23     if(ExpressionUtil.isResourceBindingExpression(value)) {
24       data_ = new ResourceBindingValue(value) ;
25     } else if(ExpressionUtil.isDataBindingExpression(value)) {
26       data_ = new DataBindingValue(value) ;
27     } else {
28       data_ = new StringValue(value) ;
29     }
30   }
31   
32   public Value getData() { return data_ ; }
33   
34   
35   public void render(XhtmlDataHandlerManager manager,
36                      ResourceBundle JavaDoc res, Writer JavaDoc w) throws IOException JavaDoc {
37     DataHandler dh = manager.getDataHandler(dataHandlerType_) ;
38     w.write(resolveValueAsString(data_ ,dh, res)) ;
39   }
40 }
Popular Tags