FileDocCategorySizeDatePackage
KVMClassName.javaAPI DocJ2ME CLDC 1.14415Wed Feb 05 15:56:02 GMT 2003runtime

KVMClassName

public class KVMClassName extends Object

Fields Summary
private String
baseName
private String
packageName
private int
depth
private char
baseType
Constructors Summary
KVMClassName(String p, String b)

 this(p, b, 0); 
KVMClassName(String p, String b, int d)

 
        this.baseName = b; 
        this.packageName = p; 
        this.depth = d;
    
KVMClassName(char p, int d)

        this.baseType = p;
        this.depth = d;
    
KVMClassName(String name)

 
        int length = name.length();
        for (depth = 0; name.charAt(depth) == '["; depth++);
        if (depth == 0) { 
            String packageName;
            int lastSlash = name.lastIndexOf('/");
            if (lastSlash == -1) { 
                this.baseName = name;
                this.packageName = null;
            } else { 
                this.packageName = name.substring(0, lastSlash);
                this.baseName = name.substring(lastSlash + 1);
            }
        } else { 
            if (depth + 1 == length) { 
                this.baseType = name.charAt(depth);
            } else { 
                String base = name.substring(depth + 1, length - 1);
                KVMClassName temp = new KVMClassName(base);
                this.baseName = temp.baseName;
                this.packageName = temp.packageName;
            }
        }
    
Methods Summary
public runtime.KVMClassNamedeltaDepth(int delta)

        if (isPrimitiveBaseType()) {
           return new KVMClassName(baseType, depth + delta);
        } else {
           return new KVMClassName(packageName, baseName, depth + delta);
        }
    
public booleanequals(java.lang.Object x)

 
        if (!(x instanceof KVMClassName)) { 
            return false;
        } 
        KVMClassName y = (KVMClassName)x;
        return  (this.depth == y.depth && this.baseType == y.baseType
                 && sameString(this.baseName, y.baseName) 
                 && sameString(this.packageName, y.packageName));
    
public java.lang.StringgetBaseName()

 return baseName; 
public chargetBaseType()

 return baseType; 
public intgetDepth()

 return depth; 
public EVMClassgetEVMClass()

 
        ClassInfo ci = ClassInfo.lookupClass(toString());
        if (ci != null) { 
            return ((EVMClass)ci.vmClass);
        } else { 
            return null;
        }
    
public java.lang.StringgetFullBaseName()

        if (depth >= 1) {
            StringBuffer b = new StringBuffer();
            for (int i = 0; i < depth; i++) {
                b.append('[");
            }
            if (isPrimitiveBaseType()) {
                b.append(baseType);
            } else {
                b.append('L").append(baseName).append(';");
            }
            return b.toString();
        } else {
            if (isPrimitiveBaseType()) {
                throw new Error("Shouldn't happen!");
            }
            return baseName;
        }
    
public java.lang.StringgetPackageName()

 return packageName; 
public inthashCode()

 
        int hash = (int)(KVMHashtable.stringHash(getFullBaseName()) + 37);
        if (packageName != null) { 
            hash += KVMHashtable.stringHash(packageName) * 3;
        } 
        return hash;
    
public booleanisArrayClass()

 return depth > 0; 
public booleanisPrimitiveBaseType()

 return baseType != 0; 
private static booleansameString(java.lang.String x, java.lang.String y)

 
        if (x == null) { 
            return y == null;
        } else { 
            return y != null && x.equals(y);
        }
    
public java.lang.StringtoString()

 
        StringBuffer b = new StringBuffer();
        if (depth >= 1) { 
            for (int i = 0; i < depth; i++) { 
                b.append('[");
            }
            if (baseType != 0) { 
                b.append(baseType);
                return b.toString();
            }
            b.append('L");
        } 
        if (packageName != null) { 
            b.append(packageName).append('/").append(baseName);
        } else { 
            b.append(baseName);
        }
        if (depth >= 1) { 
            b.append(';");
        }
        return b.toString();