You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2005/09/21 21:42:44 UTC

svn commit: r290802 [9/10] - in /struts/sandbox/trunk/ti: ./ jars/core/src/java/org/apache/ti/compiler/internal/ jars/core/src/java/org/apache/ti/compiler/internal/genmodel/ jars/core/src/java/org/apache/ti/compiler/internal/grammar/ jars/core/src/java...

Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/schema/struts-ti-config.xsd
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/schema/struts-ti-config.xsd?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/schema/struts-ti-config.xsd (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/schema/struts-ti-config.xsd Wed Sep 21 12:42:20 2005
@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+            targetNamespace="http://struts.apache.org/ti/2005/server/config"
+            xmlns:netui="http://struts.apache.org/ti/2005/server/config"
+            elementFormDefault="qualified">
+
+    <xsd:element name="ti-config">
+        <xsd:complexType>
+            <xsd:sequence>
+                <xsd:element name="expression-languages" type="netui:expression-languages" minOccurs="1" maxOccurs="1"/>
+                <xsd:element name="pageflow-action-interceptors" type="netui:pageflow-action-interceptors" minOccurs="0" maxOccurs="1"/>
+                <xsd:element name="pageflow-handlers" type="netui:pageflow-handlers" minOccurs="0" maxOccurs="1"/>
+                <xsd:element name="pageflow-config" type="netui:pageflow-config" minOccurs="0" maxOccurs="1"/>
+                <xsd:element name="pageflow-factories" type="netui:pageflow-factories" minOccurs="0" maxOccurs="1"/>
+                <xsd:element name="default-shared-flow-refs" type="netui:default-shared-flow-refs" minOccurs="0" maxOccurs="1"/>
+                <xsd:element name="type-converters" type="netui:type-converters" minOccurs="0" maxOccurs="1"/>
+                <xsd:element name="jsp-tag-config" type="netui:jsp-tag-config" minOccurs="0" maxOccurs="1"/>
+                <xsd:element name="url-config" type="netui:url-config" minOccurs="0" maxOccurs="1"/>               
+                <xsd:element name="iterator-factories" type="netui:iterator-factories" minOccurs="0" maxOccurs="1"/>
+                <xsd:element name="request-interceptors" type="netui:request-interceptors" minOccurs="0" maxOccurs="1"/>
+                <xsd:element name="prefix-handlers" type="netui:prefix-handlers" minOccurs="0" maxOccurs="1" />
+            </xsd:sequence>
+        </xsd:complexType>
+    </xsd:element>
+
+    <xsd:complexType name="custom-property">
+        <xsd:sequence>
+            <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+            <xsd:element name="value" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="interceptor">
+        <xsd:sequence>
+            <xsd:element name="interceptor-class" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+            <xsd:element name="custom-property" type="netui:custom-property" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="simple-action-interceptor">
+        <xsd:sequence>
+            <xsd:element name="intercept-path" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+            <xsd:element name="after-action" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false"/>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <xsd:complexType name="request-interceptors">
+        <xsd:sequence>
+            <xsd:element name="global" minOccurs="0" maxOccurs="1">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="request-interceptor" type="netui:interceptor" minOccurs="0" maxOccurs="unbounded"/>
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="pageflow-action-interceptors">
+        <xsd:sequence>
+            <xsd:element name="global" minOccurs="0" maxOccurs="1">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="simple-action-interceptor" type="netui:simple-action-interceptor" minOccurs="0" maxOccurs="unbounded"/>
+                        <xsd:element name="action-interceptor" type="netui:interceptor" minOccurs="0" maxOccurs="unbounded"/>
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+            <xsd:element name="per-pageflow" minOccurs="0" maxOccurs="unbounded">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="pageflow-uri" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                        <xsd:element name="simple-action-interceptor" type="netui:simple-action-interceptor" minOccurs="0" maxOccurs="unbounded"/>
+                        <xsd:element name="action-interceptor" type="netui:interceptor" minOccurs="0" maxOccurs="unbounded"/>
+                        <xsd:element name="per-action" minOccurs="0" maxOccurs="unbounded">
+                            <xsd:complexType>
+                                <xsd:sequence>
+                                    <xsd:element name="action-name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                                    <xsd:element name="simple-action-interceptor" type="netui:simple-action-interceptor" minOccurs="0" maxOccurs="unbounded"/>
+                                    <xsd:element name="action-interceptor" type="netui:interceptor" minOccurs="0" maxOccurs="unbounded"/>
+                                </xsd:sequence>
+                            </xsd:complexType>
+                        </xsd:element>
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+        </xsd:sequence>
+    </xsd:complexType>
+	
+    <xsd:complexType name="handler">
+        <xsd:sequence>
+            <xsd:element name="handler-class" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+            <xsd:element name="custom-property" type="netui:custom-property" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="pageflow-handlers">
+        <xsd:sequence>
+            <xsd:element name="action-forward-handler" type="netui:handler" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="exceptions-handler" type="netui:handler" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="forward-redirect-handler" type="netui:handler" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="login-handler" type="netui:handler" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="storage-handler" type="netui:handler" minOccurs="0" maxOccurs="unbounded"/>
+            <xsd:element name="reloadable-class-handler" type="netui:handler" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="module-config-locators">
+        <xsd:sequence>
+            <xsd:element name="module-config-locator" minOccurs="0" maxOccurs="unbounded">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="description" type="xsd:string" minOccurs="0" maxOccurs="1"/>
+                        <xsd:element name="locator-class" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+        </xsd:sequence>
+    </xsd:complexType>
+	
+    <xsd:complexType name="pageflow-config">
+        <xsd:sequence>
+            <xsd:element name="enable-self-nesting" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false"/>
+            <xsd:element name="max-forwards-per-request" type="xsd:int" minOccurs="0" maxOccurs="1" default="25"/>
+            <xsd:element name="max-nesting-stack-depth" type="xsd:int" minOccurs="0" maxOccurs="1" default="10"/> 
+            <xsd:element name="ensure-secure-forwards" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false"/> 
+            <xsd:element name="throw-session-expired-exception" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="true"/>
+            <xsd:element name="multipart-handler" minOccurs="0" maxOccurs="1" default="disabled">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string">
+                        <xsd:enumeration value="disabled"/>
+                        <xsd:enumeration value="memory"/>
+                        <xsd:enumeration value="disk"/>
+                    </xsd:restriction>
+                </xsd:simpleType>
+            </xsd:element>
+            <xsd:element name="prevent-cache" minOccurs="0" maxOccurs="1" default="default">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string">
+                        <xsd:enumeration value="default"/>
+                        <xsd:enumeration value="always"/>
+                        <xsd:enumeration value="inDevMode"/>
+                    </xsd:restriction>
+                </xsd:simpleType>
+            </xsd:element>
+            <xsd:element name="module-config-locators" type="netui:module-config-locators" minOccurs="0" maxOccurs="1"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="pageflow-factory">
+        <xsd:sequence>
+            <xsd:element name="factory-class" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+            <xsd:element name="custom-property" type="netui:custom-property" minOccurs="0" maxOccurs="unbounded"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="pageflow-factories">
+        <xsd:sequence>
+            <xsd:element name="flowcontroller-factory" type="netui:pageflow-factory" minOccurs="0" maxOccurs="1"/>
+            <xsd:element name="faces-backing-bean-factory" type="netui:pageflow-factory" minOccurs="0" maxOccurs="1"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="shared-flow-ref">
+        <xsd:sequence>
+           <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+           <xsd:element name="type" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="default-shared-flow-refs">
+        <xsd:sequence>
+            <xsd:element name="shared-flow-ref" type="netui:shared-flow-ref" minOccurs="1" maxOccurs="unbounded"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="jsp-tag-config">
+        <xsd:sequence>
+            <xsd:element name="doctype" minOccurs="0" maxOccurs="1" default="html4-loose-quirks">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string">
+                        <xsd:enumeration value="html4-loose"/>
+                        <xsd:enumeration value="html4-loose-quirks"/>
+                        <xsd:enumeration value="xhtml1-transitional"/>
+                    </xsd:restriction>
+                </xsd:simpleType>
+            </xsd:element>
+            <xsd:element name="id-javascript" minOccurs="0" maxOccurs="1" default="default">
+                <xsd:simpleType>
+                    <xsd:restriction base="xsd:string">
+                        <xsd:enumeration value="default"/>
+                        <!-- This flag will turn on Legacy JavaScript support for id and name attributes.  When this is
+                        set the default tag JavaScript will also be output. -->
+                        <xsd:enumeration value="legacy"/>
+                        <!-- This flag will make Legacy JavaScript support the only type of JavaScript output for id
+                        and name attributes. -->
+                        <xsd:enumeration value="legacyOnly"/>
+                    </xsd:restriction>
+                </xsd:simpleType>
+            </xsd:element>
+            <xsd:element name="tree-image-location" type="xsd:string" minOccurs="0" maxOccurs="1"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    
+    <xsd:complexType name="url-config">
+        <xsd:sequence>
+            <xsd:element name="url-encode-urls" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="true"/>
+            <xsd:element name="html-amp-entity" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="true"/>
+            <xsd:element name="templated-url-formatter-class" type="xsd:string" minOccurs="0" maxOccurs="1" default="org.apache.ti.pageflow.internal.DefaultTemplatedURLFormatter"/>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <xsd:complexType name="type-converters">
+        <xsd:sequence>
+            <xsd:element name="type-converter" minOccurs="0" maxOccurs="unbounded">
+                <xsd:complexType>
+                <xsd:sequence>
+                    <xsd:element name="type" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                    <xsd:element name="converter-class" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <xsd:complexType name="iterator-factories">
+        <xsd:sequence>
+            <xsd:element name="iterator-factory" minOccurs="0" maxOccurs="unbounded">
+                <xsd:complexType>
+                <xsd:sequence>
+                    <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                    <xsd:element name="factory-class" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <xsd:complexType name="expression-languages">
+        <xsd:sequence>
+            <xsd:element name="default-language" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+            <xsd:element name="expression-language" minOccurs="1" maxOccurs="unbounded">
+                <xsd:complexType>
+                <xsd:sequence>
+                    <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                    <xsd:element name="factory-class" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                    <xsd:element name="binding-contexts" type="netui:binding-contexts" minOccurs="0" maxOccurs="1"/>
+                </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <xsd:complexType name="binding-contexts">
+        <xsd:sequence>
+            <xsd:element name="binding-context" minOccurs="0" maxOccurs="unbounded">
+                <xsd:complexType>
+                <xsd:sequence>
+                    <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                    <xsd:element name="factory-class" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <xsd:complexType name="prefix-handlers">
+        <xsd:sequence>
+            <xsd:element name="prefix-handler" minOccurs="0" maxOccurs="unbounded">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                        <xsd:element name="handler-class" type="xsd:string" minOccurs="1" maxOccurs="1"/>
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+        </xsd:sequence>
+    </xsd:complexType>
+</xsd:schema>

Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/struts-ti-config-default.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/struts-ti-config-default.xml?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/struts-ti-config-default.xml (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/config/struts-ti-config-default.xml Wed Sep 21 12:42:20 2005
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<netui-config xmlns="http://struts.apache.org/ti/2004/server/config">
-
-    <expression-languages>
-        <default-language>netuiel</default-language>
-        <expression-language>
-            <name>netuiel</name>
-            <factory-class>org.apache.ti.script.el.ExpressionEvaluatorImpl$NetUIELEngineFactory</factory-class>
-        </expression-language>
-    </expression-languages>
-
-</netui-config>

Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/iterator/IteratorFactory.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/iterator/IteratorFactory.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/iterator/IteratorFactory.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/iterator/IteratorFactory.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,13 +17,13 @@
  */
 package org.apache.ti.util.iterator;
 
-import org.apache.ti.schema.config.IteratorFactories;
-import org.apache.ti.schema.config.NetuiConfigDocument.NetuiConfig;
 import org.apache.ti.util.config.ConfigUtil;
+import org.apache.ti.util.config.bean.IteratorFactoryConfig;
+import org.apache.ti.util.config.bean.NetUIConfig;
 import org.apache.ti.util.logging.Logger;
 
-import javax.sql.RowSet;
 import java.sql.ResultSet;
+
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -31,6 +31,8 @@
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+import javax.sql.RowSet;
+
 /**
  * <p/>
  * This class provides a factory that can create an {@link Iterator} for various types
@@ -51,12 +53,10 @@
  * </p>
  */
 public class IteratorFactory {
-
     /**
      * Convenience field for accessing an empty {@link Iterator}.
      */
     public static final Iterator EMPTY_ITERATOR = Collections.EMPTY_LIST.iterator();
-
     private static final Logger LOGGER = Logger.getInstance(IteratorFactory.class);
     private static final LinkedHashMap ITERATOR_FACTORIES;
 
@@ -69,7 +69,6 @@
      * @exclude
      */
     public abstract static class IteratorPlant {
-
         /**
          * If it is possible to create an iterator for this type, do so.
          * Otherwise return null.
@@ -84,33 +83,39 @@
      * @return an {@link Iterator} for the <code>object</code> or <code>null</code> if the value is null.
      */
     public static final Iterator createIterator(Object object) {
-        LOGGER.debug("Create an iterator for class: " + (object == null ? "null" : object.getClass().getName()));
+        LOGGER.debug("Create an iterator for class: " + ((object == null) ? "null" : object.getClass().getName()));
 
-        if (object == null)
+        if (object == null) {
             return null;
+        }
 
         if (object instanceof Iterator) {
             return (Iterator) object;
         } else if (object instanceof Collection) {
             Collection collection = (Collection) object;
+
             return collection.iterator();
         } else if (object instanceof Map) {
             return new MapIterator((Map) object);
         } else if (object.getClass().isArray()) {
             return new ArrayIterator(object);
-        } else if (object instanceof Enumeration)
+        } else if (object instanceof Enumeration) {
             return new EnumerationIterator((Enumeration) object);
-        else if (object instanceof ResultSet && !(object instanceof RowSet))
+        } else if (object instanceof ResultSet && !(object instanceof RowSet)) {
             return new ResultSetIterator((ResultSet) object);
+        }
 
         // check to see if there is a registered IteratorPlant that can handle this type
         Iterator ret = null;
         Iterator factories = ITERATOR_FACTORIES.keySet().iterator();
+
         while (factories.hasNext()) {
             IteratorPlant plant = (IteratorPlant) ITERATOR_FACTORIES.get(factories.next());
             ret = plant.createIterator(object);
 
-            if (ret != null) return ret;
+            if (ret != null) {
+                return ret;
+            }
         }
 
         return new AtomicObjectIterator(object);
@@ -122,34 +127,37 @@
      */
     private static final void initialize() {
         Map map = readFromConfig();
-        if (map != null)
+
+        if (map != null) {
             loadFactories(map);
+        }
     }
 
     private static final Map readFromConfig() {
-        NetuiConfig config = ConfigUtil.getConfig();
-        if (config == null)
-            return null;
+        NetUIConfig config = ConfigUtil.getConfig();
 
-        IteratorFactories factories = config.getIteratorFactories();
-        if (factories == null)
+        if (config == null) {
             return null;
+        }
 
-        org.apache.ti.schema.config.IteratorFactories.IteratorFactory[] factoryArray =
-                factories.getIteratorFactoryArray();
-        if (factoryArray == null)
-            return null;
+        IteratorFactoryConfig[] iteratorFactories = config.getIteratorFactories();
 
-        LinkedHashMap map = new LinkedHashMap();
-        for (int i = 0; i < factoryArray.length; i++) {
-            map.put(factoryArray[i].getName(), factoryArray[i].getFactoryClass());
-        }
+        if (iteratorFactories != null) {
+            LinkedHashMap map = new LinkedHashMap();
+
+            for (int i = 0; i < iteratorFactories.length; i++) {
+                map.put(iteratorFactories[i].getName(), iteratorFactories[i].getFactoryClass());
+            }
 
-        return map;
+            return map;
+        } else {
+            return null;
+        }
     }
 
     private static final void loadFactories(Map factories) {
         Iterator iterator = factories.keySet().iterator();
+
         while (iterator.hasNext()) {
             String name = (String) iterator.next();
             String className = (String) factories.get(name);
@@ -159,18 +167,24 @@
                 Class type = Class.forName(className);
                 plant = (IteratorPlant) type.newInstance();
             } catch (ClassNotFoundException cnf) {
-                LOGGER.warn("Could not create an IteratorPlant for type \"" + className + "\" because the implementation class could not be found.");
+                LOGGER.warn("Could not create an IteratorPlant for type \"" + className +
+                            "\" because the implementation class could not be found.");
+
                 continue;
             } catch (Exception e) {
                 assert e instanceof InstantiationException || e instanceof IllegalAccessException;
-                LOGGER.warn("Could not create an IteratorPlant for type \"" + className + "\" because an error occurred creating the plant.  Cause: " + e, e);
+                LOGGER.warn("Could not create an IteratorPlant for type \"" + className +
+                            "\" because an error occurred creating the plant.  Cause: " + e, e);
+
                 continue;
             }
 
             if (ITERATOR_FACTORIES.containsKey(name)) {
-                LOGGER.warn("Overwriting a previously defined IteratorPlant named \"" + name + "\" with a new IteratorPlant of type \"" + className + "\"");
-            } else
+                LOGGER.warn("Overwriting a previously defined IteratorPlant named \"" + name +
+                            "\" with a new IteratorPlant of type \"" + className + "\"");
+            } else {
                 LOGGER.info("Adding an IteratorPlant named \"" + name + "\" with implementation \"" + className + "\"");
+            }
 
             ITERATOR_FACTORIES.put(name, plant);
         }

Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/logging/Logger.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/logging/Logger.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/logging/Logger.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/logging/Logger.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,7 @@
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
+
 import java.lang.reflect.Method;
 
 /**
@@ -33,7 +34,6 @@
  */
 public class Logger
         implements Log {
-
     /**
      * Factory method for creating NetUI Logger instances.
      *
@@ -70,12 +70,14 @@
      */
     public Logger(String clientClassName) {
         Class clientClass = null;
+
         try {
             /* create a default log4j logger -- this shouldn't throw a CNF exception */
             clientClass = Class.forName(clientClassName);
         } catch (ClassNotFoundException e) {
             throw new IllegalArgumentException("Could not load NetUI logger client class '" + clientClassName + "'");
         }
+
         _logDelegate = createDefaultLogger(clientClass);
     }
 
@@ -113,80 +115,92 @@
     }
 
     public void debug(Object message) {
-        if (isDebugEnabled())
+        if (isDebugEnabled()) {
             _logDelegate.debug(message);
+        }
     }
 
     public void debug(Object message, Throwable t) {
-        if (isDebugEnabled())
+        if (isDebugEnabled()) {
             _logDelegate.debug(format(message, t));
+        }
     }
 
     public void trace(Object message) {
-        if (isTraceEnabled())
+        if (isTraceEnabled()) {
             _logDelegate.trace(message);
+        }
     }
 
     public void trace(Object message, Throwable t) {
-        if (isTraceEnabled())
+        if (isTraceEnabled()) {
             _logDelegate.trace(format(message, t));
+        }
     }
 
     public void info(Object message) {
-        if (isInfoEnabled())
+        if (isInfoEnabled()) {
             _logDelegate.info(message);
+        }
     }
 
     public void info(Object message, Throwable t) {
-        if (isInfoEnabled())
+        if (isInfoEnabled()) {
             _logDelegate.info(format(message, t));
+        }
     }
 
     public void warn(Object message) {
-        if (isWarnEnabled())
+        if (isWarnEnabled()) {
             _logDelegate.warn(message);
+        }
     }
 
     public void warn(Object message, Throwable t) {
-        if (isWarnEnabled())
+        if (isWarnEnabled()) {
             _logDelegate.warn(format(message, t));
+        }
     }
 
     public void error(Object message) {
-        if (isErrorEnabled())
+        if (isErrorEnabled()) {
             _logDelegate.error(message);
+        }
     }
 
     public void error(Object message, Throwable t) {
-        if (isErrorEnabled())
+        if (isErrorEnabled()) {
             _logDelegate.error(format(message, t));
+        }
     }
 
     public void fatal(Object message) {
-        if (isFatalEnabled())
+        if (isFatalEnabled()) {
             _logDelegate.fatal(message);
+        }
     }
 
     public void fatal(Object message, Throwable t) {
-        if (isFatalEnabled())
+        if (isFatalEnabled()) {
             _logDelegate.fatal(format(message, t));
+        }
     }
 
     private String format(Object m, Throwable t) {
-        if (t == null)
+        if (t == null) {
             return m.toString();
+        }
 
         StringWriter sw = new StringWriter();
         t.printStackTrace(new PrintWriter(sw));
-        
+
         /* note, no reason to close a StringWriter */
-        
         return m + "\n\n" + "Throwable: " + t.toString() + "\nStack Trace:\n" + sw.toString();
     }
 
     /**
      * Internal method used to create the backwards-compat NetUI logger.  This method
-     * looks up the {@link org.apache.beehive.netui.util.logging.internal.Log4JLogger}
+     * looks up the {@link org.apache.ti.util.logging.internal.Log4JLogger}
      * and creates a new instance returning the resulting {@link Log}.
      *
      * @param loggerClient the logger client
@@ -195,14 +209,16 @@
     private static final Log createDefaultLogger(Class loggerClient) {
         assert loggerClient != null : "Received a null loggerClient Class";
 
-        String className = "org.apache.beehive.netui.util.logging.internal.Log4JLogger";
+        String className = "org.apache.ti.util.logging.internal.Log4JLogger";
+
         try {
             Class logDelegateClass = Logger.class.getClassLoader().loadClass(className);
-            Method method = logDelegateClass.getMethod("getInstance", new Class[]{Class.class});
-            return (Log) method.invoke(null, new Object[]{loggerClient});
+            Method method = logDelegateClass.getMethod("getInstance", new Class[] { Class.class });
+
+            return (Log) method.invoke(null, new Object[] { loggerClient });
         } catch (Exception e) {
             IllegalStateException ie = new IllegalStateException("Could not create log implementation '" + className +
-                    "' for client of type '" + loggerClient.getName() + "'");
+                                                                 "' for client of type '" + loggerClient.getName() + "'");
             ie.initCause(e);
             throw ie;
         }

Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/logging/internal/Log4JLogger.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/logging/internal/Log4JLogger.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/logging/internal/Log4JLogger.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/logging/internal/Log4JLogger.java Wed Sep 21 12:42:20 2005
@@ -18,6 +18,7 @@
 package org.apache.ti.util.logging.internal;
 
 import org.apache.commons.logging.Log;
+
 import org.apache.log4j.Category;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
@@ -28,7 +29,7 @@
 /**
  * <p/>
  * Logging abstraction used to pipe log messages to Log4J.  This class is used for
- * NetUI backwards compatability so that previous {@link org.apache.beehive.netui.util.logging.Logger}
+ * NetUI backwards compatability so that previous {@link org.apache.ti.util.logging.Logger}
  * clients continue to log through the usual Log4J channels.
  * </p>
  *
@@ -36,7 +37,6 @@
  */
 public final class Log4JLogger
         implements Log {
-
     private static final String STRUTS_APPENDER = "commons-logging";
 
     static {
@@ -44,8 +44,9 @@
         // that we don't spam the console with all messages
         Category root = Category.getRoot();
 
-        if (root.getAppender(STRUTS_APPENDER) != null)
+        if (root.getAppender(STRUTS_APPENDER) != null) {
             root.removeAppender(STRUTS_APPENDER);
+        }
     }
 
     private Logger _logInstance;
@@ -87,68 +88,81 @@
     }
 
     public void debug(Object message) {
-        if (_logInstance.isEnabledFor(Level.DEBUG))
+        if (_logInstance.isEnabledFor(Level.DEBUG)) {
             _logInstance.debug(message);
+        }
     }
 
     public void debug(Object message, Throwable t) {
-        if (_logInstance.isEnabledFor(Level.DEBUG))
+        if (_logInstance.isEnabledFor(Level.DEBUG)) {
             _logInstance.debug(format(message, t));
+        }
     }
 
     public void trace(Object message) {
-        if (_logInstance.isEnabledFor(Level.DEBUG))
+        if (_logInstance.isEnabledFor(Level.DEBUG)) {
             _logInstance.debug(message);
+        }
     }
 
     public void trace(Object message, Throwable t) {
-        if (_logInstance.isEnabledFor(Level.DEBUG))
+        if (_logInstance.isEnabledFor(Level.DEBUG)) {
             _logInstance.debug(format(message, t));
+        }
     }
 
     public void info(Object message) {
-        if (_logInstance.isEnabledFor(Level.INFO))
+        if (_logInstance.isEnabledFor(Level.INFO)) {
             _logInstance.info(message);
+        }
     }
 
     public void info(Object message, Throwable t) {
-        if (_logInstance.isEnabledFor(Level.INFO))
+        if (_logInstance.isEnabledFor(Level.INFO)) {
             _logInstance.info(format(message, t));
+        }
     }
 
     public void warn(Object message) {
-        if (_logInstance.isEnabledFor(Level.WARN))
+        if (_logInstance.isEnabledFor(Level.WARN)) {
             _logInstance.warn(message);
+        }
     }
 
     public void warn(Object message, Throwable t) {
-        if (_logInstance.isEnabledFor(Level.WARN))
+        if (_logInstance.isEnabledFor(Level.WARN)) {
             _logInstance.warn(format(message, t));
+        }
     }
 
     public void error(Object message) {
-        if (_logInstance.isEnabledFor(Level.ERROR))
+        if (_logInstance.isEnabledFor(Level.ERROR)) {
             _logInstance.error(message);
+        }
     }
 
     public void error(Object message, Throwable t) {
-        if (_logInstance.isEnabledFor(Level.ERROR))
+        if (_logInstance.isEnabledFor(Level.ERROR)) {
             _logInstance.error(format(message, t));
+        }
     }
 
     public void fatal(Object message) {
-        if (_logInstance.isEnabledFor(Level.FATAL))
+        if (_logInstance.isEnabledFor(Level.FATAL)) {
             _logInstance.fatal(message);
+        }
     }
 
     public void fatal(Object message, Throwable t) {
-        if (_logInstance.isEnabledFor(Level.FATAL))
+        if (_logInstance.isEnabledFor(Level.FATAL)) {
             _logInstance.fatal(format(message, t));
+        }
     }
 
     private String format(Object m, Throwable t) {
-        if (t == null)
+        if (t == null) {
             return m.toString();
+        }
 
         StringWriter sw = new StringWriter();
         t.printStackTrace(new PrintWriter(sw));

Modified: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/type/TypeUtils.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/type/TypeUtils.java?rev=290802&r1=290801&r2=290802&view=diff
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/type/TypeUtils.java (original)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/type/TypeUtils.java Wed Sep 21 12:42:20 2005
@@ -4,9 +4,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,17 +17,20 @@
  */
 package org.apache.ti.util.type;
 
-import org.apache.ti.schema.config.NetuiConfigDocument.NetuiConfig;
-import org.apache.ti.schema.config.TypeConverters;
 import org.apache.ti.util.Bundle;
 import org.apache.ti.util.config.ConfigUtil;
+import org.apache.ti.util.config.bean.NetUIConfig;
+import org.apache.ti.util.config.bean.TypeConverterConfig;
 import org.apache.ti.util.internal.InternalStringBuilder;
 import org.apache.ti.util.logging.Logger;
 
 import java.io.InputStream;
+
 import java.math.BigDecimal;
 import java.math.BigInteger;
+
 import java.text.DateFormat;
+
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -42,26 +45,28 @@
  *
  */
 public final class TypeUtils {
-
     private static final Logger LOGGER = Logger.getInstance(TypeUtils.class);
     private static final String TYPE_CONVERTER_PROPERTIES = "/properties/netui-typeconverter.properties";
     private static final String EMPTY_STRING = "";
-    private static final HashMap/*<Class, BaseTypeConverter>*/ TYPE_CONVERTERS = new HashMap/*<Class, BaseTypeConverter>*/();
+    private static final HashMap /*<Class, BaseTypeConverter>*/ TYPE_CONVERTERS = new HashMap /*<Class, BaseTypeConverter>*/();
     private static String TO_STRING = null;
 
     static {
         // initialize the default type converters
         initialize();
 
-        Map/*<String, String>*/ map = readFromConfig();
+        Map /*<String, String>*/ map = readFromConfig();
+
         if (map != null) {
             load(map);
             map.clear();
         }
 
         map = readFromProperties();
-        if (map != null)
+
+        if (map != null) {
             load(map);
+        }
 
         LOGGER.info(registeredConvertersToString());
     }
@@ -97,6 +102,7 @@
     public static final Object convertToObject(String value, Class type, Locale locale) {
         BaseTypeConverter converter = lookupTypeConverter(type);
         assert converter != null;
+
         return converter.convertToObject(type, value, locale);
     }
 
@@ -173,15 +179,18 @@
      */
     private static final BaseTypeConverter lookupTypeConverter(Class type) {
         BaseTypeConverter converter = (BaseTypeConverter) TYPE_CONVERTERS.get(type);
+
         if (converter == null) {
             String msg = "Could not find a TypeConverter for converting a String to an object of type \"" +
-                    (type != null ? type.getName() : null) + "\"";
+                         ((type != null) ? type.getName() : null) + "\"";
             TypeConverterNotFoundException tcn = new TypeConverterNotFoundException(msg);
 
-            if (type == null)
+            if (type == null) {
                 msg = Bundle.getErrorString("TypeUtils_nullType");
-            else
-                msg = Bundle.getErrorString("TypeUtils_noConverterForType", new Object[]{type.getName()});
+            } else {
+                msg = Bundle.getErrorString("TypeUtils_noConverterForType", new Object[] { type.getName() });
+            }
+
             tcn.setLocalizedMessage(msg);
             LOGGER.error(msg);
 
@@ -192,38 +201,45 @@
     }
 
     private static String registeredConvertersToString() {
-        if (TO_STRING != null)
+        if (TO_STRING != null) {
             return TO_STRING;
+        }
 
         InternalStringBuilder sb = new InternalStringBuilder(256);
         sb.append(TypeUtils.class.getName() + " regestered converters (class name, TypeConverter implementation):\n");
         sb.append(":::::\n");
+
         Iterator iterator = TYPE_CONVERTERS.keySet().iterator();
+
         while (iterator.hasNext()) {
             Class key = (Class) iterator.next();
             String keyName = key.getName();
-            String value = (TYPE_CONVERTERS.get(key) != null ? TYPE_CONVERTERS.get(key).getClass().getName() : "null");
+            String value = ((TYPE_CONVERTERS.get(key) != null) ? TYPE_CONVERTERS.get(key).getClass().getName() : "null");
             sb.append(keyName);
             sb.append(", ");
             sb.append(value);
             sb.append("\n");
         }
+
         sb.append(":::::\n");
         TO_STRING = sb.toString();
 
         return TO_STRING;
     }
 
-    private static Map/*<String, String>*/ readFromProperties() {
+    private static Map /*<String, String>*/ readFromProperties() {
         Properties props = null;
         InputStream is = null;
+
         try {
             is = (TypeUtils.class).getClassLoader().getResourceAsStream(TYPE_CONVERTER_PROPERTIES);
 
-            LOGGER.debug("found type converter InputStream at " + TYPE_CONVERTER_PROPERTIES + " " + (is != null ? "true" : "false"));
+            LOGGER.debug("found type converter InputStream at " + TYPE_CONVERTER_PROPERTIES + " " +
+                         ((is != null) ? "true" : "false"));
 
-            if (is == null)
+            if (is == null) {
                 return null;
+            }
 
             props = new Properties();
             props.load(is);
@@ -231,13 +247,16 @@
             LOGGER.warn("Error occurred reading type converter properties file", e);
         } finally {
             try {
-                if (is != null) is.close();
+                if (is != null) {
+                    is.close();
+                }
             } catch (Exception ignore) {
             }
         }
 
-        LinkedHashMap/*<String, String>*/ map = new LinkedHashMap/*<String, String>*/();
+        LinkedHashMap /*<String, String>*/ map = new LinkedHashMap /*<String, String>*/();
         Enumeration e = props.propertyNames();
+
         while (e.hasMoreElements()) {
             String key = (String) e.nextElement();
             map.put(key, props.getProperty(key));
@@ -246,36 +265,37 @@
         return map;
     }
 
-    private static final Map/*<String, String>*/ readFromConfig() {
-        NetuiConfig config = ConfigUtil.getConfig();
-        if (config == null)
-            return null;
+    private static final Map /*<String, String>*/ readFromConfig() {
+        NetUIConfig config = ConfigUtil.getConfig();
 
-        TypeConverters converters = config.getTypeConverters();
-        if (converters == null)
+        if (config == null) {
             return null;
+        }
 
-        org.apache.ti.schema.config.TypeConverters.TypeConverter[] converterArray =
-                converters.getTypeConverterArray();
-        if (converterArray == null)
-            return null;
+        TypeConverterConfig[] typeConverters = config.getTypeConverters();
 
-        LinkedHashMap/*<String, String>*/ map = new LinkedHashMap/*<String, String>*/();
-        for (int i = 0; i < converterArray.length; i++) {
-            map.put(converterArray[i].getType(), converterArray[i].getConverterClass());
-        }
+        if (typeConverters != null) {
+            LinkedHashMap /*<String, String>*/ map = new LinkedHashMap /*<String, String>*/();
 
-        return map;
+            for (int i = 0; i < typeConverters.length; i++) {
+                map.put(typeConverters[i].getType(), typeConverters[i].getConverterClass());
+            }
+
+            return map;
+        } else {
+            return null;
+        }
     }
 
-    private static void load(Map/*<String, String>*/ map) {
+    private static void load(Map /*<String, String>*/ map) {
         // load the properties and continue to populate the map
         for (Iterator i = map.keySet().iterator(); i.hasNext();) {
             String key = (String) i.next();
             String className = (String) map.get(key);
 
-            if ((key == null || key.equals(EMPTY_STRING)) || (className == null || className.equals(EMPTY_STRING))) {
+            if (((key == null) || key.equals(EMPTY_STRING)) || ((className == null) || className.equals(EMPTY_STRING))) {
                 LOGGER.warn("Could not create a TypeConverter for type \"" + key + "\" and TypeConverter \"" + className + "\"");
+
                 continue;
             }
 
@@ -285,47 +305,58 @@
             try {
                 targetClazz = Class.forName(key);
             } catch (ClassNotFoundException cnf) {
-                LOGGER.warn("Could not create a TypeConverter for type \"" + key + "\" because the \"convert-to\" type could not be found.");
+                LOGGER.warn("Could not create a TypeConverter for type \"" + key +
+                            "\" because the \"convert-to\" type could not be found.");
+
                 continue;
             }
 
             Class tcClazz = null;
             BaseTypeConverter tc = null;
+
             // try to find the TypeConverter implementation
             try {
                 tcClazz = Class.forName(className);
+
                 Object obj = tcClazz.newInstance();
 
                 // this supports existing TypeConverter implementations
                 // but allows TypeUtils make calls against the BaseTypeConverter
                 // API, which supports Locale-based conversion
-                if (obj instanceof TypeConverter)
+                if (obj instanceof TypeConverter) {
                     tc = new DelegatingTypeConverter((TypeConverter) obj);
-                else if (obj instanceof BaseTypeConverter)
+                } else if (obj instanceof BaseTypeConverter) {
                     tc = (BaseTypeConverter) obj;
-                else
+                } else {
                     throw new IllegalStateException("Attempt to load illegal type converter type: " + tcClazz);
+                }
             } catch (ClassNotFoundException cnf) {
-                LOGGER.warn("Could not create a TypeConverter for type \"" + key + "\" because the TypeConverter implementation class \"" +
-                        (tcClazz != null ? tcClazz.getName() : null) + "\" could not be found.");
+                LOGGER.warn("Could not create a TypeConverter for type \"" + key +
+                            "\" because the TypeConverter implementation class \"" +
+                            ((tcClazz != null) ? tcClazz.getName() : null) + "\" could not be found.");
 
                 continue;
             } catch (Exception e) {
-                if (LOGGER.isWarnEnabled())
+                if (LOGGER.isWarnEnabled()) {
                     LOGGER.warn("Could not create a TypeConverter for type \"" + key + "\" because the implementation class \"" +
-                            (tcClazz != null ? tcClazz.getName() : null) + "\" could not be instantiated.");
+                                ((tcClazz != null) ? tcClazz.getName() : null) + "\" could not be instantiated.");
+                }
+
                 continue;
             }
-            
+
             /* found two type converters for the same class -- warn */
-            if (TYPE_CONVERTERS.containsKey(targetClazz))
-                if (LOGGER.isWarnEnabled())
+            if (TYPE_CONVERTERS.containsKey(targetClazz)) {
+                if (LOGGER.isWarnEnabled()) {
                     LOGGER.warn("Overwriting a previously defined TypeConverter named \"" + targetClazz +
-                            "\" with a new TypeConverter implementation of type \"" + className + "\"");
+                                "\" with a new TypeConverter implementation of type \"" + className + "\"");
+                }
+            }
 
-            if (LOGGER.isInfoEnabled())
+            if (LOGGER.isInfoEnabled()) {
                 LOGGER.info("Adding a type converter; target type=\"" + targetClazz.getName() +
-                        "\" TypeConverter implementation=\"" + tc.getClass().getName() + "\"");
+                            "\" TypeConverter implementation=\"" + tc.getClass().getName() + "\"");
+            }
 
             TYPE_CONVERTERS.put(targetClazz, tc);
         }
@@ -338,272 +369,329 @@
      * because JDBC uses these complex types to map SQL types to Java objects.
      */
     private static void initialize() {
-        TYPE_CONVERTERS.put(byte.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                return (value == null || value.equals(EMPTY_STRING) ? new Byte((byte) 0) : new Byte(value.trim()));
-            }
-
-        });
-        TYPE_CONVERTERS.put(Byte.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return TypeUtils.convertToObject(value, byte.class, null);
-            }
-        });
-
-        TYPE_CONVERTERS.put(boolean.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return Boolean.FALSE;
-
-                value = value.toLowerCase().trim();
-                if (value.equals("on") || value.equals("true"))
-                    return Boolean.TRUE;
-                else
-                    return Boolean.FALSE;
-            }
-        });
-        TYPE_CONVERTERS.put(Boolean.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return TypeUtils.convertToObject(value, boolean.class, null);
-            }
-        });
+        TYPE_CONVERTERS.put(byte.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    return (((value == null) || value.equals(EMPTY_STRING)) ? new Byte((byte) 0) : new Byte(value.trim()));
+                }
+            });
+        TYPE_CONVERTERS.put(Byte.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return TypeUtils.convertToObject(value, byte.class, null);
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(char.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return new Character('\u0000');
-                else
-                    return new Character(value.charAt(0));
-            }
-        });
-        TYPE_CONVERTERS.put(Character.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return TypeUtils.convertToObject(value, char.class, null);
-            }
-        });
+        TYPE_CONVERTERS.put(boolean.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return Boolean.FALSE;
+                    }
+
+                    value = value.toLowerCase().trim();
+
+                    if (value.equals("on") || value.equals("true")) {
+                        return Boolean.TRUE;
+                    } else {
+                        return Boolean.FALSE;
+                    }
+                }
+            });
+        TYPE_CONVERTERS.put(Boolean.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return TypeUtils.convertToObject(value, boolean.class, null);
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(double.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return new Double(0.0);
-                else
-                    return new Double(value.trim());
-            }
-        });
-        TYPE_CONVERTERS.put(Double.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return TypeUtils.convertToObject(value, double.class, null);
-            }
-        });
+        TYPE_CONVERTERS.put(char.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return new Character('\u0000');
+                    } else {
+                        return new Character(value.charAt(0));
+                    }
+                }
+            });
+        TYPE_CONVERTERS.put(Character.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return TypeUtils.convertToObject(value, char.class, null);
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(float.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return new Float(0.0);
-                else
-                    return new Float(value.trim());
-            }
-        });
-        TYPE_CONVERTERS.put(Float.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return TypeUtils.convertToObject(value, float.class, null);
-            }
-        });
+        TYPE_CONVERTERS.put(double.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return new Double(0.0);
+                    } else {
+                        return new Double(value.trim());
+                    }
+                }
+            });
+        TYPE_CONVERTERS.put(Double.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return TypeUtils.convertToObject(value, double.class, null);
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(int.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return new Integer(0);
-                else
-                    return new Integer(value.trim());
-            }
-        });
-        TYPE_CONVERTERS.put(Integer.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return TypeUtils.convertToObject(value, int.class, null);
-            }
-        });
+        TYPE_CONVERTERS.put(float.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return new Float(0.0);
+                    } else {
+                        return new Float(value.trim());
+                    }
+                }
+            });
+        TYPE_CONVERTERS.put(Float.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return TypeUtils.convertToObject(value, float.class, null);
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(long.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return new Long(0);
-                else
-                    return new Long(value.trim());
-            }
-        });
-        TYPE_CONVERTERS.put(Long.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return TypeUtils.convertToObject(value, long.class, null);
-            }
-        });
+        TYPE_CONVERTERS.put(int.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return new Integer(0);
+                    } else {
+                        return new Integer(value.trim());
+                    }
+                }
+            });
+        TYPE_CONVERTERS.put(Integer.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return TypeUtils.convertToObject(value, int.class, null);
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(short.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return new Short((short) 0);
-                else
-                    return new Short(value.trim());
-            }
-        });
-        TYPE_CONVERTERS.put(Short.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return TypeUtils.convertToObject(value, short.class, null);
-            }
-        });
+        TYPE_CONVERTERS.put(long.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return new Long(0);
+                    } else {
+                        return new Long(value.trim());
+                    }
+                }
+            });
+        TYPE_CONVERTERS.put(Long.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return TypeUtils.convertToObject(value, long.class, null);
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(String.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null)
-                    return null;
-                else
-                    return value;
-            }
-        });
+        TYPE_CONVERTERS.put(short.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return new Short((short) 0);
+                    } else {
+                        return new Short(value.trim());
+                    }
+                }
+            });
+        TYPE_CONVERTERS.put(Short.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return TypeUtils.convertToObject(value, short.class, null);
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(java.math.BigDecimal.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return new BigDecimal(value.trim());
-            }
-        });
+        TYPE_CONVERTERS.put(String.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if (value == null) {
+                        return null;
+                    } else {
+                        return value;
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(java.math.BigInteger.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return new BigInteger(value.trim());
-            }
-        });
+        TYPE_CONVERTERS.put(java.math.BigDecimal.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return new BigDecimal(value.trim());
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(byte[].class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else
-                    return value.getBytes();
-            }
-        });
+        TYPE_CONVERTERS.put(java.math.BigInteger.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return new BigInteger(value.trim());
+                    }
+                }
+            });
 
