FileDocCategorySizeDatePackage
ObjectType.javaAPI DocJava SE 6 API5074Tue Jun 10 00:22:22 BST 2008com.sun.org.apache.bcel.internal.generic

ObjectType

public final class ObjectType extends ReferenceType
Denotes reference such as java.lang.String.
version
$Id: ObjectType.java,v 1.1.2.1 2005/07/31 23:45:07 jeffsuttor Exp $
author
M. Dahm

Fields Summary
private String
class_name
Constructors Summary
public ObjectType(String class_name)

param
class_name fully qualified class name, e.g. java.lang.String

    super(Constants.T_REFERENCE, "L" + class_name.replace('.", '/") + ";");
    this.class_name = class_name.replace('/", '.");
  
Methods Summary
public booleanaccessibleTo(com.sun.org.apache.bcel.internal.generic.ObjectType accessor)
Java Virtual Machine Specification edition 2, 5.4.4 Access Control

    JavaClass jc = Repository.lookupClass(class_name);

    if(jc.isPublic()) {
      return true;
    } else {
      JavaClass acc = Repository.lookupClass(accessor.class_name);
      return acc.getPackageName().equals(jc.getPackageName());
    }
  
public booleanequals(java.lang.Object type)

return
true if both type objects refer to the same class.

    return (type instanceof ObjectType)?
      ((ObjectType)type).class_name.equals(class_name) : false;
  
public java.lang.StringgetClassName()

return
name of referenced class

 return class_name; 
public inthashCode()

return
a hash code value for the object.

 return class_name.hashCode(); 
public booleanreferencesClass()
If "this" doesn't reference a class, it references an interface or a non-existant entity.

    JavaClass jc = Repository.lookupClass(class_name);
    if (jc == null)
      return false;
    else
      return jc.isClass();
  
public booleanreferencesInterface()
If "this" doesn't reference an interface, it references a class or a non-existant entity.

    JavaClass jc = Repository.lookupClass(class_name);
    if (jc == null)
      return false;
    else
      return !jc.isClass();
  
public booleansubclassOf(com.sun.org.apache.bcel.internal.generic.ObjectType superclass)

    if (this.referencesInterface() || superclass.referencesInterface())
      return false;

    return Repository.instanceOf(this.class_name, superclass.class_name);