cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject cvs commit: cocoon-2.0/src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements Cell.java
Date Sat, 14 Jun 2003 00:24:07 GMT
joerg       2003/06/13 17:24:07

  Modified:    src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements
                        Cell.java
  Log:
  fixed internationalization support (encoding UTF-16), bug 15365
  
  Revision  Changes    Path
  1.2       +24 -45    cocoon-2.0/src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/Cell.java
  
  Index: Cell.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.0/src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/Cell.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Cell.java	9 Mar 2003 00:01:37 -0000	1.1
  +++ Cell.java	14 Jun 2003 00:24:07 -0000	1.2
  @@ -1,4 +1,3 @@
  -
   /*
   
    ============================================================================
  @@ -52,37 +51,36 @@
   
   package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements;
   
  -
  -
   import org.apache.poi.hssf.usermodel.HSSFCell;
   import org.apache.poi.hssf.usermodel.HSSFCellStyle;
   
   import java.io.IOException;
   
   /**
  - * internal representation of a Cell
  + * Internal representation of a Cell.
    *
    * @author Marc Johnson (marc_johnson27591@hotmail.com)
    */
  -
   // package scope
  -class Cell
  -{
  +class Cell {
  +
       private HSSFCell _cell;
   
       // original CellType value
  -    private int      _celltype;
  +    private int _celltype;
   
       /**
  -     * Constructor Cell
  +     * Constructor Cell.
  +     * Only a hack as long as the POI stuff is not maintained in the POI CVS:
  +     * Setting the encoding to UTF-16 for internationalization
  +     * (<a href="http://jakarta.apache.org/poi/javadocs/org/apache/poi/hssf/usermodel/HSSFCell.html#getEncoding()">POI
API</a>).
        *
        * @param cell
        */
  -
  -    Cell(final HSSFCell cell, final int cellType)
  -    {
  -        _cell     = cell;
  +    Cell(final HSSFCell cell, final int cellType) {
  +        _cell = cell;
           _celltype = cellType;
  +        _cell.setEncoding(HSSFCell.ENCODING_UTF_16);
       }
   
       /**
  @@ -92,36 +90,23 @@
        *
        * @exception IOException
        */
  -
  -    void setContent(final String content)
  -        throws IOException
  -    {
  -        if (_cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC)
  -        {
  -            try
  -            {
  -                if (_celltype == CellType.CELL_TYPE_FLOAT)
  -                {
  +    void setContent(final String content) throws IOException {
  +        if (_cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
  +            try {
  +                if (_celltype == CellType.CELL_TYPE_FLOAT) {
                       _cell.setCellValue(Double.parseDouble(content));
  -                }
  -                else
  -                {
  +                } else {
                       _cell.setCellValue(Integer.parseInt(content));
                   }
  +            } catch (NumberFormatException e) {
  +                throw new IOException("Invalid value for a numeric cell: " + content);
               }
  -            catch (NumberFormatException e)
  -            {
  -                throw new IOException("Invalid value for a numeric cell: "
  -                                      + content);
  -            }
  -        }
  -        else if (_cell.getCellType() == HSSFCell.CELL_TYPE_STRING)
  -        {
  +        } else if (_cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
               _cell.setCellValue(content);
           }
       }
  -    
  -    void setStyle (HSSFCellStyle style) {
  +
  +    void setStyle(HSSFCellStyle style) {
           if (style != null) {
               _cell.setCellStyle(style);
           }
  @@ -130,27 +115,21 @@
       /**
        * @return cell type
        */
  -
  -    int getCellType()
  -    {
  +    int getCellType() {
           return _cell.getCellType();
       }
   
       /**
        * @return string value
        */
  -
  -    String getStringValue()
  -    {
  +    String getStringValue() {
           return _cell.getStringCellValue();
       }
   
       /**
        * @return numeric value
        */
  -
  -    double getNumericValue()
  -    {
  +    double getNumericValue() {
           return _cell.getNumericCellValue();
       }
   }   // end package scope class Cell
  
  
  

Mime
View raw message