home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / prosrc.bin / ColumnMetaData.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  4.8 KB  |  201 lines

  1. /*
  2.  * @(#JDBCColumnMetaData.java
  3.  *
  4.  * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
  5.  *
  6.  */
  7.  /**
  8.  * <P> This class stores all information needed for a column
  9.  */
  10.  
  11. package symantec.itools.db.beans.jdbc;
  12.  
  13. import symantec.itools.db.beans.binding.*;
  14.  
  15. public class ColumnMetaData implements PersistentObjectMemberModel
  16. {
  17.     //if the column is in a invalid state, therefore it won't be included in a where clause
  18.     final static int VALID_STATE=1;
  19.     final static int INVALID_STATE=0;
  20.     //Constructors
  21.     /**
  22.     * Constructor. An empty constructor
  23.     */
  24.     public ColumnMetaData() {
  25.     }
  26.  
  27.     private boolean isPrimaryKey=false;
  28.     private int columnState=VALID_STATE;
  29.     public String m_ColumnName;
  30.  
  31.  
  32.  
  33.      /**
  34.      * Gets if a Column is Primary Key
  35.      * @return boolean.      .
  36.      */
  37.     public synchronized boolean isPrimaryKey() {
  38.         return isPrimaryKey;
  39.     }
  40.  
  41.      /**
  42.      * Sets if a Column is Primary Key
  43.      * @param value.
  44.      */
  45.     public synchronized void setPrimaryKey(boolean value) {
  46.          isPrimaryKey= value;
  47.     }
  48.  
  49.  
  50.     public synchronized boolean canBeIncludedInWhereClause()
  51.     {
  52.         boolean isNotBlob = !(getColumnDataType()==java.sql.Types.LONGVARBINARY ||
  53.             getColumnDataType()==java.sql.Types.LONGVARCHAR);
  54.         boolean isComparable=getIsComparable();
  55.         boolean isValid=(getColumnState()==VALID_STATE);
  56.         return isNotBlob && isComparable &&  isValid;
  57.     }
  58.  
  59.  
  60.       /**
  61.      * Gets the State of the Column
  62.      * @return int.     The state of the Column .
  63.      */
  64.     public synchronized int getColumnState() {
  65.         return columnState;
  66.     }
  67.  
  68.      /**
  69.      * Sets the  State of the Column
  70.      * @param value.     The state of the Column.
  71.      */
  72.     public synchronized void setColumnState(int value) {
  73.         if (value!= VALID_STATE || value !=INVALID_STATE){
  74.             return;
  75.         }
  76.         columnState = value;
  77.     }
  78.  
  79.       /**
  80.      * Gets the Name of the Column
  81.      * @return String.     The name of the Column .
  82.      */
  83.     public String getColumnName() {
  84.         return m_ColumnName;
  85.     }
  86.  
  87.      /**
  88.      * Gets the  Name of the Column
  89.      * @param value.     The name of the Column.
  90.      */
  91.     public void setColumnName(String value) {
  92.         m_ColumnName = value;
  93.     }
  94.  
  95.     public int m_ColumnDataType;
  96.  
  97.      /**
  98.      * Gets the DataType of the Column
  99.      * @return String.     The JDBC Data Type of the Column .
  100.      */
  101.     public int getColumnDataType() {
  102.         return m_ColumnDataType;
  103.     }
  104.  
  105.      /**
  106.      * Sets the DataType of the Column
  107.      * @param value.     The JDBC Data Type of the Column .
  108.      */
  109.     public void setColumnDataType(int value) {
  110.         m_ColumnDataType = value;
  111.     }
  112.  
  113.     public boolean m_IsComparable;
  114.  
  115.      /**
  116.      * Gets if the data type of a column is comparable with <,>,=,!=
  117.      * @return boolean.      .
  118.      */
  119.     public boolean getIsComparable() {
  120.         return m_IsComparable;
  121.     }
  122.  
  123.      /**
  124.      * Sets if the data type of a column is comparable with <,>,=,!=
  125.      * @param value.      .
  126.      */
  127.     public void setIsComparable(boolean value) {
  128.         m_IsComparable = value;
  129.     }
  130.  
  131.     public boolean m_IsAutoIncrement;
  132.  
  133.      /**
  134.      * Gets if the data type of a column is comparable with <,>,=,!=
  135.      * @return boolean.      .
  136.      */
  137.     public boolean getIsAutoIncrement() {
  138.         return m_IsAutoIncrement;
  139.     }
  140.  
  141.      /**
  142.      * Sets if the data type of a column is comparable with <,>,=,!=
  143.      * @param value.      .
  144.      */
  145.     public void setIsAutoIncrement(boolean value) {
  146.         m_IsAutoIncrement = value;
  147.     }
  148.     public boolean m_IsSigned;
  149.  
  150.      /**
  151.      * Gets if the data type of a column is comparable with <,>,=,!=
  152.      * @return boolean.      .
  153.      */
  154.     public boolean getIsSigned() {
  155.         return m_IsSigned;
  156.     }
  157.  
  158.      /**
  159.      * Sets if the data type of a column is comparable with <,>,=,!=
  160.      * @param value.      .
  161.      */
  162.     public void setIsSigned(boolean value) {
  163.         m_IsSigned = value;
  164.     }
  165.  
  166.     public boolean m_IsReadOnly;
  167.  
  168.      /**
  169.      * Gets if the data type of a column is comparable with <,>,=,!=
  170.      * @return boolean.      .
  171.      */
  172.     public boolean getIsReadOnly() {
  173.         return m_IsReadOnly;
  174.     }
  175.  
  176.      /**
  177.      * Sets if the data type of a column is comparable with <,>,=,!=
  178.      * @param value.      .
  179.      */
  180.     public void setIsReadOnly(boolean value) {
  181.         m_IsReadOnly = value;
  182.     }
  183.  
  184.     // PersistentObjectMemberModel interface methods...
  185.  
  186.     public String getName()
  187.     {
  188.         return getColumnName();
  189.     }
  190.  
  191.     public int getType()
  192.     {
  193.         return getColumnDataType();
  194.     }
  195.  
  196.     public boolean isWritable()
  197.     {
  198.         return !getIsReadOnly();
  199.     }
  200. }
  201.