You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ha...@apache.org on 2002/08/09 10:34:42 UTC

cvs commit: xml-cocoon2/src/java/org/apache/cocoon/util JDBCTypeConversions.java

haul        2002/08/09 01:34:42

  Modified:    src/java/org/apache/cocoon/util JDBCTypeConversions.java
  Log:
    <action dev="CH" type="add">
     Added some more types understood by modular database actions.
    </action>
  
  Revision  Changes    Path
  1.3       +22 -1     xml-cocoon2/src/java/org/apache/cocoon/util/JDBCTypeConversions.java
  
  Index: JDBCTypeConversions.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/util/JDBCTypeConversions.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JDBCTypeConversions.java	2 Jul 2002 08:36:07 -0000	1.2
  +++ JDBCTypeConversions.java	9 Aug 2002 08:34:42 -0000	1.3
  @@ -70,6 +70,7 @@
   import java.text.SimpleDateFormat;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.excalibur.source.Source;
   
   
   /**
  @@ -89,6 +90,7 @@
           constants.put("ascii", new Integer(Types.CLOB));
           constants.put("big-decimal", new Integer(Types.BIGINT));
           constants.put("binary", new Integer(Types.BLOB));
  +        constants.put("boolean", new Integer(Types.BIT));
           constants.put("byte", new Integer(Types.TINYINT));
           constants.put("string", new Integer(Types.VARCHAR));
           constants.put("date", new Integer(Types.DATE));
  @@ -277,6 +279,9 @@
                   } else if (value instanceof JDBCxlobHelper) {
                       asciiStream = ((JDBCxlobHelper) value).inputStream;
                       length = ((JDBCxlobHelper) value).length;
  +                } else if (value instanceof Source) {
  +                    asciiStream = ((Source) value).getInputStream();
  +                    length = (int)((Source) value).getContentLength();
                   } else {
                       String asciiText = (String) value;
                       asciiStream = new BufferedInputStream(new ByteArrayInputStream(asciiText.getBytes()));
  @@ -395,6 +400,8 @@
               case Types.BLOB:
                   if (value instanceof JDBCxlobHelper) {
                       statement.setBinaryStream(position, ((JDBCxlobHelper)value).inputStream, ((JDBCxlobHelper)value).length);
  +                } else if (value instanceof Source){
  +                    statement.setBinaryStream(position, ((Source)value).getInputStream(), (int)((Source)value).getContentLength());
                   } else {
                       if (value instanceof File) {
                           file = (File)value;
  @@ -412,11 +419,25 @@
                   Integer i = null;
                   if (value instanceof Integer) {
                       i = (Integer) value;
  +                } else if (value instanceof java.lang.Number) {
  +                    i = new Integer(((java.lang.Number) value).intValue());
                   } else {
  -                    i = new Integer((String) value);
  +                    i = new Integer(value.toString());
                   }
                   statement.setInt(position, i.intValue());
                   break;
  +            case Types.BIT:
  +                Boolean bo = null;
  +                if (value instanceof Boolean) {
  +                    bo = (Boolean) value;
  +                } else if (value instanceof java.lang.Number) {
  +                    bo = new Boolean(((java.lang.Number) value).intValue()==1);
  +                } else {
  +                    bo = new Boolean(value.toString());
  +                }
  +                statement.setBoolean(position, bo.booleanValue());
  +                break;
  +                    
               default:
                   throw new SQLException("Impossible exception - invalid type ");
           }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org