Skip to content

Commit f09aef4

Browse files
committed
code cleanup
1 parent 834ad54 commit f09aef4

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

src/main/java/org/htmlunit/cyberneko/html/dom/HTMLElementImpl.java

+9-25
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int getInteger(final String value) {
113113
try {
114114
return Integer.parseInt(value);
115115
}
116-
catch (final NumberFormatException except) {
116+
catch (final NumberFormatException expected) {
117117
return 0;
118118
}
119119
}
@@ -196,16 +196,13 @@ public final NodeList getElementsByTagNameNS(final String namespaceURI, final St
196196
* @return The capitalized value
197197
*/
198198
String capitalize(final String value) {
199-
final char[] chars;
200-
int i;
201-
202-
// Convert string to charactares. Convert the first one to upper case,
199+
// Convert string to characters. Convert the first one to upper case,
203200
// the other characters to lower case, and return the converted string.
204-
chars = value.toCharArray();
205-
if (chars.length > 0) {
206-
chars[ 0 ] = Character.toUpperCase(chars[ 0 ]);
207-
for (i = 1; i < chars.length; ++i) {
208-
chars[ i ] = Character.toLowerCase(chars[ i ]);
201+
if (value.length() > 0) {
202+
final char[] chars = value.toCharArray();
203+
chars[0] = Character.toUpperCase(chars[0]);
204+
for (int i=1; i < chars.length; ++i) {
205+
chars[i] = Character.toLowerCase(chars[i]);
209206
}
210207
return String.valueOf(chars);
211208
}
@@ -221,22 +218,9 @@ String capitalize(final String value) {
221218
* @return The capitalized value
222219
*/
223220
String getCapitalized(final String attrname) {
224-
final String value;
225-
final char[] chars;
226-
int i;
227-
228-
value = getAttribute(attrname);
221+
final String value = getAttribute(attrname);
229222
if (value != null) {
230-
// Convert string to charactares. Convert the first one to upper case,
231-
// the other characters to lower case, and return the converted string.
232-
chars = value.toCharArray();
233-
if (chars.length > 0) {
234-
chars[ 0 ] = Character.toUpperCase(chars[ 0 ]);
235-
for (i = 1; i < chars.length; ++i) {
236-
chars[ i ] = Character.toLowerCase(chars[ i ]);
237-
}
238-
return String.valueOf(chars);
239-
}
223+
return capitalize(value);
240224
}
241225
return value;
242226
}

0 commit comments

Comments
 (0)