⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dictionaryfield.java

📁 自己封装的数据字典,可以配置要查询的表和字段快速得到结果
💻 JAVA
字号:
package com.gisinfo.Dictionary;


/**
 * Author: Jimmy lin
 * Date: Nov 10, 2003
 * Time: 9:56:07 PM
 */
/**
 *  DictionaryField  is a bean to discribe one element in a  dictionary object.
 */
public class DictionaryField implements Comparable{
    protected String owner = "";            //this fieldName for oracle
    protected String tableName = "";
    protected String fieldName = "";
    protected String aliasTable = "";
    protected String aliasField = "";
    protected String fieldType = "";
    protected int length;
    protected int precision;
    protected String keyType = "";
    protected String character = "";
    protected String description = "";
    protected int displayOrder = Integer.MAX_VALUE ;
    protected String visibleCode = "visible";
    protected DictionaryFieldKey key = null;
  /**
   * Constructor
   */
    public DictionaryField() {
        key = new DictionaryFieldKey();
        key.setTableName(tableName);
        key.setFieldName(fieldName);
    }
    /**
     * Contructor
     * @param tableName   table name
     * @param fieldName    field name
     */
    public DictionaryField(String tableName, String fieldName) {
        this.tableName = tableName;
        this.fieldName = fieldName;
        key = new DictionaryFieldKey();
        key.setTableName(tableName);
        key.setFieldName(fieldName);
    }
    /**
     * Contructor
     * @param key   a DictionaryKey contains tablename and fieldname
     */
    public DictionaryField(DictionaryFieldKey key) {
        this.key = key;
        this.fieldName = key.getFieldName();
        this.tableName = key.getTableName();
    }
    /**
     * Get owner of table,  owner is different database
     * @return      owner
     */
    public String getOwner() {
        return owner;
    }
    /**
     *Set owner of table
     * @param owner
     */
    public void setOwner(String owner) {
        this.owner = owner;
    }
   /**
    * Get real table name  in database
    * @return   real table name
    */
    public String getTableName() {
        return tableName;
    }
   /**
    * Set table name
    * @param tableName
    */
    public void setTableName(String tableName) {
        this.tableName = tableName;
        key.setTableName(tableName);
    }
    /**
     * Get return real field name of table
     * @return    real field name
     */
    public String getFieldName() {
        return fieldName;
    }
  /**
   * Set real field name of table
   * @param fieldName
   */
    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
        key.setFieldName(fieldName);
    }
   /**
    * Get table alias  for display.
    * @return  table alias
    */
    public String getAliasTable() {
        return aliasTable;
    }
 /**
  * Set table alias .
  * @param aliasTable
  */
    public void setAliasTable(String aliasTable) {
        this.aliasTable = aliasTable;
    }
    /**
     * Get field alias for display
     * @return    field alias
     */
    public String getAliasField() {
        return aliasField;
    }
    /**
     * Set table alias
     * @param aliasField
     */
    public void setAliasField(String aliasField) {
        this.aliasField = aliasField;
    }
   /**
    * Get field type , commonly  data type, "String", "Integer"."Numeric"
    * @return   field type
    */
    public String getFieldType() {
        return fieldType;
    }
 /**
  * Set field type
  * @param fieldType
  */
    public void setFieldType(String fieldType) {
        this.fieldType = fieldType;
    }
    /**
     * Get field  length
     * @return   field length
     */
    public int getLength() {
        return length;
    }
