diff --git a/src/main/java/technology/tabula/Cell.java b/src/main/java/technology/tabula/Cell.java index 3b42b4ca..d02c8c50 100644 --- a/src/main/java/technology/tabula/Cell.java +++ b/src/main/java/technology/tabula/Cell.java @@ -27,7 +27,7 @@ public String getText(boolean useLineReturns) { return ""; } StringBuilder sb = new StringBuilder(); - Collections.sort(this.textElements, Rectangle.ILL_DEFINED_ORDER); + this.textElements.sort(Rectangle.ILL_DEFINED_ORDER); double curTop = this.textElements.get(0).getTop(); for (TextChunk tc : this.textElements) { if (useLineReturns && tc.getTop() > curTop) { diff --git a/src/main/java/technology/tabula/RectangleSpatialIndex.java b/src/main/java/technology/tabula/RectangleSpatialIndex.java index a39114a2..0e942545 100644 --- a/src/main/java/technology/tabula/RectangleSpatialIndex.java +++ b/src/main/java/technology/tabula/RectangleSpatialIndex.java @@ -32,8 +32,7 @@ public List contains(Rectangle r) { } public List intersects(Rectangle r) { - List rv = si.query(new Envelope(r.getLeft(), r.getRight(), r.getTop(), r.getBottom())); - return rv; + return si.query(new Envelope(r.getLeft(), r.getRight(), r.getTop(), r.getBottom())); } /** diff --git a/src/main/java/technology/tabula/Ruling.java b/src/main/java/technology/tabula/Ruling.java index cdab6c4f..213ce87f 100644 --- a/src/main/java/technology/tabula/Ruling.java +++ b/src/main/java/technology/tabula/Ruling.java @@ -40,9 +40,6 @@ public void normalize() { else if (Utils.within(angle, 90, 1) || Utils.within(angle, 270, 1)) { // almost vertical this.setLine(this.x1, this.y1, this.x1, this.y2); } -// else { -// System.out.println("oblique: " + this + " ("+ this.getAngle() + ")"); -// } } public boolean vertical() { @@ -231,11 +228,6 @@ public boolean equals(Object other) { return this.getP1().equals(o.getP1()) && this.getP2().equals(o.getP2()); } - @Override - public int hashCode() { - return super.hashCode(); - } - public float getTop() { return this.y1; } diff --git a/src/main/java/technology/tabula/TextChunk.java b/src/main/java/technology/tabula/TextChunk.java index 6e7722a3..9f5adbd5 100644 --- a/src/main/java/technology/tabula/TextChunk.java +++ b/src/main/java/technology/tabula/TextChunk.java @@ -209,11 +209,10 @@ public TextChunk[] splitAt(int i) { throw new IllegalArgumentException(); } - TextChunk[] rv = new TextChunk[]{ - new TextChunk(this.getTextElements().subList(0, i)), - new TextChunk(this.getTextElements().subList(i, this.getTextElements().size())) - }; - return rv; + return new TextChunk[]{ + new TextChunk(this.getTextElements().subList(0, i)), + new TextChunk(this.getTextElements().subList(i, this.getTextElements().size())) + }; } /** @@ -293,11 +292,8 @@ public boolean equals(Object obj) { return false; TextChunk other = (TextChunk) obj; if (textElements == null) { - if (other.textElements != null) - return false; - } else if (!textElements.equals(other.textElements)) - return false; - return true; + return other.textElements == null; + } else return textElements.equals(other.textElements); } public static boolean allSameChar(List textChunks) { diff --git a/src/main/java/technology/tabula/extractors/BasicExtractionAlgorithm.java b/src/main/java/technology/tabula/extractors/BasicExtractionAlgorithm.java index dcd01695..246c5342 100644 --- a/src/main/java/technology/tabula/extractors/BasicExtractionAlgorithm.java +++ b/src/main/java/technology/tabula/extractors/BasicExtractionAlgorithm.java @@ -74,7 +74,7 @@ public int compare(Ruling arg0, Ruling arg1) { @Override public int compare(TextChunk o1, TextChunk o2) { - return new java.lang.Float(o1.getLeft()).compareTo(o2.getLeft()); + return Float.compare(o1.getLeft(), o2.getLeft()); } });