Chapter Contents |
Previous |
Next |
SAS/AF Software: Class Dictionary |
Calling Methods of the GET_DATA Data Vector Class |
The GET_DATA Data Vector class contains information about one or more columns. The GET_DATA Data Vector class contains such information because the viewer can request or set information about as many columns as it likes with one call to the model's _getData or _setData method. The GET_DATA Data Vector class, however, contains information about only one row because the model's _getData and _setData methods only operate with one row at a time.
The caller of the model's _getData or _setData method is responsible for creating the instance of the GET_DATA Data Vector class passed as an argument to these methods. Therefore, if you override the model's _getData or _setData method, you need not create your own instance of the GET_DATA Data Vector class; one will be passed to you. If, however, you call the _getData or _setData method of the model directly or if your own viewer class calls _getData or _setData on the model, you are responsible for creating your own instance of the GET_DATA Data Vector class.
If you make your own instance of a GET_DATA Data Vector class, you must set up the GET_DATA data vector with information about
After making an instance of the GET_DATA Data Vector class, you should first call the _setNumberOfColumns method to tell the GET_DATA data vector how many columns exist. Then call _setRow to tell the GET_DATA data vector which row the instance refers to.
Next, for each column in the instance, you should call the _setIndex method, followed by the _setColumn method, to tell the GET_DATA data vector the information about which column you are requesting information for in each of the columns declared with the _setNumberOfColumns method.
Then you should call the _setIndex method to declare which column further method calls will refer to. If at a later point you want to change which column method calls refer to, call the _setIndex method again with the new column number. All methods of the GET_DATA Data Vector class other than the _setNumberOfColumns and _setIndex method apply to the current column, that is, the column set by the last _setIndex method call.
Calling the _setColumn method on each column index is necessary because
the columns in the GET_DATA data vector may be noncontiguous. For example,
if you are using a table editor, it may call _getData on the model with an
instance of the GET_DATA Data Vector class requesting information about two
columns. But the first column the table editor wants information about may
be column number 6, and the second column it wants information about may be
column number 3. The current column set by the _setColumn method reflects
the display order that the table editor is using, which is 6 followed by 3
in this case.
The following example is a code fragment from a situation in which a developer has created a viewer. In this code fragment, a GET_DATA data vector is created and set up with initial values. After that, the GET_DATA data vector can be sent to a model on a _setData call.
If this code fragment were used as part of an application, any objects that were instantiated during execution would need to be terminated when those objects were no longer needed. Likewise, any lists that were created during execution would need to be deleted when those lists were no longer needed.
gddvecid = instance(loadclass('sashelp.fsp. gddvec')); |
call send(gddvecid, '_setNumberOfColumns', 2); |
rowlst = makelist(); rc = insertn(rowlst, 6, -1); call send(gddvecid, '_setRow', rowlst); |
call send(gddvecid, '_setIndex', 1); collst1 = makelist(); rc = insertn(collst1, 4, -1); call send(gddvecid, '_setColumn', collst1); call send(gddvecid, '_setColor', 'green'); |
call send(gddvecid, '_setIndex', 2); collst2 = makelist(); rc = insertn(collst2, 5, -1); call send(gddvecid, '_setColumn', collst2); call send(gddvecid, '_setHjust', 'center'); |
Some of the GET_DATA Data Vector methods set or return values that are only applicable for either the form editor or the table editor. By default, it is assumed that the instance of the GET_DATA Data Vector class you create can be used by either a form editor or a table editor, and you are free to call any methods of the GET_DATA Data Vector class.
However, if you know when you make a GET_DATA data vector that it will
only be used for either a form editor or a table editor, then the GET_DATA
Data Vector class can do error checking for you by program halting when you
call a method that is not supported by the viewer you are using. For more
information, see _init in this class.
The following table shows which methods of the GET_DATA Data Vector class can be used with the Form Editor class and which can be used with the Table Editor class.
Method Name | Used in Form Editor? | Used in Table Editor? |
---|---|---|
_getBackgroundColor | Yes | Yes |
_getBackgroundPattern | No | Yes |
_getBorderColor | No | Yes |
_getBorderStyle | No | Yes |
_getBorderWidth | No | Yes |
_getClassName | Yes | No |
_getClassProperties | Yes | No |
_getColor | Yes | Yes |
_getColumn | Yes | Yes |
_getFont | Yes | Yes |
_getFormatLength | Yes | Yes |
_getHjust | Yes | Yes |
_getInherit | Yes | No |
_getInternalERROR | Yes | No |
_getLightSource | No | Yes |
_getMargin | No | Yes |
_getMeasuring | No | Yes |
_getNumberOfColumns | Yes | Yes |
_getPrinting | No | Yes |
_getProtect | Yes | Yes |
_getReverse | No | Yes |
_getRow | Yes | Yes |
_getText | No | Yes |
_getType | Yes | No |
_getUnformattedText | Yes | No |
_getUnformattedValue | Yes | No |
_getUserERROR | Yes | No |
_getVjust | No | Yes |
_getWrapping | No | Yes |
_setBackgroundColor | Yes | Yes |
_setBackgroundPattern | No | Yes |
_setBorderColor | No | Yes |
_setBorderStyle | No | Yes |
_setBorderWidth | No | Yes |
_setClassName | Yes | No |
_setClassProperties | Yes | No |
_setColor | Yes | Yes |
_setColumn | Yes | Yes |
_setFont | Yes | Yes |
_setFormatLength | Yes | Yes |
_setHjust | Yes | Yes |
_setIndex | Yes | Yes |
_setInherit | Yes | No |
_setInternalERROR | Yes | No |
_setLightSource | No | Yes |
_setMargin | No | Yes |
_setMeasuring | No | Yes |
_setNumberOfColumns | Yes | Yes |
_setPrinting | No | Yes |
_setProtect | Yes | Yes |
_setReverse | No | Yes |
_setRow | Yes | Yes |
_setText | No | Yes |
_setUnformattedText | Yes | No |
_setUnformattedValue | Yes | No |
_setUserERROR | Yes | No |
_setVjust | No | Yes |
_setWrapping | No | Yes |
Using the GET_DATA Data Vector Class with a Form Editor |
You need to make special considerations when using the GET_DATA Data Vector class with a form editor. When a form editor displays its data, it calls the _getData method on the first row of data to display, followed by calls to the model _getData method for subsequent rows. For performance reasons, most items in the GET_DATA Data Vector class are only checked for the first row that the viewer calls _getData on. Only the first row is checked because most models have the same settings for a particular column for each row that column is in. For example, in a particular model, the first column may always be red and the second column may always use a particular font. So, when the form editor calls the model with the _getData method for the first displayed row, it saves these color and font values and will not check them again for subsequent _getData calls for other rows. The form editor does check for a few items such as the data value and type, but most other items, such as font, color, and justification, are not checked.
If you are overriding the model's _getData method, consider the following about checking: If you know that your columns will always have the same characteristics regardless of the row, then you need not be concerned. If, however, you want some rows to have different characteristics for the same column, then you need to notify the viewer that this is the case so that it will know to check your settings.
To notify the viewer that it needs to check the settings for all rows, call the viewer's _updateColumn method from within the _getData method call. You should call the _updateColumn method at the end of the _getData model method. You can obtain the viewer's identifier from the model's VIEWERID instance variable.
See the Form Data Model class.
Steps for Overriding the _getData Method with a Form Editor |
To subclass Data Set Data Model and display the new subclass in a FRAME entry that contains a form editor object, follow these steps:
newdatam.class
.
sashelp.fsp.data_m.class
.
getdata
.
new.frame
.
RM FILL 'FORM EDITOR'
.
newdatam.class
.
sasuser.class
.)
Example of Overriding the _getData Method with a Form Editor |
The following SCL code produces a form editor:
getdata: method gddvecid numcols 8; call super(_SELF_, '_getData', gddvecid, numcols); call send(gddvecid, '_setIndex', 1); rowlst = makelist(); call send(gddvecid, '_getRow', rowlst); rownum = getitemn(rowlst, 1); viewerid = getnitemn(_SELF_, 'VIEWERID'); collst = makelist();
if rownum eq 1 then do; call send(gddvecid, '_setIndex', 1); rc = insertn(collst, 1, -1); call send(gddvecid, '_setUnformattedText', 'newtext'); end; |
rc = setnitemn(ivlist2, 6, 'LENGTH'); |
rc = setnitemn(ivlist2, 2, 'NROWS'); |
if rownum eq 1 then do; call send(gddvecid, '_setIndex', 3); rc = insertn(collst, 3, -1); call send(gddvecid, '_setColor', 'RED'); end; |
if rownum eq 1 then do; call send(gddvecid, '_setIndex', 4); rc = insertn(collst, 4, -1); call send(gddvecid, '_setBackgroundColor', 'GREEN'); end; |
if rownum eq 1 then do; call send(gddvecid, '_setIndex', 5); rc = insertn(collst, 5, -1); call send(gddvecid, '_setHjust', 'CENTER'); end; call send(viewerid, '_updateColumn', collst); |
rowlst = dellist (rowlst); collst = dellist (collst); endmethod; |
Steps for Overriding the _getData Method with a Table Editor |
To subclass Data Set Data Model and display the new subclass in a FRAME entry that contains a table editor object, follow these steps:
newdatam.class
.
sashelp.fsp.data_m.class.
getdata
.
new.frame
.
RM FILL 'TABLE EDITOR'
.
newdatam.class
.
sasuser.houses
.)
Example of Overriding the _getData Method with a Table Editor |
The following SCL code produces a table editor:
getdata: method gddvecid numcols 8; call super(_SELF_, '_getData', gddvecid, numcols); call send(gddvecid, '_setIndex', 1); rowlst = makelist(); call send(gddvecid, '_getRow', rowlst); rownum = getitemn(rowlst, 1);
if rownum eq 1 then do; call send(gddvecid, '_setIndex', 3); call send(gddvecid, '_setColor', 'RED'); end; |
if rownum eq 2 then do; call send(gddvecid, '_setIndex', 2); call send(gddvecid, '_setBackgroundColor', 'GREEN'); end; |
if rownum eq 2 then do; call send(gddvecid, '_setIndex', 4); call send(gddvecid, '_setHjust', 'CENTER'); end; |
if rownum eq 3 then do; call send(gddvecid, '_setIndex', 1); call send(gddvecid, '_setVjust', 'MIDDLE'); end; |
if rownum eq 3 then do; call send(gddvecid, '_setIndex', 3); call send(gddvecid, '_setBorderColor', 'ALL', 'YELLOW'); call send(gddvecid, '_setBorderWidth', 'ALL', 0.1, 'in'); end; |
if rownum eq 4 then do; call send(gddvecid, '_setIndex', 2); call send(gddvecid, '_setBorderStyle', 'ALL', 'DASHED'); call send(gddvecid, '_setBorderWidth', 'ALL', 0.1, 'in'); end; |
if rownum eq 4 then do; call send(gddvecid, '_setIndex', 4); call send(gddvecid, '_setBorderWidth', 'ALL', 0.1, 'in'); end; |
if rownum eq 5 then do; call send(gddvecid, '_setIndex', 1); call send(gddvecid, '_setMargin', 'LEFT', 0.3, 'in'); end; |
if rownum eq 5 then do; call send(gddvecid, '_setIndex', 3); call send(gddvecid, '_setReverse', 'Y'); end; |
if rownum eq 6 then do; call send(gddvecid, '_setIndex', 1); call send(gddvecid, '_setText', 'newtext'); end; |
rowlst = dellist (rowlst); endmethod; |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.