本文整理匯總了Java中org.supercsv.cellprocessor.ift.CellProcessor類的典型用法代碼示例。如果您正苦於以下問題:Java CellProcessor類的具體用法?Java CellProcessor怎麽用?Java CellProcessor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CellProcessor類屬於org.supercsv.cellprocessor.ift包,在下文中一共展示了CellProcessor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getProcessors
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* Sets up the processors used for the examples. There are 10 CSV columns, so 10 processors are defined. Empty
* columns are read as null (hence the NotNull() for mandatory columns).
*
* @return the cell processors
*/
private static CellProcessor[] getProcessors() {
final String emailRegex = "[a-z0-9\\._][email protected][a-z0-9\\.]+"; // just an example, not very robust!
StrRegEx.registerMessage(emailRegex, "must be a valid email address");
final CellProcessor[] processors = new CellProcessor[] { new UniqueHashCode(), // customerNo (must be unique)
new NotNull(), // firstName
new NotNull(), // lastName
new ParseDate("dd/MM/yyyy"), // birthDate
new NotNull(), // mailingAddress
new Optional(new ParseBool()), // married
new Optional(new ParseInt()), // numberOfKids
new NotNull(), // favouriteQuote
new StrRegEx(emailRegex), // email
new LMinMax(0L, LMinMax.MAX_LONG) // loyaltyPoints
};
return processors;
}
示例2: getAggregatedCstStatistic
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
static Statistics getAggregatedCstStatistic(final Collection<File> csv_files, CellProcessor[] processors, Integer column_index, boolean header) throws IOException {
final Statistics statistics = new Statistics();
for (File csv : csv_files) {
final CsvListReader reader = getCsvListReader(csv, header);
try {
List<Object> row;
while ((row = reader.read(processors)) != null) {
statistics.addSample((Number) row.get(column_index));
}
}
finally {
IOUtils.closeQuietly(reader);
}
}
return statistics;
}
示例3: getProcessors
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
private static CellProcessor[] getProcessors() {
final CellProcessor[] processors = new CellProcessor[]{
new ParseInt(), // id (must be unique)
new NotNull(), // address
new NotNull(), // horario
new ParseDouble(), //lat
new ParseDouble(), //long
new NotNull(), // name
new Optional(), // phone
new Optional(), // locality
new Optional(), // province
new Optional(), // postal_code
};
return processors;
}
示例4: getProcessors
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
public static CellProcessor[] getProcessors(List<String> fields) {
int fieldsSize = fields.size();
final CellProcessor[] processors = new CellProcessor[fieldsSize];
int i = 0;
for(String field : fields){
if(Arrays.asList(processorsDateType).contains(field)){
processors[i] = new Optional(new FmtDate("dd-MM-yyyy HH:mm"));
}else{
processors[i] = new ConvertNullTo("");
}
i++;
}
return processors;
}
示例5: getFieldsByExplicitIndex
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
private static Map<Integer, BeanCell> getFieldsByExplicitIndex(List<Field> fields, BeanDescriptor beanDescriptor, String context) {
Map<Integer, BeanCell> result = new HashMap<>();
for (Field field : fields) {
CsvField fieldAnnotation = field.getAnnotation(CsvField.class);
if (fieldAnnotation != null) {
if (result.containsKey(fieldAnnotation.index())) {
throw new SuperCsvException(Form.at("Explicit order-index {} was declared twice (Field: {}", fieldAnnotation.index(),
field.getName()));
}
CellProcessor cellProcessor = BeanCellProcessorExtractor.createCellProcessorFor(beanDescriptor, field, context);
FieldAccessStrategy fieldAccessStrategy = createFieldAccessStrategy(beanDescriptor.getAccessType());
result.put(fieldAnnotation.index(), new ExistingBeanCell(field, cellProcessor, fieldAccessStrategy));
}
}
return result;
}
示例6: create
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CellProcessorFactory create(ProcessingMetadata<StrMinMax> metadata) {
return new CellProcessorFactory() {
@Override
public int getOrder() {
return metadata.getAnnotation().order();
}
@Override
public CellProcessor create(CellProcessor next) {
return new org.supercsv.cellprocessor.constraint.StrMinMax(metadata.getAnnotation().min(), metadata.getAnnotation().max(), next);
}
};
}
示例7: create
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CellProcessorFactory create(ProcessingMetadata<NotNull> metadata) {
return new CellProcessorFactory() {
@Override
public int getOrder() {
return metadata.getAnnotation().order();
}
@Override
public CellProcessor create(CellProcessor next) {
return new org.supercsv.cellprocessor.constraint.NotNull(next);
}
};
}
示例8: create
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CellProcessorFactory create(ProcessingMetadata<Unique> metadata) {
return new CellProcessorFactory() {
@Override
public int getOrder() {
return metadata.getAnnotation().order();
}
@Override
public CellProcessor create(CellProcessor next) {
return new org.supercsv.cellprocessor.constraint.Unique(next);
}
};
}
示例9: create
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CellProcessorFactory create(ProcessingMetadata<StrRegEx> metadata) {
return new CellProcessorFactory() {
@Override
public int getOrder() {
return metadata.getAnnotation().order();
}
@Override
public CellProcessor create(CellProcessor next) {
return new org.supercsv.cellprocessor.constraint.StrRegEx(metadata.getAnnotation().regex(),
(StringCellProcessor) next);
}
};
}
示例10: create
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CellProcessorFactory create(ProcessingMetadata<StrLen> metadata) {
return new CellProcessorFactory() {
@Override
public int getOrder() {
return metadata.getAnnotation().order();
}
@Override
public CellProcessor create(CellProcessor next) {
return new org.supercsv.cellprocessor.constraint.Strlen(metadata.getAnnotation().requiredLengths(), next);
}
};
}
示例11: create
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CellProcessorFactory create(ProcessingMetadata<LMinMax> metadata) {
return new CellProcessorFactory() {
@Override
public int getOrder() {
return metadata.getAnnotation().order();
}
@Override
public CellProcessor create(CellProcessor next) {
LMinMax annotation = metadata.getAnnotation();
return new org.supercsv.cellprocessor.constraint.LMinMax(annotation.min(), annotation.max(),
(LongCellProcessor) next);
}
};
}
示例12: create
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CellProcessorFactory create(ProcessingMetadata<Equals> metadata) {
return new CellProcessorFactory() {
@Override
public int getOrder() {
return metadata.getAnnotation().order();
}
@Override
public CellProcessor create(CellProcessor next) {
return new org.supercsv.cellprocessor.constraint.Equals(next);
}
};
}
示例13: create
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CellProcessorFactory create(ProcessingMetadata<UniqueHashCode> metadata) {
return new CellProcessorFactory() {
@Override
public int getOrder() {
return metadata.getAnnotation().order();
}
@Override
public CellProcessor create(CellProcessor next) {
return new org.supercsv.cellprocessor.constraint.UniqueHashCode(next);
}
};
}
示例14: create
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CellProcessorFactory create(ProcessingMetadata<ForbidSubStr> metadata) {
return new CellProcessorFactory() {
@Override
public int getOrder() {
return metadata.getAnnotation().order();
}
@Override
public CellProcessor create(CellProcessor next) {
return new org.supercsv.cellprocessor.constraint.ForbidSubStr(metadata.getAnnotation().forbiddenSubStrings(), next);
}
};
}
示例15: create
import org.supercsv.cellprocessor.ift.CellProcessor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public CellProcessorFactory create(ProcessingMetadata<RequireHashCode> metadata) {
return new CellProcessorFactory() {
@Override
public int getOrder() {
return metadata.getAnnotation().order();
}
@Override
public CellProcessor create(CellProcessor next) {
return new org.supercsv.cellprocessor.constraint.RequireHashCode(metadata.getAnnotation().requiredHashCodes(), next);
}
};
}