コード例 #1
0
 String getIdentifiableName() {
   OJClass declarer = getDeclaringClass();
   String declarername;
   if (declarer == null) {
     declarername = "*" + id;
   } else {
     declarername = declarer.getName();
   }
   return declarername + "." + getName();
 }
コード例 #2
0
  public OJField getCopy() {
    /*if (isAlterable())  return substance.getCopy();*/
    /** **************** */
    // return (FieldDeclaration) substance.clone () ;
    try {

      if (substance instanceof OJFieldByteCode) {
        java.lang.reflect.Field field = ((OJFieldByteCode) substance).getByteCode();
        OJField result = (OJField) this.clone();
        // On remplace du ByteCode par du SourceCode
        FieldDeclaration fd =
            new FieldDeclaration(
                new ModifierList(field.getModifiers()),
                TypeName.forOJClass(OJClass.forClass(field.getDeclaringClass())),
                field.getName(),
                null);
        Environment env = substance.getDeclaringClass().getEnvironment();
        result.substance = new OJFieldSourceCode(env, substance.getDeclaringClass(), fd);
        return result;
      } else if (substance instanceof OJFieldSourceCode) {
        OJField result = (OJField) this.clone();
        result.substance =
            new OJFieldSourceCode(
                ((OJFieldSourceCode) this.substance).getEnvironment(),
                this.substance.getDeclaringClass(),
                (FieldDeclaration) this.substance.getSourceCode().makeRecursiveCopy());
        return result;
      }
    } catch (Exception e) {
      System.err.println("Failed to copy " + this + ": " + e);
      e.printStackTrace();
    }
    return null;
  }
コード例 #3
0
  public String toString() {
    OJClass declarer = getDeclaringClass();
    String declarername = (declarer == null) ? "*" : declarer.getName();

    StringBuffer buf = new StringBuffer();
    String modif = getModifiers().toString();
    if (!modif.equals("")) {
      buf.append(modif);
      buf.append(" ");
    }
    buf.append(getType().getName());
    buf.append(" ");
    buf.append(declarername);
    buf.append(".");
    buf.append(getName());
    return buf.toString();
  }
コード例 #4
0
 public OJField(OJClass declarer, OJModifier modif, OJClass type, String name) {
   Environment env = declarer.getEnvironment();
   ModifierList modlist = new ModifierList();
   TypeName tname = TypeName.forOJClass(type);
   modlist.add(modif.toModifier());
   FieldDeclaration d = new FieldDeclaration(modlist, tname, name, null);
   this.substance = new OJFieldSourceCode(env, declarer, d);
 }
コード例 #5
0
 OJClass getType() {
   return OJClass.forClass(javaField.getType());
 }
コード例 #6
0
 OJClass getDeclaringClass() {
   return OJClass.forClass(javaField.getDeclaringClass());
 }