Java Code Examples for org.apache.ddlutils.model.Column#setType()

The following examples show how to use org.apache.ddlutils.model.Column#setType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when the table name contains a '&' character.
 */
public void testTableNameContainsAmpersand() throws Exception
{
    String   tableName   = "test&table";
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName("value");
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName(tableName);
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"test&amp;table\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
Example 2
Source File: TestDllUtils.java    From Eagle with Apache License 2.0 5 votes vote down vote up
@Test
public void testTable(){
    Table table = new Table();
    Column column = new Column();
    column.setName("id");
    column.setDefaultValue("-1");
    column.setDescription("rowkey");
    column.setPrimaryKey(true);
    column.setType(TypeMap.VARCHAR);
    table.addColumn(column);
    table.setName("eagle_table");

    System.out.println(table.toString());

}
 
Example 3
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when a column value contains the '<' character.
 */
public void testColumnValueContainsLessCharacter() throws Exception
{
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();
    String   columnName  = "foo<bar";

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName(columnName);
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName("test");
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set(columnName, testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column column-name=\"foo&lt;bar\">" + testedValue + "</column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
Example 4
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when a column value contains the '&' character.
 */
public void testColumnValueContainsAmpersand() throws Exception
{
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();
    String   columnName  = "foo&bar";

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName(columnName);
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName("test");
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set(columnName, testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column column-name=\"foo&amp;bar\">" + testedValue + "</column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
Example 5
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when a column value contains an invalid character.
 */
public void testColumnValueContainsInvalidCharacters() throws Exception
{
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();
    String   columnName  = "the\u0000value";

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName(columnName);
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName("test");
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set(columnName, testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column>\n" +
                  "      <column-name " + DatabaseIO.BASE64_ATTR_NAME + "=\"true\">" + new String(Base64.encodeBase64(columnName.getBytes("UTF-8")), "UTF-8") + "</column-name>\n" +
                  "      <column-value>" + testedValue + "</column-value>\n" +
                  "    </column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
Example 6
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when a column name is not a valid tag,
 * and the value is invalid, and both are short.
 */
public void testColumnNameAndValueLongAndInvalid() throws Exception
{
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();
    String   columnName  = StringUtils.repeat("the\u0000name", 100);

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName(columnName);
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName("test");
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = StringUtils.repeat("the\u0000value", 40);

    bean.set("id", new Integer(1));
    bean.set(columnName, testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column>\n" +
                  "      <column-name " + DatabaseIO.BASE64_ATTR_NAME + "=\"true\">" + new String(Base64.encodeBase64(columnName.getBytes("UTF-8")), "UTF-8") + "</column-name>\n" +
                  "      <column-value " + DatabaseIO.BASE64_ATTR_NAME + "=\"true\">" + new String(Base64.encodeBase64(testedValue.getBytes("UTF-8")), "UTF-8") + "</column-value>\n" +
                  "    </column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
Example 7
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when the table name contains characters not allowed in XML.
 */
public void testTableNameContainsInvalidCharacters() throws Exception
{
    String   tableName   = "test\u0000table";
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName("value");
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName(tableName);
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table id=\"1\" value=\"" + testedValue + "\">\n" +
                  "    <table-name " + DatabaseIO.BASE64_ATTR_NAME + "=\"true\">" + new String(Base64.encodeBase64(tableName.getBytes("UTF-8")), "UTF-8") + "</table-name>\n" +
                  "  </table>\n" +
                  "</data>\n");
}
 
Example 8
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when the table name contains a '>' character.
 */
public void testTableNameContainsMoreCharacter() throws Exception
{
    String   tableName   = "test>table";
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName("value");
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName(tableName);
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"test>table\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
Example 9
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when the table name contains a '<' character.
 */
public void testTableNameContainsLessCharacter() throws Exception
{
    String   tableName   = "test<table";
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName("value");
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName(tableName);
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"test&lt;table\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
Example 10
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when the table name contains a '&' character.
 */
public void testTableNameContainsAmpersand() throws Exception
{
    String   tableName   = "test&table";
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName("value");
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName(tableName);
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"test&amp;table\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
Example 11
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when a column value contains the '>' character.
 */
public void testColumnValueContainsMoreCharacter() throws Exception
{
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();
    String   columnName  = "foo>bar";

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName(columnName);
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName("test");
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set(columnName, testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column column-name=\"foo>bar\">" + testedValue + "</column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
Example 12
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when a column value contains the '<' character.
 */
public void testColumnValueContainsLessCharacter() throws Exception
{
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();
    String   columnName  = "foo<bar";

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName(columnName);
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName("test");
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set(columnName, testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column column-name=\"foo&lt;bar\">" + testedValue + "</column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
Example 13
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when a column value contains the '&' character.
 */
public void testColumnValueContainsAmpersand() throws Exception
{
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();
    String   columnName  = "foo&bar";

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName(columnName);
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName("test");
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set(columnName, testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column column-name=\"foo&amp;bar\">" + testedValue + "</column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
Example 14
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when a column value contains an invalid character.
 */
public void testColumnValueContainsInvalidCharacters() throws Exception
{
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();
    String   columnName  = "the\u0000value";

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName(columnName);
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName("test");
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set(columnName, testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column>\n" +
                  "      <column-name " + DatabaseIO.BASE64_ATTR_NAME + "=\"true\">" + new String(Base64.encodeBase64(columnName.getBytes("UTF-8")), "UTF-8") + "</column-name>\n" +
                  "      <column-value>" + testedValue + "</column-value>\n" +
                  "    </column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
Example 15
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when a column name is not a valid tag,
 * and the value is invalid, and both are short.
 */
public void testColumnNameAndValueLongAndInvalid() throws Exception
{
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();
    String   columnName  = StringUtils.repeat("the\u0000name", 100);

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName(columnName);
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName("test");
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = StringUtils.repeat("the\u0000value", 40);

    bean.set("id", new Integer(1));
    bean.set(columnName, testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <test id=\"1\">\n" +
                  "    <column>\n" +
                  "      <column-name " + DatabaseIO.BASE64_ATTR_NAME + "=\"true\">" + new String(Base64.encodeBase64(columnName.getBytes("UTF-8")), "UTF-8") + "</column-name>\n" +
                  "      <column-value " + DatabaseIO.BASE64_ATTR_NAME + "=\"true\">" + new String(Base64.encodeBase64(testedValue.getBytes("UTF-8")), "UTF-8") + "</column-value>\n" +
                  "    </column>\n" +
                  "  </test>\n" +
                  "</data>\n");
}
 
Example 16
Source File: TestDllUtils.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Test
public void testTable(){
    Table table = new Table();
    Column column = new Column();
    column.setName("id");
    column.setDefaultValue("-1");
    column.setDescription("rowkey");
    column.setPrimaryKey(true);
    column.setType(TypeMap.VARCHAR);
    table.addColumn(column);
    table.setName("eagle_table");

    System.out.println(table.toString());

}
 
Example 17
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when the table name contains a '>' character.
 */
public void testTableNameContainsMoreCharacter() throws Exception
{
    String   tableName   = "test>table";
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName("value");
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName(tableName);
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"test>table\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
Example 18
Source File: TestDataReaderAndWriter.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the reader & writer behavior when the table name contains a '<' character.
 */
public void testTableNameContainsLessCharacter() throws Exception
{
    String   tableName   = "test<table";
    Database model       = new Database("test");
    Table    table       = new Table();
    Column   idColumn    = new Column();
    Column   valueColumn = new Column();

    idColumn.setName("id");
    idColumn.setType("INTEGER");
    idColumn.setPrimaryKey(true);
    idColumn.setRequired(true);
    valueColumn.setName("value");
    valueColumn.setType("VARCHAR");
    valueColumn.setSize("50");
    valueColumn.setRequired(true);
    table.setName(tableName);
    table.addColumn(idColumn);
    table.addColumn(valueColumn);
    model.addTable(table);

    SqlDynaBean bean        = (SqlDynaBean)model.createDynaBeanFor(model.getTable(0));
    String      testedValue = "Some Text";

    bean.set("id", new Integer(1));
    bean.set("value", testedValue);

    roundtripTest(model, bean, "UTF-8",
                  "<?xml version='1.0' encoding='UTF-8'?>\n" +
                  "<data>\n" +
                  "  <table table-name=\"test&lt;table\" id=\"1\" value=\"" + testedValue + "\" />\n" +
                  "</data>\n");
}
 
Example 19
Source File: DatabaseIO.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Reads a column element from the XML stream reader.
 * 
 * @param xmlReader The reader
 * @return The column object
 */
private Column readColumnElement(XMLStreamReader xmlReader) throws XMLStreamException, IOException
{
    Column column = new Column();

    for (int idx = 0; idx < xmlReader.getAttributeCount(); idx++)
    {
        QName attrQName = xmlReader.getAttributeName(idx);

        if (isSameAs(attrQName, QNAME_ATTRIBUTE_NAME))
        {
            column.setName(xmlReader.getAttributeValue(idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_PRIMARY_KEY))
        {
            column.setPrimaryKey(getAttributeValueAsBoolean(xmlReader, idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_REQUIRED))
        {
            column.setRequired(getAttributeValueAsBoolean(xmlReader, idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_TYPE))
        {
            column.setType(xmlReader.getAttributeValue(idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_SIZE))
        {
            column.setSize(getAttributeValueBeingNullAware(xmlReader, idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_DEFAULT))
        {
            column.setDefaultValue(xmlReader.getAttributeValue(idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_AUTO_INCREMENT))
        {
            column.setAutoIncrement(getAttributeValueAsBoolean(xmlReader, idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_DESCRIPTION))
        {
            column.setDescription(xmlReader.getAttributeValue(idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_JAVA_NAME))
        {
            column.setJavaName(xmlReader.getAttributeValue(idx));
        }
    }
    consumeRestOfElement(xmlReader);
    return column;
}
 
Example 20
Source File: DatabaseIO.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Reads a column element from the XML stream reader.
 * 
 * @param xmlReader The reader
 * @return The column object
 */
private Column readColumnElement(XMLStreamReader xmlReader) throws XMLStreamException, IOException
{
    Column column = new Column();

    for (int idx = 0; idx < xmlReader.getAttributeCount(); idx++)
    {
        QName attrQName = xmlReader.getAttributeName(idx);

        if (isSameAs(attrQName, QNAME_ATTRIBUTE_NAME))
        {
            column.setName(xmlReader.getAttributeValue(idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_PRIMARY_KEY))
        {
            column.setPrimaryKey(getAttributeValueAsBoolean(xmlReader, idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_REQUIRED))
        {
            column.setRequired(getAttributeValueAsBoolean(xmlReader, idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_TYPE))
        {
            column.setType(xmlReader.getAttributeValue(idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_SIZE))
        {
            column.setSize(getAttributeValueBeingNullAware(xmlReader, idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_DEFAULT))
        {
            column.setDefaultValue(xmlReader.getAttributeValue(idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_AUTO_INCREMENT))
        {
            column.setAutoIncrement(getAttributeValueAsBoolean(xmlReader, idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_DESCRIPTION))
        {
            column.setDescription(xmlReader.getAttributeValue(idx));
        }
        else if (isSameAs(attrQName, QNAME_ATTRIBUTE_JAVA_NAME))
        {
            column.setJavaName(xmlReader.getAttributeValue(idx));
        }
    }
    consumeRestOfElement(xmlReader);
    return column;
}