Code example for FieldPosition

Methods: getBeginIndex, getEndIndex

0
    } 
 
    protected void t_FormatWithField(int count, Format format, Object object,
            String text, Format.Field field, int begin, int end) {
        StringBuffer buffer = new StringBuffer();
        FieldPosition pos = new FieldPosition(field);
        format.format(object, buffer, pos);
 
        // System.out.println(buffer); 
        // System.out.println(pos); 
 
        if (text == null) {
            assertEquals("Test " + count + ": incorrect formatted text",
                    this.text, buffer.toString());
        } else { 
            assertEquals("Test " + count + ": incorrect formatted text", text,
                    buffer.toString());
        } 
 
        assertEquals("Test " + count + ": incorrect begin index for field "
                + field, begin, pos.getBeginIndex());
        assertEquals("Test " + count + ": incorrect end index for field"
                + field, end, pos.getEndIndex());
    } 
 
    protected void t_Format(int count, Object object, Format format,
            Vector<FieldContainer> expectedResults) {
        // System.out.println(format.format(object));