当前位置: 首页>>代码示例>>Java>>正文


Java OutputColumns类代码示例

本文整理汇总了Java中org.datacleaner.api.OutputColumns的典型用法代码示例。如果您正苦于以下问题:Java OutputColumns类的具体用法?Java OutputColumns怎么用?Java OutputColumns使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OutputColumns类属于org.datacleaner.api包,在下文中一共展示了OutputColumns类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOutputColumns

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
@Override
public OutputColumns getOutputColumns() {
    final List<String> columnNames = new ArrayList<>();
    final String from = fromColumn.getName();
    final String to = toColumn.getName();
    if (days) {
        columnNames.add("Days from " + from + " to " + to);
    }
    if (hours) {
        columnNames.add("Hours from " + from + " to " + to);
    }
    if (minutes) {
        columnNames.add("Minutes from " + from + " to " + to);
    }
    if (seconds) {
        columnNames.add("Seconds from " + from + " to " + to);
    }
    if (milliseconds || columnNames.isEmpty()) {
        columnNames.add("Milliseconds from " + from + " to " + to);
    }

    return new OutputColumns(Number.class, columnNames.toArray(new String[columnNames.size()]));
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:24,代码来源:DateDiffTransformer.java

示例2: getOutputColumns

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
@Override
public OutputColumns getOutputColumns() {
    final StringBuilder sb = new StringBuilder("Concat of ");
    for (int i = 0; i < columns.length; i++) {
        if (i != 0) {
            sb.append(",");
        }
        sb.append(columns[i].getName());
        if (i == 4) {
            sb.append("...");
            // only include a preview of columns in the default name
            break;
        }
    }
    return new OutputColumns(String.class, sb.toString());
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:17,代码来源:ConcatenatorTransformer.java

示例3: testTransform

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
public void testTransform() throws Exception {
    final MockInputColumn<String> col = new MockInputColumn<>("foobar", String.class);

    final RegexParserTransformer t = new RegexParserTransformer();
    t.column = col;
    t.pattern = Pattern.compile("(a+)(b+)|(c+)");

    final OutputColumns outputColumns = t.getOutputColumns();
    assertEquals(4, outputColumns.getColumnCount());
    assertEquals("foobar (matched part)", outputColumns.getColumnName(0));
    assertEquals("foobar (group 1)", outputColumns.getColumnName(1));
    assertEquals("foobar (group 2)", outputColumns.getColumnName(2));
    assertEquals("foobar (group 3)", outputColumns.getColumnName(3));

    assertArrayEquals(new String[] { "aabb", "aa", "bb", null }, t.transform(new MockInputRow().put(col, "aabb")));
    assertArrayEquals(new String[] { "cccc", null, null, "cccc" },
            t.transform(new MockInputRow().put(col, "cccc")));
    assertArrayEquals(new String[] { null, null, null, null }, t.transform(new MockInputRow().put(col, "dddd")));
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:20,代码来源:RegexParserTransformerTest.java

示例4: testTransformDefaultDateConfiguration

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
public void testTransformDefaultDateConfiguration() throws Exception {
    final DatePartTransformer transformer = new DatePartTransformer();
    final MockInputColumn<Date> column = new MockInputColumn<>("my date", Date.class);
    transformer.column = column;

    final OutputColumns outputColumns = transformer.getOutputColumns();
    assertEquals(3, outputColumns.getColumnCount());
    assertEquals("my date (year)", outputColumns.getColumnName(0));
    assertEquals("my date (month)", outputColumns.getColumnName(1));
    assertEquals("my date (day of month)", outputColumns.getColumnName(2));

    final Date date = DateUtils.get(2011, Month.MARCH, 16);
    final Number[] result = transformer.transform(new MockInputRow().put(column, date));
    assertEquals(3, result.length);
    assertEquals(2011, result[0]);
    assertEquals(3, result[1]);
    assertEquals(16, result[2]);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:19,代码来源:DatePartTransformerTest.java

示例5: testTransformTime

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
public void testTransformTime() throws Exception {
    final DatePartTransformer transformer = new DatePartTransformer();
    transformer.column = new MockInputColumn<>("my time", Date.class);
    transformer.year = false;
    transformer.month = false;
    transformer.dayOfMonth = false;
    transformer.hour = true;
    transformer.minute = true;
    transformer.second = true;

    final OutputColumns outputColumns = transformer.getOutputColumns();
    assertEquals(3, outputColumns.getColumnCount());
    assertEquals("my time (hour)", outputColumns.getColumnName(0));
    assertEquals("my time (minute)", outputColumns.getColumnName(1));
    assertEquals("my time (second)", outputColumns.getColumnName(2));

    final Date date = new SimpleDateFormat("HH:mm:ss").parse("13:21:55");
    final Number[] result = transformer.transform(date);
    assertEquals(3, result.length);
    assertEquals(13, result[0]);
    assertEquals(21, result[1]);
    assertEquals(55, result[2]);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:24,代码来源:DatePartTransformerTest.java

示例6: testGetOutputColumns

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
public void testGetOutputColumns() throws Exception {
    final InputColumn<?> col = new MetaModelInputColumn(new MutableColumn("name"));

    @SuppressWarnings("unchecked") final InputColumn<String> castColumn = (InputColumn<String>) col;
    TokenizerTransformer transformer = new TokenizerTransformer(castColumn, 2);

    final OutputColumns oc = transformer.getOutputColumns();

    assertEquals(2, oc.getColumnCount());
    assertEquals("name (token 1)", oc.getColumnName(0));
    assertEquals("name (token 2)", oc.getColumnName(1));

    transformer = new TokenizerTransformer(castColumn, 1);
    assertEquals("OutputColumns[name (token 1)]", transformer.getOutputColumns().toString());

    transformer = new TokenizerTransformer(castColumn, 0);
    try {
        transformer.getOutputColumns();
        fail("Exception expected");
    } catch (final IllegalArgumentException e) {
        assertEquals("Column names length must be 1 or greater", e.getMessage());
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:24,代码来源:TokenizerTransformerTest.java

示例7: getOutputColumns

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
@Override
public OutputColumns getOutputColumns() {
    final StringBuilder sb = new StringBuilder("Map: ");
    for (int i = 0; i < keys.length; i++) {
        final String key = keys[i];
        sb.append(key);
        if (sb.length() > 30) {
            sb.append("...");
            break;
        }

        if (i + 1 < keys.length) {
            sb.append(",");
        }
    }
    return new OutputColumns(new String[] { sb.toString() }, new Class[] { Map.class });
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:18,代码来源:BuildMapTransformer.java

示例8: getOutputColumns

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
@Override
public OutputColumns getOutputColumns() {
    final StringBuilder sb = new StringBuilder("List: ");
    for (int i = 0; i < values.length; i++) {
        final String key = values[i].getName();
        sb.append(key);
        if (sb.length() > 30) {
            sb.append("...");
            break;
        }

        if (i + 1 < values.length) {
            sb.append(",");
        }
    }
    return new OutputColumns(new String[] { sb.toString() }, new Class[] { List.class });
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:18,代码来源:BuildListTransformer.java

示例9: getOutputColumns

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
@Override
public OutputColumns getOutputColumns() {
    final String[] columnNames = new String[2];
    final Class<?>[] columnTypes = new Class[2];

    columnNames[0] = _column.getName() + " (" + _dictionary.getName() + " removed)";
    columnTypes[0] = String.class;

    columnNames[1] = OUTPUT_COLUMN_REMOVED_MATCHES;

    switch (_removedMatchesType) {
    case STRING:
        columnTypes[1] = String.class;
        break;
    case LIST:
        columnTypes[1] = List.class;
        break;
    default:
        throw new UnsupportedOperationException("Unsupported output type: " + _removedMatchesType);
    }

    return new OutputColumns(columnNames, columnTypes);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:24,代码来源:RemoveDictionaryMatchesTransformer.java

示例10: testSimpleScenario

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
public void testSimpleScenario() throws Exception {
    final MockInputColumn<String> col = new MockInputColumn<>("foo", String.class);
    final DateMaskMatcherTransformer t = new DateMaskMatcherTransformer(col);

    t.setDateMasks(new String[] { "yyyy-MM-dd", "yyyy-dd-MM" });
    t.init();

    final OutputColumns outputColumns = t.getOutputColumns();
    assertEquals(2, outputColumns.getColumnCount());
    assertEquals("foo 'yyyy-MM-dd'", outputColumns.getColumnName(0));
    assertEquals("foo 'yyyy-dd-MM'", outputColumns.getColumnName(1));

    assertEquals("[true, false]", Arrays.toString(t.transform(new MockInputRow().put(col, "2010-03-21"))));
    assertEquals("[false, false]", Arrays.toString(t.transform(new MockInputRow().put(col, "hello world"))));
    assertEquals("[false, false]", Arrays.toString(t.transform(new MockInputRow().put(col, null))));
    assertEquals("[true, true]", Arrays.toString(t.transform(new MockInputRow().put(col, "2010-03-11"))));
    assertEquals("[false, false]", Arrays.toString(t.transform(new MockInputRow().put(col, "2010/03/21"))));
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:19,代码来源:DateMaskMatcherTransformerTest.java

示例11: getOutputColumns

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
@Override
public OutputColumns getOutputColumns() {
    final ProductOutputField[] outputFields = ProductOutputField.values();
    final List<String> columnNames = new ArrayList<>(outputFields.length);
    final List<Class<?>> classes = new ArrayList<>(outputFields.length);

    for (ProductOutputField fieldType : outputFields) {
        columnNames.add(fieldType.getName());
        classes.add(fieldType.getDataType());
    }

    return new OutputColumns(columnNames.toArray(new String[columnNames.size()]),
            classes.toArray(new Class[classes.size()]));
}
 
开发者ID:datacleaner,项目名称:extension_product_match,代码行数:15,代码来源:ProductMatchTransformer.java

示例12: testConstructWithTypes

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
public void testConstructWithTypes() throws Exception {
    final OutputColumns oc =
            new OutputColumns(new String[] { "foo", "bar" }, new Class[] { String.class, Number.class });
    assertEquals(2, oc.getColumnCount());
    assertEquals("foo", oc.getColumnName(0));
    assertEquals("bar", oc.getColumnName(1));
    assertEquals(String.class, oc.getColumnType(0));
    assertEquals(Number.class, oc.getColumnType(1));

    assertEquals("OutputColumns[foo, bar]", oc.toString());
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:12,代码来源:OutputColumnsTest.java

示例13: testConstructVarArgNames

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
public void testConstructVarArgNames() throws Exception {
    final OutputColumns oc = new OutputColumns(Object.class, "first", "second", "third");
    assertEquals(3, oc.getColumnCount());
    assertEquals("first", oc.getColumnName(0));
    assertEquals("second", oc.getColumnName(1));
    assertEquals("third", oc.getColumnName(2));
    assertEquals(Object.class, oc.getColumnType(0));
    assertEquals(Object.class, oc.getColumnType(1));
    assertEquals(Object.class, oc.getColumnType(2));
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:11,代码来源:OutputColumnsTest.java

示例14: testConstructNullTypes

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
public void testConstructNullTypes() throws Exception {
    final OutputColumns oc = new OutputColumns(new String[] { "foo", "bar" }, null);
    assertEquals(2, oc.getColumnCount());
    assertEquals("foo", oc.getColumnName(0));
    assertEquals("bar", oc.getColumnName(1));
    assertEquals(Object.class, oc.getColumnType(0));
    assertEquals(Object.class, oc.getColumnType(1));
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:9,代码来源:OutputColumnsTest.java

示例15: testConstructUnequalLength

import org.datacleaner.api.OutputColumns; //导入依赖的package包/类
public void testConstructUnequalLength() throws Exception {
    try {
        new OutputColumns(new String[] { "foo", "bar" }, new Class[] { String.class });
        fail("Exception expected");
    } catch (final Exception e) {
        assertEquals("Column names and column types must have equal length", e.getMessage());
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:9,代码来源:OutputColumnsTest.java


注:本文中的org.datacleaner.api.OutputColumns类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。