jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java
changeset 14179 4681260d262a
parent 14171 94eb36844bd7
child 21278 ef8a3a2a72f2
equal deleted inserted replaced
14178:f2c729b81c6a 14179:4681260d262a
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
  1744             return ((Boolean)value).booleanValue();
  1744             return ((Boolean)value).booleanValue();
  1745         }
  1745         }
  1746 
  1746 
  1747         // convert to a Double and compare to zero
  1747         // convert to a Double and compare to zero
  1748         try {
  1748         try {
  1749             Double d = new Double(value.toString());
  1749             return Double.compare(Double.parseDouble(value.toString()), 0) != 0;
  1750             if (d.compareTo(new Double((double)0)) == 0) {
       
  1751                 return false;
       
  1752             } else {
       
  1753                 return true;
       
  1754             }
       
  1755         } catch (NumberFormatException ex) {
  1750         } catch (NumberFormatException ex) {
  1756             throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.boolfail").toString(),
  1751             throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.boolfail").toString(),
  1757                   new Object[] {value.toString().trim(), columnIndex}));
  1752                   new Object[] {value.toString().trim(), columnIndex}));
  1758         }
  1753         }
  1759     }
  1754     }
  4430         // sanity check.
  4425         // sanity check.
  4431         checkIndex(columnIndex);
  4426         checkIndex(columnIndex);
  4432         // make sure the cursor is on a valid row
  4427         // make sure the cursor is on a valid row
  4433         checkCursor();
  4428         checkCursor();
  4434 
  4429 
  4435         Object obj = convertNumeric(new Float(x),
  4430         Object obj = convertNumeric(Float.valueOf(x),
  4436         java.sql.Types.REAL,
  4431         java.sql.Types.REAL,
  4437         RowSetMD.getColumnType(columnIndex));
  4432         RowSetMD.getColumnType(columnIndex));
  4438 
  4433 
  4439         getCurrentRow().setColumnObject(columnIndex, obj);
  4434         getCurrentRow().setColumnObject(columnIndex, obj);
  4440     }
  4435     }
  4465     public void updateDouble(int columnIndex, double x) throws SQLException {
  4460     public void updateDouble(int columnIndex, double x) throws SQLException {
  4466         // sanity check.
  4461         // sanity check.
  4467         checkIndex(columnIndex);
  4462         checkIndex(columnIndex);
  4468         // make sure the cursor is on a valid row
  4463         // make sure the cursor is on a valid row
  4469         checkCursor();
  4464         checkCursor();
  4470         Object obj = convertNumeric(new Double(x),
  4465         Object obj = convertNumeric(Double.valueOf(x),
  4471         java.sql.Types.DOUBLE,
  4466         java.sql.Types.DOUBLE,
  4472         RowSetMD.getColumnType(columnIndex));
  4467         RowSetMD.getColumnType(columnIndex));
  4473 
  4468 
  4474         getCurrentRow().setColumnObject(columnIndex, obj);
  4469         getCurrentRow().setColumnObject(columnIndex, obj);
  4475     }
  4470     }