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 / DBTstamp.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  27.3 KB  |  754 lines

  1. /*
  2.  * @(#DBTstamp.java
  3.  *
  4.  * Copyright (c) 1997 Symantec Corporation. All Rights Reserved.
  5.  *
  6.  */
  7.  
  8. package symantec.itools.db.awt;
  9.  
  10. import java.sql.*;
  11. import symantec.itools.db.pro.*;
  12. import symantec.itools.awt.*;
  13. import java.awt.*;
  14. import java.awt.event.*;
  15. import symantec.itools.db.beans.binding.Name;
  16. import symantec.itools.db.beans.binding.Mediator;
  17. /**
  18.  * A box in which a date or timestamp can be read or entered using any common
  19.  * date or time format.
  20.  * This component is available in Visual CafΘ Database Developer Edition only.
  21.  * Use DBTstamp to:
  22.  * <UL>
  23.  * <LI>Edit a date or a timestamp.
  24.  * <LI>Display a date or timestamp in a pre-defined display format.
  25.  * </UL>
  26.  * <p>
  27.  * This component can be "bound" to a projection within a relation view
  28.  * so that it automatically gets and sets the values in that relation.
  29.  */
  30. public class DBTstamp extends symantec.itools.db.awt.Tstamp implements  ProjLink,FocusListener,ActionListener
  31. {
  32.  
  33.     private ProjBinder m_ProjBinder = null;
  34.     private String m_ScreenData = "";
  35.     private String m_BinderData = null;
  36.     private boolean m_BinderDetermines = false;
  37.     private String m_ProjectionName="";
  38.     private RelationView    m_RelationView = null;
  39.     private boolean isSet=false;
  40.  
  41.     /**
  42.      * A constant indicating how an empty string will be set when updating
  43.      * data on the dbANYWHERE server.
  44.      */
  45.     public final static int Default    =  0;
  46.     /**
  47.      * A constant indicating how an empty string will be set when updating
  48.      * data on the dbANYWHERE server.
  49.      */
  50.     public final static int Null       =  1;
  51.     /**
  52.      * A constant indicating how an empty string will be set when updating
  53.      * data on the dbANYWHERE server.
  54.      */
  55.     public final static int Blank      =  2;
  56.  
  57.     /**
  58.      * A constant indicating that the value should be displayed/entered as a
  59.      * time.
  60.      */
  61.     public static  String Time="Time";
  62.     /**
  63.      * A constant indicating that the value should be displayed/entered as a
  64.      * timestamp.
  65.      */
  66.     public static  String Timestamp="Timestamp";
  67.     /**
  68.      * A constant indicating that the value should be displayed/entered as a
  69.      * date.
  70.      */
  71.     public static  String Date="Date";
  72.  
  73.  
  74.     private String DefaultDateDisplayFormat=        "D* M* D%TH, Y*";
  75.     private String DefauldDateEntryFormat=          "MDY";
  76.     private String DefaultDateDBDisplayFormat=      "Y*-MM-DD";
  77.     private String DefaultDateDBEntryFormat=        "YMD";
  78.  
  79.     private String DefaultTimeStampDisplayFormat=   "D* M* D%TH, Y* H%:m%:s%,n3 AM";
  80.     private String DefauldTimeStampEntryFormat=     "MDYhmsn";
  81.     private String DefaultTimeStampDBDisplayFormat= "Y*-MM-DD-hh-mm-ss-n9";
  82.     private String DefaultTimeStampDBEntryFormat=   "YMDhmsn";
  83.  
  84.     private String DefaultTimeDisplayFormat=        "H%:m%:s% AM";
  85.     private String DefauldTimeEntryFormat=          "hms";
  86.     private String DefaultTimeDBDisplayFormat=      "hh-mm-ss";
  87.     private String DefaultTimeDBEntryFormat=        "hmsn";
  88.  
  89.     private String DataBaseDisplayFormat=DefaultTimeStampDBDisplayFormat;
  90.     private String DataBaseEntryFormat=DefaultTimeStampDBEntryFormat;
  91.     private String TYPE="";
  92.  
  93.     /**
  94.      * The mediator that binds this component to a data source.
  95.      */
  96.     public Mediator m_Mediator;
  97.     private String[] m_GetMethods={"getData()"};
  98.     private String[] m_SetMethods={"setData(Value)"};
  99.  
  100.     /**
  101.      * Constructs a default DBTstamp.
  102.      */
  103.     public DBTstamp()
  104.     {
  105.  
  106.         super();
  107.  
  108.         m_Mediator=new Mediator();
  109.         m_Mediator.setOutput(this);
  110.         m_Mediator.setSetMethods(m_SetMethods);
  111.         m_Mediator.setGetMethods(m_GetMethods);
  112.         this.addFocusListener(this);
  113.         this.addActionListener(this);
  114.         m_BinderData = new String();
  115.         m_ScreenData = new String();
  116.     }
  117.     /**
  118.      * Sets the format for displaying database timestamp values.
  119.      * @param form the display format
  120.      * @see #getDataBaseDisplayFormat
  121.      * @see symantec.itools.db.awt.Tstamp#getDisplayFormat
  122.      */
  123.     public void setDataBaseDisplayFormat(String format)
  124.     {
  125.         DataBaseDisplayFormat=format;
  126.     }
  127.     /**
  128.      * Gets the current format for displaying database timestamp values.
  129.      * @return the display format
  130.      * @see #setDataBaseDisplayFormat
  131.      * @see symantec.itools.db.awt.Tstamp#getDisplayFormat
  132.      */
  133.     public String getDataBaseDisplayFormat()
  134.     {
  135.         return(DataBaseDisplayFormat);
  136.     }
  137.     /**
  138.      * Sets the format for entering database timestamp values.
  139.      * @param form the entry format
  140.      * @see #getDataBaseEntryFormat
  141.      * @see symantec.itools.db.awt.Tstamp#getEntryFormat
  142.      */
  143.     public void setDataBaseEntryFormat(String format)
  144.     {
  145.         DataBaseEntryFormat=format;
  146.     }
  147.     /**
  148.      * Gets the current format for entering database timestamp values.
  149.      * @return the entry format
  150.      * @see #setDataBaseEntryFormat
  151.      * @see symantec.itools.db.awt.Tstamp#getEntryFormat
  152.      */
  153.     public String getDataBaseEntryFormat()
  154.     {
  155.         return(DataBaseEntryFormat);
  156.     }
  157.     /**
  158.      * Gets the current datatype being displayed and/or entered.
  159.      * @return the datatype. One of: Time, Timestamp, or Date
  160.      * @see #Time
  161.      * @see #Timestamp
  162.      * @see #Date
  163.      */
  164.     public String getType()
  165.     {
  166.         return(TYPE);
  167.     }
  168.  
  169.     /**
  170.      * Sets the datatype being displayed and/or entered.
  171.      * This changes the entry and display formats appropriately.
  172.      * @param type the datatype. One of: Time, Timestamp, or Date
  173.      * @see #Time
  174.      * @see #Timestamp
  175.      * @see #Date
  176.      */
  177.  
  178.     public void setType(String type)
  179.     {
  180.  
  181.         TYPE=type;
  182.         if(type.equals(Date)){
  183.  
  184.             if(m_DisplayFormat.equals(""))this.setDisplayFormat(DefaultDateDisplayFormat);
  185.             if(m_EntryFormat.equals(""))this.setEntryFormat(DefauldDateEntryFormat);
  186.             setDataBaseDisplayFormat(DefaultDateDBDisplayFormat);
  187.             setDataBaseEntryFormat(DefaultDateDBEntryFormat);
  188.         }
  189.  
  190.         else if(type.equals(Time)){
  191.             if(m_DisplayFormat.equals(""))this.setDisplayFormat(DefaultTimeDisplayFormat);
  192.             if(m_EntryFormat.equals(""))this.setEntryFormat(DefauldTimeEntryFormat);
  193.             setDataBaseDisplayFormat(DefaultTimeDBDisplayFormat);
  194.             setDataBaseEntryFormat(DefaultTimeDBEntryFormat);
  195.         }
  196.  
  197.         else if(type.equals(Timestamp)){
  198.             if(m_DisplayFormat.equals(""))this.setDisplayFormat(DefaultTimeStampDisplayFormat);
  199.             if(m_EntryFormat.equals(""))this.setEntryFormat(DefauldTimeStampEntryFormat);
  200.             setDataBaseDisplayFormat(DefaultTimeStampDBDisplayFormat);
  201.             setDataBaseEntryFormat(DefaultTimeStampDBEntryFormat);
  202.         }
  203.     }
  204.  
  205.     /**
  206.      * Called when this component has been bound to a projection within an
  207.      * RelationView.  This component notes the ProjBinder object so that it
  208.      * may notify the dbANYWHERE server of data changes made.
  209.      * <p>
  210.      * This is a method in the ProjLink interface.
  211.      *
  212.      * @param binder used to notify the dbANYWHERE server of any data changes
  213.      * that are to be persistant.
  214.      * This object is a window into the particular column data to which this
  215.      * component has been bound
  216.      *
  217.      * @see symantec.itools.db.pro.ProjLink#init
  218.      */
  219.     public void init(ProjBinder binder)
  220.     {
  221.         m_ProjBinder = binder;
  222.         setEditable(m_ProjBinder);
  223.     }
  224.  
  225.     /**
  226.      * Binds this component to a given projection within the specified
  227.      * relation view.
  228.      *
  229.      * @param relView the relation view to bind with
  230.      * @param projection the projection in relView to bind with
  231.      * @exception SQLException
  232.      * if a SQL database access error occurred
  233.      */
  234.     public synchronized void setBinding(RelationView relView, String projection)
  235.     {
  236.  
  237.         m_RelationView = relView;
  238.         m_ProjectionName = projection;
  239.         String dataBindingName = "";
  240.         try {
  241.             dataBindingName = relView.getName();
  242.         }
  243.         catch (java.sql.SQLException e) {
  244.             raiseException(e);
  245.         }
  246.         dataBindingName += "@" + projection;
  247.         setDataBinding(dataBindingName);
  248.         if (java.beans.Beans.isDesignTime()) {
  249.             return;
  250.         }
  251.  
  252.         if (m_RelationView == null || m_ProjectionName == null) {
  253.             return; // nothing to do
  254.         }
  255.  
  256.         if (m_ProjectionName.equals("")) {
  257.             return; //  nothing to do
  258.         }
  259.  
  260.         try {
  261.             Name name = new Name(m_RelationView.getName(),m_ProjectionName);
  262.             m_Mediator.setDataBinding(name.getFullName());
  263.         }
  264.         catch (java.sql.SQLException e) {
  265.             raiseException(e);
  266.         }
  267.  
  268.     }
  269.  
  270.  
  271.  
  272.     synchronized String getRelationViewName() {
  273.         if (m_RelationView != null) {
  274.             try {
  275.                 return m_RelationView.getName();
  276.             }
  277.             catch (Exception ex) {
  278.                 raiseException(ex);
  279.             }
  280.         }
  281.         return "null";
  282.     }
  283.     /**
  284.      * Specifies how an empty string will be set when updating data on
  285.      * the dbANYWHERE server.
  286.      *
  287.      * @param blank one of Default, Null, or Blank
  288.      *
  289.      * @see #Default
  290.      * @see #Null
  291.      * @see #Blank
  292.      * @see symantec.itools.db.pro.ProjBinder#setValueFromString(java.lang.String, int, int)
  293.      */
  294.  
  295.  
  296.     //*************************************************************************//
  297.     //                                                                         //
  298.     // FUNCTION: notifyDataChange                                              //
  299.     //                                                                         //
  300.     //  PURPOSE:                                                               //
  301.     //    Implement the ProjLink interface function, notifyDataChange().       //
  302.     //    This function is called when the projection's data changes at        //
  303.     //    the database.                                                        //
  304.     //                                                                         //
  305.     // PARAMETERS:                                                             //
  306.     //  @param binder The ProjBinder binder object which this component can use//
  307.     //                to get or change data at the database server.            //
  308.     //                                                                         //
  309.     //  RETURNS:                                                               //
  310.     //                                                                         //
  311.     // COMMENTS:                                                               //
  312.     //                                                                         //
  313.     //  Step 1: set m_ProjBinder equal to binder object                        //
  314.     //  Step 2: synchronize m_BinderData with binder object                    //
  315.     //  Step 3: synchronize m_ScreenData with current screen                   //
  316.     //  Step 4: if the two are different then                                  //
  317.     //       - set m_ScreenData equal to m_BinderData to avoid recursion       //
  318.     //       - call setText to update screen                                   //
  319.     //  Step 5: enable or disable editing based on binder                      //
  320.     //                                                                         //
  321.     //*************************************************************************//
  322.  
  323.     /**
  324.      * This method is called to update the value of this dbAWARE component.
  325.      * It is called when the dbANYWHERE server has detected a data change made
  326.      * within the scope of the current row of the RelationView bound to this
  327.      * component.
  328.      * The ProjBinder object passed into the notification is used to get the
  329.      * new data value.
  330.      * <p>
  331.      * This is a method in the ProjLink interface.
  332.      *
  333.      * @param binder used to get the current value from the dbANYWHERE server.
  334.      * This object is a window into the particular column data to which this
  335.      * component has been bound
  336.      *
  337.      * @see symantec.itools.db.pro.ProjLink#notifyDataChange
  338.      */
  339.     public void notifyDataChange(ProjBinder binder)
  340.     {
  341.  
  342.     }
  343.  
  344.     //*************************************************************************//
  345.     //                                                                         //
  346.     // FUNCTION: notifyInputChange                                             //
  347.     //                                                                         //
  348.     //  PURPOSE: Handle any event that causes us to send data to binder object //
  349.     //                                                                         //
  350.     //  PARAMETERS:                                                            //
  351.     //                                                                         //
  352.     //  RETURNS:                                                               //
  353.     //                                                                         //
  354.     // COMMENTS:                                                               //
  355.     //                                                                         //
  356.     //                                                                         //
  357.     //  Step 1: synchronize m_ScreenData with current screen                   //
  358.     //  Step 2: if m_ScreenData differs from m_BinderData then...              //
  359.     //       - set m_BinderData equal to m_ScreenData to avoid recursion       //
  360.     //       - call m_Binder.setString to update binder                        //
  361.     //                                                                         //
  362.     //*************************************************************************//
  363.  
  364.     boolean notifyInputChanged(String input)
  365.     {
  366.  
  367.         return true;
  368.     }
  369.  
  370.     //*************************************************************************//
  371.     //                                                                         //
  372.     // FUNCTION: notifySetData                                                 //
  373.     //                                                                         //
  374.     //  PURPOSE: Send data to binder                                           //
  375.     //                                                                         //
  376.     //  PARAMETERS:                                                            //
  377.     //  @param binder The ProjBinder binder object which this component can use//
  378.     //                to change data at the database server.                   //
  379.     //                                                                         //
  380.     //  RETURNS:                                                               //
  381.     //                                                                         //
  382.     // COMMENTS:                                                               //
  383.     //                                                                         //
  384.     //                                                                         //
  385.     //*************************************************************************//
  386.  
  387.     /**
  388.      * This method is called to ensure the value of this dbAWARE component is
  389.      * not lost.
  390.      * It is called when the dbANYWHERE server has detected a data change made
  391.      * within the current row of the RelationView bound to this component.
  392.      * The ProjBinder object passed into the notification is used to set the
  393.      * new data value.
  394.      * <p>
  395.      * This is a method in the ProjLink interface.
  396.      *
  397.      * @param binder used to notify the dbANYWHERE server of any data changes
  398.      * that are to be persistant.
  399.      * This object is a window into the particular column data to which this
  400.      * component has been bound
  401.      * @return   true if success or false if failure.
  402.      * @exception SQLException
  403.      * if a SQL database access error occurred
  404.      * @see symantec.itools.db.pro.ProjLink#notifySetData
  405.      */
  406.     public boolean notifySetData(ProjBinder binder) throws SQLException
  407.     {
  408.         return ( notifyInputChanged(getText()) );
  409.     }
  410.  
  411.     //*************************************************************************//
  412.     //                                                                         //
  413.     // FUNCTION: setEditable                                                   //
  414.     //                                                                         //
  415.     //  PURPOSE: Enable or disable input                                       //
  416.     //                                                                         //
  417.     //  PARAMETERS:                                                            //
  418.     //  @param binder The ProjBinder binder object which this component can use//
  419.     //                to change data at the database server.                   //
  420.     //                                                                         //
  421.     //  RETURNS:                                                               //
  422.     //                                                                         //
  423.     // COMMENTS:                                                               //
  424.     //                                                                         //
  425.     //*************************************************************************//
  426.  
  427.     void setEditable(ProjBinder binder)
  428.     {
  429.         //Disable input if binder is not writeable
  430.         boolean isWritable = false;
  431.  
  432.         try
  433.         {
  434.             if (binder != null)
  435.             {
  436.                 RelationView rv = binder.getRelationView();
  437.                 if (rv != null && (rv.getCurrentRecordState()
  438.                                          != Record.RECSTATE_INVALID))
  439.                 {
  440.                     isWritable = binder.isWritable();
  441.                 }
  442.             }
  443.         }
  444.         catch (SQLException Ex)
  445.         {
  446.             raiseException(Ex);
  447.         }
  448.         super.setEditable(isWritable);
  449.     }
  450.  
  451.     //*************************************************************************//
  452.     //                                                                         //
  453.     // FUNCTION: setEditable                                                   //
  454.     //                                                                         //
  455.     //  PURPOSE: Set editable attribute                                        //
  456.     //                                                                         //
  457.     //  PARAMETERS:                                                            //
  458.     //                                                                         //
  459.     //  RETURNS:                                                               //
  460.     //                                                                         //
  461.     // COMMENTS:                                                               //
  462.     //                                                                         //
  463.     //*************************************************************************//
  464.  
  465.     /**
  466.      * Conditionally sets the contents of this component to user-editable.
  467.      */
  468.     public void setEditable(boolean value)
  469.     {
  470.         m_BinderDetermines = value;
  471.         super.setEditable(value);
  472.     }
  473.  
  474.     /**
  475.      * Sets the display and input format.
  476.      * @param dispfmt the new display and entry format
  477.      * @see symantec.itools.db.awt.Tstamp#getDisplayFormat
  478.      */
  479.     public void setDisplayFormat(String dispFmt)
  480.     {
  481.         super.setDisplayFormat(dispFmt);
  482.         notifyDataChange(m_ProjBinder);
  483.     }
  484.  
  485.     /**
  486.      * Processes events for this component.
  487.      * This is a standard Java AWT method which gets called by the AWT
  488.      * to handle this component's events. The default handler for
  489.      * components dispatches to one of the following methods as needed:
  490.      * action(), gotFocus(), lostFocus(), keyDown(), keyUp(), mouseEnter(),
  491.      * mouseExit(), mouseMove(), mouseDrag(), mouseDown(), or mouseUp().
  492.      *
  493.      * @param event the event to handle
  494.      * @return true if the event was handled and no further action is needed,
  495.      * false to pass the event to this component's parent
  496.      * @see java.awt.Component#action
  497.      * @see java.awt.Component#gotFocus
  498.      * @see java.awt.Component#lostFocus
  499.      * @see java.awt.Component#keyDown
  500.      * @see java.awt.Component#keyUp
  501.      * @see java.awt.Component#mouseEnter
  502.      * @see java.awt.Component#mouseExit
  503.      * @see java.awt.Component#mouseMove
  504.      * @see java.awt.Component#mouseDrag
  505.      * @see java.awt.Component#mouseDown
  506.      * @see java.awt.Component#mouseUp
  507.      */
  508.  
  509.     public void actionPerformed(ActionEvent e)
  510.     {
  511.         if(getText().trim().length()<3)
  512.         {
  513.             if(m_BinderData.length()==0)
  514.             setTstamp(new java.util.Date());
  515.         }
  516.         else
  517.         {
  518.             setTstamp(getText(),getEntryFormat());
  519.         }
  520.         printTstamp();
  521.         isSet=true;
  522.      }
  523.  
  524.     /**
  525.      * This method commits the component's data to its data source.
  526.      * <p>
  527.      * A method of the FocusListener interface.
  528.      * @param e the event
  529.      */
  530.     public void focusLost(FocusEvent e)
  531.     {
  532.         if(getText().trim().length()>=3)
  533.         {
  534.             setTstamp(getText(),getEntryFormat());
  535.             printTstamp();
  536.             isSet=true;
  537.         }
  538.         else if (getText().trim().length()<3)
  539.         {
  540.             isSet=false;
  541.         }
  542.         m_Mediator.commit();
  543.  
  544.     }
  545.     /**
  546.      * Takes no action.
  547.      * <p>
  548.      * A method of the FocusListener interface.
  549.      * @param e the event
  550.      */
  551.     public void focusGained(FocusEvent e)
  552.     {}
  553.  
  554.     /**
  555.      * Returns the projection in the RelationView that this component is bound with.
  556.      * @see #setProjection
  557.      */
  558.     public String getProjection() {
  559.         return m_ProjectionName;
  560.     }
  561.  
  562.     /**
  563.      * Binds this component to the given projection within the RelationView
  564.      * the component is currently bound with.
  565.      * @see #getProjection
  566.      * @see #getRelationView
  567.      */
  568.     public void setProjection(String projection) {
  569.         try {
  570.             setBinding(m_RelationView, projection);
  571.         }
  572.         catch (Exception ex) {
  573.             raiseException(ex);
  574.         }
  575.     }
  576.  
  577.     /**
  578.      * Gets the RelationView that this component is bound with.
  579.      * @return the RelationView currently bound with
  580.      * @see #setRelationView
  581.      * @see #getProjection
  582.      */
  583.     public RelationView getRelationView() {
  584.         return m_RelationView;
  585.     }
  586.  
  587.     /**
  588.      * Sets the RelationView that this component is bound with.
  589.      * @param value the RelationView to bind with
  590.      * @see #getRelationView
  591.      * @see #setProjection
  592.      */
  593.     public void setRelationView(RelationView rv) {
  594.         try {
  595.             setBinding(rv, m_ProjectionName);
  596.         }
  597.         catch (Exception ex) {
  598.             raiseException(ex);
  599.         }
  600.     }
  601.  
  602.     /**
  603.      * The font used for editable text.
  604.      */
  605.     public Font font;
  606.     /**
  607.      * Sets the font used for editable text.
  608.      * @param f the font
  609.      * @see #getEditFont
  610.      */
  611.     public void setEditFont(Font f)
  612.     {
  613.         font=f;
  614.     }
  615.     /**
  616.      * Gets the font used for editable text.
  617.      * @return the font
  618.      * @see #setEditFont
  619.      */
  620.     public Font getEditFont()
  621.     {
  622.         return font;
  623.     }
  624.     /**
  625.      * Sets when the component commits its changes.
  626.      * @param value the new dynamic update mode value
  627.      * @see #getDynamicUpdate
  628.      */
  629.     public void setDynamicUpdate(boolean b)
  630.     {
  631.     }
  632.     /**
  633.      * Indicates when the component commits its changes.
  634.      * @see #setDynamicUpdate
  635.      */
  636.     public boolean getDynamicUpdate()
  637.     {
  638.         return false;
  639.     }
  640.     /**
  641.      * Sets the value of this component to the given value.
  642.      * @param value the new component value
  643.      * @see #getData
  644.      */
  645.     public void setData(Object value)
  646.     {
  647.  
  648.         if(value==null || value.equals("")){
  649.             // System.out.println("null");
  650.             setText("");
  651.             isSet=false;
  652.             return;
  653.         }
  654.         isSet=true;
  655.         if(TYPE.equals("")){
  656.             if (value instanceof java.sql.Date) setType(Date);
  657.             else if (value instanceof java.sql.Time) setType(Time);
  658.             else if (value instanceof java.sql.Timestamp) setType(Timestamp);
  659.         }
  660.         readDate(value.toString(),DataBaseEntryFormat);
  661.         setText(exTstamp(getDisplayFormat()));
  662.  
  663.     }
  664.     /**
  665.      * Gets the value of this component.
  666.      * @return the current component value
  667.      * @see #setData
  668.      */
  669.     public Object getData()
  670.     {
  671.  
  672.         if(!isSet) return null;
  673.  
  674.         else if(TYPE==Date){
  675.             java.sql.Date o=new  java.sql.Date(year-1900,month,day);
  676.             return (Object)o;
  677.         }
  678.         else if(TYPE==Time){
  679.             java.sql.Time o=new  java.sql.Time(hour,minute,second);
  680.             return (Object)o;
  681.         }
  682.         else if(TYPE==Timestamp){
  683.              java.sql.Timestamp o=new  java.sql.Timestamp(year-1900,month,day,hour,minute,second,nanosec);
  684.              return (Object)o;
  685.         }
  686.  
  687.     return null;
  688.     }
  689.  
  690.     /**
  691.      * Sets the name of the data item to bind this component to.
  692.      * @param name the data item name, like "MyTable@MyColumn"
  693.      * @see #getDataBinding
  694.      */
  695.     public void setDataBinding(String name)
  696.     {
  697.         m_Mediator.setDataBinding(name);
  698.     }
  699.  
  700.     /**
  701.      * Gets the name of the data item this component is bound to.
  702.      * @returns the data item name, like "MyTable@MyColumn"
  703.      * @see #setDataBinding
  704.      */
  705.     public String getDataBinding()
  706.     {
  707.         return  m_Mediator.getDataBinding();
  708.     }
  709.  
  710.     /**
  711.      * Specifies how an empty string will be set when updating data on
  712.      * the dbANYWHERE server.
  713.      *
  714.      * @param blank one of Default, Null, or Blank
  715.      *
  716.      * @see #Default
  717.      * @see #Null
  718.      * @see #Blank
  719.      * @see symantec.itools.db.pro.ProjBinder#setValueFromString(java.lang.String, int, int)
  720.      */
  721.     public void setTreatBlankAs(int treatAs)
  722.     {
  723.         setEmptyMeansNull(treatAs == m_Mediator.Null);
  724.     }
  725.  
  726.      /**
  727.      * Sets the value of the Empty Means Null property.
  728.      * This determines how an empty string will be saved when updating data on
  729.      * the database server.
  730.      * A value of <code>true</code>indicates an empty string will be saved as a
  731.      * SQL NULL value. Otherwise it will be saved as a blank value.
  732.      * @param propertyValue <code>true</code> for NULL, <code>false</code> for BLANK
  733.      * @see #getEmptyMeansNull
  734.      */
  735.     public void setEmptyMeansNull(boolean propertyValue)
  736.     {
  737.         m_Mediator.setEmptyMeansNull(propertyValue);
  738.     }
  739.  
  740.      /**
  741.      * Gets the value of the Empty Means Null property.
  742.      * This determines how an empty string will be saved when updating data on
  743.      * the database server.
  744.      * A value of <code>true</code>indicates an empty string will be saved as a
  745.      * SQL NULL value. Otherwise it will be saved as a blank value.
  746.      * @return <code>true</code> for NULL, <code>false</code> for BLANK
  747.      * @see #setEmptyMeansNull
  748.      */
  749.     public boolean getEmptyMeansNull()
  750.     {
  751.         return m_Mediator.getEmptyMeansNull();
  752.     }
  753. }
  754.