protected void setUp() throws Exception {
   super.setUp();
   this.field1 = FieldFactory.getFieldValue(null);
   this.field2 = FieldFactory.getFieldValue(null);
   this.field3 = FieldFactory.getFieldValue("A");
   this.field4 = FieldFactory.getFieldValue("A");
   this.field5 = FieldFactory.getFieldValue("B");
 }
Exemplo n.º 2
0
 @Test
 public void test_unsupported() {
   try {
     factory.build(-1);
     fail();
   } catch (UnsupportedOperationException err) {
     assertEquals("Unsupported form field type", err.getMessage());
   }
 }
Exemplo n.º 3
0
class EmployeeInfoDesc {

  private static final EntityDescriptorBuilder builder =
      EntityDescriptorBuilder.init("EmployeeInfo");

  public static final EntityDescriptor INSTANCE = builder.get();
  public static final StringField FIRST_NAME =
      FieldFactory.init(builder, "firstName").createStringField();
  public static final StringField LAST_NAME =
      FieldFactory.init(builder, "lastName").createStringField();
  public static final OneToOneRelationField EMPLOYEE =
      FieldFactory.init(builder, "employee").createOneToOneRelationField(EmployeeDesc.INSTANCE);
  private static final IntegerField ID = FieldFactory.init(builder, "id").createIntegerField();

  static {
    builder.addKeyField(ID);
  }
}
Exemplo n.º 4
0
  public void testDate() throws Exception {
    SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
    String s = df.format(df.parse("10-Jul-1974"));
    final FieldValue val =
        FieldFactory.getFieldValue(s, ValueType.DATE_TYPE, new DateFormatsImpl());
    assertEquals(Date.class, val.getValue().getClass());

    Date dt = (Date) val.getValue();
    assertEquals(s, df.format(dt));
  }
 /** Decode character from XML */
 public void characters(char[] ch, int start, int length) {
   if (inField) {
     myFieldFactory.characters(ch, start, length);
   } else if (inHeader) {
   } else {
     logger.warn("### inField = " + inField);
     logger.warn("### inHeader = " + inHeader);
     logger.warn("########## Don't know what to do");
   }
 }
  /**
   * Decode EndField from XML.
   *
   * @return A new Field created with data read
   */
  public Header endElement(String qName) {
    logger.debug("end element " + qName);

    // in Field already ?
    if (inField) {
      myFieldFactory.endElement(qName);
      if (qName.equals(Element.TAG_ELEMENT_FIELD)) {
        logger.debug("Adding Field");
        inField = false;
        myHeader.add(myFieldFactory.endElement(qName));
      }
    }
    // is it a Header ?
    else if (qName.equals(Element.TAG_ELEMENT_HEADER)) {
      logger.debug("Ending : Header");
      inHeader = false;
      return myHeader;
    } else {
      logger.warn("Don't know how to deal with tag");
    }
    return null;
  }
  /** Decode startElemennt from XML */
  public void startElement(String qName, Attributes attributes) {
    logger.debug("start element " + qName);

    // in Field already ?
    if (inField) {
      myFieldFactory.startElement(qName, attributes);
    }
    // is it a Header ?
    else if (qName.equals(Element.TAG_ELEMENT_HEADER)) {
      logger.debug("Entering Header");
      myHeader = new Header();
      inHeader = true;
    }
    // a Field ?
    else if (qName.equals(Element.TAG_ELEMENT_FIELD)) {
      logger.debug("Entering Field");
      inField = true;
      myFieldFactory.startElement(qName, attributes);
    } else {
      logger.warn("Don't know how to deal with tag");
    }
  }
Exemplo n.º 8
0
 public void testBigInteger() {
   final FieldValue val =
       FieldFactory.getFieldValue("424242", ValueType.BIG_INTEGER_TYPE, new DateFormatsImpl());
   assertEquals(BigInteger.class, val.getValue().getClass());
   assertTrue(val.getValue().equals(new BigInteger("424242")));
 }
Exemplo n.º 9
0
 public void testBigDecimal() {
   final FieldValue val =
       FieldFactory.getFieldValue("42.42", ValueType.BIG_DECIMAL_TYPE, new DateFormatsImpl());
   assertEquals(BigDecimal.class, val.getValue().getClass());
   assertTrue(val.getValue().equals(new BigDecimal("42.42")));
 }
Exemplo n.º 10
0
 @Test
 public void test() {
   assertTrue(factory.build(AcroFields.FIELD_TYPE_TEXT) instanceof TextField);
   assertTrue(factory.build(AcroFields.FIELD_TYPE_CHECKBOX) instanceof CheckboxField);
 }
Exemplo n.º 11
0
 @Override
 public Field generateDungeon(String groundImage, String decoImage) {
   return fieldFactory.generateDungeon(groundImage, decoImage);
 }