Skip to content

Commit 5577f1f

Browse files
committed
- Minor update in one of the Image class constructors
- Updated the equals() method in the javaxt.utils.Value class to better handle BigDecimals. - Added toString() method to the Function class. git-svn-id: svn://192.168.0.80/JavaXT/javaxt-core@791 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent e176af2 commit 5577f1f

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

src/javaxt/io/Image.java

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ public Image(String PathToImageFile){
6666
this(new java.io.File(PathToImageFile));
6767
}
6868

69-
public Image(java.io.File File){
70-
createBufferedImage(File);
69+
public Image(java.io.File file){
70+
try{ createBufferedImage(new FileInputStream(file)); }
71+
catch(Exception e){}
7172
}
7273

7374
public Image(java.io.InputStream InputStream){
@@ -547,27 +548,12 @@ public void addImage(javaxt.io.Image in, int x, int y, boolean expand){
547548
}
548549

549550

550-
//**************************************************************************
551-
//** createBufferedImage
552-
//**************************************************************************
553-
/** Used to create a BufferedImage from a File */
554-
555-
private void createBufferedImage(java.io.File file){
556-
try{
557-
createBufferedImage(new FileInputStream(file));
558-
}
559-
catch(Exception e){
560-
//printError(e);
561-
}
562-
}
563-
564-
565551
//**************************************************************************
566552
//** createBufferedImage
567553
//**************************************************************************
568554
/** Used to create a BufferedImage from a InputStream */
569555

570-
private void createBufferedImage(java.io.InputStream input){
556+
private void createBufferedImage(java.io.InputStream input) {
571557
try{
572558
//bufferedImage = ImageIO.read(input);
573559

@@ -592,7 +578,7 @@ private void createBufferedImage(java.io.InputStream input){
592578
}
593579

594580

595-
input.close();
581+
input.close();
596582
}
597583
catch(Exception e){
598584
//e.printStackTrace();

src/javaxt/sql/Function.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@ public boolean hasValues(){
4545
public Object[] getValues(){
4646
return values;
4747
}
48+
49+
public String toString(){
50+
return function;
51+
}
4852
}

src/javaxt/utils/Value.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,22 @@ public boolean equals(Object obj){
269269
else{
270270
if (value==null) return false;
271271
}
272+
273+
274+
//Special case for BigDecimal. BigDecimal objects equal only if they are
275+
//equal in value and scale. Thus 2.0 is not equal to 2.00 when compared
276+
//using the equals() method. The following code removes this ambiguity.
277+
if (!obj.equals(value)){
278+
if (obj.getClass().equals(value.getClass())){
279+
if (obj.getClass().equals(java.math.BigDecimal.class)){
280+
java.math.BigDecimal bd1 = (java.math.BigDecimal) obj;
281+
java.math.BigDecimal bd2 = (java.math.BigDecimal) value;
282+
return bd1.stripTrailingZeros().equals(bd2.stripTrailingZeros());
283+
}
284+
}
285+
}
286+
287+
272288
return obj.equals(value);
273289
}
274290

0 commit comments

Comments
 (0)