/**
 * Set field length
 * @param length
 */
    public void setLength(int length) {
        this.length = length;
    }
    /**
     * Get precision
     * @return   precision
     */
    public int getPrecision() {
        return precision;
    }
   /**
    * Set precision
    * @param precision
    */
    public void setPrecision(int precision) {
        this.precision = precision;
    }
   /**
    * Get key type , commonly  "commonbox", "list" etc.
    * @return   key type
    */
    public String getKeyType() {
        return keyType;
    }
 /**
  * Set key type
  * @param keyType
  */
    public void setKeyType(String keyType) {
        this.keyType = keyType;
    }
   /**
    * Get character
    * @return    character
    */
    public String getCharacter() {
        return character;
    }
  /**
   * Set character
   * @param character
   */
    public void setCharacter(String character) {
        this.character = character;
    }
   /**
    * Get discription of  field
    * @return     discription
    */
    public String getDescription() {
        return description;
    }
  /**
   * Set dicription
   * @param description
   */
    public void setDescription(String description) {
        this.description = description;
    }
   /**
    * Get key wich contain table name and field name
    * @return    dictionary key
    */
    public DictionaryFieldKey getKey() {
        return key;
    }
    /**
     * Set key
     * @param key
     */
    public void setKey(DictionaryFieldKey key) {
        this.key = key;
    }
   /**
    * Get  priority of  field when display
    * @return   priority
    */
    public int getDisplayOrder() {
        return displayOrder;
    }
    /**
     * Set priority
     * @param displayOrder
     */
    public void setDisplayOrder(int displayOrder) {
        this.displayOrder = displayOrder;
    }
    /**
     *  Get visible expression
     * @return    visible expression
     */
    public String getVisibleCode() {
        return visibleCode;
    }
    /**
     *   Set visible expression
     * @param visibleCode
     */
    public void setVisibleCode(String visibleCode) {
        this.visibleCode = visibleCode;
    }
    /**
     * Judge if field is  Date type
     * @return  true or false
     */
    public boolean isDate(){
        return fieldType.equalsIgnoreCase("date");
    }
    /**
     * Judge if field is visible
     * @return  true or false
     */
    public boolean isVisible(){
         String[] invisibleValues = DictionaryProperties.getInvisibleValues();
         if (invisibleValues == null || invisibleValues.length ==0) return true;
         for (int i = 0; i < invisibleValues.length ; i ++){
                if (this.visibleCode .equalsIgnoreCase(invisibleValues[i])) return false;
         }
         return true;
    }
    /**
     * Judge if field is Integer type
     * @return   true or false
     */
    public boolean isInteger(){
         return fieldType.equalsIgnoreCase("integer") ||
                    fieldType.equalsIgnoreCase("number") ||
                    fieldType.equalsIgnoreCase("DECIMAL")||
                    fieldType.equalsIgnoreCase("SMALLINT") ;
    }
    /**
     * Judge if field is String type
     * @return   true or false
     */
    public boolean isString(){
          return ((fieldType.equalsIgnoreCase("varchar")) ||
                      (fieldType.equalsIgnoreCase("char"))||
                  (fieldType.equalsIgnoreCase("string")))||
                  fieldType.equalsIgnoreCase("CHARACTER") ||
                  fieldType.equalsIgnoreCase("character") ||
                  fieldType.equalsIgnoreCase("MEMO") ||
                  fieldType.equalsIgnoreCase("varchar2") ;
    }
    /**
     * Judge if field is Float type
     * @return  true or false
     */
    public boolean isFloat(){
        return (fieldType.equalsIgnoreCase("float") ||
                     fieldType.equalsIgnoreCase("float"));
    }
    /**
     * Judge if field is Double type
     * @return  true or false
     */
    public boolean isDouble(){
        return fieldType.equalsIgnoreCase("double");
    }
    /**
     * Compare two fields
     * @param obj
     * @return   true or false
     */
    public boolean equals(Object obj) {
        if (this == obj)
           return true;
        if (obj instanceof DictionaryField){
            DictionaryField field = (DictionaryField)obj;
            return this.key .equals(field.getKey());
        }
        return false;
    }
    /**
     * Comare two fields
     * @param o
     * @return   a negative integer, zero, or a positive integer as this object
     *		is less than, equal to, or greater than the specified object.
     */
    public int compareTo(Object o) {
      if (!(o instanceof DictionaryField)) {
            try {
                throw new Exception("The input parameter isn't DictionaryField object!\n");
            } catch (Exception e) {
                e.printStackTrace();
               return this.toString() .compareTo(o.toString() ); //use  toString to compare
            }
        }
        DictionaryField anotherField = (DictionaryField)o;
        return new Integer(this.displayOrder).compareTo(new Integer(anotherField.displayOrder ));
    }

    public String toString() {
        return this.aliasField ;
    }
}

⌨️ 快捷键说明

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