empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r683173 [2/10] - in /incubator/empire-db/trunk/core/Empire-db: ./ .settings/ bin/ lib/ src/ src/META-INF/ src/org/ src/org/apache/ src/org/apache/empire/ src/org/apache/empire/commons/ src/org/apache/empire/data/ src/org/apache/empire/data/...
Date Wed, 06 Aug 2008 08:47:43 GMT
Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/ObjectUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/ObjectUtils.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/ObjectUtils.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/ObjectUtils.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,446 @@
+/*
+ * ESTEAM Software GmbH
+ */
+package org.apache.empire.commons;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.commons.beanutils.MethodUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This class contains common functions for comparing and converting values of type Object. 
+ * 
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public final class ObjectUtils
+{
+    /**
+     * This class eplicitly defines that an Object has not been assined a value.<BR>
+     * This may be used in cases where the value of null may be a valid value.
+     */
+    public static class NoValue
+    {
+        private NoValue()
+        { /* dummy */
+        }
+        @Override
+        public String toString()
+        {
+        	return "[NO-VALUE]";
+        }
+    }
+    
+    /**
+     * Constant that defines a object of type NoValue.
+     * This may be used in cases where the value of null is a valid value.
+     */
+    public static final NoValue NO_VALUE = new NoValue();
+    
+    // Logger
+    private static final Log log = LogFactory.getLog(ObjectUtils.class);
+
+    private static SimpleDateFormat dateFormat   = new SimpleDateFormat("yyyy-MM-dd");
+    private static SimpleDateFormat timeFormat   = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+
+    private ObjectUtils()
+    {
+        // Static Function only
+        // No instance may be created
+    }
+    
+    /**
+     * Checks whether an object has no value.
+     * A Object is empty if and only if the Object is null or if its an empty string. 
+     * @param o the object to check
+     * @return true if the Object is null or if its an empty string. 
+     */
+    public static boolean isEmpty(Object o)
+    {
+        if (o==null || o==ObjectUtils.NO_VALUE)
+            return true;
+        if ((o instanceof String) && ((String)o).length()==0)
+            return true;
+        // not empty
+        return false;
+    }
+    
+    /**
+     * Compares two objects for equality 
+     * @param o1 the first object
+     * @param o2 the second object
+     * @return true if both objects are equal or false otherwise
+     */
+    public static boolean compareEqual(Object o1, Object o2)
+    {
+        // Check for Null Values
+        if (o1==null || o2==null)
+            return (o1==o2);
+        // Check classes
+        if (o1.getClass().equals(o2.getClass()))
+            return o1.equals(o2);
+        // Classes don't match
+        // Use equal check first
+        if (o1.equals(o2) || o2.equals(o1))
+            return true;
+        // Check Numbers
+        if (o1 instanceof Number && o2 instanceof Number)
+        {   // boolean test = obj1.equals(obj2);
+            double d1 = ((Number)o1).doubleValue();
+            double d2 = ((Number)o2).doubleValue(); 
+            return (d1==d2);
+        }
+        // Check Strings
+        return o1.toString().equals(o2.toString());
+    }
+    
+    /**
+     * Checks whether a preferred value is valid and returns an alternative value if not.
+     * @param preferred the preferred return value
+     * @param alternative the alternative return value used if the preferred value is null 
+     * @return the preferred value if it is not null or the alternative value otherwise
+     */
+    public static <T> T coalesce(T preferred, T alternative)
+    {
+        return (preferred!=null ? preferred : alternative);
+    }
+    
+    /**
+     * Converts an object value to an integer.
+     * <P>
+     * If the object value supplied is null or if conversion is not possible then the default value is returned.
+     * @param v the obect to convert
+     * @param defValue the default value if o is null or conversion is not possible 
+     * @return the Integer value of o or a default value
+     */
+    public static int getInteger(Object v, int defValue)
+    {
+        if (v==null)
+            return defValue;
+        if (v instanceof Number)
+            return ((Number)v).intValue();
+        // Try to convert
+        try
+        {
+            String str = v.toString();
+            if (str.length()==0)
+                return defValue;
+            // Parse String
+            return Integer.parseInt(str);
+        } catch (Exception e)
+        {
+            log.error(e.getMessage(), e);
+            return defValue;
+        }
+    }
+    
+    /**
+     * Converts an object value to an integer.
+     * <P>
+     * If the object value supplied is null or if conversion is not possible then 0 is returned.
+     * @param v the object value to convert
+     * @return the Integer value of o or 0
+     */
+    public static int getInteger(Object v)
+    {
+        return getInteger(v, 0); 
+    }
+    
+    /**
+     * Converts an object value to a long.
+     * <P>
+     * If the object value supplied is null or if conversion is not possible then the default value is returned.
+     * @param v the obect to convert
+     * @param defValue the default value if o is null or conversion is not possible 
+     * @return the Integer value of o or a default value
+     */
+    public static long getLong(Object v, long defValue)
+    {
+        if (v==null)
+            return defValue;
+        if (v instanceof Number)
+            return ((Number)v).longValue();
+        // Try to convert
+        try
+        {
+            String str = v.toString();
+            if (str.length()==0)
+                return defValue;
+            // Parse String
+            return Long.parseLong(str);
+        } catch (Exception e)
+        {
+            log.error(e.getMessage(), e);
+            return defValue;
+        }
+    }
+    
+    /**
+     * Converts an object value to a long.
+     * <P>
+     * If the object value supplied is null or if conversion is not possible then 0 is returned.
+     * @param v the object value to convert
+     * @return the Long value of o or 0
+     */
+    public static long getLong(Object v)
+    {
+        return getLong(v, 0); 
+    }
+    
+    /**
+     * Converts an object value to a double.
+     * <P>
+     * If the object value supplied is null or if conversion is not possible then defValue is returned.
+     * @param v the object value to convert
+     * @return the Long value of o or defValue
+     */
+    public static double getDouble(Object v, double defValue)
+    {
+        // Get Double value
+        if (v==null)
+            return defValue;
+        if (v instanceof Number)
+            return ((Number)v).doubleValue();
+        // parse String for Integer value
+        try
+        {
+            String  val = v.toString(); 
+            return Double.parseDouble(val);
+        } catch (Exception e)
+        {
+            log.error("Cannot convert value to double!", e);
+            return defValue;
+        }
+    }
+
+    /**
+     * Converts an object value to a double.
+     * <P>
+     * If the object value supplied is null or if conversion is not possible then 0.0 is returned.
+     * @param v the object value to convert
+     * @return the Long value of o or 0
+     */
+    public static double getDouble(Object v)
+    {
+        return getDouble(v, 0.0);
+    }
+    
+    /**
+     * Converts an object value to a boolean.
+     * <P>
+     * If the object value supplied is null or if conversion is not possible then false is returned.
+     * @param v the object to convert
+     * @return the boolean value of o (true or false)
+     */
+    public static boolean getBoolean(Object v)
+    {
+        // Get Boolean value
+        if (v==null)
+            return false;
+        if (v instanceof Boolean)
+            return ((Boolean)v).booleanValue();
+        if (v instanceof Number)
+            return (((Number)v).intValue()!=0);
+        // parse String for boolean value
+        String  val = v.toString(); 
+        return (val.equalsIgnoreCase("Y") || val.equalsIgnoreCase("true"));
+    }
+    
+    /**
+     * Converts an object value to a Date.
+     * <P>
+     * If the object value supplied is null or if conversion is not possible then null is returned.
+     * @param v the object to convert
+     * @param locale the locale used for conversion
+     * @return the Date value of o or null
+     */
+    public static Date getDate(Object v, Locale locale)
+    {
+        if (v==null)
+            return null;
+        if (v instanceof Date)
+            return ((Date)v);
+        // Get Calendar
+        if (v instanceof Number)
+        {   // Get Date from a number
+            long l = ((Number)v).longValue();
+            if (l==0)
+                return DateUtils.getDateNow();
+            // Year or full date/time?
+            /*
+            if (l<10000)
+            {   // Year only
+                Calendar calendar = Calendar.getInstance(getSafeLocale(locale));
+                calendar.set((int)l, 1, 1);
+                return calendar.getTime();
+            }
+            */
+            // Date from long
+            return new Date(l);
+        }
+        // Try to parse
+        return DateUtils.parseDate(v.toString(), locale);
+    }
+    
+    /**
+     * Converts an object value to a Date.
+     * <P>
+     * @param v the object to convert
+     * @return the Date value of o or null
+     */
+    public static Date getDate(Object v)
+    {
+        // Get DateTime value
+        if (v==null)
+            return null;
+        if (v instanceof java.util.Date)
+            return ((java.util.Date)v);
+        // Convert from String
+        try
+        {   String str = v.toString();
+            if (str.length() > 10)
+                return timeFormat.parse(str);
+            else
+                return dateFormat.parse(str);
+        } catch (Exception e)
+        {
+            log.error("Cannot convert value to date!", e);
+            return null;
+        }
+    }
+    
+    /**
+     * Formats a given date object to a standard date string.
+     * The date string is locale independent and has the follwowing format:
+     *  "yyyy-MM-dd hh:mm:ss"      
+     * 
+     * @param date the date to be formated
+     * @param withTime indicates whether the date string should include the time or not
+     * @return the date string
+     */
+    public static String formatDate(Date date, boolean withTime)
+    {
+        return (withTime) ? timeFormat.format(date) : dateFormat.format(date);
+    }
+    
+    /**
+     * Generic conversion function that will convert a object to another value type.
+     * @param c the value type to convert to
+     * @param v the object to convert
+     * @return the Date value of o or null
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> T convert(Class<T> c, Object v)
+        throws ClassCastException
+    {
+        if (v==null || c.isInstance(v))
+            return (T)v;
+        // Convert
+        if (c.isAssignableFrom(Boolean.class))
+            return c.cast(getBoolean(v));
+        if (c.isAssignableFrom(Integer.class))
+            return c.cast(getInteger(v));
+        if (c.isAssignableFrom(Long.class))
+            return c.cast(getLong(v));
+        if (c.isAssignableFrom(String.class))
+            return c.cast(v.toString());
+        // other
+        return c.cast(v);
+    }
+
+    @SuppressWarnings("unchecked")
+    public static final boolean isAssignmentCompatible(Class target, Class source)
+    {
+        // try plain assignment
+        if (target.isAssignableFrom(source))
+            return true;
+        // Get Class form Primitive Type
+        if (source.isPrimitive())
+        {   // Get's the Java Class representing the primitive type
+            source = MethodUtils.getPrimitiveWrapper(source);
+            if (source == null)
+                return false;
+            if (target.isAssignableFrom(source))
+                return true;
+        }
+        // Get Class form Primitive Type
+        if (target.isPrimitive())
+        {   // Get's the Java Class representing the primitive type
+            target = MethodUtils.getPrimitiveWrapper(target);
+            if (target == null)
+                return false;
+            if (target.isAssignableFrom(source))
+                return true;
+        }
+        // Assume all numeric types can be converted to target class
+        Class numberClass = Number.class;
+        if (numberClass.isAssignableFrom(target) &&
+            numberClass.isAssignableFrom(source))
+        {   // Both are numeric
+            return true;
+        }
+        // Not compatible
+        return false;
+    }
+    
+    /**
+     * Generic conversion function that will convert a list to another list type.
+     * @return the new list type
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> List<T> convert(Class<T> t, Collection<? extends T> source)
+        throws ClassCastException
+    {
+        List<T> target = new ArrayList<T>();
+        target.addAll(source);
+        return target;
+    }
+    
+    /**
+     * Converts an Object array to a String array.
+     * @param objArray the object array to convert
+     * @param defValue default value which will be set for all null objects 
+     * @return the String array
+     */
+    public static String[] toStringArray(Object[] objArray, String defValue)
+    {
+        if (objArray==null)
+            return null;
+        String[] strArray = new String[objArray.length];
+        for (int i=0; i<objArray.length; i++)
+        {
+            if (objArray[i]!=null)
+                strArray[i]=objArray[i].toString();
+            else 
+                strArray[i]=defValue;
+        }
+        return strArray;
+    }
+    
+    /**
+     * returns wheter or not a array contains a certain item
+     * @param array the array to search
+     * @param item the item to search for
+     * @return true if the array contains the item or false otherwise
+     */
+    public static <T> boolean contains(T[] array, T item)
+    {
+        if (array==null)
+            return false;
+        for (int i=0; i<array.length; i++)
+        {
+            if (array[i]==item)
+                return true;
+            if (array[i]!=null && array[i].equals(item))
+                return true;
+        }
+        return false;
+    }
+    
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/OptionEntry.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/OptionEntry.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/OptionEntry.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/OptionEntry.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,44 @@
+/*
+ * ESTEAM Software GmbH
+ */
+package org.apache.empire.commons;
+
+/**
+ * This class defines one possible value of a field and it's description<BR>
+ * This class is used by the Options class to implement a set of options 
+ * where the option value us used as the key for the set.<BR>
+ * The text should only be used for display purposes e.g. to display a drop-down in a user interface.<BR>
+ * <P>
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public class OptionEntry
+{
+    private Object value;
+    private String text;
+    
+    public OptionEntry(Object value, String text)
+    {
+        this.value = value;
+        this.text = text;
+    }
+
+    public Object getValue()
+    {
+        return value;
+    }
+
+    public String getValueString()
+    {   // Convenience Function   
+        return (value!=null ? String.valueOf(value) : "");
+    }
+    
+    public String getText()
+    {
+        return text;
+    }
+
+    public void setText(String text)
+    {
+        this.text = text;
+    }
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/Options.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/Options.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/Options.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/Options.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,242 @@
+/*
+ * ESTEAM Software GmbH
+ */
+package org.apache.empire.commons;
+
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.apache.empire.xml.XMLUtil;
+import org.w3c.dom.Element;
+
+
+/**
+ * This class represents a list of possible values that are valid for a particular field.<BR>
+ * Additionally the class provides a text string describing the value for display purposes.<BR>
+ * The class is implemented as a set of OptionEntry objects 
+ * where the entry value is used as the key for the set and thus must be unique.<BR>
+ * <P> 
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+@SuppressWarnings("serial")
+public class Options extends AbstractSet<OptionEntry>
+{
+    public enum InsertPos
+    {
+        Top, Bottom, Sort
+    }
+
+    private static final String EMPTY_STRING = "";
+
+    private ArrayList<OptionEntry> list = new ArrayList<OptionEntry>();
+    
+    public Options()
+    {
+        // Default constructor
+    }
+    
+    public Options(Options other)
+    {
+        this.addAll(other);
+    }
+    
+    public Options(OptionEntry [] entries)
+    {
+        for (int i=0; i<entries.length; i++)
+            this.add(entries[i]);
+    }
+
+    protected int getIndex(Object value)
+    {
+        // Find an Entry
+        if (value instanceof Entry)
+            value = ((Entry) value).getKey();
+        if (value instanceof OptionEntry)
+            value = ((OptionEntry) value).getValue();
+        // Find it now
+        int size = list.size();
+        for (int i = 0; i < size; i++)
+        { // Search List for Index
+            Object v = list.get(i).getValue();
+            if (ObjectUtils.compareEqual(value, v))
+                return i;
+        }
+        return -1;
+    }
+    
+    protected OptionEntry createOptionEntry(Object value, String text)
+    {
+        return new OptionEntry(value, text);
+    }
+
+    public OptionEntry getEntry(Object value)
+    {
+        int i = getIndex(value);
+        return (i >= 0 ? list.get(i) : null);
+    }
+
+    public String get(Object value)
+    {
+        int i = getIndex(value);
+        return (i >= 0 ? list.get(i).getText() : EMPTY_STRING);
+    }
+
+    public Object getValueAt(int i)
+    {
+        return (i>=0 && i<list.size() ? list.get(i).getValue() : null);
+    }
+
+    public String getTextAt(int i)
+    {
+        return (i>=0 && i<list.size() ? list.get(i).getText() : EMPTY_STRING);
+    }
+
+    public Set<Object> getValues()
+    {
+        HashSet<Object> set = new HashSet<Object>(list.size());
+        for (OptionEntry e : list)
+            set.add(e.getValue());
+        return set;
+    }
+
+    public void set(Object value, String text, InsertPos pos)
+    {
+        if (text == null)
+        { // text must not be null!
+            return;
+        }
+        // Find Index
+        int i = getIndex(value);
+        if (i >= 0)
+        { // already present
+            list.get(i).setText(text);
+        } 
+        else
+        {   // find insert pos
+            int index;
+            if (pos == InsertPos.Top)
+                index = 0;
+            else if (pos == InsertPos.Sort)
+                index = findInsertPos(text);
+            else // bottom is default
+                index = list.size();
+            // add entry now
+            list.add(index, createOptionEntry(value, text));
+        }
+    }
+
+    public void set(Object value, String text)
+    {
+        set(value, text, InsertPos.Bottom);
+    }
+
+    public void add(Object value, String text, boolean noCheck)
+    {
+        if (noCheck)
+        { // fast add to list, without check for existing key
+            // handle with care!
+            list.add(createOptionEntry(value, text));
+        } 
+        else
+            set(value, text);
+    }
+
+    @Override
+    public boolean add(OptionEntry option)
+    {
+        if (option.getText() == null)
+        { // text must not be null!
+            return false;
+        }
+        int i = getIndex(option.getValue());
+        if (i >= 0)
+            list.set(i, option);
+        else
+            list.add(option);
+        return true;
+    }
+
+    @Override
+    public void clear()
+    {
+        list.clear();
+    }
+
+    @Override
+    public boolean contains(Object object)
+    {
+        // Check if exits
+        return (getIndex(object) >= 0);
+    }
+
+    public boolean containsValue(Object object)
+    {
+        // Check if exits
+        return (getIndex(object) >= 0);
+    }
+
+    @Override
+    public boolean isEmpty()
+    {
+        return (list.size() == 0);
+    }
+
+    @Override
+    public Iterator<OptionEntry> iterator()
+    {
+        return list.iterator();
+    }
+
+    @Override
+    public boolean remove(Object object)
+    {
+        // Check if exits
+        int i = getIndex(object);
+        if (i < 0)
+            return false; // Element not found
+        // remove
+        list.remove(i);
+        return true;
+    }
+
+    @Override
+    public int size()
+    {
+        return list.size();
+    }
+
+    @Override
+    public Object[] toArray()
+    {
+        return list.toArray();
+    }
+
+    public void addXml(Element element, long flags)
+    { // add All Options
+        Iterator<OptionEntry> i = iterator();
+        while (i.hasNext())
+        {
+            OptionEntry e = i.next();
+            String value = String.valueOf(e.getValue());
+            // Create Option Element
+            Element opt = XMLUtil.addElement(element, "option", e.getText());
+            opt.setAttribute("value", value);
+        }
+    }
+
+    private int findInsertPos(String text)
+    {
+        int i = 0;
+        for (; i < list.size(); i++)
+        {
+            OptionEntry e = list.get(i);
+            if (text.compareToIgnoreCase(e.getText()) <= 0)
+                break;
+        }
+        return i;
+    }
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/StringUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/StringUtils.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/StringUtils.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/StringUtils.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,379 @@
+/*
+ * ESTEAM Software GmbH
+ */
+package org.apache.empire.commons;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * This class contains common functions for comparing and converting values of type String. 
+ * 
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public class StringUtils
+{
+    private StringUtils()
+    {
+        // Static Function only
+        // No instance may be created
+    }
+
+    /**
+     * Converts a value to a string.
+     * If the value is null then the default value is returned.
+     * 
+     * @param value the value to convert
+     * @param defValue default value which to return if value is null
+     * @return returns a String representation of the value or null if value is null
+     */
+    public static String toString(Object value, String defValue)
+    {
+        return ((value!=null) ? value.toString() : defValue);
+    }
+
+    /**
+     * Converts a value to a string.
+     * If the value is null then null will be returned.
+     * 
+     * @param value the value to convert
+     * @return returns a String representation of the value or null if value is null
+     */
+    public static String toString(Object value)
+    {
+        return toString(value, null);
+    }
+
+    /**
+     * Converts an array of objects to a string.
+     * 
+     * @param array array of objects
+     * @param defValue default value which to return if array is null
+     * @return returns a String representation of the array or the defaultValue if array is null
+     */
+    public static String toString(Object[] array, String defValue)
+    {
+        String s = arrayToString(array, "/");
+        return (s!=null ? s : defValue);
+    }
+
+    /**
+     * Converts an array of objects to a string.
+     * 
+     * @param array array of objects
+     * @return returns a String representation of the array or null if the array is null
+     */
+    public static String toString(Object[] array)
+    {
+        return toString(array, null);
+    }
+
+    /**
+     * Converts a value to a string.
+     * if the value is null an empty string is returned.
+     * 
+     * @param value the value to convert
+     * @return returns a String representation of the Object or an empty stringif o is null
+     */
+    public static String valueOf(Object value)
+    {
+        return toString(value, "");
+    }
+
+    /**
+     * Converts an objects to a string.
+     * 
+     * @param array array of objects
+     * @return returns a String representation of the array or an empty String if the array is null
+     */
+    public static String valueOf(Object[] array)
+    {
+        return toString(array, "");
+    }
+    
+    /**
+     * Returns the preferred String if it is not empty
+     * ot the alternative String otherwise.
+     * 
+     * @param preferred the preferred String
+     * @param alternative the alternative String if the preferred String is not valid
+     * @return the preferred String if it is not empty ot the alternative String otherwise 
+     */
+    public static String coalesce(String preferred, String alternative)
+    {
+        return isValid(preferred) ? preferred : alternative;        
+    }
+
+    /**
+     * Returns null if the value supplied is null or an empty String. 
+     * 
+     * @param value the value to check
+     * @return null if the value supplied is null or an empty String or the value as a string otherwise 
+     */
+    public static String nullIfEmpty(Object value)
+    {
+        if (value==null)
+            return null;
+        String strval = value.toString();
+        return ((strval.length()==0) ? null : strval);   
+    }
+
+    /**
+     * Converts an array of objects to a string.
+     * 
+     * @param array array of objects
+     * @return returns a String
+     */
+    public static String arrayToString(Object[] array, String separator)
+    {
+        if (array == null || array.length < 1)
+            return null; // Empty
+        if (array.length > 1)
+        { // multi Column Key
+            StringBuilder buf = new StringBuilder();
+            for (int i = 0; i < array.length; i++)
+            {
+                if (i > 0)
+                    buf.append(separator);
+                buf.append(array[i]);
+            }
+            return buf.toString();
+        }
+        // Only one member
+        return array[0].toString();
+    }
+
+    /**
+     * Converts a string to an array of objects.
+     * 
+     * @param string the source string to parse
+     * @param separator the separator string by which the parts are separated
+     * @return returns a String
+     */
+    public static String[] stringToArray(String string, String separator)
+    {
+        if (string == null || isEmpty(separator))
+            return null; // Empty
+        // Count the items first
+        int sepLength = separator.length();
+        int count = 0;
+        int pos = -1;
+        while ((pos=string.indexOf(separator, pos+sepLength))>=0)
+                count++;
+        // Alloc an array
+        String[] array = new String[count+1];
+        if (count>0)
+        {
+            int beg = 0;
+            for (int i=0; true; i++)
+            {
+                int end = string.indexOf(separator, beg);
+                if (end>beg)
+                {   // Add Item
+                    array[i] = string.substring(beg, end);
+                    beg = end + sepLength;
+                }
+                else
+                {   // Last Item
+                    array[i] = string.substring(beg);
+                    break;
+                }
+            }
+        }
+        else
+        {
+            array[0] = string;
+        }
+        // Only one member
+        return array;
+    }
+
+    /**
+     * Converts an collection of objects to a string.
+     * 
+     * @param c the collection to add
+     * @return returns a String
+     */
+    public static String collectionToString(Collection<? extends Object> c, String separator)
+    {
+        if (c == null || c.size()==0)
+            return null; // Empty
+        // Iterator
+        StringBuilder buf = new StringBuilder();
+        boolean addSep = false;
+        Iterator i = c.iterator();
+        while (i.hasNext())
+        {
+            if (addSep)
+                buf.append(separator);
+            buf.append(valueOf(i.next()));
+            addSep = true;
+        }
+        return buf.toString();
+    }
+    
+    public static boolean isEmpty(String s)
+    {
+        return (s==null || s.trim().length()==0);
+    }
+    
+    public static boolean isValid(String s)
+    {
+        return (s!=null && s.trim().length()>0);
+    }
+
+    public static boolean isEmail(String s)
+    {
+        int indexOfAtChar = s.indexOf("@");
+        if (indexOfAtChar > 0)
+        {
+            int indexOfDotChar = s.indexOf(".", indexOfAtChar);
+            if (indexOfDotChar > 0)
+            {
+                return true;
+            }
+            return false;
+        }
+        return false;
+    }
+    
+    /**
+     * Validates a given string. If the string is empty then null is returned. 
+     * Otherwise the trimmed string is returned. 
+     * @param s the string to validate
+     * @return the string or null if s was empty.
+     */
+    public static String validate(String s)
+    {
+        if (s==null)
+            return null;
+        s = s.trim();
+        if (s.length()==0)
+            return null;
+        return s;
+    }
+    
+    /**
+     * Replaces all occances of first character in a string by a string.
+     * 
+     * @param source the original String.
+     * @param find the String to be replaced
+     * @param replace the replacement string
+     * 
+     * @return a new string with all occurances of <code>find</code> in <code>source</code> replaced by <code>replace</code>
+     */
+    public static String replace(String source, String find, String replace)
+    {
+        // Check params
+        if (source == null || find == null || find.length()==0)
+            return source;
+        // Find the character
+        int index = source.indexOf(find);
+        if (index < 0)
+            return source;
+        if (replace==null)
+            replace="";
+        // replace and find again
+        int len = find.length();
+        return source.substring(0,index)
+             + replace
+             + replace(source.substring(index+len), find, replace); 
+    }
+
+    /**
+     * Returns a String with all occurrences of <code>from</code> within <code>orig</code> replaced with <code>to</code>.
+     * If <code>orig</code> contains no occurrences of <code>from</code>, or if <code>from</code> is equal to
+     * <code>to</code>,<code>orig</code> itself is returned rather than a copy being made. If orig is <code>null</code>,
+     * <code>null</code> is returned.
+     * 
+     * @param source the original String.
+     * @param find the String to be replaced
+     * @param replace the replacement string
+     * 
+     * @return a new string with all occurances of <code>find</code> in <code>source</code> replaced by <code>replace</code>
+     */
+    public static String replaceAll(String source, String find, String replace)
+    {
+        if (source == null)
+            return null;
+        if (find == null)
+        {
+            find = "";
+        }
+        if (replace == null)
+        {
+            replace = "";
+        }
+        int fromLength = find.length();
+        int start = source.indexOf(find);
+        if (start == -1)
+            return source;
+
+        boolean greaterLength = (replace.length() >= fromLength);
+
+        StringBuilder buffer;
+        // If the "to" parameter is longer than (or
+        // as long as) "from", the final length will
+        // be at least as large
+        if (greaterLength)
+        {
+            if (find.equals(replace))
+                return source;
+            buffer = new StringBuilder(source.length());
+        } 
+        else
+        {
+            buffer = new StringBuilder();
+        }
+
+        char[] origChars = source.toCharArray();
+
+        int copyFrom = 0;
+        while (start != -1)
+        {
+            buffer.append(origChars, copyFrom, start - copyFrom);
+            buffer.append(replace);
+            copyFrom = start + fromLength;
+            start = source.indexOf(find, copyFrom);
+        }
+        buffer.append(origChars, copyFrom, origChars.length - copyFrom);
+
+        return buffer.toString();
+    }
+
+    public static String replaceBRbyLF(String s)
+    {
+        return replaceAll(replaceAll(s, "<br/>", "\n\n"), "<br />", "\n\n");
+    }
+
+    public static String trimAll(String orig)
+    {
+        if (orig == null)
+            return null;
+        String str = orig.trim();
+        StringBuilder strBuf = new StringBuilder(str.length());
+        boolean hasSpace = false;
+        for (int i = 0, j = 0; i < str.length(); i++)
+        {
+            if (str.charAt(i) == ' ')
+            {
+                if (!hasSpace)
+                {
+                    strBuf.append(' ');
+                    hasSpace = true;
+                }
+            } 
+            else
+            {
+                j = str.indexOf(' ', i);
+                if (j == -1)
+                    j = str.length();
+                strBuf.append(str.substring(i, j));
+                hasSpace = false;
+                i = j - 1;
+            }
+        }
+
+        return strBuf.toString();
+    }
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/package.html
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/package.html?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/package.html (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/commons/package.html Wed Aug  6 01:47:37 2008
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+/*
+ * ESTEAM Software GmbH, 12.12.2007
+ */
+-->
+</head>
+<body>
+
+This package contains various common classes for error handling, specific data types and data type conversion.
+
+</body></html>
\ No newline at end of file

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/Column.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/Column.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/Column.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/Column.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,41 @@
+/*
+ * ESTEAM Software GmbH, 11.09.2007
+ */
+package org.apache.empire.data;
+
+/**
+ * The column interface provides methods for accessing metadata that is only relevant for updateing records.
+ * <P>
+ * This interface inherits from ColumnExpr which provides futher metadata.
+ * <P>
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public interface Column extends ColumnExpr
+{
+
+    /**
+     * Returns the maximum size a value for this column is allowed to have.
+     * <P>
+     * For the data type DECIMAL the size defines the scale and precision of the value.
+     * <P>
+     * @return Returns the maximum size a value for this column is allowed to have.
+     */
+    double getSize();
+
+    /**
+     * Returns whether or not the value for this column must be
+     * supplied (i.e. it is mandatory) or not.
+     * <P>
+     * @return Returns true if the value for this column must be supplied
+     */
+    boolean isRequired();
+
+    /**
+     * Returns true if the values for this column are generally
+     * read only (like i.e. for sequence generated values).
+     * <P>
+     * @return Returns true if the values for this column are generally read-only
+     */
+    boolean isReadOnly();
+
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/ColumnExpr.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/ColumnExpr.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/ColumnExpr.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/ColumnExpr.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,69 @@
+/*
+ * ESTEAM Software GmbH, 17.09.2007
+ */
+package org.apache.empire.data;
+
+import org.apache.empire.commons.Options;
+
+/**
+ * The column interface provides methods for accessing metadata that is relevant for managing
+ * and displaying data available through the RecordData interface.
+ * <P>
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public interface ColumnExpr
+{
+
+    /**
+     * Returns the column's data type.
+     * @see DataType
+     * @return the column's data type
+     */
+    DataType getDataType();
+
+    /**
+     * Returns the physical column name.
+     * @return the physical column name
+     */
+    String getName();
+
+    /**
+     * Returns the column's display title.
+     * @return the column's display title
+     */
+    String getTitle();
+
+    /**
+     * Returns the column's control type used for displaying and entering data.
+     * @return the column's control type used for displaying and entering data
+     */
+    String getControlType();
+
+    /**
+     * Returns futher metadata attributes.
+     * @param name the name of the attribute
+     * @return futher metadata attributes
+     */
+    Object getAttribute(String name);
+
+    /**
+     * Returns an option set with possible column values and their
+     * corresponding display text.
+     * @return option set with possible column values and their corresponding display text
+     */
+    Options getOptions();
+
+    /**
+     * Returns the name of a Java bean property to which this column is mapped.
+     * @return the name of a Java bean property to which this column is mapped
+     */
+    String getBeanPropertyName();
+
+    /**
+     * Returns the underlying source column (if any).
+     * If an expression is based not based on a particutlar column this function returns null.
+     * @return the column on which this expression is based or null if not applicable.
+     */
+    Column getSourceColumn();
+
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/DataType.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/DataType.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/DataType.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/DataType.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,73 @@
+/*
+ * ESTEAM Software GmbH
+ */
+package org.apache.empire.data;
+
+/**
+ * DataType is an enumeration of data types that are supported
+ * with the empire-db component.
+ * 
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public enum DataType
+{
+    /**
+     * Unknown, used internally only for sql phrases
+     */
+    UNKNOWN, //      = 0;
+    
+    /**
+     * Integer value (16, 32 or 64 bit)
+     */
+    INTEGER, //      = 1;
+    
+    /**
+     * A numeric sequence generated value
+     */
+    AUTOINC, //      = 2;
+    
+    /**
+     * Small text (represents varchar)
+     */
+    TEXT, //         = 3;
+    
+    /**
+     * Date only value (without time)
+     */
+    DATE, //         = 4;
+    
+    /**
+     * Date value including time. Also knows a timestamp
+     */
+    DATETIME, //     = 5;
+    
+    /**
+     * Fixed length character value.
+     */
+    CHAR, //         = 6;
+    
+    /**
+     * Double precision floating point value
+     */
+    DOUBLE, //       = 7;
+    
+    /**
+     * Decimal numeric value (size indicates scale and precision)
+     */
+    DECIMAL, //      = 8;
+    
+    /**
+     * Boolean field (emulated if not supported by dbms as number or char)
+     */
+    BOOL, //         = 9;
+    
+    /**
+     * Long text > 2K
+     */
+    CLOB, //         = 10;
+    
+    /**
+     * Binary data
+     */
+    BLOB, //         = 11;
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/Record.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/Record.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/Record.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/Record.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,128 @@
+/*
+ * ESTEAM Software GmbH, 07.12.2007
+ */
+package org.apache.empire.data;
+
+import java.util.Collection;
+
+import org.apache.empire.commons.Options;
+
+
+/**
+ * The record interface provides methods used for updating data.
+ * <P>
+ * A object implementing the record interface is essentially a so called "dynamic bean".
+ * <P>
+ * This interface inherits from RecordData which provides further data access methods.
+ * <P>
+ * The Record interface is implmented by the class {@link org.apache.empire.db.DBRecord}
+ * <P>
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public interface Record extends RecordData
+{
+
+    /**
+     * returns true if the record is valid.
+     * @return true if the record is valid
+     */
+    boolean isValid();
+
+    /**
+     * returns true if the record has been modified.
+     * @return true if the record has been modified or false otherwise
+     */
+    boolean isModified();
+
+    /**
+     * returns true if this record is a new record.
+     * @return true if this record is a new record
+     */
+    boolean isNew();
+
+
+    /**
+     * returns the column at the specified index.
+     * @param index index of a requested column
+     * @return the column on the specified index
+     */
+    Column getColumn(int index);
+    
+    /**
+     * returns an array of key columns which uniquely identify the record.
+     * @return the array of key columns if any
+     */
+    Column[] getKeyColumns();    
+
+    /**
+     * returns true if the field is read-only.
+     * @param column the requested column
+     * @return true if the field is read-only
+     */
+    boolean isFieldReadOnly(Column column);
+
+    /**
+     * returns true if the field is visible to the client.
+     * @param column the column to check for visibility
+     * @return true if the field is visible to the client
+     */
+    boolean isFieldVisible(Column column);
+
+    /**
+     * returns the Options list for the given record field.
+     * @param column the column to check for visibility
+     * @return an options collection containing all allowed field values
+     */
+    Options getFieldOptions(Column column);
+
+
+    /**
+     * sets a record value based on the field index.
+     * @param i index of the field for which to set the value
+     * @param value the new field value
+     * @return true if value has been set or false if the value cannot be set for this field
+     */
+    boolean setValue(int i, Object value);
+
+    /**
+     * sets a record value based on a column.
+     * @param column the requested column
+     * @param value the new record value for the given column
+     * @return true if value has been set or false if the value cannot be set for this column
+     */
+    boolean setValue(Column column, Object value);
+
+    /**
+     * checks whether or not the field for the given column has been modified since it has been loaded.
+     * @param column the requested column
+     * @return Returns true if a column has been modified
+     */
+    boolean wasModified(Column column);
+
+    // ------- Java Bean Support -------
+
+    /**
+     * sets all record values from a particular bean.
+     * <P>
+     * The bean must provide corresponding getter functions for all desired column.
+     * <P>
+     * In order to map column names to property names 
+     * the property name is detected by ColumnExpr.getBeanPropertyName()     
+     * <P>
+     * @param bean the Java Bean from which to read the value from
+     * @param ignoreList list of column to ignore
+     * @return true if at least one field value has been successfully set    
+     */
+    boolean setBeanValues(Object bean, Collection<Column> ignoreList);
+
+    /**
+     * sets all record values from a particular bean.
+     * <P>
+     * The bean must provide corresponding getter functions for all desired column.
+     * <P>
+     * @param bean the Java Bean from which to read the value from
+     * @return true if at least one field value has been successfully set    
+     */
+    boolean setBeanValues(Object bean);
+
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/RecordData.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/RecordData.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/RecordData.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/RecordData.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,100 @@
+/*
+ * ESTEAM Software GmbH, 07.12.2007
+ */
+package org.apache.empire.data;
+
+import java.util.Collection;
+
+/**
+ * The RecordData interface provides methods for accessing data and context specific metadata.
+ * <P>
+ * The Record interface is implmented by the classes {@link org.apache.empire.db.DBReader}
+ * and {@link org.apache.empire.db.DBRecord}.
+ * <P>
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public interface RecordData
+{
+    /**
+     * returns the number of field available
+     * @return field count
+     */
+    int getFieldCount();
+
+    /**
+     * returns the index of the given column expression
+     * Indexed operations provide better performace for bulk processing  
+     * @param column the column for which to return the index
+     * @return the field index of the given column
+     */
+    int getFieldIndex(ColumnExpr column);
+    
+    /**
+     * returns the index of the column expression with the given name
+     * @param column the name of the column for which to return the index
+     * @return the field index of the given column
+     */
+    int getFieldIndex(String column);
+    
+    /**
+     * returns the column expression for a given column
+     * This is the reverse operation of getFieldIndex()
+     * @param i field index of the column expression
+     * @return the column expression object or null if the index is out of range
+     */
+    ColumnExpr getColumnExpr(int i);
+
+    /**
+     * returns the value of the field at the given index position 
+     * Indexed operations provide better performace for bulk processing compared to getValue(ColumnExpr)  
+     * @param index the field index for which to return the value
+     * @return the record value for the given field
+     */
+    Object getValue(int index);
+    
+    /**
+     * returns the record value for a particular column 
+     * @param column the column for which to return the value
+     * @return the record value for the given column
+     */
+    Object getValue(ColumnExpr column);
+    
+    /**
+     * checks if the field at the given index position contains no value (null) 
+     * Indexed operations provide better performace for bulk processing compared to isNull(ColumnExpr)  
+     * @param index the field index
+     * @return true if the field value is null or false otherwise
+     */
+    boolean isNull(int index);
+
+    /**
+     * checks if the record contains no value (null) for the given column  
+     * @param column the column
+     * @return true if the value for the column is null or false otherwise
+     */
+    boolean isNull(ColumnExpr column);
+
+    // ------- Java Bean Support -------
+
+    /**
+     * writes all field values into a static Java Bean.
+     * <P>
+     * In order to map column names to property names 
+     * the property name is detected by ColumnExpr.getBeanPropertyName()     
+     * @param bean the Java Bean for which to set the properties
+     * @param ignoreList list of columns to skip (optional)
+     * @return true if at least one property has been successfully set
+     */
+    boolean getBeanProperties(Object bean, Collection<ColumnExpr> ignoreList);
+
+    /**
+     * writes all field values into a static Java Bean.
+     * <P>
+     * In order to map column names to property names 
+     * the property name is detected by ColumnExpr.getBeanPropertyName()     
+     * @param bean the Java Bean for which to set the properties
+     * @return true if at least one property has been successfully set
+     */
+    boolean getBeanProperties(Object bean);
+
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanClass.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanClass.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanClass.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanClass.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,113 @@
+/*
+ * ESTEAM Software GmbH, 02.07.2008
+ */
+package org.apache.empire.data.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.empire.data.Column;
+import org.apache.empire.data.DataType;
+
+
+/**
+ * BeanObject
+ * This class defines Metadata for any type of java class.
+ * For each class you want to describe create one Metadata class and derive it from BeanClass.
+ * A metadata defintion consitst primarily of the class name and a list of properties.  
+ * @author Rainer
+ */
+public abstract class BeanClass
+{
+    private String name;
+    private List<BeanProperty> properties = new ArrayList<BeanProperty>();
+    private Column[] keyColumns;
+    
+    protected BeanDomain domain; // internal
+
+    protected BeanClass(String name) 
+    {
+        this.name = name;
+    }
+
+    protected void addProp(BeanProperty prop)
+    {
+        properties.add(prop);
+        prop.beanClass = this;
+    }
+
+    protected final BeanProperty addProp(String propname, DataType dataType, double size, boolean required)
+    {
+        BeanProperty prop = new BeanProperty(propname, dataType, size, required, "text", false);
+        addProp(prop);
+        return prop;
+    }
+
+    protected final BeanProperty addProp(String propname, DataType dataType, double size, boolean required, String controlType)
+    {
+        BeanProperty prop = new BeanProperty(propname, dataType, size, required, controlType, false);
+        addProp(prop);
+        return prop;
+    }
+
+    protected final BeanProperty addProp(String propname, DataType dataType, double size, boolean required, String controlType, boolean readOnly)
+    {
+        BeanProperty prop = new BeanProperty(propname, dataType, size, required, controlType, required);
+        addProp(prop);
+        return prop;
+    }
+
+    /**
+     * Sets the list of key columns.
+     * @param keyColumns the list of key columns.
+     */
+    protected void setKeyColumns(Column[] keyColumns)
+    {
+        this.keyColumns = keyColumns;
+    }
+
+    /**
+     * Sets the key to a single column
+     * @param keyColumn
+     */
+    protected final void setKeyColumn(Column keyColumn)
+    {
+        setKeyColumns(new Column[] { keyColumn });
+    }
+    
+    /**
+     * returns the name of this class
+     * @return the class name
+     */
+    public String getName() 
+    {
+        return name;
+    }
+
+    /**
+     * returns the list of properties for this class.
+     * @return the list of properties for this class.
+     */
+    public List<BeanProperty> getProperties() 
+    {
+        return properties;
+    }
+
+    /**
+     * returns the domain this class belongs to (if any)
+     * @return the domain this class belongs to or null. 
+     */
+    public BeanDomain getDomain()
+    {
+        return domain;
+    }
+
+    /**
+     * returns the list of key columns (if any)
+     * @return the list of key columns or null.
+     */
+    public Column[] getKeyColumns()
+    {
+        return keyColumns;
+    }
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanDomain.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanDomain.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanDomain.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanDomain.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,43 @@
+/*
+ * ESTEAM Software GmbH, 02.07.2008
+ */
+package org.apache.empire.data.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * BeanDomain
+ * This class defines Metadata for a domain of java classes.
+ * Create a new class for your domain metadata and derive it from BeanDomain.
+ * Then create a BeanClass subclass (preferably as a nested class) for each of your domain objects.
+ * A metadata defintion consitst primarily of the domain name and a list of classes.  
+ * @author Rainer
+ */
+public abstract class BeanDomain
+{
+    private String name;
+    private List<BeanClass> classes = new ArrayList<BeanClass>();
+    
+    protected BeanDomain(String name)
+    {
+        this.name = name;
+    }
+
+    protected void addClass(BeanClass beanClass)
+    {
+        classes.add(beanClass);
+        beanClass.domain = this;
+    }
+    
+    public String getName()
+    {
+        return name;
+    }
+    
+    public List<BeanClass> getClasses()
+    {
+        return classes;
+    }
+    
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanProperty.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanProperty.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanProperty.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanProperty.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,127 @@
+/*
+ * ESTEAM Software GmbH, 02.07.2008
+ */
+package org.apache.empire.data.bean;
+
+import org.apache.empire.commons.Options;
+import org.apache.empire.data.Column;
+import org.apache.empire.data.DataType;
+
+/**
+ * BeanObject
+ * This class defines Metadata for a single property.
+ * @author Rainer
+ */
+public class BeanProperty implements Column
+{
+    private String   name;        // required
+    private DataType dataType;    // required
+    private double   size;        // required
+    private boolean  required;    // required
+    private String   controlType; // optional (default is 'text')
+    private boolean  readOnly;    // optional
+    private String   title;       // optional
+    private Options  options;     // optional
+    
+    protected BeanClass beanClass;  // internal;
+    
+    // --- ColumnExpr interface implementation ---
+    
+    public BeanProperty(String name, DataType dataType, double size, boolean required, String controlType, boolean readOnly)
+    {
+        this.name = name;
+        this.dataType = dataType;
+        this.size = size;
+        this.required = required;
+        this.controlType = controlType;
+        this.readOnly = readOnly;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public DataType getDataType()
+    {
+        return dataType;
+    }
+
+    public Object getAttribute(String name)
+    {
+        return null;
+    }
+
+    public String getTitle()
+    {
+        if (title==null)
+            return name;
+        return title;
+    }
+
+    public Options getOptions()
+    {
+        return options;
+    }
+
+    public String getControlType()
+    {
+        return controlType;
+    }
+
+    public String getBeanPropertyName()
+    {
+        return name;
+    }
+
+    public Column getSourceColumn()
+    {
+        return this;
+    }
+
+    // --- Column interface implementation ---
+    
+    public double getSize()
+    {
+        return size;
+    }
+
+    public boolean isReadOnly()
+    {
+        return readOnly;
+    }
+
+    public boolean isRequired()
+    {
+        return required;
+    }
+
+    // --- others ---
+
+    /**
+     * returns the bean class of this property.
+     * May be NULL if BeanProperty is used 'stand alone'
+     */
+    public BeanClass getBeanClass()
+    {
+        return beanClass;
+    }
+    
+    // --- setters ---
+
+    public void setControlType(String controlType)
+    {
+        this.controlType = controlType;
+    }
+
+    public void setOptions(Options options) 
+    {
+        this.options = options;
+    }
+
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanRecordProxy.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanRecordProxy.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanRecordProxy.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/BeanRecordProxy.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,366 @@
+/*
+ * ESTEAM Software GmbH, 01.07.2008
+ */
+package org.apache.empire.data.bean;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.beanutils.BeanUtilsBean;
+import org.apache.commons.beanutils.PropertyUtilsBean;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.ErrorObject;
+import org.apache.empire.commons.Errors;
+import org.apache.empire.commons.ObjectUtils;
+import org.apache.empire.commons.Options;
+import org.apache.empire.data.Column;
+import org.apache.empire.data.ColumnExpr;
+import org.apache.empire.data.Record;
+
+
+/**
+ * BeanRecordProxy
+ * This class defines proxy that allows any POJO to behave like a record object.
+ * @author Rainer
+ */
+public class BeanRecordProxy<T> extends ErrorObject implements Record
+{
+    protected static Log log = LogFactory.getLog(BeanRecordProxy.class);
+    
+    private List<Column> columns;
+    private Column[] keyColumns;
+    private boolean[] modified;
+
+    private T data;
+
+    public BeanRecordProxy(T data, List<Column> columns, Column[] keyColumns)
+    {
+        this.data = data;
+        this.columns = columns;
+        this.keyColumns = keyColumns;
+    }
+
+    public BeanRecordProxy(List<Column> columns, Column[] keyColumns)
+    {
+        this(null, columns, keyColumns);
+    }
+
+    public BeanRecordProxy(T data, BeanClass beanClass)
+    {
+        this(data, 
+             ObjectUtils.convert(Column.class, beanClass.getProperties()), 
+             beanClass.getKeyColumns());
+    }
+
+    public BeanRecordProxy(BeanClass beanClass)
+    {
+        this(null, 
+             ObjectUtils.convert(Column.class, beanClass.getProperties()), 
+             beanClass.getKeyColumns());
+    }
+    
+    public T getBean()
+    {
+        return data;
+    }
+
+    public void setBean(T data)
+    {
+        this.data = data;
+    }
+
+    public Column getColumn(int index)
+    {
+        return columns.get(index);
+    }
+
+    public ColumnExpr getColumnExpr(int index)
+    {
+        return columns.get(index);
+    }
+
+    public Column[] getKeyColumns()
+    {
+        return keyColumns;
+    }
+
+    /**
+     * Returns the array of primary key columns.
+     * @return the array of primary key columns
+     */
+    public Object[] getKeyValues()
+    {
+        if (keyColumns==null)
+            return null;
+        // Get key values
+        Object[] key = new Object[keyColumns.length];
+        for (int i=0; i<keyColumns.length; i++)
+            key[i] = this.getValue(keyColumns[i]);
+        // the key
+        return key;
+    }
+
+    public int getFieldCount()
+    {
+        return columns.size();
+    }
+
+    public int getFieldIndex(ColumnExpr column)
+    {
+        for (int i=0; i<columns.size(); i++)
+        {
+            if (columns.get(i).equals(column))
+                return i;
+        }
+        return -1;
+    }
+
+    public int getFieldIndex(String columnName)
+    {
+        for (int i=0; i<columns.size(); i++)
+        {
+            if (columns.get(i).getName().equals(columnName))
+                return i;
+        }
+        return -1;
+    }
+
+    public Options getFieldOptions(Column column)
+    {
+        return column.getOptions();
+    }
+
+    public boolean isFieldReadOnly(Column column)
+    {
+        return ObjectUtils.contains(keyColumns, column);
+    }
+
+    public boolean isFieldVisible(Column column)
+    {
+        return true;
+    }
+
+    public boolean isModified()
+    {
+        return (modified!=null);
+    }
+
+    public boolean isNew()
+    {
+        if (!isValid())
+            return error(Errors.InvalidProperty, "bean");
+        // Record is new until all key fields have been supplied
+        clearError();
+        if (keyColumns!=null)
+        {   // Check all Key Columns
+            for (int i=0; i<keyColumns.length; i++)
+            {
+                Object value = getValue(keyColumns[i]);
+                if ((value instanceof Number) && ((Number)value).longValue()==0)
+                    return true;
+                if (ObjectUtils.isEmpty(value))
+                    return true;
+            }
+        }
+        // Not new
+        return false;
+    }
+
+    public boolean isValid()
+    {
+        return (data!=null);
+    }
+
+    public Object getValue(ColumnExpr column)
+    {
+        if (!isValid())
+        {   error(Errors.InvalidProperty, "bean");
+            return null;
+        }
+        return getBeanPropertyValue(data, column);
+    }
+
+    public Object getValue(int index)
+    {
+        return getValue(getColumn(index));
+    }
+
+    public boolean isNull(ColumnExpr column)
+    {
+        return ObjectUtils.isEmpty(getValue(column));
+    }
+
+    public boolean isNull(int index)
+    {
+        return isNull(getColumn(index));
+    }
+
+    /**
+     * sets the value of a field.
+     */
+    public boolean setValue(Column column, Object value)
+    {
+        if (!isValid())
+            return error(Errors.InvalidProperty, "bean");
+        // Track modification status
+        if (ObjectUtils.compareEqual(getValue(column), value)==false)
+        {
+            if (modified== null)
+                modified = new boolean[columns.size()]; 
+            modified[getFieldIndex(column)] = true;
+        }
+        // Set Value
+        return setBeanPropertyValue(data, column, value);
+    }
+
+    /**
+     * sets the value of a field.
+     */
+    public boolean setValue(int i, Object value)
+    {
+        return setValue(getColumn(i), value);
+    }
+
+    /**
+     * Detects whether or not a particular field has been modified.
+     */
+    public boolean wasModified(Column column)
+    {
+        int index = getFieldIndex(column);
+        if (index<0)
+            return error(Errors.ItemNotFound, column.getName());
+        clearError();
+        return (modified!=null && modified[index]);
+    }
+
+    /**
+     * clears the modification status of the object and all fields.
+     */
+    public void clearModified()
+    {
+        modified = null;
+    }
+
+    // --------------- Bean support ------------------
+
+    public boolean getBeanProperties(Object bean)
+    {
+        return getBeanProperties(bean, null);
+    }
+
+    public boolean getBeanProperties(Object bean, Collection<ColumnExpr> ignoreList)
+    {
+        // Add all Columns
+        int count = 0;
+        for (int i = 0; i < getFieldCount(); i++)
+        { // Check Property
+            Column column = getColumn(i);
+            if (column.isReadOnly())
+                continue;
+            if (ignoreList != null && ignoreList.contains(column))
+                continue; // ignore this property
+            // Get Property Name
+            setBeanPropertyValue(bean, column, getValue(i));
+        }
+        return (count > 0);
+    }
+
+    public boolean setBeanValues(Object bean, Collection<Column> ignoreList)
+    {
+        // Add all Columns
+        int count = 0;
+        for (int i = 0; i < getFieldCount(); i++)
+        { // Check Property
+            Column column = getColumn(i);
+            if (column.isReadOnly())
+                continue;
+            if (ignoreList != null && ignoreList.contains(column))
+                continue; // ignore this property
+            // Get Property Name
+            String property = column.getBeanPropertyName();
+            Object value = getBeanPropertyValue(bean, property);
+            if (value==null && this.hasError())
+                continue;
+            if (setValue(column, value))
+                count++;
+        }
+        return (count > 0);
+    }
+
+    public boolean setBeanValues(Object bean)
+    {
+        return setBeanValues(bean, null);
+    }
+
+    // --------------- private ------------------
+    
+    private Object getBeanPropertyValue(Object bean, ColumnExpr column)
+    {
+        // Check Params
+        if (column==null)
+        {   error(Errors.InvalidArg, "column");
+            return null;
+        }
+        return getBeanPropertyValue(bean, column.getBeanPropertyName()); 
+    }
+
+    private Object getBeanPropertyValue(Object bean, String property)
+    {
+        // Check Params
+        if (bean==null || property==null)
+        {   error(Errors.InvalidArg, "property");
+            return null;
+        }
+        try
+        {   // Get Property Value
+            clearError();
+            PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
+            return pub.getSimpleProperty(bean, property);
+
+        } catch (IllegalAccessException e)
+        {   log.error(bean.getClass().getName() + ": unable to get property '" + property + "'");
+            error(e);
+            return null;
+        } catch (InvocationTargetException e)
+        {   log.error(bean.getClass().getName() + ": unable to get property '" + property + "'");
+            error(e);
+            return null;
+        } catch (NoSuchMethodException e)
+        {   log.warn(bean.getClass().getName() + ": no getter available for property '" + property + "'");
+            error(e);
+            return null;
+        }
+    }
+
+    private boolean setBeanPropertyValue(Object bean, Column column, Object value)
+    {
+        // Check Params
+        if (bean==null || column==null)
+            return error(Errors.InvalidArg, "column");
+        // Get Property Name
+        String property = column.getBeanPropertyName(); 
+        try
+        {   // Get Property Value
+            clearError();
+            if (ObjectUtils.isEmpty(value))
+                value = null;
+            BeanUtils.setProperty(bean, property, value);
+            // PropertyUtilsBean pub = BeanUtilsBean.getInstance().getPropertyUtils();
+            // pub.setSimpleProperty(data, property, value);
+            return success();
+        } catch (IllegalArgumentException e) {
+            log.error(bean.getClass().getName() + ": invalid argument for property '" + property + "'");
+            return error(e);
+        } catch (IllegalAccessException e)
+        {   log.error(bean.getClass().getName() + ": unable to set property '" + property + "'");
+            return error(e);
+        } catch (InvocationTargetException e)
+        {   log.error(bean.getClass().getName() + ": unable to set property '" + property + "'");
+            return error(e);
+        }    
+    }
+    
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/package.html
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/package.html?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/package.html (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/bean/package.html Wed Aug  6 01:47:37 2008
@@ -0,0 +1,22 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+/*
+ * ESTEAM Software, 01.07.2008
+ */
+-->
+</head>
+<body>
+This package contains implmentations of Empire's data and metadata interfaces for JavaBeans of Data Tranfer Objects (DTO's).
+<p>
+Metadata is provides using the classes BeanDomain, BeanClass and BeanProperty.<br>
+It is recommended to derive a class from BeanDomain and provide a description for every contained class 
+using a nested class derived from BeanClass. Then in each BeanClass' constructor define the list of properties
+by using the add() Method, which will return a BeanProperty object. This may be stored in a final field for static 
+metadata access.
+</p><p>
+The class BeanRecordProxy allows accessing JavaBean to DTO data though the Record interface defined in the 
+org.apache.empire.data namespace.
+</p>
+</body></html>

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/package.html
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/package.html?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/package.html (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/data/package.html Wed Aug  6 01:47:37 2008
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+/*
+ * ESTEAM Software GmbH, 12.12.2007
+ */
+-->
+</head>
+<body>
+
+This package contains interfaces for data and metadata handling.
+
+</body></html>
\ No newline at end of file

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBBlobData.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBBlobData.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBBlobData.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBBlobData.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,156 @@
+/*
+ * ESTEAM Software GmbH, 11.03.2005
+ */
+package org.apache.empire.db;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This class allocates methods to store binary large objects in the database.
+ *
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public class DBBlobData
+{
+    /** Logger */
+    private static final Log log          = LogFactory.getLog(DBBlobData.class);
+
+    /**
+     * The stream associated with this object
+     */
+    private InputStream   inputStream     = null;
+
+    /**
+     * The length of the data in the <code>inputStream</code>.
+     */
+    private int           length          = 0;
+
+    /**
+     * The defaultEncoding used for the constructor.
+     *
+     * @see DBBlobData#DBBlobData(String)
+     * @see DBBlobData#setDefaultEncoding(String)
+     */
+    private static String defaultEncoding = null;
+
+    /**
+     * Constructor to pass LOB data to the setValue methods
+     * of a record, consisting of the input stream where
+     * the data can be loaded from and the length of the data.
+     *
+     * @param inputStream The stream where the data will be read from
+     * @param length The number of bytes to read from the stream
+     * @throws IllegalArgumentException If the inputStream is null
+     */
+    public DBBlobData(InputStream inputStream, int length)
+    	throws IllegalArgumentException
+    {
+        if (inputStream == null)
+        {
+            throw new IllegalArgumentException("inputStream was null");
+        }
+        this.inputStream = inputStream;
+        this.length = length;
+    }
+
+    /**
+     * Constructor for LobData from a byte array.
+     *
+     * @param data The byte array
+     * @see java.lang.String#getBytes(java.lang.String)
+     * @throws IllegalArgumentException If the text is null or the encoding is unsupported
+     */
+    public DBBlobData(byte[] data)
+    	throws IllegalArgumentException
+    {
+        if (data == null)
+        {
+            throw new IllegalArgumentException("data was null");
+        }
+        // Set Input Stream
+        this.inputStream = new ByteArrayInputStream(data);
+        this.length = data.length;
+    }
+
+    /**
+     * Constructor for LobData from a string.
+     *
+     * @param text The string to be used as data
+     * @param encoding The encoding of the string. The string must be converted to a byte array to put in the BLOB. It is
+     *            necessary to convert the string.
+     * @see java.lang.String#getBytes(java.lang.String)
+     * @throws IllegalArgumentException If the text is null or the encoding is unsupported
+     */
+    public DBBlobData(String text, String encoding)
+    	throws IllegalArgumentException
+    {
+        byte[] byteArray = null;
+        if (text == null)
+        {
+            throw new IllegalArgumentException("text was null");
+        }
+        if (encoding == null)
+        {
+            throw new IllegalArgumentException("encoding was null");
+        }
+        try
+        {
+            byteArray = text.getBytes(encoding);
+            this.inputStream = new ByteArrayInputStream(byteArray);
+            this.length = byteArray.length;
+        } catch (UnsupportedEncodingException uee)
+        {
+            log.error("Unsupported encoding " + encoding, uee);
+            throw new IllegalArgumentException("encoding " + encoding + " is unsupported");
+        }
+    }
+
+    /**
+     * Constructor for LobData from a string.
+     *
+     * @param text The string to be used as data. The encoding is set using setDefaultEncoding
+     * @see java.lang.String#getBytes(java.lang.String)
+     * @throws IllegalArgumentException If the text is null or the encoding is unsupported
+     */
+    public DBBlobData(String text)
+    	throws IllegalArgumentException
+    {
+        this(text, defaultEncoding);
+    }
+    
+    /**
+     * Returns the inputStream with the binary data for the BLOB.
+     *
+     * @return Returns the inputStream with the binary data for the BLOB
+     */
+    public InputStream getInputStream()
+    {
+        return inputStream;
+    }
+
+    /**
+     * Returns the length of the BLOB data in bytes.
+     * 
+     * @return Returns the length of the BLOB data in bytes
+     */
+    public int getLength()
+    {
+        return length;
+    }
+
+    /**
+     * Sets the defaultEncoding used in a constructor.
+     *
+     * @param defaultEncoding Set the defaultEncoding used in a constructor
+     * @see DBBlobData#DBBlobData(String)
+     */
+    public static void setDefaultEncoding(String defaultEncoding)
+    {
+        DBBlobData.defaultEncoding = defaultEncoding;
+    }
+}
\ No newline at end of file

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBClobData.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBClobData.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBClobData.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBClobData.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,96 @@
+/*
+ * ESTEAM Software GmbH, 11.03.2005
+ * 
+ */
+package org.apache.empire.db;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+/**
+ * This class allocates methods to store binary character objects in the database.
+ *
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public class DBClobData
+{
+    /**
+     * The reader associated with this object
+     */
+    private Reader     reader = null;
+
+    /**
+     * The length of the data in the <code>reader</code>
+     */
+    private int        length = 0;
+
+    /**
+     * Constructor to pass LOB data to the setValue methods of
+     * a record, consisting of the input stream where the data can be
+     * loaded from and the length of the data.
+     *
+     * @param reader The reader where the character data will be read from
+     * @param length The number of characters to read from the reader
+     * @throws IllegalArgumentException If the reader is null
+     */
+    public DBClobData(Reader reader, int length)
+                                         throws IllegalArgumentException
+    {
+        if (reader == null)
+        {
+            throw new IllegalArgumentException("reader was null");
+
+        }
+        this.reader = reader;
+        this.length = length;
+    }
+
+    /**
+     * Constructor for LobData from a string.
+     *
+     * @param text The string to be used as data
+     * @throws IllegalArgumentException If the text is null
+     */
+    public DBClobData(String text)
+                                  throws IllegalArgumentException
+    {
+        if (text == null)
+        {
+            throw new IllegalArgumentException("text was null");
+        }
+        reader = new StringReader(text);
+        this.length = text.length();
+    }
+
+    /**
+     * Set the defaultEncoding used in a constructor.
+     *
+     * @return Returns the reader with the character data for the CLOB
+     */
+    public Reader getReader()
+    {
+        return reader;
+    }
+
+    /**
+     * Returns the length of the CLOB data in characters.
+     *
+     * @return Returns the length of the CLOB data in characters
+     */
+    public int getLength()
+    {
+        return length;
+    }
+
+    /**
+     * Returns a CLOB String.
+     *
+     * @return Returns CLOB String
+     */
+    @Override
+    public String toString()
+    {
+        // WARNING: String contained in reader is NOT supplied.
+        return super.toString();
+    }
+}
\ No newline at end of file

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBCmdType.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBCmdType.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBCmdType.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBCmdType.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,16 @@
+/*
+ * ESTEAM Software GmbH
+ */
+package org.apache.empire.db;
+
+/**
+ * This enum allocates the available command types.
+ *
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public enum DBCmdType
+{
+    CREATE, //  = 0;
+    DROP,   //  = 1;
+    ALTER, //   = 2;
+}

Added: incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBCmpType.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBCmpType.java?rev=683173&view=auto
==============================================================================
--- incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBCmpType.java (added)
+++ incubator/empire-db/trunk/core/Empire-db/src/org/apache/empire/db/DBCmpType.java Wed Aug  6 01:47:37 2008
@@ -0,0 +1,46 @@
+/*
+ * ESTEAM Software GmbH
+ */
+package org.apache.empire.db;
+
+/**
+ * This enum allocates the available compare types.
+ *
+ * @author ESTEAM software <A TARGET="esteam" HREF="http://www.esteam.de">www.esteam.de </A>
+ */
+public enum DBCmpType
+{
+    NONE, //         = -1,
+    EQUAL, //        =  0,
+    NOTEQUAL, //     =  1,
+    LESSTHAN, //     =  2,
+    MOREOREQUAL, //  =  3,
+    GREATERTHAN, //  =  4,
+    LESSOREQUAL, //  =  5,
+    LIKE, //         =  6,
+    NOTLIKE, //      =  7,
+    NULL, //         =  8,
+    NOTNULL, //      =  9,
+    BETWEEN, //      = 10,
+    NOTBETWEEN, //   = 11,
+    IN, //           = 12,
+    NOTIN; //        = 13,
+    
+    public static DBCmpType getNullType(DBCmpType type)
+    {
+        switch(type)
+        {
+            case NOTEQUAL:
+            case MOREOREQUAL:
+            case LESSOREQUAL:
+            case NOTLIKE:
+            case NOTNULL:
+            case NOTBETWEEN:
+            case NOTIN:
+            // Compare with NOT null
+                 return DBCmpType.NOTNULL;
+            // Compare with null
+            default: return DBCmpType.NULL;
+        }
+    }
+}



Mime
View raw message