KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > config > jaxb > JaxbProperty


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.config.jaxb;
31
32 import com.caucho.config.AttributeStrategy;
33 import com.caucho.config.ConfigException;
34 import com.caucho.config.NodeBuilder;
35 import com.caucho.el.Expr;
36 import com.caucho.xml.QName;
37
38 import org.w3c.dom.Node JavaDoc;
39
40 public class JaxbProperty extends AttributeStrategy {
41   /**
42    * Configures the parent object with the given node.
43    *
44    * @param builder the calling node builder (context)
45    * @param bean the bean to be configured
46    * @param name the name of the property
47    * @param node the configuration node for the value
48    */

49   public void configure(NodeBuilder builder,
50                         Object JavaDoc bean,
51                         QName name,
52                         Node JavaDoc node)
53     throws ConfigException
54   {
55     configureElement(builder, bean, name, node);
56   }
57   
58   /**
59    * Configures the parent object with the given node.
60    *
61    * @param builder the calling node builder (context)
62    * @param bean the bean to be configured
63    * @param name the name of the property
64    * @param value the attribute value
65    */

66   public void configureAttribute(NodeBuilder builder,
67                  Object JavaDoc bean,
68                  QName name,
69                  String JavaDoc value)
70     throws ConfigException
71   {
72   }
73   
74   /**
75    * Configures the parent object with the given node.
76    *
77    * @param builder the calling node builder (context)
78    * @param bean the bean to be configured
79    * @param name the name of the property
80    * @param value the attribute value
81    */

82   public void configureElement(NodeBuilder builder,
83                    Object JavaDoc bean,
84                    QName name,
85                    Node JavaDoc value)
86     throws ConfigException
87   {
88   }
89
90   protected static boolean evalBoolean(NodeBuilder builder, String JavaDoc textValue)
91   {
92     if (textValue.indexOf("${") >= 0)
93       return builder.evalBoolean(textValue);
94     else if (textValue.equals("true") || textValue.equals("1"))
95       return true;
96     else
97       return false;
98   }
99
100   protected static long evalLong(NodeBuilder builder, String JavaDoc textValue)
101   {
102     if (textValue.indexOf("${") >= 0)
103       return builder.evalLong(textValue);
104     else
105       return Expr.toLong(textValue, null);
106   }
107 }
108
Popular Tags