FileDocCategorySizeDatePackage
SourcePosition.javaAPI DocAndroid 1.5 API4528Wed May 06 22:41:02 BST 2009com.android.dx.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
non-null; convenient "no information known" instance
private final com.android.dx.rop.cst.CstUtf8
sourceFile
null-ok; name of the file of origin or null if unknown
private final int
address
>= -1; the bytecode address, or -1 if that information is unknown
private final int
line
>= -1; the line number, or -1 if that information is unknown
Constructors Summary
public SourcePosition(com.android.dx.rop.cst.CstUtf8 sourceFile, int address, int line)
Constructs an instance.

param
sourceFile null-ok; name of the file of origin or null if unknown
param
address >= -1; original bytecode address or -1 if unknown
param
line >= -1; original line number or -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
>= -1; the address or -1 if unknown

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

return
>= -1; the original line number or -1 if unknown

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

return
null-ok; the source file or null if unknown

        return sourceFile;
    
public inthashCode()
{@inheritDoc}

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

param
other non-null; the instance to compare to
return
true iff the lines match

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

param
other non-null; the instance to compare to
return
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();