1
1
/*
2
- * Copyright (c) 2007, 2023 Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2007, 2024 Oracle and/or its affiliates. All rights reserved.
3
3
*
4
4
* This program and the accompanying materials are made available under the
5
5
* terms of the Eclipse Distribution License v. 1.0, which is available at
@@ -77,7 +77,7 @@ public int parseInt(String s) {
77
77
78
78
/**
79
79
* Faster but less robust {@code String->int} conversion.
80
- *
80
+ * <p>
81
81
* Note that:
82
82
* <ol>
83
83
* <li>XML Schema allows '+', but {@link Integer#valueOf(String)} is not.
@@ -175,7 +175,7 @@ public static float _parseFloat(CharSequence _val) {
175
175
* jfloat.valueOf ignores leading and trailing whitespaces,
176
176
whereas this is not allowed in xfloat.
177
177
* jfloat.valueOf allows "float type suffix" (f, F) to be
178
- appended after float literal (e.g., 1.52e-2f), whereare
178
+ appended after float literal (e.g., 1.52e-2f), whereas
179
179
this is not the case of xfloat.
180
180
181
181
gray zone
@@ -195,7 +195,7 @@ appended after float literal (e.g., 1.52e-2f), whereare
195
195
return Float .NEGATIVE_INFINITY ;
196
196
}
197
197
198
- if (s .length () == 0
198
+ if (s .isEmpty ()
199
199
|| !isDigitOrPeriodOrSign (s .charAt (0 ))
200
200
|| !isDigitOrPeriodOrSign (s .charAt (s .length () - 1 ))) {
201
201
throw new NumberFormatException ();
@@ -241,7 +241,7 @@ public static double _parseDouble(CharSequence _val) {
241
241
return Double .NEGATIVE_INFINITY ;
242
242
}
243
243
244
- if (val .length () == 0
244
+ if (val .isEmpty ()
245
245
|| !isDigitOrPeriodOrSign (val .charAt (0 ))
246
246
|| !isDigitOrPeriodOrSign (val .charAt (val .length () - 1 ))) {
247
247
throw new NumberFormatException (val );
@@ -398,7 +398,7 @@ public static QName _parseQName(CharSequence text, NamespaceContext nsc) {
398
398
uri = nsc .getNamespaceURI (prefix );
399
399
// uri can never be null according to javadoc,
400
400
// but some users reported that there are implementations that return null.
401
- if (uri == null || uri .length () == 0 ) // crap. the NamespaceContext interface is broken.
401
+ if (uri == null || uri .isEmpty () ) // crap. the NamespaceContext interface is broken.
402
402
// error: unbound prefix
403
403
{
404
404
throw new IllegalArgumentException ("prefix " + prefix + " is not bound to a namespace" );
@@ -520,7 +520,7 @@ public String printDate(Calendar val) {
520
520
521
521
public static String _printDate (Calendar val ) {
522
522
if (null == val ) throw new IllegalArgumentException ("val is null" );
523
- return CalendarFormatter .doFormat (( new StringBuilder ( "%Y-%M-%D" ). append ( " %z")). toString () ,val );
523
+ return CalendarFormatter .doFormat ("%Y-%M-%D%z" ,val );
524
524
}
525
525
526
526
@ Override
@@ -592,7 +592,7 @@ public static String _printQName(QName val, NamespaceContext nsc) {
592
592
String prefix = nsc .getPrefix (val .getNamespaceURI ());
593
593
String localPart = val .getLocalPart ();
594
594
595
- if (prefix == null || prefix .length () == 0 ) { // be defensive
595
+ if (prefix == null || prefix .isEmpty () ) { // be defensive
596
596
qname = localPart ;
597
597
} else {
598
598
qname = prefix + ':' + localPart ;
@@ -706,7 +706,7 @@ private static int guessLength(String text) {
706
706
* base64Binary data is likely to be long, and decoding requires
707
707
* each character to be accessed twice (once for counting length, another
708
708
* for decoding.)
709
- *
709
+ * <p>
710
710
* A benchmark showed that taking {@link String} is faster, presumably
711
711
* because JIT can inline a lot of string access (with data of 1K chars, it was twice as fast)
712
712
*/
@@ -799,7 +799,7 @@ public static String _printBase64Binary(byte[] input, int offset, int len) {
799
799
800
800
/**
801
801
* Encodes a byte array into a char array by doing base64 encoding.
802
- *
802
+ * <p>
803
803
* The caller must supply a big enough buffer.
804
804
*
805
805
* @return
@@ -841,7 +841,7 @@ public static int _printBase64Binary(byte[] input, int offset, int len, char[] b
841
841
/**
842
842
* Encodes a byte array into another byte array by first doing base64 encoding
843
843
* then encoding the result in ASCII.
844
- *
844
+ * <p>
845
845
* The caller must supply a big enough buffer.
846
846
*
847
847
* @return
@@ -1050,7 +1050,7 @@ private static void formatTimeZone(Calendar cal, StringBuilder buf) {
1050
1050
offset *= -1 ;
1051
1051
}
1052
1052
1053
- offset /= 60 * 1000 ; // offset is in milli-seconds
1053
+ offset /= 60 * 1000 ; // offset is in milliseconds
1054
1054
1055
1055
formatTwoDigits (offset / 60 , buf );
1056
1056
buf .append (':' );
0 commit comments