Skip to content

Commit

Permalink
String.isEmpty() and LinkedList.peekFirst() is not part of the Java 5…
Browse files Browse the repository at this point in the history
….0 API.
  • Loading branch information
uggedal authored and jhy committed Jul 2, 2011
1 parent 5eecccd commit 40a3575
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/jsoup/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void parseEndTag() {
String tagName = tq.consumeWord();
tq.chompTo(">");

if (!tagName.isEmpty()) {
if (tagName.length() != 0) {
Tag tag = Tag.valueOf(tagName);
popStackToClose(tag);
}
Expand All @@ -117,7 +117,7 @@ private void parseStartTag() {
tq.consume("<");
String tagName = tq.consumeWord();

if (tagName.isEmpty()) { // doesn't look like a start tag after all; put < back on stack and handle as text
if (tagName.length() == 0) { // doesn't look like a start tag after all; put < back on stack and handle as text
tq.addFirst("&lt;");
parseTextNode();
return;
Expand Down Expand Up @@ -156,7 +156,7 @@ private void parseStartTag() {
// <base href>: update the base uri
if (child.tagName().equals("base")) {
String href = child.absUrl("href");
if (!href.isEmpty()) { // ignore <base target> etc
if (href.length() != 0) { // ignore <base target> etc
baseUri = href;
doc.setBaseUri(href); // set on the doc so doc.createElement(Tag) will get updated base
}
Expand Down Expand Up @@ -187,7 +187,7 @@ private Attribute parseAttribute() {
}
tq.consumeWhitespace();
}
if (!key.isEmpty())
if (key.length() != 0)
return Attribute.createFromEncoded(key, value);
else {
tq.consume(); // unknown char, keep popping so not get stuck
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jsoup/parser/TokenQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public String chompTo(String seq) {
*/
public boolean consumeWhitespace() {
boolean seen = false;
while (!queue.isEmpty() && Character.isWhitespace(queue.peekFirst())) {
while (!queue.isEmpty() && Character.isWhitespace(queue.peek())) {
consume();
seen = true;
}
Expand All @@ -206,7 +206,7 @@ public boolean consumeWhitespace() {
*/
public String consumeWord() {
StringBuilder wordAccum = new StringBuilder();
while (!queue.isEmpty() && Character.isLetterOrDigit(queue.peekFirst())) {
while (!queue.isEmpty() && Character.isLetterOrDigit(queue.peek())) {
wordAccum.append(queue.removeFirst());
}
return wordAccum.toString();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/jsoup/select/SelectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class SelectorTest {
assertEquals("div", els.get(2).tagName());
assertEquals("bar", els.get(2).attr("title"));
assertEquals("div", els.get(3).tagName());
assertTrue(els.get(3).attr("title").isEmpty()); // missing attributes come back as empty string
assertTrue(els.get(3).attr("title").length() == 0); // missing attributes come back as empty string
assertFalse(els.get(3).hasAttr("title"));
assertEquals("span", els.get(4).tagName());
}
Expand Down

0 comments on commit 40a3575

Please sign in to comment.