FileDocCategorySizeDatePackage
SourcePosition.javaAPI DocAndroid 5.1 API4555Thu Mar 12 22:18:30 GMT 2015com.android.dexgen.rop.code

SourcePosition

public final class SourcePosition extends Object
Information about a source position for code, which includes both a line number and original bytecode address.

Fields Summary
public static final SourcePosition
NO_INFO
{@code non-null;} convenient "no information known" instance
private final com.android.dexgen.rop.cst.CstUtf8
sourceFile
{@code null-ok;} name of the file of origin or {@code null} if unknown
private final int
address
{@code >= -1;} the bytecode address, or {@code -1} if that information is unknown
private final int
line
{@code >= -1;} the line number, or {@code -1} if that information is unknown
Constructors Summary
public SourcePosition(com.android.dexgen.rop.cst.CstUtf8 sourceFile, int address, int line)
Constructs an instance.

param
sourceFile {@code null-ok;} name of the file of origin or {@code null} if unknown
param
address {@code >= -1;} original bytecode address or {@code -1} if unknown
param
line {@code >= -1;} original line number or {@code -1} if unknown


                                                     
           
        if (address < -1) {
            throw new IllegalArgumentException("address < -1");
        }

        if (line < -1) {
            throw new IllegalArgumentException("line < -1");
        }

        this.sourceFile = sourceFile;
        this.address = address;
        this.line = line;
    
Methods Summary
public booleanequals(java.lang.Object other)
{@inheritDoc}

        if (!(other instanceof SourcePosition)) {
            return false;
        }

        if (this == other) {
            return true;
        }

        SourcePosition pos = (SourcePosition) other;

        return (address == pos.address) && sameLineAndFile(pos);
    
public intgetAddress()
Gets the original bytecode address.

return
{@code >= -1;} the address or {@code -1} if unknown

        return address;
    
public intgetLine()
Gets the original line number.

return
{@code >= -1;} the original line number or {@code -1} if unknown

        return line;
    
public com.android.dexgen.rop.cst.CstUtf8getSourceFile()
Gets the source file, if known.

return
{@code null-ok;} the source file or {@code null} if unknown

        return sourceFile;
    
public inthashCode()
{@inheritDoc}

        return sourceFile.hashCode() + address + line;
    
public booleansameLine(com.android.dexgen.rop.code.SourcePosition other)
Returns whether the lines match between this instance and the one given.

param
other {@code non-null;} the instance to compare to
return
{@code true} iff the lines match

        return (line == other.line);
    
public booleansameLineAndFile(com.android.dexgen.rop.code.SourcePosition other)
Returns whether the lines and files match between this instance and the one given.

param
other {@code non-null;} the instance to compare to
return
{@code true} iff the lines and files match

        return (line == other.line) &&
            ((sourceFile == other.sourceFile) ||
             ((sourceFile != null) && sourceFile.equals(other.sourceFile)));
    
public java.lang.StringtoString()
{@inheritDoc}

        StringBuffer sb = new StringBuffer(50);

        if (sourceFile != null) {
            sb.append(sourceFile.toHuman());
            sb.append(":");
        }

        if (line >= 0) {
            sb.append(line);
        }

        sb.append('@");

        if (address < 0) {
            sb.append("????");
        } else {
            sb.append(Hex.u2(address));
        }

        return sb.toString();