getOriginal() {
49 | return beanMapping;
50 | }
51 |
52 |
53 | public String[] getHeader() {
54 | return header;
55 | }
56 |
57 | public String[] getNameMapping() {
58 | return nameMapping;
59 | }
60 |
61 | public CellProcessor[] getCellProcessorsForReading() {
62 | return cellProcessorsForReading;
63 | }
64 |
65 | public CellProcessor[] getCellProcessorsForWriting() {
66 | return cellProcessorsForWriting;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/io/CsvErrorHandler.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.io;
2 |
3 | import org.supercsv.exception.SuperCsvException;
4 |
5 | /**
6 | * CSV処理に失敗したときの戦略。
7 | *
8 | * @since 2.3
9 | * @author T.TSUCHIE
10 | *
11 | */
12 | @FunctionalInterface
13 | public interface CsvErrorHandler {
14 |
15 | /**
16 | * 例外発生時に何も行わない実装を取得します。
17 | * 例外を無視して続けて処理したい場合に利用します。
18 | * @return 空の実装を返します。
19 | */
20 | static CsvErrorHandler empty() {
21 | return new CsvErrorHandler() {
22 |
23 | @Override
24 | public void onError(SuperCsvException exception) {
25 | // ignore error
26 | }
27 |
28 | };
29 | }
30 |
31 | /**
32 | * CSV処理に失敗したときに呼び出される処理です。
33 | * @param exception 発生したCSVに関する例外
34 | */
35 | void onError(SuperCsvException exception);
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/io/CsvReadStatus.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.io;
2 |
3 |
4 | /**
5 | * CSVの読み込み処理ステータスを表現する列挙型です。
6 | *
7 | * @since 2.3
8 | * @author T.TSUCHIE
9 | *
10 | */
11 | public enum CsvReadStatus {
12 |
13 | /**
14 | * 読み込み時にCSVファイルを最後まで読み込んだとき。
15 | */
16 | EOF,
17 | /**
18 | * 読み込み/書き込み処理に成功したとき。
19 | */
20 | SUCCESS,
21 | /**
22 | * 読み込み/書き込み処理に失敗したとき。
23 | */
24 | ERROR;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/io/CsvSuccessHandler.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.io;
2 |
3 |
4 | /**
5 | * CSV処理に成功したときの戦略。
6 | *
7 | * @since 2.3
8 | * @author T.TSUCHIE
9 | *
10 | * @param マッピング対象のBeanのクラスタイプ
11 | */
12 | @FunctionalInterface
13 | public interface CsvSuccessHandler {
14 |
15 | /**
16 | * CSVの行に対する処理が正常に行われたときに呼び出されます。
17 | * @param record CSVの行をマッピングしたBeanオブジェクト。
18 | */
19 | void onSuccess(T record);
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/io/CsvWriteStatus.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.io;
2 |
3 |
4 | /**
5 | * CSVの書き込み処理ステータスを表現する列挙型です。
6 | *
7 | * @since 2.3
8 | * @author T.TSUCHIE
9 | *
10 | */
11 | public enum CsvWriteStatus {
12 |
13 | /**
14 | * 書き込み処理に成功したとき。
15 | */
16 | SUCCESS,
17 | /**
18 | * 書き込み処理に失敗したとき。
19 | */
20 | ERROR;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/io/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * CSVの読み書きを行う機能を提供します。
3 | *
4 | * @author T.TSUCHIE
5 | *
6 | */
7 | package com.github.mygreen.supercsv.io;
8 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/localization/MessageParseException.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.localization;
2 |
3 |
4 | /**
5 | * メッセージのフォーマットに失敗した際にスローされる例外
6 | * @author T.TSUCHIE
7 | *
8 | */
9 | public class MessageParseException extends RuntimeException {
10 |
11 | /** serialVersionUID */
12 | private static final long serialVersionUID = 1L;
13 |
14 | private final String value;
15 |
16 | public MessageParseException(final String value, final String message) {
17 | super(message);
18 | this.value = value;
19 | }
20 |
21 | /**
22 | * value を取得する
23 | * @return the value
24 | */
25 | public String getValue() {
26 | return value;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/localization/MessageResolver.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.localization;
2 |
3 | import java.util.Optional;
4 |
5 | /**
6 | * メッセージを解決する機能を提供するインターフェース。
7 | *
8 | * @author T.TSUCHIE
9 | *
10 | */
11 | public interface MessageResolver {
12 |
13 | /**
14 | * コードを指定してメッセージを取得する。
15 | * @param code メッセージのコード。
16 | * @return 指定したコードが見つからない場合は、空を返す。
17 | */
18 | public Optional getMessage(String code);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/localization/Messages.properties:
--------------------------------------------------------------------------------
1 | ####################################
2 | # エラーメッセージ
3 | ####################################
4 |
5 | noinit.onLazyRead=見出し情報を元にした初期化が完了していません。LazyCsvAnnotationBeanReader#init() で初期化する必要があります。
6 | noinit.onLazyWrite=見出し情報を元にした初期化が完了していません。LazyCsvAnnotationBeanWriter#init() で初期化する必要があります。
7 |
8 | anno.notFound='{property}' において、アノテーション {anno} が見つかりません。
9 | anno.required='{property}' において、アノテーション {anno} の付与は必須です。
10 |
11 | anno.attr.required='{property}' において、アノテーション {anno} の属性 '{attrName}' の指定は必須です。
12 | anno.attr.duplicated='{property}' において、アノテーション {anno} の属性 '{attrName}' の値([${f:join(attrValues, ', ')}])が重複しています。
13 | anno.attr.min='{property}' において、アノテーション {anno} の属性 '{attrName}' の値({attrValue})は、{min}以上の値を設定してください。
14 | anno.attr.invalidType='{property}' において、アノテーション {anno} の属性 '{attrName}' の値({attrValue})は、{type}${empty(pattern) ? '' : ' (' + pattern + ')'}として不正です。
15 |
16 | anno.CsvWordReplace.invalidSize='{property}' において、アノテーション {anno} の属性 'words' と 'replacements' の配列のサイズが一致しません。設定されている属性 'words' のサイズは{wordsSize}、'replacements' のサイズは{replacementsSize}です。
17 | anno.CsvDateTimeRange.minMaxWrong='{property}' において、アノテーション {anno} の属性 'min' の値({minValue})は、属性 'max' の値({maxValue})より以前の値で設定してください。
18 | anno.CsvNumberRange.minMaxWrong='{property}' において、アノテーション {anno} の属性 'min' の値({minValue})は、属性 'max' の値({maxValue})以下の値で設定してください。
19 | anno.CsvLengthBetween.minMaxWrong='{property}' において、アノテーション {anno} の属性 'min' の値({minValue})は、属性 'max' の値({maxValue})以下の値で設定してください。
20 |
21 | anno.CsvPartial.columSizeMin='{property}' において、アノテーション @CsvPartial の属性 'columnSize' の値 ({columnSize}) は、定義している最大の @CsvColumn の属性 'number' の値({maxColumnNumber})以上の設定をしてください。
22 |
23 | anno.CsvOverridesAnnotation.notFoundAttr=アノテーション {compositionAnno} において、アノテーション @CsvOverridesAnnotation で上書きするアノテーション {overrideAnno} の属性({attrType} {attrName}) が見つかりません。
24 | anno.CsvOverridesAnnotation.failGetAttr=アノテーション {compositionAnno} の属性 '{attrName}' の値の取得に失敗しました。
25 |
26 | lazy.noDeteminedColumns='{property}' のヘッダー([${f:join(headers, ', ')}])において、定義しているが一致しないラベル([${f:join(labels, ', ')}])があります。
27 |
28 | # 単語の定義
29 | key.regex=正規表現
30 | key.dateTime=日時
31 |
32 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/localization/PropertiesMessageResolver.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.localization;
2 |
3 | import java.util.Objects;
4 | import java.util.Optional;
5 | import java.util.Properties;
6 |
7 |
8 | /**
9 | * {@link Properties}を元にメッセージを解決するためのクラス。
10 | *
11 | * @version 2.0
12 | * @author T.TSUCHIE
13 | *
14 | */
15 | public class PropertiesMessageResolver implements MessageResolver {
16 |
17 | private Properties properties;
18 |
19 | /**
20 | * デフォルトのコンストラクタ。
21 | * プロパティの中身は空です。
22 | */
23 | public PropertiesMessageResolver() {
24 | this.properties = new Properties();
25 | }
26 |
27 | /**
28 | * プロパティを指定してインスタンスを作成する。
29 | * @param properties
30 | * @throws NullPointerException properties is null.
31 | */
32 | public PropertiesMessageResolver(final Properties properties) {
33 | Objects.requireNonNull(properties, "properties should not be null.");
34 |
35 | this.properties = properties;
36 | }
37 |
38 | /**
39 | * {@inheritDoc}
40 | */
41 | @Override
42 | public Optional getMessage(final String code) {
43 | return Optional.ofNullable(properties.getProperty(code));
44 | }
45 |
46 | /**
47 | *
48 | * @return 設定されているプロパティを取得する。
49 | */
50 | public Properties getProperties() {
51 | return properties;
52 | }
53 |
54 | /**
55 | * プロパティを設定する
56 | * @param properties 設定されているプロパティ
57 | */
58 | public void setProperties(Properties properties) {
59 | this.properties = properties;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/localization/SpringMessageResolver.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.localization;
2 |
3 | import java.util.Optional;
4 |
5 | import org.springframework.context.MessageSource;
6 | import org.springframework.context.NoSuchMessageException;
7 | import org.springframework.context.support.MessageSourceAccessor;
8 |
9 |
10 | /**
11 | * Springの{@link MessageSource}をブリッジする{@link MessageResolver}。
12 | *
13 | * @version 2.0
14 | * @author T.TSUCHIE
15 | *
16 | */
17 | public class SpringMessageResolver implements MessageResolver {
18 |
19 | protected MessageSourceAccessor messageSourceAccessor;
20 |
21 | public SpringMessageResolver() {
22 |
23 | }
24 |
25 | public SpringMessageResolver(final MessageSource messageSource) {
26 | setMessageSource(messageSource);
27 | }
28 |
29 | /**
30 | * {@inheritDoc}
31 | */
32 | @Override
33 | public Optional getMessage(final String code) {
34 | try {
35 | return Optional.of(messageSourceAccessor.getMessage(code));
36 |
37 | } catch(NoSuchMessageException e) {
38 | return Optional.empty();
39 | }
40 | }
41 |
42 | /**
43 | * メッセージソースを設定する
44 | * @param messageSource Springのメッセージソース
45 | */
46 | public void setMessageSource(final MessageSource messageSource) {
47 | this.messageSourceAccessor = new MessageSourceAccessor(messageSource);
48 | }
49 |
50 | /**
51 | * メッセージソースを取得する。
52 | * @return 現在設定されているメッセージソースをラップした{@link MessageSourceAccessor}を返す。
53 | */
54 | protected MessageSourceAccessor getMessageSourceAccessor() {
55 | return messageSourceAccessor;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/localization/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * エラーメッセージを処理する機能を提供します。
3 | *
4 | * @author T.TSUCHIE
5 | *
6 | */
7 | package com.github.mygreen.supercsv.localization;
8 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Super CSVのBeanマップをアノテーションで行う機能を提供します。
3 | *
4 | * @author T.TSUCHIE
5 | *
6 | */
7 | package com.github.mygreen.supercsv;
8 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/util/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * ユーティリティ機能を提供します。
3 | *
4 | * @since 1.2
5 | * @author T.TSUCHIE
6 | *
7 | */
8 | package com.github.mygreen.supercsv.util;
9 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/validation/CsvFieldValidator.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.validation;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | import org.supercsv.util.CsvContext;
7 |
8 | import com.github.mygreen.supercsv.cellprocessor.format.TextPrinter;
9 |
10 | /**
11 | * フィールドに対するValidator
12 | *
13 | * @since 2.0
14 | * @author T.TSUCHIE
15 | *
16 | */
17 | @FunctionalInterface
18 | public interface CsvFieldValidator {
19 |
20 | /**
21 | * メッセージ変数を取得する。
22 | * デフォルトの場合、下記の値が設定される。
23 | *
24 | * - lineNumber : カラムの値に改行が含まれている場合を考慮した実際の行番号です。1から始まります。
25 | * - rowNumber : CSVの行番号です。1から始まります。
26 | * - columnNumber : CSVの列番号です。1から始まります。
27 | * - label : カラムの見出し名です。
28 | * - value : 実際のカラムの値です。
29 | * - printer : カラムの値に対数するフォーマッタです。{@link TextPrinter#print(Object)}でvalue値を文字列に変換します。
30 | *
31 | *
32 | * @param field フィールド情報
33 | * @return メッセージ変数のマップ。
34 | */
35 | default Map createMessageVariables(final CsvField field) {
36 |
37 | final CsvContext csvContext = field.getValidationContext().getCsvContext();
38 |
39 | final Map variables = new HashMap<>();
40 | variables.put("lineNumber", csvContext.getLineNumber());
41 | variables.put("rowNumber", csvContext.getRowNumber());
42 | variables.put("columnNumber", field.getColumnNumber());
43 | variables.put("label", field.getLabel());
44 | variables.put("validatedValue", field.getValue());
45 | variables.put("printer", field.getColumnMapping().getFormatter());
46 |
47 | return variables;
48 |
49 | }
50 |
51 | /**
52 | * フィールドの値の入力値検証を行います。
53 | * @param bindingErrors エラー情報。
54 | * @param field フィールド情報
55 | */
56 | void validate(CsvBindingErrors bindingErrors, CsvField field);
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/validation/CsvValidator.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.validation;
2 |
3 | /**
4 | * CSVのレコード(Beanクラス)に対する入力値検証のインタフェース。
5 | *
6 | * @param Beanのクラスタイプ
7 | * @since 2.0
8 | * @author T.TSUCHIE
9 | *
10 | */
11 | public interface CsvValidator {
12 |
13 | /**
14 | * レコードの値を検証する。
15 | * @param record 検証対象のレコードオブジェクト
16 | * @param bindingErrors エラー情報
17 | * @param validationContext マッピング情報。
18 | */
19 | void validate(R record, CsvBindingErrors bindingErrors, ValidationContext validationContext);
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/validation/ValidationContext.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.validation;
2 |
3 | import org.supercsv.util.CsvContext;
4 |
5 | import com.github.mygreen.supercsv.builder.BeanMapping;
6 |
7 | /**
8 | * 入力値検証する際のContext.
9 | *
10 | * @param Beanのタイプ。
11 | * @since 2.0
12 | * @author T.TSUCHIE
13 | *
14 | */
15 | public class ValidationContext {
16 |
17 | private final CsvContext csvContext;
18 |
19 | private final BeanMapping beanMapping;
20 |
21 | public ValidationContext(final CsvContext csvContext, final BeanMapping beanMapping) {
22 | this.csvContext = csvContext;
23 | this.beanMapping = beanMapping;
24 | }
25 |
26 | public CsvContext getCsvContext() {
27 | return csvContext;
28 | }
29 |
30 | public BeanMapping getBeanMapping() {
31 | return beanMapping;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/validation/beanvalidation/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Bean Validation(JSR-303/JSR-349)と連携する機能を提供します。
3 | * @since 2.0
4 | * @author T.TSUCHIE
5 | *
6 | */
7 | package com.github.mygreen.supercsv.validation.beanvalidation;
8 |
--------------------------------------------------------------------------------
/src/main/java/com/github/mygreen/supercsv/validation/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 入力値検証に関する機能を提供します。
3 | *
4 | * @since 2.0
5 | * @author T.TSUCHIE
6 | *
7 | */
8 | package com.github.mygreen.supercsv.validation;
9 |
--------------------------------------------------------------------------------
/src/main/javadoc/overview.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | CSVのJavaライブラリであるSuper CSVに、アノテーション機能を追加したライブラリです。
7 |
8 | プロジェクト情報
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main/javadoc/resources/external-link-12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mygreen/super-csv-annotation/3bd1a0fd54e6905a5762f5d58a9e3de0a65c00f9/src/main/javadoc/resources/external-link-12.png
--------------------------------------------------------------------------------
/src/site/memo/memo.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mygreen/super-csv-annotation/3bd1a0fd54e6905a5762f5d58a9e3de0a65c00f9/src/site/memo/memo.txt
--------------------------------------------------------------------------------
/src/site/site.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | org.apache.maven.skins
5 | maven-fluido-skin
6 | 1.6
7 |
8 |
9 |
19 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/site/sphinx/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2 | // README at: https://github.com/devcontainers/templates/tree/main/src/python
3 | {
4 | "name": "Sphinx",
5 | // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6 | "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
7 | "runArgs": ["--name", "supser-csv-annotation-sphinx"],
8 |
9 | "workspaceFolder": "/home/vscode/project/sphinx",
10 |
11 | "containerEnv": {
12 | "TZ": "Asia/Tokyo",
13 | "NODE_VERSION": "18.20.5",
14 | "CONTAINER_WORKSPACE_FOLDER": "${containerWorkspaceFolder}"
15 | },
16 |
17 | "mounts": [
18 | // ドキュメントのソース
19 | "source=${localWorkspaceFolder},target=/home/vscode/project/sphinx,type=bind,consistency=cached",
20 | // ドキュメントのビルド出力先
21 | "source=${localWorkspaceFolder}/../../../target,target=/home/vscode/project/target,type=bind,consistency=cached",
22 | // node_modules(volumeeとしてマウント)
23 | "source=super-csv-annotation-sphinx-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume"
24 | ],
25 |
26 | // Features to add to the dev container. More info: https://containers.dev/features.
27 | // "features": {},
28 |
29 | // Use 'postCreateCommand' to run commands after the container is created.
30 | "onCreateCommand": "/bin/bash .devcontainer/on_create.sh",
31 |
32 | // Configure tool-specific properties.
33 | "customizations": {
34 | "vscode": {
35 | "settings": {
36 | "textlint.languages": [
37 | "markdown",
38 | "restructuredtext"
39 | ]
40 | },
41 | "extensions": [
42 | "oderwat.indent-rainbow",
43 | "mosapride.zenkaku",
44 | "lextudio.restructuredtext",
45 | "taichi.vscode-textlint"
46 | ]
47 | }
48 | },
49 |
50 | // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
51 | "remoteUser": "vscode"
52 | }
53 |
--------------------------------------------------------------------------------
/src/site/sphinx/.devcontainer/on_create.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "========= Setup permission =========="
4 | sudo chown -R vscode:vscode node_modules
5 |
6 | echo "========= Setup alias =========="
7 | cat << EOF >> ~/.bashrc
8 | alias ll='ls -l'
9 | alias la='ls -A'
10 | alias l='ls -CF'
11 | EOF
12 |
13 | echo "========= Setup Sphinx =========="
14 | pip3 install -r .devcontainer/requirements.txt
15 |
16 | echo "========= Setup Textlint =========="
17 | # reStructuredText用をASTに変換するPythonモジュールのインストール「docutils-ast-writer」
18 | # ・「textlint-plugin-rst」で使用する。
19 | # ・Sphinxに合わせた docutils に対応したフォークしたモジュール。
20 | mkdir ~/python_modules && cd ~/python_modules
21 | pip3 install -e git+https://github.com/mygreen/docutils-ast-writer@mygreen#egg=docutils-ast-writer
22 | cd ${CONTAINER_WORKSPACE_FOLDER}
23 |
24 | source $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION}
25 |
26 | ## npm ciを post create で実行すると、textlintのインストール前にVScodeが開かれtextlintのサーバ起動に失敗するため、
27 | ## on create で実行する。
28 | npm ci
29 |
30 | echo "=========================="
31 | echo "Finish ! on create"
32 | echo "=========================="
33 |
34 |
--------------------------------------------------------------------------------
/src/site/sphinx/.devcontainer/requirements.txt:
--------------------------------------------------------------------------------
1 | sphinx==7.4.*
2 | sphinx_rtd_theme==2.0.0
3 | janome
4 |
--------------------------------------------------------------------------------
/src/site/sphinx/.gitignore:
--------------------------------------------------------------------------------
1 | ## sphinx
2 | /build
3 | /_build
4 |
5 | ## node
6 | /.cache
7 | /node_modules
8 |
9 | ## for tmporary file.
10 | *~
11 | ~*
12 | \#*\#
13 |
--------------------------------------------------------------------------------
/src/site/sphinx/.textlintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "plugins": {
3 | "rst": {
4 | "parseCommand": "rst2ast -q --no-file-insertion"
5 | }
6 | },
7 | "filters": {},
8 | "rules": {
9 | "preset-ja-technical-writing": true,
10 | "preset-jtf-style": true
11 | }
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/src/site/sphinx/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line, and also
5 | # from the environment for the first two.
6 | SPHINXOPTS ?=
7 | SPHINXBUILD ?= sphinx-build
8 | SOURCEDIR = source
9 | BUILDDIR = build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21 |
--------------------------------------------------------------------------------
/src/site/sphinx/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "Building sphinx documentation for version $1"
4 |
5 | SCRIPT_DIR=$(cd $(dirname $0); pwd)
6 | cd $SCRIPT_DIR
7 |
8 | if [ -e ./build ]; then
9 | echo "step - remove old build directory."
10 | sudo /bin/rm -rf ./build/*
11 | fi
12 |
13 | echo "step - make html by sphinx."
14 | make html PACKAGE_VERSION=$1
15 |
16 | TARGET_DIR=../target
17 | echo "step - remove target sphinx directory."
18 | sudo /bin/rm -rf ${TARGET_DIR}/site/sphinx
19 | /bin/mkdir -p ${TARGET_DIR}/site/sphinx
20 |
21 | echo "step - copy build html to target directory."
22 | /bin/cp -vr ./build/html/* ${TARGET_DIR}/site/sphinx/
23 |
24 | ## github-pagesのsphinx対応
25 | echo "step - create file or .nojekyll."
26 | touch ${TARGET_DIR}/site/.nojekyll
27 |
--------------------------------------------------------------------------------
/src/site/sphinx/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | pushd %~dp0
4 |
5 | REM Command file for Sphinx documentation
6 |
7 | if "%SPHINXBUILD%" == "" (
8 | set SPHINXBUILD=sphinx-build
9 | )
10 | set SOURCEDIR=source
11 | set BUILDDIR=build
12 |
13 | if "%1" == "" goto help
14 |
15 | %SPHINXBUILD% >NUL 2>NUL
16 | if errorlevel 9009 (
17 | echo.
18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19 | echo.installed, then set the SPHINXBUILD environment variable to point
20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you
21 | echo.may add the Sphinx directory to PATH.
22 | echo.
23 | echo.If you don't have Sphinx installed, grab it from
24 | echo.http://sphinx-doc.org/
25 | exit /b 1
26 | )
27 |
28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29 | goto end
30 |
31 | :help
32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33 |
34 | :end
35 | popd
36 |
--------------------------------------------------------------------------------
/src/site/sphinx/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "super-csv-annotation-sphinx",
3 | "version": "1.0.0",
4 | "description": "Super CSV AnnotationのSphinx + Textlint用のプロジェクト。",
5 | "main": "index.js",
6 | "scripts": {
7 | "build": "rm -rf build && make html",
8 | "deploy": "/bin/bash deploy.sh",
9 | "lint": "npx textlint ./source/*.rst"
10 | },
11 | "keywords": [],
12 | "author": "T.TSUCHIE",
13 | "license": "ISC",
14 | "devDependencies": {
15 | "textlint": "^13.4.1",
16 | "textlint-plugin-rst": "github:shiguredo/textlint-plugin-rst#shiguredo",
17 | "textlint-rule-preset-ja-technical-writing": "^7.0.0",
18 | "textlint-rule-preset-jtf-style": "^2.3.14"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/_static/external-link-12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mygreen/super-csv-annotation/3bd1a0fd54e6905a5762f5d58a9e3de0a65c00f9/src/site/sphinx/source/_static/external-link-12.png
--------------------------------------------------------------------------------
/src/site/sphinx/source/_static/jquery.externallink.js:
--------------------------------------------------------------------------------
1 | /**
2 | * jQuery Plugin
3 | * 外部リンクに、taget="_blank" を付与し、かつアイコン画像も付与する。
4 | */
5 | (function( $ ) {
6 |
7 | $.fn.externalLink = function( options ) {
8 |
9 | var settings = $.extend( {
10 | cssClass : 'external',
11 | iconUrl : 'images/externalink.png',
12 | startUrl : ''
13 | }, options);
14 |
15 | $(this).find('a').each(function() {
16 | var href = $(this).attr('href');
17 | if(href != undefined && href != null && href != "") {
18 |
19 | if(href.indexOf('http://') == 0 || href.indexOf('https://') == 0
20 | || (settings.startUrl.length > 0 && href.indexOf(settings.startUrl) == 0) ) {
21 |
22 | $(this).attr("target", "_blank");
23 | $(this).addClass(settings.cssClass);
24 |
25 | if(settings.iconUrl.length > 0) {
26 | var img = $('
').addClass('icon_externallink').attr('src', settings.iconUrl);
27 | $(this).append(img);
28 | }
29 |
30 | }
31 |
32 | }
33 | });
34 |
35 | return this;
36 |
37 | };
38 | })( jQuery );
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/_static/mycustom.css:
--------------------------------------------------------------------------------
1 | @charset "UTF-8";
2 |
3 | /**
4 | * コンテンツの領域の広さを広げる
5 | */
6 | .wy-nav-content {
7 | max-width: 100%;
8 | }
9 |
10 | /**
11 | * 表内の改行のインデントを解除する
12 | */
13 | td div.line-block {
14 | margin-left: 0 !important;
15 | margin-bottom: 0 !important;
16 | }
17 |
18 | /**
19 | * ナビゲーションのキャプション
20 | */
21 | div.wy-menu p.caption {
22 | background-color: #AAAAAA;
23 | margin-top: 10px;
24 | font-size: 105%;
25 | padding: 0 1.018em;
26 | color: #232722;
27 | }
28 |
29 | /**
30 | * 狭いときのナビゲーション
31 | */
32 | .wy-nav-top {
33 | background-color: #8ca210;
34 | }
35 |
36 | /**
37 | * 検索コンテナの背景色
38 | */
39 | .wy-side-nav-search {
40 |
41 | background-color: #8ca210;
42 | }
43 |
44 | /**
45 | * 外部リンクのアイコン
46 | */
47 | img.icon_externallink {
48 | margin-left: 3px;
49 | margin-bottom: 3px;
50 |
51 | vertical-align: middle;
52 | }
53 |
54 | a.externalink[target="_blank"] {
55 | padding-right:15px;
56 | background: url(external-link-12.png)no-repeat right;
57 | }
58 |
59 |
60 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/_templates/layout.html:
--------------------------------------------------------------------------------
1 | {% extends "!layout.html" %}
2 |
3 |
4 | {% set css_files = css_files + [ "_static/mycustom.css" ] %}
5 |
6 | {%- block extrahead %}
7 | {{ super() }}
8 |
9 | {%- endblock%}
10 |
11 |
12 | {%- block menu %}
13 | 関連リンク
14 |
20 |
21 | {{ super() }}
22 |
23 | {%- endblock%}
24 |
25 |
26 | {% block footer %}
27 |
28 |
29 |
39 |
40 |
41 |
42 |
49 |
50 | {{ super() }}
51 | {% endblock %}
52 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/configuration.rst:
--------------------------------------------------------------------------------
1 | ======================================
2 | システム設定
3 | ======================================
4 |
5 |
6 | .. 以降は、埋め込んで作成する
7 | .. include:: ./configuration_configuration.rst
8 | .. include:: ./configuration_systemproperty.rst
9 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/configuration_systemproperty.rst:
--------------------------------------------------------------------------------
1 | --------------------------------------------------------
2 | Javaシステムプロパティによる設定
3 | --------------------------------------------------------
4 |
5 | Javaシステムプロパティによる設定可能な項目一覧を下記に示します。
6 |
7 | javaシステムプロパティは、JVMの起動パラメータ ``-Dxxx=yyy`` または、 ``System.setProperty("xxx", "yyy")`` で指定します。
8 |
9 | .. list-table:: Javaシステムプロパティによる設定項目一覧
10 | :widths: 30 70
11 | :header-rows: 1
12 |
13 | * - プロパティ名
14 | - 説明
15 |
16 | * - | *supercsv.annotation.jexlRestricted*
17 | | *[2.4+]*
18 | - | ``ExpressionLanguageJEXLImpl`` にて、JEXLを Restrict パーミッションでEL式を評価するか指定します。
19 | | デフォルトは `true` で、`JexlPermissions.RESTRICTED `_ でEL式が評価されます。
20 | | 値を `false` に指定すると、`JexlPermissions.UNRESTRICTED `_ が設定され、EL式が制限なく評価されますが、
21 | | ただし、ELインジェクションの脆弱性に繋がる可能性があるので注意してください。
22 |
23 | * - | *supercsv.annotation.jexlPermissions*
24 | | *[2.4+]*
25 | - | ``ExpressionLanguageJEXLImpl`` にて、JEXLを評価する際のパーミッションを指定します。
26 | | EL式中で実行/参照可能なパッケージを指定し、複数指定するときはカンマ(`,`)区切りで指定します。
27 | | 例 . `sample1.*,sample2.core.*`。
28 | | このプロパティは、 ``supercsv.annotation.jexlRestricted`` の値が `true` のときにおいて、Restrictパーミッションで実行されるときのみ有効になります。
29 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/conversion.rst:
--------------------------------------------------------------------------------
1 | ======================================
2 | 値の変換方法
3 | ======================================
4 |
5 | 読み込み時の文字列を各クラスのタイプにパースする前と、書き込み時の各クラスから文字列にフォーマットした後の文字列に対して、値を変換できます。
6 |
7 | 例えば、トリミングや大文字に変換などを行うことができます。
8 |
9 |
10 | .. 以降は、埋め込んで作成する
11 | .. include:: ./conversion_annotation.rst
12 | .. include:: ./conversion_custom.rst
13 |
14 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/format.rst:
--------------------------------------------------------------------------------
1 | ======================================
2 | 書式の指定方法
3 | ======================================
4 |
5 | 数値や日時型などに対して書式を指定する方法を説明します。
6 |
7 | 独自のクラスタイプに対応しても、専用クラスを用意することで対応できます。
8 |
9 | .. 以降は、埋め込んで作成する
10 | .. include:: ./format_annotation.rst
11 | .. include:: ./format_custom.rst
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/format_annotation.rst:
--------------------------------------------------------------------------------
1 | --------------------------------------------------------
2 | 書式指定用の既存のアノテーション
3 | --------------------------------------------------------
4 |
5 |
6 | .. list-table:: 書式を指定する既存のアノテーション
7 | :widths: 30 55 15
8 | :header-rows: 1
9 |
10 | * - アノテーション
11 | - 概要
12 | - 参照
13 |
14 | * - :doc:`@CsvBooleanFormat `
15 | - ブール型に対する書式を指定します。
16 | - `JavaDoc <../apidocs/com/github/mygreen/supercsv/annotation/format/CsvBooleanFormat.html>`__
17 |
18 | * - :doc:`@CsvNumberFormat `
19 | - 数値型に対する書式を指定します。
20 | - `JavaDoc <../apidocs/com/github/mygreen/supercsv/annotation/format/CsvNumberFormat.html>`__
21 |
22 | * - :doc:`@CsvDateTimeFormat `
23 | - 日時型に対する書式を指定します。
24 | - `JavaDoc <../apidocs/com/github/mygreen/supercsv/annotation/format/CsvDateTimeFormat.html>`__
25 |
26 | * - :doc:`@CsvEnumFormat `
27 | - 列挙型に対する書式を指定します。
28 | - `JavaDoc <../apidocs/com/github/mygreen/supercsv/annotation/format/CsvEnumFormat.html>`__
29 |
30 |
31 |
32 | .. 以降は、埋め込んで作成する
33 | .. include:: ./format_annotation_boolean.rst
34 | .. include:: ./format_annotation_number.rst
35 | .. include:: ./format_annotation_datetime.rst
36 | .. include:: ./format_annotation_enum.rst
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/index.rst:
--------------------------------------------------------------------------------
1 | .. Super CSV Annotation documentation master file, created by
2 | sphinx-quickstart on Fri Dec 02 23:06:46 2016.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Welcome to Super CSV Annotation
7 | ================================================
8 |
9 | JavaのCSVファイルのライブラリ「 `Super CSV `_ 」に、アノテーション機能を追加したライブラリです。
10 |
11 | .. toctree::
12 | :numbered:
13 | :maxdepth: 3
14 | :caption: 目次
15 |
16 | howtouse
17 | basic
18 | format
19 | conversion
20 | validation
21 | composition
22 | partialization
23 | fixedsizecolumn
24 | labelledcolumn
25 | processorbuilder
26 | lifecycle
27 | spring
28 | configuration
29 | migration
30 | release
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/lifecycle.rst:
--------------------------------------------------------------------------------
1 | ===============================================================
2 | ライフサイクルイベントの管理
3 | ===============================================================
4 |
5 | レコード単位に、読み込み/書き込みの前後のイベントをハンドリングできます。
6 |
7 | 実装方法として、JavaBeanに直接処理を実装する方法と、リスナークラスを指定して別のクラスで実装する方法の2種類があります。
8 |
9 |
10 | .. 以降は、埋め込んで作成する
11 | .. include:: ./lifecycle_annotation.rst
12 | .. include:: ./lifecycle_listener.rst
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/lifecycle_listener.rst:
--------------------------------------------------------------------------------
1 | --------------------------------------------------------
2 | リスナークラスによるライフサイクルの管理
3 | --------------------------------------------------------
4 |
5 | リスナークラスはPOJOで作成し、ライスサイクル用のアノテーションでメソッドを実装します。
6 |
7 | 処理対象のレコードオブジェクトが必要なため、基本的に引数にはレコードクラスを指定しておきます。
8 |
9 | .. sourcecode:: java
10 | :linenos:
11 |
12 |
13 | import com.github.mygreen.supercsv.annotation.CsvPostRead;
14 | import com.github.mygreen.supercsv.annotation.CsvPostWrite;
15 | import com.github.mygreen.supercsv.annotation.CsvPreRead;
16 | import com.github.mygreen.supercsv.annotation.CsvPreWrite;
17 |
18 | // リスナークラスの定義
19 | public class SampleListener {
20 |
21 | @CsvPreRead
22 | public void handlePreRead(final SampleCsv record) {
23 |
24 | // レコードの読み込み前に呼び出されます。
25 | }
26 |
27 | @CsvPostRead
28 | public void handlePostRead(final SampleCsv record, final CsvBindingErrors bindingErrors, final Class>[] groups) {
29 |
30 | // レコードの読み込み後に呼び出されます。
31 |
32 | }
33 |
34 | @CsvPreWrite
35 | public void handlePreWrite(final SampleCsv record, final CsvBindingErrors bindingErrors, final Class>[] groups) {
36 |
37 | // レコードの書き込み前に呼び出されます。
38 |
39 | }
40 |
41 | @CsvPostWrite
42 | public void handlePostWrite(final SampleCsv record, final CsvBindingErrors bindingErrors, final Class>[] groups) {
43 |
44 | // レコードの書き込み後に呼び出されます。
45 |
46 | }
47 |
48 | }
49 |
50 |
51 | 使用する際には、``@CsvBean(listeners=<リスナークラス>)`` にクラスを指定します。
52 |
53 |
54 | .. sourcecode:: java
55 | :linenos:
56 |
57 |
58 | import com.github.mygreen.supercsv.annotation.CsvBean;
59 | import com.github.mygreen.supercsv.annotation.CsvColumn;
60 |
61 | // リスナクラスを指定します
62 | @CsvBean(header=true, listeners=SampleListener.class)
63 | public class SampleCsv {
64 |
65 | @CsvColumn(number=1, label="ID")
66 | private Integer id;
67 |
68 | @CsvColumn(number=2, label="値")
69 | private String value;
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/migration.rst:
--------------------------------------------------------------------------------
1 | ======================================
2 | マイグレーション
3 | ======================================
4 |
5 | バージョン間で互換正がなくなった設定や機能などを説明します。
6 | バージョンアップする際の参考にしてください。
7 |
8 | :doc:`リリースノート ` も参考にしてください。
9 |
10 | --------------------------------------------------------
11 | To ver.2.2
12 | --------------------------------------------------------
13 |
14 | * クラスパスルートに配置しているプロパティファイル ``SuperCsvMessages.properties`` を、文字コードがUTF-8のテキストファイルに修正してください。
15 |
16 | * ``ResourceBundleMessageResolver`` のデフォルトの動作を変更したため、ASCIIコードに変換する必要は無くなりました。
17 |
18 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/spring.rst:
--------------------------------------------------------------------------------
1 | ======================================
2 | Spring Frameworkとの連携
3 | ======================================
4 |
5 | DI(Depenency Injection) 機能のフレームワーク `Spring Framework `_ と連携できます。
6 |
7 | Spring Frameworkのコンテナで管理可能、DI可能な部分は、次の箇所になります。
8 |
9 | これらの機能・箇所は、 ``BeanFactory`` によるインスタンスを新しく作成する箇所であり、その実装を ``SpringBeanFactory`` に切り替え得ることで、DIを実現します。
10 |
11 |
12 | .. list-table:: Spring Frameworkとの連携可能な箇所
13 | :widths: 40 60
14 | :header-rows: 1
15 |
16 | * - 機能・箇所
17 | - 説明
18 |
19 | * - :doc:`独自の書式を指定する機能 `
20 | - ``TextFormatter`` の実装クラスがSpringBeanとして管理可能です。
21 |
22 | * - :doc:`独自の変換処理の実装機能 `
23 | - ``ConversionProcessorFactory`` の実装クラスがSpringBeanとして管理可能です。
24 |
25 | * - :doc:`独自のカラム値の検証の実装機能 `
26 | - ``ConstraintProcessorFactory`` の実装クラスがSpringBeanとして管理可能です。
27 |
28 | * - :doc:`独自のValidatorの実装機能 `
29 | - ``CsvValidator`` の実装クラスがSpringBeanとして管理可能です。
30 |
31 | * - :doc:`独自のリスナーの実装機能 `
32 | - リスナクラスがSpringBeanとして管理可能です。
33 |
34 | * - :doc:`独自のProcessorBuilder実装機能 `
35 | - ``ProcessorBuilder`` の実装クラスがSpringBeanとして管理可能です。
36 |
37 | * - :doc:`BeanValidationの連携機能 `
38 | - *BeanValidation* の検証用の実装クラスがSpringBeanとして管理可能です。
39 |
40 | * - :doc:`エラーメッセージのカスタマイズ機能 `
41 | - ``MessageResolver`` の内容を ``MessagSource`` から参照可能です。
42 |
43 |
44 |
45 | --------------------------------------------------------
46 | ライブラリの追加
47 | --------------------------------------------------------
48 |
49 | Spring Frameworkを利用する際には、ライブリを追加します。
50 | Mavenを利用している場合は、pom.xmlに以下を追加します。
51 |
52 | Spring Frameworkのバージョンは、3.0以上を指定してください。
53 |
54 | .. sourcecode:: xml
55 | :linenos:
56 |
57 |
58 | org.springframework
59 | spring-context
60 | 4.3.2.RELEASE
61 |
62 |
63 |
64 |
65 | .. 以降は、埋め込んで作成する
66 | .. include:: ./spring_beanfactory.rst
67 | .. include:: ./spring_message.rst
68 |
69 |
70 |
--------------------------------------------------------------------------------
/src/site/sphinx/source/validation.rst:
--------------------------------------------------------------------------------
1 | ======================================
2 | 値の検証方法
3 | ======================================
4 |
5 |
6 | .. 以降は、埋め込んで作成する
7 | .. include:: ./validation_annotation.rst
8 | .. include:: ./validation_custom.rst
9 | .. include:: ./validation_validator.rst
10 | .. include:: ./validation_handle.rst
11 | .. include:: ./validation_message.rst
12 | .. include:: ./validation_beanvalidation.rst
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/test/data/data_equaled_value.txt:
--------------------------------------------------------------------------------
1 | -1000
2 | 1000
--------------------------------------------------------------------------------
/src/test/data/data_forbidden_word.txt:
--------------------------------------------------------------------------------
1 | 馬鹿
2 | 阿呆
3 |
--------------------------------------------------------------------------------
/src/test/data/data_replaced_word.txt:
--------------------------------------------------------------------------------
1 | 下さい,ください
2 | 御願い,お願い
3 |
--------------------------------------------------------------------------------
/src/test/data/data_required_word.txt:
--------------------------------------------------------------------------------
1 | 今日
2 | 天気
3 | よろしく
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_error_column_size.csv:
--------------------------------------------------------------------------------
1 | id,数字1,number2,string1,string2,date1,date2,enum1,列挙型2,boolean1,boolean2
2 | 1,"999,110",10.2,abcd,12345,2000-01-01 00:01:02,2000年02月03日,RED,赤,true,
3 | 2,-12,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,×,,
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_error_elinjection_column.csv:
--------------------------------------------------------------------------------
1 | id,value
2 | 1,abc${''.getClass().forName('java.lang.Runtime').getRuntime().exec('notepad')}efg
3 | 2,かきくけこ
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_error_elinjection_header.csv:
--------------------------------------------------------------------------------
1 | id,abc${''.getClass().forName('java.lang.Runtime').getRuntime().exec('notepad')}efg
2 | 1,あいうえお
3 | 2,かきくけこ
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_error_header_size.csv:
--------------------------------------------------------------------------------
1 | id,数字1,number2,string1,string2,date1,date2,enum1,列挙型2,boolean1
2 | 1,"999,110",10.2,abcd,12345,2000-01-01 00:01:02,2000年02月03日,RED,赤,true,
3 | 2,-12,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,×
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_error_header_value.csv:
--------------------------------------------------------------------------------
1 | id,間違い,number2,string1,string2,date1,date2,enum1,列挙型2,boolean1,boolean2
2 | 1,"999,110",10.2,abcd,12345,2000-01-01 00:01:02,2000年02月03日,RED,赤,true,
3 | 2,-12,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,×
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_error_wrong_pattern.csv:
--------------------------------------------------------------------------------
1 | id,数字1,number2,string1,string2,date1,date2,enum1,列挙型2,boolean1,boolean2
2 | 1,"999,110",10.2,abcd,12345,2000/01/01 00:01:02,2000年02月03日,RED,赤,true,
3 | 2,-12,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,×
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_external_error_enum.csv:
--------------------------------------------------------------------------------
1 | ID,名前,入社日付,ロール,郵便番号
2 | 1,山田 太郎,2020/04/01,aaa,001-1111
3 | 2,鈴木 次郎,2021/09/30,Developer,002-2222
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_external_error_type.csv:
--------------------------------------------------------------------------------
1 | ID,名前,入社日付,ロール,郵便番号
2 | 1,山田 太郎,2020/04/01,Admin,0011111
3 | 2,鈴木 次郎,2021/09/30,Developer,002-2222
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_external_normal.csv:
--------------------------------------------------------------------------------
1 | ID,名前,入社日付,ロール,郵便番号
2 | 1,山田 太郎,2020/04/01,Admin,001-1111
3 | 2,鈴木 次郎,2021/09/30,Developer,002-2222
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_fixedColumn.csv:
--------------------------------------------------------------------------------
1 | no,ユーザ名 ,誕生日____,コメント
2 | 1,山田 太郎 ,1980-01-28,全ての項目に値が設定
3 | 2,田中 次郎 ,__________,誕生日の項目が空。
4 | 3,鈴木 三郎 ,2000-03-25,コメントを切落とす。あいう。
5 |
--------------------------------------------------------------------------------
/src/test/data/test_read_lazy.csv:
--------------------------------------------------------------------------------
1 | no,name,"生年月日","備考"
2 | 1,"山田太郎",2000/10/01,"あいうえお"
3 | 2,"鈴木次郎",2012/01/02,
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_lazy_fixedColumn.csv:
--------------------------------------------------------------------------------
1 | no,誕生日____,ユーザ名 ,コメント
2 | 1,1980-01-28,山田 太郎 ,全ての項目に値が設定
3 | 2,__________,田中 次郎 ,誕生日の項目が空。
4 | 3,2000-03-25,鈴木 三郎 ,コメントを切落とす。あいう。
5 |
--------------------------------------------------------------------------------
/src/test/data/test_read_lazy_noHeader.csv:
--------------------------------------------------------------------------------
1 | 1,"山田太郎",2000/10/01,"あいうえお"
2 | 2,"鈴木次郎",2012/01/02,
3 |
--------------------------------------------------------------------------------
/src/test/data/test_read_lazy_partial.csv:
--------------------------------------------------------------------------------
1 | id,名前,誕生日,電話番号,住所,有効期限,削除フラグ,備考
2 | 1,山田太郎,1980-01-02,03-1234-1234,東京都○×市,2017-12-31,レ,コメント1
3 | 2,鈴木次郎,1982-02-03,018-123-4567,秋田県△△市,2017-12-31,-,
4 | 3,佐藤花子,1983-03-04,0853-12-3456,島根県××市,2017-12-31,レ,コメント3
5 |
--------------------------------------------------------------------------------
/src/test/data/test_read_lazy_wrong_pattern.csv:
--------------------------------------------------------------------------------
1 | no,name,"生年月日","備考"
2 | 1,"山田太郎",2000-10-01,"あいうえお"
3 | 2,"鈴木次郎",2012/01/02,
4 |
--------------------------------------------------------------------------------
/src/test/data/test_read_normal.csv:
--------------------------------------------------------------------------------
1 | id,数字1,number2,string1,string2,date1,date2,enum1,列挙型2,boolean1,boolean2
2 | 1,"999,110",10.2,abcd,12345,2000-01-01 00:01:02,2000年02月03日,RED,赤,true,
3 | 2,-12,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,×
4 |
--------------------------------------------------------------------------------
/src/test/data/test_spring_read_error_notFound_userName.csv:
--------------------------------------------------------------------------------
1 | ユーザID,ユーザ名,メールアドレス
2 | 001,hoge,hoge@example.com
3 |
--------------------------------------------------------------------------------
/src/test/data/test_spring_read_normal.csv:
--------------------------------------------------------------------------------
1 | ユーザID,ユーザ名,メールアドレス
2 | 001,test,test@example.com
3 | 002,admin,admin@example.com
4 |
--------------------------------------------------------------------------------
/src/test/data/test_write_append.csv:
--------------------------------------------------------------------------------
1 | id,数字1,number2,string1,string2,date1,date2,enum1,列挙型2,boolean1,boolean2
2 | 1,"999,110",10.2,abcd,12345,2000-01-01 00:01:02,2000年02月03日,RED,赤,true,×
3 | 2,-12,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,×
4 | 3,"-98,765",10.2,abcd,12345,2000-01-01 00:01:02,2000年02月03日,RED,赤,true,×
5 | 4,0,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,×
6 |
--------------------------------------------------------------------------------
/src/test/data/test_write_error_continue.csv:
--------------------------------------------------------------------------------
1 | id,数字1,number2,string1,string2,date1,date2,enum1,列挙型2,boolean1,boolean2
2 | 2,-12,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,×
3 |
--------------------------------------------------------------------------------
/src/test/data/test_write_fixedColumn.csv:
--------------------------------------------------------------------------------
1 | no,ユーザ名 ,誕生日____,コメント
2 | 1,山田 太郎 ,1980-01-28,全ての項目に値が設定
3 | 2,田中 次郎 ,__________,誕生日の項目が空。
4 | 3,鈴木 三郎 ,2000-03-25,コメントを切落とす。
5 |
--------------------------------------------------------------------------------
/src/test/data/test_write_ignore_constaint.csv:
--------------------------------------------------------------------------------
1 | id,数字1,number2,string1,string2,date1,date2,enum1,列挙型2,boolean1,boolean2
2 | 1,"1,000,000",10.2,,12345,2000-01-01 00:01:02,2000年02月03日,RED,赤,true,×
3 | 2,-12,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,×
4 |
--------------------------------------------------------------------------------
/src/test/data/test_write_lazy_error_continue.csv:
--------------------------------------------------------------------------------
1 | 生年月日,name,no,備考
2 | 2012/01/02,鈴木次郎,2,
3 |
--------------------------------------------------------------------------------
/src/test/data/test_write_lazy_fixedColumn_noSetHeader.csv:
--------------------------------------------------------------------------------
1 | no,誕生日____,コメント ,ユーザ名
2 | 1,1980-01-28,全ての項目に値が設定,山田 太郎
3 | 2,__________,生日の項目が空。 ,田中 次郎
4 | 1,2000-03-25,コメントを切落とす。,鈴木 三郎
5 |
--------------------------------------------------------------------------------
/src/test/data/test_write_lazy_fixedColumn_setHeader.csv:
--------------------------------------------------------------------------------
1 | no,ユーザ名 ,誕生日____,コメント
2 | 1,山田 太郎 ,1980-01-28,全ての項目に値が設定
3 | 2,田中 次郎 ,__________,生日の項目が空。
4 | 1,鈴木 三郎 ,2000-03-25,コメントを切落とす。
5 |
--------------------------------------------------------------------------------
/src/test/data/test_write_lazy_noSetHeader.csv:
--------------------------------------------------------------------------------
1 | 生年月日,name,no,備考
2 | 2000/10/01,山田太郎,1,あいうえお
3 | 2012/01/02,鈴木次郎,2,
4 |
--------------------------------------------------------------------------------
/src/test/data/test_write_lazy_noSetHeader_append.csv:
--------------------------------------------------------------------------------
1 | 生年月日,name,no,備考
2 | 2000/10/01,山田太郎,1,あいうえお
3 | 2012/01/02,鈴木次郎,2,
4 | 2005/03/05,山本花子,3,かきくけこ
5 | 2011/04/12,佐藤三郎,4,
6 |
--------------------------------------------------------------------------------
/src/test/data/test_write_lazy_noSetHeader_noHeader.csv:
--------------------------------------------------------------------------------
1 | 2000/10/01,山田太郎,1,あいうえお
2 | 2012/01/02,鈴木次郎,2,
3 |
--------------------------------------------------------------------------------
/src/test/data/test_write_lazy_partial.csv:
--------------------------------------------------------------------------------
1 | id,名前,誕生日,電話番号,住所,有効期限,削除フラグ,備考
2 | 1,山田太郎,,,,1980-01-02,,コメント1
3 | 2,鈴木次郎,,,,1982-02-03,,
4 | 3,佐藤花子,,,,1983-03-04,,コメント3
5 |
--------------------------------------------------------------------------------
/src/test/data/test_write_lazy_partial_noSetHeader.csv:
--------------------------------------------------------------------------------
1 | id,備考,誕生日,名前,住所,有効期限,column7,column8
2 | 1,コメント1,,山田太郎,,1980-01-02,,
3 | 2,,,鈴木次郎,,1982-02-03,,
4 | 3,コメント3,,佐藤花子,,1983-03-04,,
5 |
--------------------------------------------------------------------------------
/src/test/data/test_write_lazy_setHeader.csv:
--------------------------------------------------------------------------------
1 | no,name,生年月日,備考
2 | 1,山田太郎,2000/10/01,あいうえお
3 | 2,鈴木次郎,2012/01/02,
4 |
--------------------------------------------------------------------------------
/src/test/data/test_write_normal.csv:
--------------------------------------------------------------------------------
1 | id,数字1,number2,string1,string2,date1,date2,enum1,列挙型2,boolean1,boolean2
2 | 1,"999,110",10.2,abcd,12345,2000-01-01 00:01:02,2000年02月03日,RED,赤,true,×
3 | 2,-12,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,×
4 |
--------------------------------------------------------------------------------
/src/test/data/test_write_partial.csv:
--------------------------------------------------------------------------------
1 | id,数字1,number2,string1,string2,date1,date2,enum1,列挙型2,boolean1,boolean2
2 | 1,"999,110",,abcd,,2000-01-01 00:01:02,,RED,,true,
3 | 2,-12,,あいうえお,,2000-02-01 03:04:05,,BLUE,,false,
4 |
--------------------------------------------------------------------------------
/src/test/data/test_write_tab.csv:
--------------------------------------------------------------------------------
1 | "id" "数字1" "number2" "string1" "string2" "date1" "date2" "enum1" "列挙型2" "boolean1" "boolean2"
2 | "1" "999,110" "10.2" "abcd" "12345" "2000-01-01 00:01:02" "2000年02月03日" "RED" "赤" "true" "×"
3 | "2" "-12" "あいうえお" "" "2000-02-01 03:04:05" "BLUE" "false" "×"
4 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/DefaultBeanFactoryTest.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder;
2 |
3 | import static org.junit.Assert.*;
4 | import static org.assertj.core.api.Assertions.*;
5 |
6 | import org.junit.Before;
7 | import org.junit.Test;
8 |
9 |
10 | /**
11 | * {@link DefaultBeanFactory}のテスタ
12 | *
13 | * @since 2.2
14 | * @author T.TSUCHIE
15 | *
16 | */
17 | public class DefaultBeanFactoryTest {
18 |
19 | private BeanFactory, Object> beanFactory;
20 |
21 | @Before
22 | public void setUp() throws Exception {
23 | this.beanFactory = new DefaultBeanFactory();
24 | }
25 |
26 | @Test
27 | public void testCreate_staticClass() {
28 |
29 | StaticClass bean = (StaticClass) beanFactory.create(StaticClass.class);
30 | assertThat(bean.doExecute()).isEqualTo("static-class");
31 |
32 | }
33 |
34 | @Test
35 | public void testCreate_nonStaticClass() {
36 |
37 | NonStaticClass bean = (NonStaticClass) beanFactory.create(NonStaticClass.class);
38 | assertThat(bean.doExecute()).isEqualTo("non-static-class");
39 |
40 | }
41 |
42 | /**
43 | * staticクラス
44 | *
45 | */
46 | private static class StaticClass {
47 |
48 | String message = "static-class";
49 |
50 | String doExecute() {
51 | return message;
52 | }
53 |
54 | }
55 |
56 | /**
57 | * 非staticクラス
58 | *
59 | */
60 | private static class NonStaticClass {
61 |
62 | String message = "non-static-class";
63 |
64 | String doExecute() {
65 | return message;
66 | }
67 |
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/SampleObject.xsd:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/spring/CsvUserNameExist.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder.spring;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Repeatable;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | import com.github.mygreen.supercsv.annotation.constraint.CsvConstraint;
11 |
12 | /**
13 | *
14 | *
15 | * @since 2.0
16 | * @author T.TSUCHIE
17 | *
18 | */
19 | @Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
20 | @Retention(RetentionPolicy.RUNTIME)
21 | @Documented
22 | @Repeatable(CsvUserNameExist.List.class)
23 | @CsvConstraint(UserNameExistFactory.class)
24 | public @interface CsvUserNameExist {
25 |
26 | String message() default "{com.github.mygreen.supercsv.builder.spring.CsvUserNameExist.message}";
27 |
28 | Class>[] groups() default {};
29 |
30 | /**
31 | * アノテーションの処理順序の定義。
32 | * @return 値が大きいほど後に実行されます。
33 | * 値が同じ場合は、アノテーションのクラス名の昇順になります。
34 | */
35 | int order() default 0;
36 |
37 | @Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
38 | @Retention(RetentionPolicy.RUNTIME)
39 | @Documented
40 | @interface List {
41 |
42 | CsvUserNameExist[] value();
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/spring/UrlFormatter.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder.spring;
2 |
3 | import java.net.MalformedURLException;
4 | import java.net.URL;
5 |
6 | import org.springframework.context.annotation.Scope;
7 | import org.springframework.stereotype.Component;
8 |
9 | import com.github.mygreen.supercsv.cellprocessor.format.AbstractTextFormatter;
10 | import com.github.mygreen.supercsv.cellprocessor.format.TextParseException;
11 |
12 |
13 | /**
14 | * {@link URL}のフォーマッタ。
15 | * Springで管理する。ただし、prototypeスコープ。
16 | *
17 | * @since 2.0
18 | * @author T.TSUCHIE
19 | *
20 | */
21 | @Scope("prototype")
22 | @Component
23 | public class UrlFormatter extends AbstractTextFormatter {
24 |
25 | @Override
26 | public URL parse(final String text) {
27 |
28 | try {
29 | return new URL(text);
30 | } catch(MalformedURLException e) {
31 | throw new TextParseException(text, URL.class, e);
32 | }
33 |
34 | }
35 |
36 | @Override
37 | public String print(final URL object) {
38 | return object.toExternalForm();
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/spring/UrlProcessorBuilder.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder.spring;
2 |
3 | import java.net.URL;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Component;
7 |
8 | import com.github.mygreen.supercsv.builder.AbstractProcessorBuilder;
9 | import com.github.mygreen.supercsv.builder.Configuration;
10 | import com.github.mygreen.supercsv.builder.FieldAccessor;
11 | import com.github.mygreen.supercsv.cellprocessor.format.TextFormatter;
12 |
13 | @Component
14 | public class UrlProcessorBuilder extends AbstractProcessorBuilder {
15 |
16 | @Autowired
17 | private UrlFormatter formatter;
18 |
19 | @Autowired
20 | private UserNameExistFactory userNameExistFactory;
21 |
22 | @Override
23 | protected void init() {
24 | super.init();
25 |
26 | registerForConstraint(CsvUserNameExist.class, userNameExistFactory);
27 | }
28 |
29 | @Override
30 | protected TextFormatter getDefaultFormatter(final FieldAccessor field, final Configuration config) {
31 | return formatter;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/spring/UserListener.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder.spring;
2 |
3 | import java.net.URL;
4 | import java.util.Map;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.stereotype.Component;
8 |
9 | import com.github.mygreen.supercsv.annotation.CsvPostRead;
10 | import com.github.mygreen.supercsv.annotation.CsvPreWrite;
11 | import com.github.mygreen.supercsv.validation.CsvBindingErrors;
12 | import com.github.mygreen.supercsv.validation.CsvField;
13 | import com.github.mygreen.supercsv.validation.CsvFieldValidator;
14 | import com.github.mygreen.supercsv.validation.ValidationContext;
15 |
16 | /**
17 | * {@link UserCsv}に対するリスナクラス
18 | *
19 | * @since 2.0
20 | * @author T.TSUCHIE
21 | *
22 | */
23 | @Component
24 | public class UserListener {
25 |
26 | @Autowired
27 | private UserService userSerivce;
28 |
29 | @CsvPreWrite
30 | @CsvPostRead
31 | public void validate(final UserCsv record, final ValidationContext validationContext, final CsvBindingErrors bindingErrors) {
32 |
33 | final CsvField homepageField = new CsvField<>(validationContext, record, "homepage");
34 | homepageField.add(new CsvFieldValidator() {
35 |
36 | @Override
37 | public void validate(final CsvBindingErrors bindingErrors, final CsvField field) {
38 | if(field.isEmpty()) {
39 | return;
40 | }
41 |
42 | if(!userSerivce.isValidProtocol(field.getValue())) {
43 |
44 | Map vars = createMessageVariables(field);
45 | vars.put("protocol", field.getValue().getProtocol());
46 |
47 | bindingErrors.rejectValue(field.getName(), field.getType(), "fieldError.homepage.supportedProtocol", vars);
48 | }
49 | }
50 | })
51 | .validate(bindingErrors);
52 |
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/spring/UserMailPattern.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder.spring;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Repeatable;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | import javax.validation.Constraint;
11 | import javax.validation.Payload;
12 |
13 | /**
14 | * BeanValidationの制約のアノテーション
15 | *
16 | * @since 2.0
17 | * @author T.TSUCHIE
18 | *
19 | */
20 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE})
21 | @Retention(RetentionPolicy.RUNTIME)
22 | @Documented
23 | @Repeatable(UserMailPattern.List.class)
24 | @Constraint(validatedBy=UserMailPatternValidator.class)
25 | public @interface UserMailPattern {
26 |
27 | // 共通の属性の定義
28 | Class>[] groups() default {};
29 | String message() default "{com.github.mygreen.supercsv.builder.spring.UserMailPattern.message}";
30 | Class extends Payload>[] payload() default {};
31 |
32 | // 複数のアノテーションを指定する場合の定義
33 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE})
34 | @Retention(RetentionPolicy.RUNTIME)
35 | @Documented
36 | @interface List {
37 | UserMailPattern[] value();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/spring/UserMailPatternValidator.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder.spring;
2 |
3 | import javax.validation.ConstraintValidator;
4 | import javax.validation.ConstraintValidatorContext;
5 |
6 | import org.springframework.beans.factory.annotation.Autowired;
7 |
8 |
9 | /**
10 | * Springで管理する
11 | *
12 | * @since 2.0
13 | * @author T.TSUCHIE
14 | *
15 | */
16 | public class UserMailPatternValidator implements ConstraintValidator {
17 |
18 | // SpringBeanをインジェクションします。
19 | @Autowired
20 | private UserService userService;
21 |
22 | @Override
23 | public void initialize(final UserMailPattern constraintAnnotation) {
24 |
25 | }
26 |
27 | @Override
28 | public boolean isValid(final String value, final ConstraintValidatorContext context) {
29 |
30 | // nullの場合は対象外
31 | if(value == null) {
32 | return true;
33 | }
34 |
35 | return userService.isMailPattern(value);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/spring/UserNameExist.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder.spring;
2 |
3 | import org.supercsv.cellprocessor.ift.CellProcessor;
4 | import org.supercsv.cellprocessor.ift.StringCellProcessor;
5 | import org.supercsv.util.CsvContext;
6 |
7 | import com.github.mygreen.supercsv.cellprocessor.ValidationCellProcessor;
8 |
9 | /**
10 | * ユーザ名の存在チェックを行う制約のCellProcessor
11 | *
12 | * @since 2.0
13 | * @author T.TSUCHIE
14 | *
15 | */
16 | public class UserNameExist extends ValidationCellProcessor implements StringCellProcessor {
17 |
18 | private final UserService userService;
19 |
20 | public UserNameExist(final UserService userService) {
21 | checkPreconditions(userService);
22 | this.userService = userService;
23 | }
24 |
25 | public UserNameExist(final UserService userService, final CellProcessor next) {
26 | super(next);
27 | checkPreconditions(userService);
28 | this.userService = userService;
29 | }
30 |
31 | private static void checkPreconditions(final UserService userService) {
32 | if(userService == null) {
33 | throw new NullPointerException("userService should not be null");
34 | }
35 |
36 | }
37 |
38 | @Override
39 | public T execute(final Object value, final CsvContext context) {
40 |
41 | if(value == null) {
42 | return next.execute(value, context);
43 | }
44 |
45 | final String result = value.toString();
46 | if(!userService.existByUserName(result)) {
47 | throw createValidationException(context)
48 | .messageFormat("%s dose not found user name.", result)
49 | .rejectedValue(result)
50 | .build();
51 | }
52 |
53 | return next.execute(value, context);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/spring/UserNameExistFactory.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder.spring;
2 |
3 | import java.util.Optional;
4 |
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Component;
7 | import org.supercsv.cellprocessor.ift.CellProcessor;
8 |
9 | import com.github.mygreen.supercsv.builder.Configuration;
10 | import com.github.mygreen.supercsv.builder.FieldAccessor;
11 | import com.github.mygreen.supercsv.cellprocessor.ConstraintProcessorFactory;
12 | import com.github.mygreen.supercsv.cellprocessor.format.TextFormatter;
13 |
14 | /**
15 | * {@link UserNameExist}を作成するCellProcessorの作成。
16 | * Springで管理する。
17 | *
18 | * @since 2.0
19 | * @author T.TSUCHIE
20 | *
21 | */
22 | @Component
23 | public class UserNameExistFactory implements ConstraintProcessorFactory {
24 |
25 | @Autowired
26 | private UserService userService;
27 |
28 | @Override
29 | public Optional create(final CsvUserNameExist anno, final Optional next,
30 | final FieldAccessor field, final TextFormatter> formatter, final Configuration config) {
31 |
32 | final UserNameExist processor = next.map(n -> new UserNameExist(userService, n))
33 | .orElseGet(() -> new UserNameExist(userService));
34 | processor.setValidationMessage(anno.message());
35 |
36 | return Optional.of(processor);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/spring/UserService.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder.spring;
2 |
3 | import java.net.URL;
4 | import java.util.regex.Pattern;
5 |
6 | import org.springframework.stereotype.Service;
7 |
8 | /**
9 | * Springで管理するテスト用のサービス
10 | * Springで管理する。
11 | *
12 | * @since 2.0
13 | * @author T.TSUCHIE
14 | *
15 | */
16 | @Service
17 | public class UserService {
18 |
19 | /**
20 | * ユーザ名が存在するかどうか。
21 | * @param userName チェック対象のユーザ名。
22 | * @return trueの場合、ユーザ名が存在する。
23 | */
24 | public boolean existByUserName(final String userName) {
25 |
26 | if(userName == null) {
27 | return false;
28 |
29 | } else if(userName.equals("admin") || userName.equals("test")) {
30 | return true;
31 | }
32 |
33 | return false;
34 |
35 | }
36 |
37 | /**
38 | * URLが許可されたプロトコルかどうか
39 | * @param url チェック対象のURL
40 | * @return
41 | */
42 | public boolean isValidProtocol(final URL url) {
43 | String protocol = url.getProtocol();
44 |
45 | return protocol.equals("http") || protocol.equals("https");
46 | }
47 |
48 | /**
49 | * メールアドレスのパターンのチェック
50 | * @param mail チェック対象のメールアドレス
51 | * @return
52 | */
53 | public boolean isMailPattern(final String mail) {
54 |
55 | Pattern pattern = Pattern.compile(".+@.+");
56 |
57 | return pattern.matcher(mail).matches();
58 |
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/builder/spring/UserValidator.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.builder.spring;
2 |
3 | import org.springframework.beans.factory.annotation.Autowired;
4 | import org.springframework.stereotype.Component;
5 |
6 | import com.github.mygreen.supercsv.validation.CsvBindingErrors;
7 | import com.github.mygreen.supercsv.validation.CsvValidator;
8 | import com.github.mygreen.supercsv.validation.ValidationContext;
9 |
10 | /**
11 | * {@link UserCsv}に対するValidator
12 | * @since 2.0
13 | * @author T.TSUCHIE
14 | *
15 | */
16 | @Component
17 | public class UserValidator implements CsvValidator {
18 |
19 | @Autowired
20 | private UserService userService;
21 |
22 | @Override
23 | public void validate(final UserCsv record, final CsvBindingErrors bindingErrors,
24 | final ValidationContext validationContext) {
25 |
26 | // TODO: 実装する
27 |
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/cellprocessor/NextCellProcessor.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.cellprocessor;
2 |
3 | import org.supercsv.cellprocessor.CellProcessorAdaptor;
4 | import org.supercsv.cellprocessor.ift.BoolCellProcessor;
5 | import org.supercsv.cellprocessor.ift.DateCellProcessor;
6 | import org.supercsv.cellprocessor.ift.DoubleCellProcessor;
7 | import org.supercsv.cellprocessor.ift.LongCellProcessor;
8 | import org.supercsv.cellprocessor.ift.StringCellProcessor;
9 | import org.supercsv.util.CsvContext;
10 |
11 | /**
12 | * CellProcessor to user for unit tests that test chaining.
13 | * simply return whatever is passed into it.
14 | *
15 | * @since 1.2
16 | * @author T.TSUCHIE
17 | *
18 | */
19 | public class NextCellProcessor extends CellProcessorAdaptor
20 | implements StringCellProcessor, DateCellProcessor, DoubleCellProcessor, LongCellProcessor, BoolCellProcessor {
21 |
22 | public NextCellProcessor() {
23 | super();
24 | }
25 |
26 | @Override
27 | public T execute(final Object value, final CsvContext context) {
28 | return next.execute(value, context);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/cellprocessor/constraint/NextCellProcessor.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.cellprocessor.constraint;
2 |
3 | import org.supercsv.cellprocessor.CellProcessorAdaptor;
4 | import org.supercsv.cellprocessor.ift.BoolCellProcessor;
5 | import org.supercsv.cellprocessor.ift.DateCellProcessor;
6 | import org.supercsv.cellprocessor.ift.DoubleCellProcessor;
7 | import org.supercsv.cellprocessor.ift.LongCellProcessor;
8 | import org.supercsv.cellprocessor.ift.StringCellProcessor;
9 | import org.supercsv.util.CsvContext;
10 |
11 | /**
12 | * CellProcessor to user for unit tests that test chaining.
13 | * simply return whatever is passed into it.
14 | *
15 | * @since 1.2
16 | * @author T.TSUCHIE
17 | *
18 | */
19 | public class NextCellProcessor extends CellProcessorAdaptor
20 | implements StringCellProcessor, DateCellProcessor, DoubleCellProcessor, LongCellProcessor, BoolCellProcessor {
21 |
22 | public NextCellProcessor() {
23 | super();
24 | }
25 |
26 | @Override
27 | public T execute(final Object value, final CsvContext context) {
28 | return next.execute(value, context);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/cellprocessor/conversion/DefaultValueTest.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.cellprocessor.conversion;
2 |
3 | import static org.junit.Assert.*;
4 | import static org.assertj.core.api.Assertions.*;
5 | import static com.github.mygreen.supercsv.tool.TestUtils.*;
6 |
7 | import org.junit.Before;
8 | import org.junit.Test;
9 |
10 | /**
11 | * {@link DefaultValue}のテスタ
12 | *
13 | * @since 2.0
14 | * @author T.TSUCHIE
15 | *
16 | */
17 | public class DefaultValueTest {
18 |
19 | private DefaultValue processor;
20 | private DefaultValue processorChain;
21 |
22 | private String returnValue = "123";
23 |
24 | @Before
25 | public void setUp() throws Exception {
26 | this.processor = new DefaultValue(returnValue);
27 | this.processorChain = new DefaultValue(returnValue, new NextCellProcessor());
28 | }
29 |
30 | @Test
31 | public void testConstructor() {
32 |
33 | assertThat(processor.getReturnValue()).isEqualTo(returnValue);
34 |
35 | }
36 |
37 | @Test
38 | public void testConstuctor_returnValueNull() {
39 | assertThat(new DefaultValue(null).getReturnValue()).isNull();
40 |
41 | }
42 |
43 | @Test
44 | public void testExecute_inputNull() {
45 |
46 | String input = null;
47 |
48 | assertThat((Object)processor.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(returnValue);
49 | assertThat((Object)processorChain.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(returnValue);
50 |
51 | }
52 |
53 | @Test
54 | public void testExecute_inputNotNull() {
55 |
56 | String input = "abc";
57 |
58 | assertThat((Object)processor.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(input);
59 | assertThat((Object)processorChain.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(input);
60 |
61 | }
62 |
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/cellprocessor/conversion/LowerTest.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.cellprocessor.conversion;
2 |
3 | import static org.junit.Assert.*;
4 | import static org.assertj.core.api.Assertions.*;
5 | import static com.github.mygreen.supercsv.tool.TestUtils.*;
6 |
7 | import org.junit.Before;
8 | import org.junit.Test;
9 | import org.supercsv.cellprocessor.ift.CellProcessor;
10 |
11 | /**
12 | * {@link Lower}のテスタ。
13 | *
14 | * @since 2.0
15 | * @author T.TSUCHIE
16 | *
17 | */
18 | public class LowerTest {
19 |
20 | private CellProcessor processor;
21 | private CellProcessor processorChain;
22 |
23 | @Before
24 | public void setUp() throws Exception {
25 | this.processor = new Lower();
26 | this.processorChain = new Lower(new NextCellProcessor());
27 | }
28 |
29 | @Test
30 | public void testExecute_inputNull() {
31 |
32 | assertThat((Object)processor.execute(null, ANONYMOUS_CSVCONTEXT)).isNull();;
33 |
34 | }
35 |
36 | @Test
37 | public void testExecute() {
38 |
39 | String input = "AbCd";
40 | String expected = "abcd";
41 |
42 | assertThat((Object)processor.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(expected);
43 | assertThat((Object)processorChain.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(expected);
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/cellprocessor/conversion/NextCellProcessor.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.cellprocessor.conversion;
2 |
3 | import org.supercsv.cellprocessor.CellProcessorAdaptor;
4 | import org.supercsv.cellprocessor.ift.BoolCellProcessor;
5 | import org.supercsv.cellprocessor.ift.DateCellProcessor;
6 | import org.supercsv.cellprocessor.ift.DoubleCellProcessor;
7 | import org.supercsv.cellprocessor.ift.LongCellProcessor;
8 | import org.supercsv.cellprocessor.ift.StringCellProcessor;
9 | import org.supercsv.util.CsvContext;
10 |
11 | /**
12 | * CellProcessor to user for unit tests that test chaining.
13 | * simply return whatever is passed into it.
14 | *
15 | * @since 1.2
16 | * @author T.TSUCHIE
17 | *
18 | */
19 | public class NextCellProcessor extends CellProcessorAdaptor
20 | implements StringCellProcessor, DateCellProcessor, DoubleCellProcessor, LongCellProcessor, BoolCellProcessor {
21 |
22 | public NextCellProcessor() {
23 | super();
24 | }
25 |
26 | @Override
27 | public T execute(final Object value, final CsvContext context) {
28 | return next.execute(value, context);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/cellprocessor/conversion/TrimTest.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.cellprocessor.conversion;
2 |
3 | import static org.junit.Assert.*;
4 | import static org.assertj.core.api.Assertions.*;
5 | import static com.github.mygreen.supercsv.tool.TestUtils.*;
6 |
7 | import org.junit.Before;
8 | import org.junit.Test;
9 | import org.supercsv.cellprocessor.ift.CellProcessor;
10 |
11 | /**
12 | * {@link Trim}のテスタ
13 | *
14 | * @version 2.0
15 | * @since 1.2
16 | * @author T.TSUCHIE
17 | *
18 | */
19 | public class TrimTest {
20 |
21 | private CellProcessor processor;
22 | private CellProcessor processorChain;
23 |
24 | @Before
25 | public void setUp() {
26 | processor = new Trim();
27 | processorChain = new Trim(new NextCellProcessor());
28 | }
29 |
30 | @Test(expected=NullPointerException.class)
31 | public void testConstructor_nextNull() {
32 | new Trim(null);
33 | fail();
34 | }
35 |
36 | @Test
37 | public void testExecute_inputNoWhitespace() {
38 | String input = "abc";
39 |
40 | assertThat((Object)processor.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(input);
41 | assertThat((Object)processorChain.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(input);
42 | }
43 |
44 | @Test
45 | public void testExecute_inputSurroundingSpace() {
46 | String input = " abc ";
47 | String expected = "abc";
48 |
49 | assertThat((Object)processor.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(expected);
50 | assertThat((Object)processorChain.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(expected);
51 | }
52 |
53 | @Test
54 | public void testExecute_inputSurroundingWhitespace() {
55 | String input = "\tabc \n";
56 | String expected = "abc";
57 |
58 | assertThat((Object)processor.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(expected);
59 | assertThat((Object)processorChain.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(expected);
60 | }
61 |
62 | @Test
63 | public void testExecute_inputNull() {
64 | assertThat((Object)processor.execute(null, ANONYMOUS_CSVCONTEXT)).isNull();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/cellprocessor/conversion/UpperTest.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.cellprocessor.conversion;
2 |
3 | import static org.junit.Assert.*;
4 | import static org.assertj.core.api.Assertions.*;
5 | import static com.github.mygreen.supercsv.tool.TestUtils.*;
6 |
7 | import org.junit.Before;
8 | import org.junit.Test;
9 | import org.supercsv.cellprocessor.ift.CellProcessor;
10 |
11 | /**
12 | * {@link Upper}のテスタ。
13 | *
14 | * @since 2.0
15 | * @author T.TSUCHIE
16 | *
17 | */
18 | public class UpperTest {
19 |
20 | private CellProcessor processor;
21 | private CellProcessor processorChain;
22 |
23 |
24 | @Before
25 | public void setUp() throws Exception {
26 | this.processor = new Upper();
27 | this.processorChain = new Upper(new NextCellProcessor());
28 | }
29 |
30 | @Test
31 | public void testExecute_inputNull() {
32 |
33 | assertThat((Object)processor.execute(null, ANONYMOUS_CSVCONTEXT)).isNull();
34 |
35 | }
36 |
37 | @Test
38 | public void testExecute() {
39 |
40 | String input = "AbCd";
41 | String expected = "ABCD";
42 |
43 | assertThat((Object)processor.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(expected);
44 | assertThat((Object)processorChain.execute(input, ANONYMOUS_CSVCONTEXT)).isEqualTo(expected);
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/io/SampleELInjectionBean.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.io;
2 |
3 | import com.github.mygreen.supercsv.annotation.CsvBean;
4 | import com.github.mygreen.supercsv.annotation.CsvColumn;
5 | import com.github.mygreen.supercsv.annotation.constraint.CsvRequire;
6 | import com.github.mygreen.supercsv.annotation.constraint.CsvWordForbid;
7 |
8 | /**
9 | * ELインジェクション確認用のテストBean。
10 | *
11 | * @since 2.4
12 | * @author T.TSUCHIE
13 | *
14 | */
15 | @CsvBean(header = true, validateHeader = true)
16 | public class SampleELInjectionBean {
17 |
18 | @CsvRequire
19 | @CsvColumn(number = 1)
20 | private int id;
21 |
22 | @CsvWordForbid("getRuntime")
23 | @CsvColumn(number = 2)
24 | private String value;
25 |
26 | public int getId() {
27 | return id;
28 | }
29 |
30 | public void setId(int id) {
31 | this.id = id;
32 | }
33 |
34 | public String getValue() {
35 | return value;
36 | }
37 |
38 | public void setValue(String value) {
39 | this.value = value;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/io/SampleEnum.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.io;
2 |
3 |
4 | /**
5 | * テスト用の列挙型
6 | *
7 | * @since 1.2
8 | * @author T.TSUCHIE
9 | *
10 | */
11 | public enum SampleEnum {
12 |
13 | RED("赤"), BLUE("青"), YELLOW("黄");
14 |
15 | final String aliasName;
16 |
17 | private SampleEnum(String aliasName) {
18 | this.aliasName = aliasName;
19 | }
20 |
21 | public String aliasName() {
22 | return aliasName;
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/io/SampleLazyBean.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.io;
2 |
3 | import java.io.Serializable;
4 | import java.time.LocalDate;
5 |
6 | import com.github.mygreen.supercsv.annotation.CsvBean;
7 | import com.github.mygreen.supercsv.annotation.CsvColumn;
8 | import com.github.mygreen.supercsv.annotation.constraint.CsvRequire;
9 | import com.github.mygreen.supercsv.annotation.format.CsvDateTimeFormat;
10 |
11 | /**
12 | * テスト用の名前によるマッピング
13 | *
14 | * @since 2.1
15 | * @author T.TSUCHIE
16 | *
17 | */
18 | @CsvBean(header=true, validateHeader=true)
19 | public class SampleLazyBean implements Serializable {
20 |
21 | /** serialVersionUID */
22 | private static final long serialVersionUID = 1L;
23 |
24 | // ラベルがフィールド名
25 | @CsvColumn
26 | @CsvRequire
27 | private int no;
28 |
29 | // 列番号を指定
30 | @CsvColumn(number=2)
31 | @CsvRequire
32 | private String name;
33 |
34 | // ラベルだけ指定
35 | @CsvColumn(label="生年月日")
36 | @CsvDateTimeFormat(pattern="uuuu/MM/dd")
37 | private LocalDate birthday;
38 |
39 | // 番号とラベルの両方を指定
40 | @CsvColumn(number=4, label="備考")
41 | private String comment;
42 |
43 | public int getNo() {
44 | return no;
45 | }
46 |
47 | public void setNo(int no) {
48 | this.no = no;
49 | }
50 |
51 | public String getName() {
52 | return name;
53 | }
54 |
55 | public void setName(String name) {
56 | this.name = name;
57 | }
58 |
59 | public LocalDate getBirthday() {
60 | return birthday;
61 | }
62 |
63 | public void setBirthday(LocalDate birthday) {
64 | this.birthday = birthday;
65 | }
66 |
67 | public String getComment() {
68 | return comment;
69 | }
70 |
71 | public void setComment(String comment) {
72 | this.comment = comment;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/io/SampleLazyPartialBean.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.io;
2 |
3 | import java.time.LocalDate;
4 |
5 | import com.github.mygreen.supercsv.annotation.CsvBean;
6 | import com.github.mygreen.supercsv.annotation.CsvColumn;
7 | import com.github.mygreen.supercsv.annotation.CsvPartial;
8 |
9 | /**
10 | * 部分的にカラムを読み込む。
11 | *
12 | * @since 2.1
13 | * @author T.TSUCHIE
14 | *
15 | */
16 | @CsvBean(header=true, validateHeader=true)
17 | @CsvPartial(columnSize=8, headers={
18 | @CsvPartial.Header(number=3, label="誕生日"),
19 | @CsvPartial.Header(number=5, label="住所")
20 | })
21 | public class SampleLazyPartialBean {
22 |
23 | @CsvColumn(number=1)
24 | private int id;
25 |
26 | @CsvColumn(label="名前")
27 | private String name;
28 |
29 | @CsvColumn(number=6, label="有効期限")
30 | private LocalDate expiredDate;
31 |
32 | @CsvColumn(label="備考")
33 | private String comment;
34 |
35 | public int getId() {
36 | return id;
37 | }
38 |
39 | public void setId(int id) {
40 | this.id = id;
41 | }
42 |
43 | public String getName() {
44 | return name;
45 | }
46 |
47 | public void setName(String name) {
48 | this.name = name;
49 | }
50 |
51 | public LocalDate getExpiredDate() {
52 | return expiredDate;
53 | }
54 |
55 | public void setExpiredDate(LocalDate expiredDate) {
56 | this.expiredDate = expiredDate;
57 | }
58 |
59 | public String getComment() {
60 | return comment;
61 | }
62 |
63 | public void setComment(String comment) {
64 | this.comment = comment;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/tool/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * テスト専用の独自のユーティリティなどのクラスです。Junitのアサーションなどが格納されています。
3 | *
4 | * @author T.TSUCHIE
5 | *
6 | */
7 | package com.github.mygreen.supercsv.tool;
8 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/util/UtilsTest.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.util;
2 |
3 | import static org.junit.Assert.*;
4 | import static org.assertj.core.api.Assertions.*;
5 | import static com.github.mygreen.supercsv.tool.TestUtils.*;
6 |
7 | import org.junit.Test;
8 |
9 | /**
10 | * {@link Utils}のテスタ
11 | *
12 | * @since 2.0
13 | * @author T.TSUCHIE
14 | *
15 | */
16 | public class UtilsTest {
17 |
18 | /**
19 | * {@link Utils#getPrimitiveDefaultValue(Class)}
20 | */
21 | @Test
22 | public void testGetPrimitiveDefaultValue() {
23 |
24 | {
25 | // null
26 | assertThatThrownBy(() -> Utils.getPrimitiveDefaultValue(null)).isInstanceOf(NullPointerException.class);
27 | }
28 |
29 | {
30 | // non-primitive
31 | assertThat(Utils.getPrimitiveDefaultValue(Integer.class)).isNull();
32 | }
33 |
34 | {
35 | // primitive
36 | assertThat(Utils.getPrimitiveDefaultValue(boolean.class)).isEqualTo(false);
37 | assertThat(Utils.getPrimitiveDefaultValue(char.class)).isEqualTo('\u0000');
38 | assertThat(Utils.getPrimitiveDefaultValue(byte.class)).isEqualTo((byte)0);
39 | assertThat(Utils.getPrimitiveDefaultValue(short.class)).isEqualTo((short)0);
40 | assertThat(Utils.getPrimitiveDefaultValue(int.class)).isEqualTo(0);
41 | assertThat(Utils.getPrimitiveDefaultValue(long.class)).isEqualTo(0L);
42 | assertThat(Utils.getPrimitiveDefaultValue(float.class)).isEqualTo(0.0f);
43 | assertThat(Utils.getPrimitiveDefaultValue(double.class)).isEqualTo(0.0d);
44 |
45 |
46 | }
47 |
48 |
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/java/com/github/mygreen/supercsv/validation/CsvBindingErrorsTest.java:
--------------------------------------------------------------------------------
1 | package com.github.mygreen.supercsv.validation;
2 |
3 | import static org.junit.Assert.*;
4 | import static org.assertj.core.api.Assertions.*;
5 |
6 | import org.junit.Before;
7 | import org.junit.Test;
8 |
9 | /**
10 | * {@link CsvBindingErrors}のテスタ
11 | *
12 | * @since 2.0
13 | * @author T.TSUCHIE
14 | *
15 | */
16 | public class CsvBindingErrorsTest {
17 |
18 |
19 | @Before
20 | public void setUp() throws Exception {
21 | }
22 |
23 | @Test
24 | public void test() {
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/test/external/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * JEXL3.4のパーミッション外部パッケージでのテスト
3 | */
4 | package test.external;
--------------------------------------------------------------------------------
/src/test/resources/SpringTestContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | com.github.mygreen.supercsv.localization.SuperCsvMessages
25 | TestMessages
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | .%d{HH:mm:ss.SSS} [%thread] %-5level %logger{15} - %msg %n
6 |
7 |
8 | TRACE
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------