cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/acting AbstractDatabaseAction.java
Date Wed, 07 Mar 2001 15:52:53 GMT
bloritsch    01/03/07 07:52:53

  Modified:    src/org/apache/cocoon/acting Tag: xml-cocoon2
                        AbstractDatabaseAction.java
  Log:
  Added functionality to import from a really long string, or an Ascii File.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.11  +18 -4     xml-cocoon/src/org/apache/cocoon/acting/Attic/AbstractDatabaseAction.java
  
  Index: AbstractDatabaseAction.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/acting/Attic/AbstractDatabaseAction.java,v
  retrieving revision 1.1.2.10
  retrieving revision 1.1.2.11
  diff -u -r1.1.2.10 -r1.1.2.11
  --- AbstractDatabaseAction.java	2001/03/06 21:17:23	1.1.2.10
  +++ AbstractDatabaseAction.java	2001/03/07 15:52:51	1.1.2.11
  @@ -18,7 +18,9 @@
   import java.sql.Types;
   import java.net.URL;
   import java.io.File;
  +import java.io.InputStream;
   import java.io.FileInputStream;
  +import java.io.StringBufferInputStream;
   import java.math.BigDecimal;
   import java.util.ArrayList;
   import java.util.Collections;
  @@ -166,7 +168,7 @@
    * </table>
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1.2.10 $ $Date: 2001/03/06 21:17:23 $
  + * @version CVS $Revision: 1.1.2.11 $ $Date: 2001/03/07 15:52:51 $
    */
   public abstract class AbstractDatabaseAction extends AbstractComplimentaryConfigurableAction
implements Configurable {
       protected Map files = new HashMap();
  @@ -235,9 +237,21 @@
   
           switch (typeObject.intValue()) {
               case Types.CLOB:
  -                File asciiFile = (File) request.get(attribute);
  -                FileInputStream asciiStream = new FileInputStream(asciiFile);
  -                statement.setAsciiStream(position, asciiStream, (int) asciiFile.length());
  +                Object attr = request.get(attribute);
  +                int length = -1;
  +                InputStream asciiStream = null;
  +
  +                if (attr instanceof File) {
  +                    File asciiFile = (File) attr;
  +                    asciiStream = new FileInputStream(asciiFile);
  +                    length = (int) asciiFile.length();
  +                } else {
  +                    String asciiText = (String) attr;
  +                    asciiStream = new StringBufferInputStream(asciiText);
  +                    length = asciiText.length();
  +                }
  +
  +                statement.setAsciiStream(position, asciiStream, length);
                   break;
               case Types.BIGINT:
                   statement.setBigDecimal(position, new BigDecimal((String) value));
  
  
  

Mime
View raw message