PageNumberField extends Field { @Override public FieldType getFieldType() { switch (type) { case PREVIOUS_PAGE: return FieldType.PREVIOUS_PAGE_NUMBER_FIELD; case CURRENT_PAGE: return FieldType.CURRENT_PAGE_NUMBER_FIELD; case NEXT_PAGE: return FieldType.NEXT_PAGE_NUMBER_FIELD; default: return null; } } PageNumberField(OdfElement odfElement); void setDisplayPage(DisplayType type); void setNumberFormat(NumberFormat format); TextPageNumberElement getOdfElement(); @Override FieldType getFieldType();  }
@Test public void testGetFieldType() { try { TextDocument doc = TextDocument.newTextDocument(); PageNumberField numberField = Fields.createCurrentPageNumberField(doc.newParagraph("Current Page Number:")); Assert.assertNotNull(numberField); FieldType fieldType = numberField.getFieldType(); Assert.assertNotNull(fieldType); Assert.assertEquals(fieldType, FieldType.CURRENT_PAGE_NUMBER_FIELD); numberField.setDisplayPage(DisplayType.PREVIOUS_PAGE); FieldType fieldType1 = numberField.getFieldType(); Assert.assertEquals(fieldType1, FieldType.PREVIOUS_PAGE_NUMBER_FIELD); numberField.setDisplayPage(DisplayType.NEXT_PAGE); FieldType fieldType2 = numberField.getFieldType(); Assert.assertEquals(fieldType2, FieldType.NEXT_PAGE_NUMBER_FIELD); } catch (Exception e) { Logger.getLogger(PageNumberFieldTest.class.getName()).log(Level.SEVERE, null, e); Assert.fail(e.getMessage()); } }