-        TYPE_CONVERTERS.put(Byte[].class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-                else {
-                    byte[] bytes = value.getBytes();
-                    Byte[] wBytes = new Byte[bytes.length];
+        TYPE_CONVERTERS.put(byte[].class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        return value.getBytes();
+                    }
+                }
+            });
 
-                    for (int i = 0; i < bytes.length; i++)
-                        wBytes[i] = new Byte(bytes[i]);
+        TYPE_CONVERTERS.put(Byte[].class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    } else {
+                        byte[] bytes = value.getBytes();
+                        Byte[] wBytes = new Byte[bytes.length];
+
+                        for (int i = 0; i < bytes.length; i++) {
+                            wBytes[i] = new Byte(bytes[i]);
+                        }
 
-                    return wBytes;
+                        return wBytes;
+                    }
                 }
-            }
-        });
+            });
 
-        TYPE_CONVERTERS.put(Date.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-
-                try {
-                    if (locale == null)
-                        locale = Locale.getDefault();
-
-                    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
-                    return df.parse(value);
-                } catch (java.text.ParseException pe) {
-                    String msg = "Caugnt an error converting a String to a DateFormat.SHORT formatted Date";
-                    LOGGER.warn(msg, pe);
-
-                    TypeConversionException tce = new TypeConversionException(msg, pe);
-                    tce.setLocalizedMessage(Bundle.getString("TypeUtils_javaUtilDateConvertError", new Object[]{pe.getMessage()}));
-                    throw tce;
+        TYPE_CONVERTERS.put(Date.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    }
+
+                    try {
+                        if (locale == null) {
+                            locale = Locale.getDefault();
+                        }
+
+                        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
+
+                        return df.parse(value);
+                    } catch (java.text.ParseException pe) {
+                        String msg = "Caugnt an error converting a String to a DateFormat.SHORT formatted Date";
+                        LOGGER.warn(msg, pe);
+
+                        TypeConversionException tce = new TypeConversionException(msg, pe);
+                        tce.setLocalizedMessage(Bundle.getString("TypeUtils_javaUtilDateConvertError",
+                                                                 new Object[] { pe.getMessage() }));
+                        throw tce;
+                    }
                 }
-            }
-        });
+            });
 
         /* http://java.sun.com/j2se/1.4.1/docs/api/java/sql/Date.html */
