Tutorial: Learning to Create Java Custom Toolkit Support > Learning to Support a Complex Control > Implementing Support for the AllLights Control > Implementing Support for New Identification Properties

Implementing Support for New Identification Properties

In this section, you implement the methods that support the new identification properties you defined for the AllLights test object class.

Analyze the AllLights custom class to see the properties it supports. Determine which properties you can access from the new support class to provide the relevant identification properties to UFT.

Notice the public methods GetcounterOn, which allows you to check how many lights are on at a given time, and isSet, which tells you the status of a particular light.

  1. Implement the oncount_attr method.

    In the oncount_attr method, replace the code return null; with
    return String.valueOf(((AllLights)obj).GetcounterOn());

    This implementation retrieves the counter from the AllLights custom class and returns it to UFT.

  2. Implement the onlist_attr method.

    In the onlist_attr method, delete the code return null; and implement the method as follows to scan all of the lights and create a list of all the lights that are on:

    public String onlist_attr (Object obj) {
        AllLights lights = (AllLights) obj;
        StringBuffer buffer = new StringBuffer();
        for (int i=0; i<5; i++)
            for (int j=0;j<5;j++)
                if (lights.isSet(j,i)) {
                    buffer.append (" ");
                    buffer.append (i*5+j+1);
                    }
        return buffer.toString();
    }
    
  3. Implement the gameover_attr method.

    In the gameover_attr method, delete the code return null; and implement the method as follows to return Yes or No depending on whether or not all of the lights are on:

    public String gameover_attr(Object obj) {
        if (((AllLights) obj).GetcounterOn() == 25)
            return "Yes";
        return "No";
    }
    

    Select File > Save or click the Save button to save the AllLightsCS.java file.