Section 37.6. TypeAdapter


37.6. TypeAdapter

As we saw in Chapter 25, a TypeAdapter manages conversion between the text in table cells and Java values. More specifically, a TypeAdapter object provides the following methods:

  • get(), to get data from a specified field of an object in the application

  • set(), to set data into a specified field of an object

  • invoke(), to call the specified method (with no arguments) in the object

  • toString(), to provide a String form of the value, such as for use in the report

  • parse(), to parse text from a table cell and convert it into a value of the appropriate data type

  • equals(), to check that two values of that data type are equal

In addition, a TypeAdapter has several public instance variables. For our purposes, only the variable target is relevant to the following chapters of this part. To use a TypeAdapter with a particular object, such as to get() a value from it, we first need to assign that object to the target variable of the TypeAdapter. See the source code for TypeAdapter for further details.

Only some classes are managed by TypeAdapter, so a mechanism is provided to manage other classes, including those that are application specific. We saw in Chapter 25 that the conversion and comparison of classes, such as Money, are handled by overriding the parse() method in a fixture.



    Fit for Developing Software. Framework for Integrated Tests
    Fit for Developing Software: Framework for Integrated Tests
    ISBN: 0321269349
    EAN: 2147483647
    Year: 2005
    Pages: 331

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net