本文整理汇总了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()]));
}
示例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());
}
示例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")));
}
示例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]);
}
示例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]);
}
示例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());
}
}
示例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 });
}
示例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 });
}
示例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);
}
示例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"))));
}
示例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()]));
}
示例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());
}
示例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));
}
示例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));
}
示例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());
}
}