pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/apache/axis-axis2-java-core/commit/c7fffd08e033a3988defe56f9d93faac4095ba04

link crossorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-52276e82f63bb403.css" /> Merge branch 'AXIS2-6041' of github.com:sndurkin/axis-axis2-java-core… · apache/axis-axis2-java-core@c7fffd0 · GitHub
Skip to content

Commit c7fffd0

Browse files
author
Robert Lazarski
committed
Merge branch 'AXIS2-6041' of github.com:sndurkin/axis-axis2-java-core into sndurkin-AXIS2-6041
2 parents 4bec1cb + 4440730 commit c7fffd0

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,9 +1290,14 @@ public static List toList(Object[] array) {
12901290
* @return 0 if equal , + value if greater than , - value if less than
12911291
*/
12921292
public static int compare(int intValue, String value) {
1293-
int other = Integer.parseInt(value);
1294-
return intValue < other ? -1 : (intValue == other ? 0 : 1);
1295-
1293+
int param;
1294+
try {
1295+
NumberFormat nf = NumberFormat.getInstance();
1296+
param = nf.parse(value).intValue();
1297+
} catch (Exception e) {
1298+
throw new ObjectConversionException(e);
1299+
}
1300+
return intValue < param ? -1 : (intValue == param ? 0 : 1);
12961301
}
12971302

12981303
/**
@@ -1320,7 +1325,14 @@ public static float compare(float floatValue, String value) {
13201325
* @return 0 if equal , + value if greater than , - value if less than
13211326
*/
13221327
public static long compare(long longValue, String value) {
1323-
return longValue - Long.parseLong(value);
1328+
long param;
1329+
try {
1330+
NumberFormat nf = NumberFormat.getInstance();
1331+
param = nf.parse(value).longValue();
1332+
} catch (Exception e) {
1333+
throw new ObjectConversionException(e);
1334+
}
1335+
return longValue - param;
13241336
}
13251337

13261338
/**
@@ -1329,7 +1341,14 @@ public static long compare(long longValue, String value) {
13291341
* @return 0 if equal , + value if greater than , - value if less than
13301342
*/
13311343
public static int compare(short shortValue, String value) {
1332-
return shortValue - Short.parseShort(value);
1344+
short param;
1345+
try {
1346+
NumberFormat nf = NumberFormat.getInstance();
1347+
param = nf.parse(value).shortValue();
1348+
} catch (Exception e) {
1349+
throw new ObjectConversionException(e);
1350+
}
1351+
return shortValue - param;
13331352
}
13341353

13351354
/**

modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,4 +583,46 @@ public void testCompareBigIntegerValueIsGreaterThanOrEqualToTotalDigitsFacetRest
583583
long result = ConverterUtil.compare(value, decimalNotationString);
584584
assertThat(result).isGreaterThanOrEqualTo(0L);
585585
}
586+
587+
public void testCompareLongIsLessThanTotalDigitsFacetRestriction() {
588+
long value = 1L;
589+
String totalDigitsFromXsd = "1";
590+
String decimalNotationString = ConverterUtil.convertToStandardDecimalNotation(totalDigitsFromXsd).toPlainString();
591+
assertThat(ConverterUtil.compare(value, decimalNotationString)).isLessThan(0L);
592+
}
593+
594+
public void testCompareLongIsGreaterThanOrEqualToTotalDigitsFacetRestriction() {
595+
long value = 10L;
596+
String totalDigitsFromXsd = "1";
597+
String decimalNotationString = ConverterUtil.convertToStandardDecimalNotation(totalDigitsFromXsd).toPlainString();
598+
assertThat(ConverterUtil.compare(value, decimalNotationString)).isGreaterThanOrEqualTo(0L);
599+
}
600+
601+
public void testCompareIntIsLessThanTotalDigitsFacetRestriction() {
602+
int value = 1;
603+
String totalDigitsFromXsd = "1";
604+
String decimalNotationString = ConverterUtil.convertToStandardDecimalNotation(totalDigitsFromXsd).toPlainString();
605+
assertThat(ConverterUtil.compare(value, decimalNotationString)).isLessThan(0);
606+
}
607+
608+
public void testCompareIntIsGreaterThanOrEqualToTotalDigitsFacetRestriction() {
609+
int value = 10;
610+
String totalDigitsFromXsd = "1";
611+
String decimalNotationString = ConverterUtil.convertToStandardDecimalNotation(totalDigitsFromXsd).toPlainString();
612+
assertThat(ConverterUtil.compare(value, decimalNotationString)).isGreaterThanOrEqualTo(0);
613+
}
614+
615+
public void testCompareShortIsLessThanTotalDigitsFacetRestriction() {
616+
short value = 1;
617+
String totalDigitsFromXsd = "1";
618+
String decimalNotationString = ConverterUtil.convertToStandardDecimalNotation(totalDigitsFromXsd).toPlainString();
619+
assertThat(ConverterUtil.compare(value, decimalNotationString)).isLessThan(0);
620+
}
621+
622+
public void testCompareShortIsGreaterThanOrEqualToTotalDigitsFacetRestriction() {
623+
short value = 10;
624+
String totalDigitsFromXsd = "1";
625+
String decimalNotationString = ConverterUtil.convertToStandardDecimalNotation(totalDigitsFromXsd).toPlainString();
626+
assertThat(ConverterUtil.compare(value, decimalNotationString)).isGreaterThanOrEqualTo(0);
627+
}
586628
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy