1 /*
2 * Copyright 2014 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.orangesignal.csv.annotation;
18
19 import java.lang.annotation.ElementType;
20 import java.lang.annotation.Retention;
21 import java.lang.annotation.RetentionPolicy;
22 import java.lang.annotation.Target;
23
24 /**
25 * <p>フィールドが区切り文字形式のデータ項目であることを示します。</p>
26 * <pre>
27 * 項目との対応付けの設定例:
28 *
29 * @CsvColumn(position = 0)
30 * @CsvColumn(name = "価格")
31 * @CsvColumn(position = 0, name = "価格")
32 * @CsvColumn(name = "価格", access = CsvColumnAccessType.READ)
33 * @CsvColumn(name = "銘柄", required = true, defaultValue = "日経225")
34 *
35 *
36 * 書式形式文字列の設定例:
37 *
38 * @CsvColumn(format = "yyyy/MM/dd")
39 * @CsvColumn(format = "yyyy/MM/dd", language = "ja")
40 * @CsvColumn(format = "yyyy/MM/dd", language = "ja", country = "JP")
41 * @CsvColumn(format = "yyyy/MM/dd HH:mm:ss", timezone = "Asia/Tokyo")
42 * @CsvColumn(format = "yyyy/MM/dd HH:mm:ss", language = "ja", country = "JP", timezone = "Asia/Tokyo")
43 *
44 * @CsvColumn(format = "#,##0.0000")
45 * @CsvColumn(format = "#,##0.0000", country = "JP")
46 * @CsvColumn(format = "#,##0.0000", language = "ja", country = "JP")
47 * @CsvColumn(format = "\u00A4\u00A4 #,##0.0000", currency = "USD")
48 * @CsvColumn(format = "\u00A4\u00A4 #,##0.0000", language = "ja", country = "JP", currency = "USD")
49 * </pre>
50 *
51 * @author Koji Sugisawa
52 */
53 @Target({ ElementType.FIELD, ElementType.METHOD })
54 @Retention(RetentionPolicy.RUNTIME)
55 public @interface CsvColumn {
56
57 /**
58 * 項目位置を返します。
59 *
60 * @return 項目位置
61 */
62 int position() default -1;
63
64 /**
65 * 項目名を返します。項目名が設定されていない場合は、フィールド名が使用されます。
66 * 項目名はヘッダ行を使用する場合に使用されます。
67 *
68 * @return 項目名
69 */
70 String name() default "";
71
72 /**
73 * 書式形式文字列を返します。
74 *
75 * @return 書式形式文字列
76 * @since 1.2.2
77 */
78 String format() default "";
79
80 /**
81 * 書式形式文字列の {@link java.util.Locale} として使用する言語コード (2 桁の小文字からなる ISO-639 コード) を返します。
82 *
83 * @return 言語コード (2 桁の小文字からなる ISO-639 コード)
84 * @since 1.2.2
85 */
86 String language() default "";
87
88 /**
89 * 書式形式文字列の {@link java.util.Locale} として使用する国コード (2 桁の大文字からなる ISO-3166 コード) を返します。
90 *
91 * @return 国コード (2 桁の大文字からなる ISO-3166 コード)
92 * @since 1.2.2
93 */
94 String country() default "";
95
96 /**
97 * 書式形式文字列の {@link java.util.TimeZone} として使用するタイムゾーン ID を返します。
98 *
99 * @return タイムゾーン ID
100 * @since 1.2.2
101 */
102 String timezone() default "";
103
104 /**
105 * 書式形式文字列の {@link java.util.Currency} として使用する通貨コード (ISO 4217 コード) を返します。
106 *
107 * @return 通貨コード (ISO 4217 コード)
108 * @since 1.2.2
109 */
110 String currency() default "";
111
112 /**
113 * この項目のアクセスモードを返します。
114 *
115 * @return この項目へのアクセスモード
116 * @since 2.2
117 */
118 CsvColumnAccessType access() default CsvColumnAccessType.READ_WRITE;
119
120 /**
121 * 必須項目かどうかを返します。
122 *
123 * @return 必須項目かどうか
124 * @since 2.2
125 */
126 boolean required() default false;
127
128 /**
129 * この項目のデフォルト値を返します。
130 *
131 * @return この項目のデフォルト値
132 * @since 2.2
133 */
134 String defaultValue() default "";
135
136 }