-        TYPE_CONVERTERS.put(java.sql.Date.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING)) return null;
-
-                try {
-                    return java.sql.Date.valueOf(value);
-                } catch (Exception e) {
-                    String msg = "Caught an error converting a String to a java.sql.Date";
-                    LOGGER.error(msg, e);
-
-                    TypeConversionException tce = new TypeConversionException(msg, e);
-                    tce.setLocalizedMessage(Bundle.getString("TypeUtils_javaSqlDateConvertError", new Object[]{e.getMessage()}));
-                    throw tce;
+        TYPE_CONVERTERS.put(java.sql.Date.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    }
+
+                    try {
+                        return java.sql.Date.valueOf(value);
+                    } catch (Exception e) {
+                        String msg = "Caught an error converting a String to a java.sql.Date";
+                        LOGGER.error(msg, e);
+
+                        TypeConversionException tce = new TypeConversionException(msg, e);
+                        tce.setLocalizedMessage(Bundle.getString("TypeUtils_javaSqlDateConvertError",
+                                                                 new Object[] { e.getMessage() }));
+                        throw tce;
+                    }
                 }
-            }
-        });
+            });
 
         /* http://java.sun.com/j2se/1.4.1/docs/api/java/sql/Timestamp.html */
-        TYPE_CONVERTERS.put(java.sql.Timestamp.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-
-                try {
-                    return java.sql.Timestamp.valueOf(value);
-                } catch (Exception e) {
-                    String msg = "Caught an error converting a String to a java.sql.Timestamp";
-                    LOGGER.error(msg, e);
-
-                    TypeConversionException tce = new TypeConversionException(msg, e);
-                    tce.setLocalizedMessage(Bundle.getString("TypeUtils_javaSqlTimestampConvertError", new Object[]{e.getMessage()}));
-                    throw tce;
+        TYPE_CONVERTERS.put(java.sql.Timestamp.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    }
+
+                    try {
+                        return java.sql.Timestamp.valueOf(value);
+                    } catch (Exception e) {
+                        String msg = "Caught an error converting a String to a java.sql.Timestamp";
+                        LOGGER.error(msg, e);
+
+                        TypeConversionException tce = new TypeConversionException(msg, e);
+                        tce.setLocalizedMessage(Bundle.getString("TypeUtils_javaSqlTimestampConvertError",
+                                                                 new Object[] { e.getMessage() }));
+                        throw tce;
+                    }
                 }
-            }
-        });
+            });
 
         /* http://java.sun.com/j2se/1.4.1/docs/api/java/sql/Time.html */
