Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* #%L
* Nuiton CSV
* %%
* Copyright (C) 2011 CodeLutin, Tony Chemit, Brendan Le Ny
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
package org.nuiton.csv;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
import org.nuiton.util.StringUtil;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* TODO
*
* @author Brendan Le Ny - [email protected]
* @author Tony Chemit - [email protected]
* @since 2.4
*/
public class Common {
public static final ValueParserFormatter STRING =
new StringValueParser();
public static final ValueFormatter> TO_STRING_FORMATTER =
new ToStringValueFormatter();
public static final ValueParserFormatter BOOLEAN =
new BooleanParserFormatter(null, true);
public static final ValueParserFormatter PRIMITIVE_BOOLEAN =
new BooleanParserFormatter(false, false);
public static ValueParserFormatter CHAR =
new CharacterParserFormatter(null, true);
public static ValueParserFormatter PRIMITIVE_SHORT =
new ShortParserFormatter((short) 0, false);
public static ValueParserFormatter SHORT =
new ShortParserFormatter(null, true);
public static ValueParserFormatter INTEGER =
new IntegerParserFormatter(null, true);
public static ValueParserFormatter PRIMITIVE_INTEGER =
new IntegerParserFormatter(0, false);
public static ValueParserFormatter LONG =
new LongParserFormatter(null, true);
public static ValueParserFormatter PRIMITIVE_LONG =
new LongParserFormatter(0l, false);
public static ValueParserFormatter FLOAT =
new FloatParserFormatter(null, true);
public static ValueParserFormatter PRIMITIVE_FLOAT =
new FloatParserFormatter(0f, false);
public static ValueParserFormatter DOUBLE =
new DoubleParserFormatter(null, true);
public static ValueParserFormatter DOUBLE_PRIMITIVE =
new DoubleParserFormatter(0d, false);
public static final ValueParserFormatter DAY =
new DateValue("dd/MM/yyyy");
public static final ValueParserFormatter DAY_TIME =
new DateValue("dd/MM/yyyy HH:mm");
public static final ValueParserFormatter DAY_TIME_SECOND =
new DateValue("dd/MM/yyyy HH:mm:ss");
public static final ValueParserFormatter TIME =
new DateValue("HH:mm");
/** A week in a given year, ie "1/2011" until "52/2011" */
public static final ValueParserFormatter WEEK =
new DateValue("w/yyyy");
public static final ValueParserFormatter YEAR =
new DateValue("yyyy");
public static , T> MapProperty newMapProperty(String propertyName) {
return new MapProperty(propertyName);
}
public static BeanProperty newBeanProperty(String propertyName) {
return new BeanProperty(propertyName);
}
public static > ValueParserFormatter newEnumByNameParserFormatter(Class enumType) {
return new EnumByNameParserFormatter(enumType);
}
public static > ValueParserFormatter newEnumByOrdinalParserFormatter(Class enumType) {
return new EnumByOrdinalParserFormatter(enumType);
}
public static class StringValueParser implements ValueParserFormatter {
@Override
public String parse(String value) {
return value;
}
@Override
public String format(String value) {
return value == null ? "" : value;
}
}
public static class ToStringValueFormatter implements ValueFormatter