diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-10-16 06:11:39 -0300 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2018-10-16 06:11:39 -0300 |
| commit | d2be5b73d7a5653ad5c8273c17284346baa6f1c7 (patch) | |
| tree | 9d3c6adb193f53588bd5d004fdf80c0381685351 /base/src/main/java/bjc/utils/ioutils/blocks/Block.java | |
| parent | 0308029629a12711b849ea7765639b9b1f9e03d2 (diff) | |
| parent | d1d01769e7c55f7f62dc01cadf420d5f63424584 (diff) | |
Merge branch 'master' of github.com:bculkin2442/bjc-utils2
Diffstat (limited to 'base/src/main/java/bjc/utils/ioutils/blocks/Block.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/ioutils/blocks/Block.java | 61 |
1 files changed, 17 insertions, 44 deletions
diff --git a/base/src/main/java/bjc/utils/ioutils/blocks/Block.java b/base/src/main/java/bjc/utils/ioutils/blocks/Block.java index 61d473c..bf0257e 100644 --- a/base/src/main/java/bjc/utils/ioutils/blocks/Block.java +++ b/base/src/main/java/bjc/utils/ioutils/blocks/Block.java @@ -27,19 +27,26 @@ public class Block { */ public final int blockNo; + /** + * The line offset number for this block. + * + * Essentially, this is the absolute number of lines that this block is + * into whatever source it came from, where as startLine and endLine are + * relative to the BlockReader this Block is from. + */ public int lineOffset; /** * Create a new block. * * @param blockNo - * The number of this block. + * The number of this block. * @param contents - * The contents of this block. + * The contents of this block. * @param startLine - * The line this block started on. + * The line this block started on. * @param endLine - * The line this block ended. + * The line this block ended. */ public Block(final int blockNo, final String contents, final int startLine, final int endLine) { this.contents = contents; @@ -49,50 +56,16 @@ public class Block { } @Override - public int hashCode() { - final int prime = 31; - int result = 1; - - result = prime * result + blockNo; - result = prime * result + (contents == null ? 0 : contents.hashCode()); - result = prime * result + endLine; - result = prime * result + startLine; - - return result; - } - - @Override - public boolean equals(final Object obj) { - if(this == obj) return true; - if(obj == null) return false; - if(!(obj instanceof Block)) return false; - - final Block other = (Block) obj; - - if(blockNo != other.blockNo) return false; - - if(contents == null) { - if(other.contents != null) return false; - } else if(!contents.equals(other.contents)) return false; - - if(endLine != other.endLine) return false; - if(startLine != other.startLine) return false; - - return true; - } - - @Override public String toString() { - if(lineOffset != -1) { + if (lineOffset != -1) { String fmt = "Block #%d (from lines %d (%d) to %d (%d)), length: %d characters"; - return String.format(fmt, blockNo, startLine + lineOffset, - startLine, endLine + lineOffset, + return String.format(fmt, blockNo, startLine + lineOffset, startLine, endLine + lineOffset, endLine + lineOffset, contents.length()); - } else { - String fmt = "Block #%d (from lines %d to %d), length: %d characters"; - - return String.format(fmt, blockNo, startLine, endLine, contents.length()); } + + String fmt = "Block #%d (from lines %d to %d), length: %d characters"; + + return String.format(fmt, blockNo, startLine, endLine, contents.length()); } } |
