Package com.android.ide.common.blame
Class SourcePosition
- java.lang.Object
-
- com.android.ide.common.blame.SourcePosition
-
- All Implemented Interfaces:
java.io.Serializable
@Immutable public final class SourcePosition extends java.lang.Object implements java.io.SerializableAn immutable position in a text file, used in errors to point the user to an issue.Positions that are unknown are represented by -1.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static SourcePositionUNKNOWN
-
Constructor Summary
Constructors Modifier Constructor Description SourcePosition(int lineNumber, int column, int offset)SourcePosition(int startLine, int startColumn, int startOffset, int endLine, int endColumn, int endOffset)protectedSourcePosition(SourcePosition copy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareEnd(SourcePosition other)Compares the end of this SourcePosition with another.intcompareStart(SourcePosition other)Compares the start of this SourcePosition with another.booleanequals(java.lang.Object obj)static SourcePositionfromString(java.lang.String string)Given the human-readable formatted string, returns a source position object.intgetEndColumn()intgetEndLine()intgetEndOffset()intgetStartColumn()intgetStartLine()intgetStartOffset()inthashCode()java.lang.StringtoString()Outputs positions as human-readable formatted strings.
-
-
-
Field Detail
-
UNKNOWN
@NonNull public static final SourcePosition UNKNOWN
-
-
Constructor Detail
-
SourcePosition
public SourcePosition(int startLine, int startColumn, int startOffset, int endLine, int endColumn, int endOffset)
-
SourcePosition
public SourcePosition(int lineNumber, int column, int offset)
-
SourcePosition
protected SourcePosition(SourcePosition copy)
-
-
Method Detail
-
toString
public java.lang.String toString()
Outputs positions as human-readable formatted strings. e.g.84 84-86 84:5 84:5-28 85:5-86:47
- Overrides:
toStringin classjava.lang.Object- Returns:
- a human readable position.
-
fromString
public static SourcePosition fromString(java.lang.String string)
Given the human-readable formatted string, returns a source position object.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getStartLine
public int getStartLine()
-
getStartColumn
public int getStartColumn()
-
getStartOffset
public int getStartOffset()
-
getEndLine
public int getEndLine()
-
getEndColumn
public int getEndColumn()
-
getEndOffset
public int getEndOffset()
-
compareStart
public int compareStart(@NonNull SourcePosition other)Compares the start of this SourcePosition with another.- Returns:
- 0 if they are the same, < 0 if this < other and > 0 if this > other
-
compareEnd
public int compareEnd(@NonNull SourcePosition other)Compares the end of this SourcePosition with another.- Returns:
- 0 if they are the same, < 0 if this < other and > 0 if this > other
-
-