-        TYPE_CONVERTERS.put(java.sql.Time.class, new BaseTypeConverter() {
-            public Object convertToObject(Class type, String value, Locale locale) {
-                if (value == null || value.equals(EMPTY_STRING))
-                    return null;
-
-                try {
-                    return java.sql.Time.valueOf(value);
-                } catch (Exception e) {
-                    String msg = "Caught an error converting a String to a java.sql.Time";
-                    LOGGER.error(msg, e);
-
-                    TypeConversionException tce = new TypeConversionException(msg, e);
-                    tce.setLocalizedMessage(Bundle.getString("TypeUtils_javaSqlTimeConvertError", new Object[]{e.getMessage()}));
-                    throw tce;
+        TYPE_CONVERTERS.put(java.sql.Time.class,
+                            new BaseTypeConverter() {
+                public Object convertToObject(Class type, String value, Locale locale) {
+                    if ((value == null) || value.equals(EMPTY_STRING)) {
+                        return null;
+                    }
+
+                    try {
+                        return java.sql.Time.valueOf(value);
+                    } catch (Exception e) {
+                        String msg = "Caught an error converting a String to a java.sql.Time";
+                        LOGGER.error(msg, e);
+
+                        TypeConversionException tce = new TypeConversionException(msg, e);
+                        tce.setLocalizedMessage(Bundle.getString("TypeUtils_javaSqlTimeConvertError",
+                                                                 new Object[] { e.getMessage() }));
+                        throw tce;
+                    }
                 }
-            }
-        });
+            });
     }
 }

Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/DomUtils.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/DomUtils.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/DomUtils.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/DomUtils.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.ti.util.xml;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>This class exists simply because DOM is so inconvenient to use.</p>
+ */
+public final class DomUtils {
+    /* do not construct */
+    private DomUtils() {
+    }
+
+    /**
+     * <p>Returns the first child element with the given name. Returns
+     * <code>null</code> if not found.</p>
+     *
+     * @param parent parent element
+     * @param name name of the child element
+     * @return child element
+     */
+    public static Element getChildElementByName(Element parent, String name) {
+        NodeList children = parent.getChildNodes();
+
+        for (int i = 0; i < children.getLength(); i++) {
+            Node node = children.item(i);
+
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                Element element = (Element) node;
+
+                if (element.getTagName().equals(name)) {
+                    return element;
+                }
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * <p>Returns a list of child elements with the given
+     * name. Returns an empty list if there are no such child
+     * elements.</p>
+     *
+     * @param parent parent element
+     * @param name name of the child element
+     * @return child elements
+     */
+    public static List getChildElementsByName(Element parent, String name) {
+        List elements = new ArrayList();
+
+        NodeList children = parent.getChildNodes();
+
+        for (int i = 0; i < children.getLength(); i++) {
+            Node node = children.item(i);
+
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                Element element = (Element) node;
+
+                if (element.getTagName().equals(name)) {
+                    elements.add(element);
+                }
+            }
+        }
+
+        return elements;
+    }
+
+    /**
+     * <p>Returns the text value of a child element. Returns
+     * <code>null</code> if there is no child element found.</p>
+     *
+     * @param parent parent element
+     * @param name name of the child element
+     * @return text value
+     */
+    public static String getChildElementText(Element parent, String name) {
+        // Get children
+        List list = DomUtils.getChildElementsByName(parent, name);
+
+        if (list.size() == 1) {
+            Element child = (Element) list.get(0);
+
+            StringBuffer buf = new StringBuffer();
+
+            NodeList children = child.getChildNodes();
+
+            for (int i = 0; i < children.getLength(); i++) {
+                Node node = children.item(i);
+
+                if ((node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.CDATA_SECTION_NODE)) {
+                    Text text = (Text) node;
+                    buf.append(text.getData().trim());
+                }
+            }
+
+            return buf.toString();
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * <p>Returns the text value of a child element. Returns
+     * <code>null</code> if there is no child element found.</p>
+     *
+     * @param element element
+     * @return text value
+     */
+    public static String getElementText(Element element) {
+        StringBuffer buf = new StringBuffer();
+
+        NodeList children = element.getChildNodes();
+
+        for (int i = 0; i < children.getLength(); i++) {
+            Node node = children.item(i);
+
+            if ((node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.CDATA_SECTION_NODE)) {
+                Text text = (Text) node;
+                buf.append(text.getData().trim());
+            }
+        }
+
+        return buf.toString();
+    }
+
+    /**
+     * <p>Returns an array of text values of a child element. Returns
+     * <code>null</code> if there is no child element found.</p>
+     *
+     * @param parent parent element
+     * @param name name of the child element
+     * @return text value
+     */
+    public static String[] getChildElementTextArr(Element parent, String name) {
+        // Get all the elements
+        List children = getChildElementsByName(parent, name);
+
+        String[] str = new String[children.size()];
+
+        for (int i = 0; i < children.size(); i++) {
+            Node child = (Node) children.get(i);
+
+            StringBuffer buf = new StringBuffer();
+
+            NodeList nodes = child.getChildNodes();
+
+            for (int j = 0; j < nodes.getLength(); j++) {
+                Node node = nodes.item(j);
+
+                if ((node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.CDATA_SECTION_NODE)) {
+                    Text text = (Text) node;
+                    buf.append(text.getData().trim());
+                }
+            }
+
+            str[i] = buf.toString();
+        }
+
+        return str;
+    }
+
+    /**
+     * <p>Retutns the value of the named attribute of the given
+     * element. If there is no such attribute, returns null.</p>
+     *
+     * @param element element
+     * @param name name
+     * @return value
+     */
+    public static String getAttributeValue(Element element, String name) {
+        Attr attribute = element.getAttributeNode(name);
+
+        if (attribute == null) {
+            return null;
+        } else {
+            return attribute.getValue();
+        }
+    }
+}

Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/LocalFileEntityResolver.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/LocalFileEntityResolver.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/LocalFileEntityResolver.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/LocalFileEntityResolver.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.ti.util.xml;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Entity resolver that tries to find the resource locally (from classloader, under a given path prefix) before trying
+ * to resolve via the network.
+ */
+public class LocalFileEntityResolver
+        implements EntityResolver {
+    private String _resourcePathPrefix;
+
+    /**
+     * Constructor.
+     * @param resourcePathPrefix The path prefix to use when trying to resolve a file locally.
+     */
+    public LocalFileEntityResolver(String resourcePathPrefix) {
+        _resourcePathPrefix = resourcePathPrefix;
+    }
+
+    /**
+     * Resolve the entity.  First try to find it locally, then fallback to the network.
+     */
+    public InputSource resolveEntity(String publicID, String systemID)
+            throws SAXException, IOException {
+        InputSource localFileInput = resolveLocalEntity(systemID);
+
+        return (localFileInput != null) ? localFileInput : new InputSource(systemID);
+    }
+
+    /**
+     * Resolve the given entity locally.
+     */
+    public InputSource resolveLocalEntity(String systemID)
+            throws SAXException, IOException {
+        String localFileName = systemID;
+        int fileNameStart = localFileName.lastIndexOf('/') + 1;
+
+        if (fileNameStart < localFileName.length()) {
+            localFileName = systemID.substring(fileNameStart);
+        }
+
+        ClassLoader cl = LocalFileEntityResolver.class.getClassLoader();
+        InputStream stream = cl.getResourceAsStream(_resourcePathPrefix + localFileName);
+
+        if (stream != null) {
+            return new InputSource(stream);
+        } else if (_resourcePathPrefix.endsWith(localFileName)) {
+            // If the resource path prefix itself resolves to the right file, use that.
+            return new InputSource(_resourcePathPrefix);
+        }
+
+        return null;
+    }
+}

Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/XmlInputStreamResolver.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/XmlInputStreamResolver.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/XmlInputStreamResolver.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/XmlInputStreamResolver.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.ti.util.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public abstract class XmlInputStreamResolver {
+    public abstract String getResourcePath();
+
+    public abstract InputStream getInputStream() throws IOException;
+}

Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/validation/SchemaValidationException.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/validation/SchemaValidationException.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/validation/SchemaValidationException.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/validation/SchemaValidationException.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,41 @@
+/*
+ * B E A   S Y S T E M S
+ * Copyright 2002-2004  BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.ti.util.xml.validation;
+
+
+/**
+ */
+public class SchemaValidationException
+        extends RuntimeException {
+    public SchemaValidationException() {
+        super();
+    }
+
+    public SchemaValidationException(String msg) {
+        super(msg);
+    }
+
+    public SchemaValidationException(Throwable cause) {
+        super(cause);
+    }
+
+    public SchemaValidationException(String msg, Throwable cause) {
+        super(msg, cause);
+    }
+}

Added: struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/validation/SchemaValidator.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/validation/SchemaValidator.java?rev=290802&view=auto
==============================================================================
--- struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/validation/SchemaValidator.java (added)
+++ struts/sandbox/trunk/ti/jars/core/src/java/org/apache/ti/util/xml/validation/SchemaValidator.java Wed Sep 21 12:42:20 2005
@@ -0,0 +1,28 @@
+/*
+ * B E A   S Y S T E M S
+ * Copyright 2002-2004  BEA Systems, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.ti.util.xml.validation;
+
+import java.io.InputStream;
+
+/**
+ *
+ */
+public abstract class SchemaValidator {
+    public abstract void validate(InputStream xmlInputStream, String schemaResourcePath);
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org