Code example for ChoiceFormat

Methods: equals

0
        String[] orangeFormats = { "Inverted Orange", "No Orange",
                "Almost No Orange", "Normal Orange", "Expensive Orange" }; 
 
        ChoiceFormat appleChoiceFormat = new ChoiceFormat(appleLimits,
                appleFormats);
        ChoiceFormat orangeChoiceFormat = new ChoiceFormat(orangeLimits,
                orangeFormats);
        ChoiceFormat orangeChoiceFormat2 = new ChoiceFormat(patternString);
        ChoiceFormat hybridChoiceFormat = new ChoiceFormat(appleLimits,
                orangeFormats);
 
        assertTrue("Apples should not equal oranges", !appleChoiceFormat
                .equals(orangeChoiceFormat));
        assertTrue("Different limit list--should not appear as equal",
                !orangeChoiceFormat.equals(hybridChoiceFormat));
        assertTrue("Different format list--should not appear as equal",
                !appleChoiceFormat.equals(hybridChoiceFormat));
        assertTrue("Should be equal--identical format", appleChoiceFormat
                .equals(appleChoiceFormat));
        assertTrue("Should be equals--same limits, same formats",
                orangeChoiceFormat.equals(orangeChoiceFormat2));
 
        ChoiceFormat f2 = new ChoiceFormat(
                "0#Less than one|1#one|1<Between one and two|2<Greater than two"); 
        assertTrue("Not equal", f1.equals(f2));
    }