abstractfield.java

来自「RESIN 3.2 最新源码」· Java 代码 · 共 1,025 行 · 第 1/2 页

JAVA
1,025
字号
    if (objThis.equals("super"))      return generateSuperGetter("this");    else      return objThis + "." + getGetterName() + "()";        /*    else if (! isAbstract())      return obj + "." + _getterMethod.getName() + "()";    else if (_getterMethod != null)      return obj + "." + _getterMethod.getName() + "()";    else      return generateSuperGetter(obj);    */  }  /**   * Generates the field setter.   *   * @param value the non-null value   */  public String generateSet(String objThis, String value)  {    if (objThis.equals("super"))      return generateSuperSetter("this", value);    else      return objThis + "." + getSetterName() + "(" + value + ")";    /*    else if (isFieldAccess()) {      // jpa/0h09      return obj + "." + getSetterName() + "(" + value + ")";    }    else if (_setterMethod != null)      return obj + "." + _setterMethod.getName() + "(" + value + ")";    else      return obj +  ""; // ejb/0gb9     */  }  /**   * Generates the field getter.   *   * @param value the non-null value   */  public void generateGet(JavaWriter out, String objThis)    throws IOException  {    out.print(generateGet(objThis));  }  /**   * Generates set code, which goes through the active calls, i.e.   * not a direct call to the underlying field.   */  public void generateSet(JavaWriter out, String obj, String value)    throws IOException  {    out.println(generateSet(obj, value) + ";");  }   /**   * Generates the super getter method implementation   */  public void generateSuperGetterMethod(JavaWriter out)    throws IOException  {    out.println();    out.println("public final " + getJavaTypeName() + " __caucho_super_get_" + getName() + "()");    out.println("{");    out.pushDepth();    if (isAbstract() || getGetterMethod() == null)      out.println("return " + getFieldName() + ";");    else if (this instanceof IdField)      out.println("return " + getGetterName() + "();");    else      out.println("return super." + getGetterName() + "();");    out.popDepth();    out.println("}");  }  /**   * Generates the super setter method implementation   */  public void generateSuperSetterMethod(JavaWriter out)    throws IOException  {    out.println();    out.println("public final void __caucho_super_set_" + getName() + "(" + getJavaTypeName() + " v)");    out.println("{");    out.pushDepth();    if (isAbstract() || getGetterMethod() == null)      out.println(getFieldName() + " = v;");    else if (getSetterMethod() == null) {    }    else if (this instanceof IdField)      out.println(getSetterMethod().getName() + "(v);");    else      out.println("super." + getSetterMethod().getName() + "(v);");    out.popDepth();    out.println("}");  }  /**   * Generates the getter method implementation.   */  public void generateGetterMethod(JavaWriter out)    throws IOException  {  }  /**   * Generates the setter method implementation.   */  public void generateSetterMethod(JavaWriter out)    throws IOException  {  }  /**   * Generates the detachment code   */  public void generateDetach(JavaWriter out)    throws IOException  {  }  //  // SQL generation  //    /**   * Generates the select clause for an entity load.   */  public String generateLoadSelect(AmberTable table, String id)  {    return null;  }  /**   * Generates the select clause.   */  public String generateSelect(String id)  {    return null;  }  /**   * Generates the JPA QL select clause.   */  public String generateJavaSelect(String id)  {    return null;  }  /**   * Generates the where clause.   */  public String generateWhere(String id)  {    return null;  }  /**   * Generates the where clause.   */  public void generateUpdate(CharBuffer sql)  {  }  /**   * Generates loading cache   */  public void generateUpdate(JavaWriter out, String maskVar, String pstmt,                             String index)    throws IOException  {    int group = getIndex() / 64;    long mask = 1L << getIndex() % 64;    out.println();    out.println("if ((" + maskVar + "_" + group + " & " + mask + "L) != 0) {");    out.pushDepth();    generateStatementSet(out, pstmt, index);    out.popDepth();    out.println("}");  }  /**   * Generates loading code   */  public boolean hasLoadGroup(int index)  {    return index == _loadGroupIndex;  }  /**   * Generates loading code   */  public int generateLoad(JavaWriter out, String rs,                          String indexVar, int index)    throws IOException  {    return index;  }  /**   * Generates loading code after the basic fields.   */  public int generatePostLoadSelect(JavaWriter out, int index)    throws IOException  {    return index;  }  /**   * Generates loading cache   */  public void generateLoadFromObject(JavaWriter out, String obj)    throws IOException  {    if (getGetterMethod() == null || getSetterMethod() == null)      return;    String getter = getGetterName();    String loadVar = "__caucho_loadMask_" + (getLoadGroupIndex() / 64);    long loadMask = (1L << getLoadGroupIndex());    out.println("if ((" + loadVar + " & " + loadMask + "L) != 0)");    out.print("  ");    out.println("  " + generateSuperSetter("this", generateGet(obj)) + ";");  }  /**   * Generates loading for a native query   */  public int generateLoadNative(JavaWriter out, int index)    throws IOException  {    return index;  }  /**   * Generates loading for a native query   */  public void generateNativeColumnNames(ArrayList<String> names)  {  }  /**   * Generates loading cache   */  public void generateUpdateFromObject(JavaWriter out, String obj)    throws IOException  {    out.println(generateSuperSetter("this", generateGet(obj)) + ";");  }  /**   * Returns the null value.   */  public String generateNull()  {    return "null";  }  /**   * Returns the field name.   */  protected String getFieldName()  {    return getName();  }  /**   * Generates the insert.   */  public final String generateInsert()  {    return null;  }  /**   * Generates the insert.   */  public void generateInsertColumns(ArrayList<String> columns)  {  }  /**   * Generates the table create.   */  public String generateCreateTableSQL(AmberPersistenceUnit manager)  {    return null;  }  /**   * Generates the set clause.   */  public void generateStatementSet(JavaWriter out, String pstmt, String index)    throws IOException  {    generateStatementSet(out, pstmt, index, "super");  }  /**   * Generates the set clause for the insert clause.   */  public void generateInsertSet(JavaWriter out, String pstmt,                                String index, String obj)    throws IOException  {    generateStatementSet(out, pstmt, index, obj);  }  /**   * Generates the set clause for the insert clause.   */  public void generateUpdateSet(JavaWriter out, String pstmt,                                String index, String obj)    throws IOException  {    generateStatementSet(out, pstmt, index, obj);  }  /**   * Generates any code needed before a persist occurs   */  public void generatePrePersist(JavaWriter out)    throws IOException  {  }  /**   * Updates the cached copy.   */  public void generateCopyUpdateObject(JavaWriter out,                                       String dst, String src,                                       int updateIndex)    throws IOException  {    // commented out: jpa/0l03    if (getIndex() == updateIndex) {      String value = generateGet(src);      out.println(generateSet(dst, value) + ";");    }  }  /**   * Updates the cached copy.   */  public void generateCopyLoadObject(JavaWriter out,                                     String dst, String src,                                     int loadIndex)    throws IOException  {    // jpa/0g0l    if (getLoadGroupIndex() != loadIndex)      return;    String value = generateGet(src);    // jpa/0l43 out.println(generateStatementSet(dst, value) + ";");    boolean isJPA = getEntitySourceType().getPersistenceUnit().isJPA();    if (isJPA	&& ! (dst.equals("cacheEntity")	      || dst.equals("super")	      || dst.equals("item"))) {      // jpa/0j5fn: merge()      out.println("if (isFullMerge)");      out.println("  " + generateSet(dst, value) + ";");      out.println("else");      out.print("  ");    }    if (! dst.equals("super"))      out.println(generateSuperSetter(dst, value) + ";");    else      out.println(generateSuperSetter("this", value) + ";");  }  /**   * Updates the cached copy.   */  public void generateMergeFrom(JavaWriter out,				String dst, String src)    throws IOException  {    // jpa/0g0l    //if (getLoadGroupIndex() != loadIndex)    //  return;    String value = generateGet(src);    // jpa/0l43    out.println(generateSet(dst, value) + ";");  }  /**   * Checks entity-relationships from an object.   */  public void generateDumpRelationships(JavaWriter out,                                        int updateIndex)    throws IOException  {  }  /**   * Generates the set clause.   */  public void generateStatementSet(JavaWriter out, String pstmt,                          String index, String obj)    throws IOException  {  }  /**   * Converts to an object.   */  public String toObject(String value)  {    return value;  }  /**   * Links to the target.   */  public void link()  {  }  /**   * Generates the pre-delete code   */  public void generatePreDelete(JavaWriter out)    throws IOException  {  }  /**   * Generates the delete foreign   */  public void generatePostDelete(JavaWriter out)    throws IOException  {  }  /**   * Generates the expire code   */  public void generateExpire(JavaWriter out)    throws IOException  {  }  /**   * Generates code for foreign entity create/delete   */  public void generateInvalidateForeign(JavaWriter out)    throws IOException  {  }  /**   * Deletes the children   */  public void childDelete(AmberConnection aConn, Serializable primaryKey)    throws SQLException  {  }  /**   * Generates code to convert to the type from the object.   */  public String generateCastFromObject(String value)  {    return value;  }  /**   * Generates code to test the equals.   */  public String generateEquals(String leftBase, String value)  {    return leftBase + ".equals(" + value + ")";  }  /**   * Creates the expression for the field.   */  public AmberExpr createExpr(QueryParser parser, PathExpr parent)  {    throw new UnsupportedOperationException(getClass().getName());  }  @Override  public String toString()  {    return getClass().getSimpleName() + "[" + getName() + "," + getSourceType() + "]";  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?