home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-18 | 6.1 KB | 195 lines |
- /*
- * Copyright (c) 1997 Krumel & Associates, Inc. All Rights Reserved.
- *
- * www.krumel.com - controls@krumel.com
- *
- * Permission is given to the buyer of this package for one software
- * developer to use this software on one CPU (one workstation) and to make
- * one backup copy. You may uitilize and/or modify this class for use in your
- * projects. You may distribute or sell any executable which results from
- * using this code in yur application, except a utility or class of similar
- * nature to this product. You may distribute this product in compiled
- * form only, but soley to be used with your cmpiled executable product
- * for the puposes of dynamic loading. You may NOT redistribute the source
- * code in any form or make it accessible through a network or other
- * distribution media to others. Please refer to the file "copyright.html"
- * for further important copyright and licensing information.
- *
- * The source code is the confidential and proprietary information
- * of Krumel & Associates, Inc. ("Confidential Information"). You shall
- * not disclose such Confidential Information and shall use it only in
- * accordance with the terms of the license agreement you entered into
- * with Krumel & Associates, Inc..
-
- * KRUMEL & ASSOCIATES MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
- * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
- * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. KRUMEL & ASSOCIATES SHALL NOT
- * BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
- * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
- */
-
- package symantec.itools.db.awt;
-
-
- /**
- * This class is designed to work with the DefaultDataSource, but with care should be
- * usable by other DataSource classes.<p>
- * CAUTION - CAUTION - CAUTION
- * A TableCell should never hold onto this object (or any other Data object) for more
- * than one invocation because a DataSource will usually reuse this object.
- */
- public class DefaultData implements Data {
- int row;
- int col;
- DataSource dataSource;
-
- /**
- * Constructs a DefaultData object that uses the specified data source.
- * @param ds the data source to use
- */
- public DefaultData(DataSource ds) {
- dataSource = ds;
- }
-
- /**
- * Sets the coordinates of this datum.
- * @param the row index
- * @param the column index
- */
- public void setRowAndCol(int r, int c) {
- row = r;
- col = c;
- }
-
- /**
- * Gets the value of the type flag to indicate the type of information
- * held by the data object.
- */
- public int type() {
- return dataSource.type(row, col);
- }
-
- /**
- * Gets whether the data can be modified.
- */
- public boolean isEditable(int row, int col) {
- return dataSource.isDataEditable(row, col);
- }
-
- /**
- * Gets whether the data has been changed since last committed.
- * <p>
- * In this implementation, false is always returned.
- */
- public boolean changed() { return false; }
-
- /**
- * Requests the value of the data be returned to the last save point.
- * <p>
- * In this implementation, no action is taken.
- */
- public void rollback() {}
-
- /**
- * Commits the current data as the current value. This method is normally called
- * by the data source when a commit request was issued.
- * <p>
- * In this implementation, no action is taken.
- */
- public void commit() {}
-
- /**
- * Gets whether the data supports multiple predefined choice data.
- */
- public boolean supportsChoice() {
- return dataSource.supportsChoice(row, col);
- }
-
- /**
- * Gets an array of Data objects that define the predefined values associated
- * with a field.
- * @exception TypeNotSupported if the data source does not support the type of
- * action requested or is not successful
- */
- public Data[] getChoices() throws TypeNotSupported {
- return dataSource.getChoices(row, col);
- }
-
- /**
- * Sets the string value for the data.
- */
- public void setText(String t) {
- dataSource.setText(row, col, t);
- }
-
- //pos is space where to be inserted (0 = first char)
- /**
- * Inserts a character into the string data.
- * @param pos the position in the string to insert the character. Follows the
- * same rules as the StringBuffer class.
- * @param c The character to insert.
- */
- public void insertChar(int pos, char c) {
- //this will most likely throw a STringIndexOUtOfBoundsException
- dataSource.insertChar(row, col, pos, c);
- }
-
- /**
- * Sets the string value for the field using a character.
- */
- public void setText(char c) {
- setText(String.valueOf(c));
- }
-
- /**
- * Appends a character to the end of the string data.
- */
- public void appendChar(char c) {
- dataSource.appendChar(row, col, c);
- }
-
- /**
- * Sets the string value to the empty string.
- */
- public void clearText() {
- dataSource.clearText(row, col);
- }
-
- /**
- * Removes a character from the string data for the field.
- */
- public void deleteChar(int pos) {
- //this will most likely throw a STringIndexOUtOfBoundsException
- dataSource.deleteChar(row, col, pos);
- }
-
- /**
- * Gets a substring from the string data for the field.
- */
- public String subString(int spos, int epos) {
- return dataSource.subString(row, col, spos, epos);
- }
-
- /**
- * Sets a new image for the field.
- */
- public void setImage(java.awt.Image i) {
- dataSource.setImage(row, col, i);
- }
-
- /**
- * Gets the current string value for the field.
- */
- public String toString() {
- return dataSource.toString(row, col);
- }
-
- /**
- * Gets teh current image value for the field.
- */
- public java.awt.Image toImage() {
- return dataSource.toImage(row, col);
- }
- }
-