📄 table.java
字号:
if (col.isInheritance()) { inheritanceColumn = col; } columnList.add(col); columnsByName.put(col.getName(), col); columnsByJavaName.put(col.getJavaName(), col); col.setPosition(columnList.size()); needsTransactionInPostgres |= col.requiresTransactionInPostgres(); } /** * A utility function to create a new foreign key * from attrib and add it to this table. * * @param attrib the xml attributes * @return the created ForeignKey */ public ForeignKey addForeignKey(Attributes attrib) { ForeignKey fk = new ForeignKey(); fk.loadFromXML(attrib); addForeignKey(fk); return fk; } /** * Gets the column that subclasses of the class representing this * table can be produced from. */ public Column getChildrenColumn() { return inheritanceColumn; } /** * Get the objects that can be created from this table. */ public List getChildrenNames() { if (inheritanceColumn == null || !inheritanceColumn.isEnumeratedClasses()) { return null; } List children = inheritanceColumn.getChildren(); List names = new ArrayList(children.size()); for (int i = 0; i < children.size(); i++) { names.add(((Inheritance) children.get(i)).getClassName()); } return names; } /** * Adds the foreign key from another table that refers to this table. * * @param fk A foreign key refering to this table */ public void addReferrer(ForeignKey fk) { if (referrers == null) { referrers = new ArrayList(5); } referrers.add(fk); } /** * Get list of references to this table. * * @return A list of references to this table */ public List getReferrers() { return referrers; } /** * Set whether this table contains a foreign PK * * @param b */ public void setContainsForeignPK(boolean b) { containsForeignPK = b; } /** * Determine if this table contains a foreign PK */ public boolean getContainsForeignPK() { return containsForeignPK; } /** * A list of tables referenced by foreign keys in this table * * @return A list of tables */ public List getForeignTableNames() { if (foreignTableNames == null) { foreignTableNames = new ArrayList(1); } return foreignTableNames; } /** * Adds a new FK to the FK list and set the * parent table of the column to the current table * * @param fk A foreign key */ public void addForeignKey(ForeignKey fk) { fk.setTable (this); foreignKeys.add(fk); if (foreignTableNames == null) { foreignTableNames = new ArrayList(5); } if (foreignTableNames.contains(fk.getForeignTableName())) { foreignTableNames.add(fk.getForeignTableName()); } } /** * Return true if the column requires a transaction in Postgres */ public boolean requiresTransactionInPostgres() { return needsTransactionInPostgres; } /** * A utility function to create a new id method parameter * from attrib and add it to this table. */ public IdMethodParameter addIdMethodParameter(Attributes attrib) { IdMethodParameter imp = new IdMethodParameter(); imp.loadFromXML(attrib); addIdMethodParameter(imp); return imp; } /** * Adds a new ID method parameter to the list and sets the parent * table of the column associated with the supplied parameter to this table. * * @param imp The column to add as an ID method parameter. */ public void addIdMethodParameter(IdMethodParameter imp) { imp.setTable(this); if (idMethodParameters == null) { idMethodParameters = new ArrayList(2); } idMethodParameters.add(imp); } /** * Adds a new index to the index list and set the * parent table of the column to the current table */ public void addIndex(Index index) { index.setTable (this); indices.add(index); } /** * A utility function to create a new index * from attrib and add it to this table. */ public Index addIndex(Attributes attrib) { Index index = new Index(); index.loadFromXML(attrib); addIndex(index); return index; } /** * Adds a new Unique to the Unique list and set the * parent table of the column to the current table */ public void addUnique(Unique unique) { unique.setTable(this); unices.add(unique); } /** * A utility function to create a new Unique * from attrib and add it to this table. * * @param attrib the xml attributes */ public Unique addUnique(Attributes attrib) { Unique unique = new Unique(); unique.loadFromXML(attrib); addUnique(unique); return unique; } /** * Get the name of the Table */ public String getName() { return name; } /** * Set the name of the Table */ public void setName(String newName) { name = newName; } /** * Get the description for the Table */ public String getDescription() { return description; } /** * Set the description for the Table * * @param newDescription description for the Table */ public void setDescription(String newDescription) { description = newDescription; } /** * Get name to use in Java sources */ public String getJavaName() { if (javaName == null) { List inputs = new ArrayList(2); inputs.add(name); inputs.add(javaNamingMethod); try { javaName = NameFactory.generateName(NameFactory.JAVA_GENERATOR, inputs); } catch (EngineException e) { log.error(e, e); } } return javaName; } /** * Set name to use in Java sources */ public void setJavaName(String javaName) { this.javaName = javaName; } /** * Get the method for generating pk's */ public String getIdMethod() { if (idMethod == null) { return IDMethod.NO_ID_METHOD; } else { return idMethod; } } /** * Set the method for generating pk's */ public void setIdMethod(String idMethod) { this.idMethod = idMethod; } /** * Skip generating sql for this table (in the event it should * not be created from scratch). * @return value of skipSql. */ public boolean isSkipSql() { return (skipSql || isAlias() || isForReferenceOnly()); } /** * Set whether this table should have its creation sql generated. * @param v Value to assign to skipSql. */ public void setSkipSql(boolean v) { this.skipSql = v; } /** * JavaName of om object this entry references. * @return value of external. */ public String getAlias() { return alias; } /** * Is this table specified in the schema or is there just * a foreign key reference to it. * @return value of external. */ public boolean isAlias() { return (alias != null); } /** * Set whether this table specified in the schema or is there just * a foreign key reference to it. * @param v Value to assign to alias. */ public void setAlias(String v) { this.alias = v; } /** * Interface which objects for this table will implement * @return value of interface. */ public String getInterface() { return enterface; } /** * Interface which objects for this table will implement * @param v Value to assign to interface. */ public void setInterface(String v) { this.enterface = v; } /** * When a table is abstract, it marks the business object class that is * generated as being abstract. If you have a table called "FOO", then the * Foo BO will be <code>public abstract class Foo</code> * This helps support class hierarchies * * @return value of abstractValue. */ public boolean isAbstract() { return abstractValue; } /** * When a table is abstract, it marks the business object * class that is generated as being abstract. If you have a * table called "FOO", then the Foo BO will be * <code>public abstract class Foo</code> * This helps support class hierarchies * * @param v Value to assign to abstractValue. */ public void setAbstract(boolean v) { this.abstractValue = v; } /** * Get the value of package. * * @return value of package.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -