• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision179 (tree)
Time2016-01-01 15:59:47
Authort_nakayama1971

Log Message

(empty log message)

Change Summary

Incremental Difference

--- trunk/framework/pjSvc/src/project/check/TopMessage.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/TopMessage.java (revision 179)
@@ -0,0 +1,58 @@
1+package project.check;
2+
3+import java.util.function.Consumer;
4+
5+import online.model.check.ItemCheckBase;
6+import project.common.master.Msg;
7+import core.config.Factory;
8+import core.exception.LogicalException;
9+import core.util.ArrayUtil;
10+
11+/**
12+ * トップメッセージ設定
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class TopMessage extends ItemCheckBase implements Consumer<LogicalException> {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+ /** リターンコード */
24+ private final String rc;
25+
26+ /**
27+ * コンストラクタ
28+ * @param msgId メッセージID
29+ * @param param メッセージパラメータ
30+ */
31+ public TopMessage(final String msgId, final String... param) {
32+ this(null, msgId, param);
33+ }
34+
35+ /**
36+ * コンストラクタ
37+ * @param status ステータスコード
38+ * @param msgId メッセージID
39+ * @param param メッセージパラメータ
40+ */
41+ public TopMessage(final String status, final String msgId, final String... param) {
42+ this.mid = msgId;
43+ this.prm = ArrayUtil.copyOf(param);
44+ this.rc = status;
45+ }
46+
47+ /**
48+ * @see java.util.function.Consumer#accept(java.lang.Object)
49+ */
50+ @Override
51+ public void accept(final LogicalException ex) {
52+ Msg msg = Factory.create(Msg.class);
53+ super.getMessageList().add(0, msg.getMessage(this.mid, this.prm));
54+ super.getStatusList().add(0, msg.getStatus(this.mid));
55+
56+ throw new LogicalException(ex.getMessage(), this.rc);
57+ }
58+}
--- trunk/framework/pjSvc/src/project/check/existence/MustCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/existence/MustCheck.java (revision 179)
@@ -0,0 +1,73 @@
1+package project.check.existence;
2+
3+import java.util.Objects;
4+import java.util.Optional;
5+
6+import online.model.ModelUtil;
7+import project.check.BaseCheck;
8+import project.master.MsgUtil;
9+import core.util.ArrayUtil;
10+import core.util.bean.Pair;
11+
12+/**
13+ * 必須入力チェック
14+ *
15+ * @author Tadashi Nakayama
16+ * @version 1.0.0
17+ */
18+public final class MustCheck extends BaseCheck {
19+
20+ /** メッセージID */
21+ private final String mid;
22+ /** メッセージパラメータ */
23+ private final String[] prm;
24+
25+ /**
26+ * コンストラクタ
27+ */
28+ public MustCheck() {
29+ this.mid = null;
30+ this.prm = null;
31+ }
32+
33+ /**
34+ * コンストラクタ
35+ *
36+ * @param msgId メッセージID
37+ * @param param メッセージパラメータ
38+ */
39+ public MustCheck(final String msgId, final String... param) {
40+ this.mid = msgId;
41+ this.prm = ArrayUtil.copyOf(param);
42+ }
43+
44+ /**
45+ * @see online.model.check.ItemCheck#check(java.lang.String...)
46+ */
47+ @Override
48+ public void check(final String... items) {
49+ Optional<Pair<String, Integer>> check = Optional.empty();
50+ for (final String item : items) {
51+ String[] val = super.getArrayParameter(item);
52+ if (val == null || val.length == 0) {
53+ if (!MsgUtil.hasItemMessage(super.getUniModel(), item)) {
54+ super.addTopMessage(this.mid, this.prm);
55+ MsgUtil.putMessage(super.getUniModel(), item, this.mid, this.prm);
56+ }
57+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(0))));
58+ continue;
59+ }
60+
61+ for (int j = 0; j < val.length; j++) {
62+ if (!super.isTarget(j)) {
63+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
64+ } else if (Objects.toString(val[j], "").isEmpty()) {
65+ super.setMessage(item, j, this.mid, this.prm);
66+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
67+ }
68+ }
69+ }
70+
71+ check.ifPresent(this::throwKeepCheckException);
72+ }
73+}
--- trunk/framework/pjSvc/src/project/check/existence/AnyOneCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/existence/AnyOneCheck.java (revision 179)
@@ -0,0 +1,73 @@
1+package project.check.existence;
2+
3+import java.util.Objects;
4+import java.util.Optional;
5+
6+import project.check.BaseCheck;
7+import project.master.MsgUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+
12+/**
13+ * どれか一つ以上必須入力チェック
14+ *
15+ * @author Tadashi Nakayama
16+ * @version 1.0.0
17+ */
18+public final class AnyOneCheck extends BaseCheck {
19+
20+ /** メッセージID */
21+ private final String mid;
22+ /** メッセージパラメータ */
23+ private final String[] prm;
24+
25+ /**
26+ * コンストラクタ
27+ */
28+ public AnyOneCheck() {
29+ this.mid = null;
30+ this.prm = null;
31+ }
32+
33+ /**
34+ * コンストラクタ
35+ *
36+ * @param msgId メッセージID
37+ * @param param メッセージパラメータ
38+ */
39+ public AnyOneCheck(final String msgId, final String... param) {
40+ this.mid = msgId;
41+ this.prm = ArrayUtil.copyOf(param);
42+ }
43+
44+ /**
45+ * @see online.model.check.ItemCheck#check(java.lang.String...)
46+ */
47+ @Override
48+ public void check(final String... items) {
49+ Optional<Pair<String, Integer>> check = Optional.empty();
50+ for (final String item : items) {
51+ boolean one = false;
52+ String[] val = super.getArrayParameter(item);
53+ if (val != null) {
54+ for (final String str : val) {
55+ if (!Objects.toString(str, "").isEmpty()) {
56+ one = true;
57+ break;
58+ }
59+ }
60+ }
61+
62+ if (!one) {
63+ if (!MsgUtil.hasItemMessage(super.getUniModel(), item)) {
64+ super.addTopMessage(this.mid, this.prm);
65+// MsgUtil.putMessage(super.getUniModel(), item, this.mid, this.prm);
66+ }
67+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(0))));
68+ }
69+ }
70+
71+ check.ifPresent(this::throwKeepCheckException);
72+ }
73+}
--- trunk/framework/pjSvc/src/project/check/existence/ElementCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/existence/ElementCheck.java (revision 179)
@@ -0,0 +1,86 @@
1+package project.check.existence;
2+
3+import java.util.Objects;
4+import java.util.Optional;
5+
6+import online.model.ModelUtil;
7+import project.check.BaseCheck;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 選択項目配列内妥当性チェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class ElementCheck extends BaseCheck {
18+
19+ /** 項目チェック対象配列 */
20+ private final String[] array;
21+ /** メッセージID */
22+ private final String mid;
23+ /** メッセージパラメータ */
24+ private final String[] prm;
25+
26+ /**
27+ * コンストラクタ
28+ * @param s 項目チェック対象配列
29+ */
30+ public ElementCheck(final String[] s) {
31+ this.array = ArrayUtil.copyOf(s);
32+ this.mid = null;
33+ this.prm = null;
34+ }
35+
36+ /**
37+ * コンストラクタ
38+ *
39+ * @param s 項目チェック対象配列
40+ * @param msgId メッセージID
41+ * @param param メッセージパラメータ
42+ */
43+ public ElementCheck(final String[] s, final String msgId, final String... param) {
44+ this.array = ArrayUtil.copyOf(s);
45+ this.mid = msgId;
46+ this.prm = ArrayUtil.copyOf(param);
47+ }
48+
49+ /**
50+ * @see online.model.check.ItemCheck#check(java.lang.String...)
51+ */
52+ @Override
53+ public void check(final String... items) {
54+ Optional<Pair<String, Integer>> check = Optional.empty();
55+ for (final String item : items) {
56+ String[] val = super.getArrayParameter(item);
57+ for (int j = 0; val != null && j < val.length; j++) {
58+ if (!super.isTarget(j)) {
59+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
60+ } else if (Objects.toString(val[j], "").isEmpty()) {
61+ continue;
62+ } else if (!compare(val[j])) {
63+ super.setMessage(item, j, this.mid, this.prm);
64+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
65+ }
66+ }
67+ }
68+
69+ check.ifPresent(this::throwKeepCheckException);
70+ }
71+
72+ /**
73+ * 配列内存在チェック
74+ *
75+ * @param val チェック値
76+ * @return 配列内に存在する場合 true を返す。
77+ */
78+ private boolean compare(final String val) {
79+ for (int i = 0; this.array != null && i < this.array.length; i++) {
80+ if (this.array[i].equals(val)) {
81+ return true;
82+ }
83+ }
84+ return false;
85+ }
86+}
--- trunk/framework/pjSvc/src/project/check/existence/EquivalentCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/existence/EquivalentCheck.java (revision 179)
@@ -0,0 +1,67 @@
1+package project.check.existence;
2+
3+import java.util.Optional;
4+
5+import project.check.BaseCheck;
6+import project.master.MsgUtil;
7+import core.util.ArrayUtil;
8+import core.util.bean.Pair;
9+
10+/**
11+ * 項目長等価チェック
12+ *
13+ * @author Tadashi Nakayama
14+ * @version 1.0.0
15+ */
16+public final class EquivalentCheck extends BaseCheck {
17+
18+ /** メッセージID */
19+ private final String mid;
20+ /** メッセージパラメータ */
21+ private final String[] prm;
22+
23+ /**
24+ * コンストラクタ
25+ */
26+ public EquivalentCheck() {
27+ this.mid = null;
28+ this.prm = null;
29+ }
30+
31+ /**
32+ * コンストラクタ
33+ *
34+ * @param msgId メッセージID
35+ * @param param メッセージパラメータ
36+ */
37+ public EquivalentCheck(final String msgId, final String... param) {
38+ this.mid = msgId;
39+ this.prm = ArrayUtil.copyOf(param);
40+ }
41+
42+ /**
43+ * @see online.model.check.ItemCheck#check(java.lang.String...)
44+ */
45+ @Override
46+ public void check(final String... items) {
47+ Optional<Pair<String, Integer>> check = Optional.empty();
48+ int length = -1;
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ if (length == -1) {
52+ length = 0;
53+ if (val != null) {
54+ length = val.length;
55+ }
56+ } else if (val == null || length != val.length) {
57+ if (!MsgUtil.hasItemMessage(super.getUniModel(), item)) {
58+ super.addTopMessage(this.mid, this.prm);
59+ MsgUtil.putMessage(super.getUniModel(), item, this.mid, this.prm);
60+ }
61+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(0))));
62+ }
63+ }
64+
65+ check.ifPresent(this::throwNoMoreCheckException);
66+ }
67+}
--- trunk/framework/pjSvc/src/project/check/existence/EmptyCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/existence/EmptyCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.existence;
2+
3+import java.util.Objects;
4+import java.util.Optional;
5+
6+import online.model.ModelUtil;
7+import project.check.BaseCheck;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 空であることチェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class EmptyCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public EmptyCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public EmptyCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (!super.isTarget(j)) {
53+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
54+ } else if (!Objects.toString(val[j], "").isEmpty()) {
55+ super.setMessage(item, j, this.mid, this.prm);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwKeepCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/existence/NotEmptyCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/existence/NotEmptyCheck.java (revision 179)
@@ -0,0 +1,73 @@
1+package project.check.existence;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import project.common.CheckUtil;
8+import project.master.MsgUtil;
9+import core.util.ArrayUtil;
10+import core.util.bean.Pair;
11+
12+/**
13+ * 空白空文字チェック
14+ *
15+ * @author Tadashi Nakayama
16+ * @version 1.0.0
17+ */
18+public final class NotEmptyCheck extends BaseCheck {
19+
20+ /** メッセージID */
21+ private final String mid;
22+ /** メッセージパラメータ */
23+ private final String[] prm;
24+
25+ /**
26+ * コンストラクタ
27+ */
28+ public NotEmptyCheck() {
29+ this.mid = null;
30+ this.prm = null;
31+ }
32+
33+ /**
34+ * コンストラクタ
35+ *
36+ * @param msgId メッセージID
37+ * @param param メッセージパラメータ
38+ */
39+ public NotEmptyCheck(final String msgId, final String... param) {
40+ this.mid = msgId;
41+ this.prm = ArrayUtil.copyOf(param);
42+ }
43+
44+ /**
45+ * @see online.model.check.ItemCheck#check(java.lang.String...)
46+ */
47+ @Override
48+ public void check(final String... items) {
49+ Optional<Pair<String, Integer>> check = Optional.empty();
50+ for (final String item : items) {
51+ String[] val = super.getArrayParameter(item);
52+ if (val == null || val.length == 0) {
53+ if (!MsgUtil.hasItemMessage(super.getUniModel(), item)) {
54+ super.addTopMessage(this.mid, this.prm);
55+ MsgUtil.putMessage(super.getUniModel(), item, this.mid, this.prm);
56+ }
57+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(0))));
58+ continue;
59+ }
60+
61+ for (int j = 0; j < val.length; j++) {
62+ if (!super.isTarget(j)) {
63+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
64+ } else if (CheckUtil.isZenTrimEmpty(val[j])) {
65+ super.setMessage(item, j, this.mid, this.prm);
66+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
67+ }
68+ }
69+ }
70+
71+ check.ifPresent(this::throwKeepCheckException);
72+ }
73+}
--- trunk/framework/pjSvc/src/project/check/existence/AllorNothingCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/existence/AllorNothingCheck.java (revision 179)
@@ -0,0 +1,66 @@
1+package project.check.existence;
2+
3+import java.util.Objects;
4+import java.util.Optional;
5+
6+import project.check.BaseCheck;
7+import project.master.MsgUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 全く入力無しか、全て必須入力チェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class AllorNothingCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public AllorNothingCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public AllorNothingCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (Objects.toString(val[j], "").isEmpty()) {
53+ if (!MsgUtil.hasItemMessage(super.getUniModel(), item)) {
54+ super.addTopMessage(this.mid, this.prm);
55+ }
56+ // if (!MsgUtil.hasItemMessage(super.getUniModel(), item, j)) {
57+ // MsgUtil.putItemMessage(super.getUniModel(), item, j, this.mid, this.prm);
58+ // }
59+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
60+ }
61+ }
62+ }
63+
64+ check.ifPresent(this::throwKeepCheckException);
65+ }
66+}
--- trunk/framework/pjSvc/src/project/check/existence/BeingCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/existence/BeingCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.existence;
2+
3+import java.util.Objects;
4+import java.util.Optional;
5+
6+import online.model.ModelUtil;
7+import project.check.BaseCheck;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 文字必須チェック(nullはOK)
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class BeingCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public BeingCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public BeingCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (!super.isTarget(j)) {
53+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
54+ } else if (Objects.toString(val[j], "").isEmpty()) {
55+ super.setMessage(item, j, this.mid, this.prm);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwKeepCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/BaseCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/BaseCheck.java (revision 179)
@@ -0,0 +1,84 @@
1+package project.check;
2+
3+import online.model.check.ItemCheck;
4+import online.model.check.ItemCheckBase;
5+import online.model.check.KeepCheckException;
6+import online.model.check.NoMoreCheckException;
7+import project.common.master.Msg;
8+import project.master.MsgUtil;
9+import core.config.Factory;
10+import core.util.bean.Pair;
11+
12+/**
13+ * チェック親クラス
14+ *
15+ * @author Tadashi Nakayama
16+ * @version 1.0.0
17+ */
18+public abstract class BaseCheck extends ItemCheckBase implements ItemCheck {
19+
20+ /**
21+ * チェック対象判断
22+ *
23+ * @param loc 位置
24+ * @return チェック対象の場合 true を返す。
25+ */
26+ protected final boolean isTarget(final int loc) {
27+ return super.getPredicate() == null || super.getPredicate().test(Integer.valueOf(loc));
28+ }
29+
30+ /**
31+ * トップメッセージ追加
32+ *
33+ * @param mid メッセージID
34+ * @param prms パラメタ
35+ */
36+ protected final void addTopMessage(final String mid, final String... prms) {
37+ Msg msg = Factory.create(Msg.class);
38+ super.getMessageList().add(msg.getMessage(mid, prms));
39+ super.getStatusList().add(msg.getStatus(mid));
40+ }
41+
42+ /**
43+ * メッセージ設定
44+ * @param item 項目名
45+ * @param loc 位置
46+ * @param mid メッセージID
47+ * @param prm メッセージパラメタ
48+ */
49+ protected final void setMessage(final String item,
50+ final int loc, final String mid, final String... prm) {
51+ if (!MsgUtil.hasItemMessage(super.getUniModel(), item)) {
52+ addTopMessage(mid, prm);
53+ }
54+ if (!MsgUtil.hasItemMessage(super.getUniModel(), item, loc)) {
55+ MsgUtil.putItemMessage(super.getUniModel(), item, loc, mid, prm);
56+ }
57+ }
58+
59+ /**
60+ * 例外メッセージ取得
61+ * @param item 項目名
62+ * @param loc 位置
63+ * @return 例外メッセージ
64+ */
65+ private String getExceptionMessage(final String item, final Integer loc) {
66+ return String.join(":", this.getClass().getName(), item, String.valueOf(loc));
67+ }
68+
69+ /**
70+ * KeepCheckException
71+ * @param p Pair
72+ */
73+ protected final void throwKeepCheckException(final Pair<String, Integer> p) {
74+ throw new KeepCheckException(getExceptionMessage(p.left(), p.right()));
75+ }
76+
77+ /**
78+ * NoMoreCheckException
79+ * @param p Pair
80+ */
81+ protected final void throwNoMoreCheckException(final Pair<String, Integer> p) {
82+ throw new NoMoreCheckException(getExceptionMessage(p.left(), p.right()));
83+ }
84+}
--- trunk/framework/pjSvc/src/project/check/master/MasterCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/master/MasterCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.master;
2+
3+import java.util.Objects;
4+import java.util.Optional;
5+
6+import online.model.ModelUtil;
7+import project.check.BaseCheck;
8+import project.svc.generic.QueryService;
9+import core.config.Factory;
10+import core.util.bean.Pair;
11+
12+/**
13+ * マスタ存在チェック
14+ *
15+ * @author Tadashi Nakayama
16+ * @version 1.0.0
17+ */
18+public final class MasterCheck extends BaseCheck {
19+
20+ /** クエリファイル */
21+ private final String query;
22+ /** メッセージID */
23+ private final String mid;
24+
25+ /**
26+ * コンストラクタ
27+ *
28+ * @param sql クエリファイル
29+ * @param msgId メッセージID
30+ */
31+ public MasterCheck(final String msgId, final String sql) {
32+ this.query = sql;
33+ this.mid = msgId;
34+ }
35+
36+ /**
37+ * @see online.model.check.ItemCheck#check(java.lang.String...)
38+ */
39+ @Override
40+ public void check(final String... items) {
41+ QueryService ql = Factory.create(QueryService.class);
42+ ModelUtil.setModelValue(ql, super.getUniModel());
43+ ql.setSessionUser(super.getSessionUser());
44+ ql.setQueryFile(this.query);
45+
46+ Optional<Pair<String, Integer>> check = Optional.empty();
47+ for (final String item : items) {
48+ String[] vals = super.getArrayParameter(item);
49+ for (int j = 0; vals != null && j < vals.length; j++) {
50+ if (!super.isTarget(j)) {
51+ vals[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
52+ } else if (Objects.toString(vals[j], "").isEmpty()) {
53+ continue;
54+ } else if (!ql.search()) {
55+ super.setMessage(item, j, this.mid);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwNoMoreCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/master/NoMasterCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/master/NoMasterCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.master;
2+
3+import java.util.Objects;
4+import java.util.Optional;
5+
6+import online.model.ModelUtil;
7+import project.check.BaseCheck;
8+import project.svc.generic.QueryService;
9+import core.config.Factory;
10+import core.util.bean.Pair;
11+
12+/**
13+ * マスタ不在チェック
14+ *
15+ * @author Tadashi Nakayama
16+ * @version 1.0.0
17+ */
18+public final class NoMasterCheck extends BaseCheck {
19+
20+ /** クエリファイル */
21+ private final String query;
22+ /** メッセージID */
23+ private final String mid;
24+
25+ /**
26+ * コンストラクタ
27+ *
28+ * @param sql クエリファイル
29+ * @param msgId メッセージID
30+ */
31+ public NoMasterCheck(final String msgId, final String sql) {
32+ this.query = sql;
33+ this.mid = msgId;
34+ }
35+
36+ /**
37+ * @see online.model.check.ItemCheck#check(java.lang.String...)
38+ */
39+ @Override
40+ public void check(final String... items) {
41+ QueryService ql = Factory.create(QueryService.class);
42+ ModelUtil.setModelValue(ql, super.getUniModel());
43+ ql.setSessionUser(super.getSessionUser());
44+ ql.setQueryFile(this.query);
45+
46+ Optional<Pair<String, Integer>> check = Optional.empty();
47+ for (final String item : items) {
48+ String[] vals = super.getArrayParameter(item);
49+ for (int j = 0; vals != null && j < vals.length; j++) {
50+ if (!super.isTarget(j)) {
51+ vals[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
52+ } else if (Objects.toString(vals[j], "").isEmpty()) {
53+ continue;
54+ } else if (ql.search()) {
55+ super.setMessage(item, j, this.mid);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwNoMoreCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/master/CodeCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/master/CodeCheck.java (revision 179)
@@ -0,0 +1,78 @@
1+package project.check.master;
2+
3+import java.util.Objects;
4+import java.util.Optional;
5+
6+import online.model.ModelUtil;
7+import project.check.BaseCheck;
8+import project.master.CodeKeeper;
9+import core.config.Factory;
10+import core.util.ArrayUtil;
11+import core.util.bean.Pair;
12+
13+
14+/**
15+ * コードマスタ存在チェック
16+ *
17+ * @author Tadashi Nakayama
18+ * @version 1.0.0
19+ */
20+public final class CodeCheck extends BaseCheck {
21+
22+ /** コード区分 */
23+ private final String kubun;
24+ /** メッセージID */
25+ private final String mid;
26+ /** メッセージパラメータ */
27+ private final String[] prm;
28+
29+ /**
30+ * コンストラクタ
31+ *
32+ * @param kbn 区分
33+ */
34+ public CodeCheck(final String kbn) {
35+ this.kubun = kbn;
36+ this.mid = null;
37+ this.prm = null;
38+ }
39+
40+ /**
41+ * コンストラクタ
42+ *
43+ * @param kbn 区分
44+ * @param msgId メッセージID
45+ * @param param メッセージパラメータ
46+ */
47+ public CodeCheck(final String kbn, final String msgId, final String... param) {
48+ this.kubun = kbn;
49+ this.mid = msgId;
50+ this.prm = ArrayUtil.copyOf(param);
51+ }
52+
53+ /**
54+ * @see online.model.check.ItemCheck#check(java.lang.String...)
55+ */
56+ @Override
57+ public void check(final String... items) {
58+
59+ CodeKeeper ck = Factory.create(CodeKeeper.class);
60+
61+ Optional<Pair<String, Integer>> check = Optional.empty();
62+ for (final String item : items) {
63+ String[] vals = super.getArrayParameter(item);
64+ for (int j = 0; vals != null && j < vals.length; j++) {
65+ if (!super.isTarget(j)) {
66+ vals[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
67+ } else if (Objects.toString(vals[j], "").isEmpty()) {
68+ continue;
69+ } else if (!ck.isValidCode(this.kubun, vals[j])) {
70+ super.setMessage(item, j, this.mid, this.prm);
71+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
72+ }
73+ }
74+ }
75+
76+ check.ifPresent(this::throwNoMoreCheckException);
77+ }
78+}
--- trunk/framework/pjSvc/src/project/check/range/ByteRangeCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/range/ByteRangeCheck.java (revision 179)
@@ -0,0 +1,112 @@
1+package project.check.range;
2+
3+import java.nio.charset.Charset;
4+import java.util.Objects;
5+import java.util.Optional;
6+
7+import online.model.ModelUtil;
8+import online.model.check.ItemCheckBase;
9+import project.check.BaseCheck;
10+import project.common.CheckUtil;
11+import core.util.ArrayUtil;
12+import core.util.bean.Pair;
13+
14+/**
15+ * 指定バイト数範囲内チェック
16+ *
17+ * @author Tadashi Nakayama
18+ * @version 1.0.0
19+ */
20+public final class ByteRangeCheck extends BaseCheck {
21+
22+ /** 最大バイト数 */
23+ private final int maxlen;
24+ /** 最小バイト数 */
25+ private final int minlen;
26+ /** エンコード */
27+ private final Charset enc;
28+ /** メッセージID */
29+ private final String mid;
30+ /** メッセージパラメータ */
31+ private final String[] prm;
32+
33+ /**
34+ * コンストラクタ
35+ *
36+ * @param min 指定最小バイト数
37+ * @param max 指定最大バイト数
38+ */
39+ public ByteRangeCheck(final int min, final int max) {
40+ this(min, max, ItemCheckBase.getMapping());
41+ }
42+
43+ /**
44+ * コンストラクタ
45+ *
46+ * @param min 指定最小バイト数
47+ * @param max 指定最大バイト数
48+ * @param msgId メッセージID
49+ * @param param メッセージパラメータ
50+ */
51+ public ByteRangeCheck(final int min, final int max, final String msgId, final String... param) {
52+ this(min, max, ItemCheckBase.getMapping(), msgId, param);
53+ }
54+
55+ /**
56+ * コンストラクタ
57+ *
58+ * @param min 指定最小バイト数
59+ * @param max 指定最大バイト数
60+ * @param charset エンコード
61+ */
62+ public ByteRangeCheck(final int min, final int max, final Charset charset) {
63+ this.minlen = min;
64+ this.maxlen = max;
65+ this.enc = charset;
66+ this.mid = null;
67+ this.prm = null;
68+ }
69+
70+ /**
71+ * コンストラクタ
72+ *
73+ * @param min 指定最小バイト数
74+ * @param max 指定最大バイト数
75+ * @param charset エンコード
76+ * @param msgId メッセージID
77+ * @param param メッセージパラメータ
78+ */
79+ public ByteRangeCheck(final int min, final int max, final Charset charset,
80+ final String msgId, final String... param) {
81+ this.minlen = min;
82+ this.maxlen = max;
83+ this.enc = charset;
84+ this.mid = msgId;
85+ this.prm = ArrayUtil.extend(param, String.valueOf(max), String.valueOf(min));
86+ }
87+
88+ /**
89+ * @see online.model.check.ItemCheck#check(java.lang.String...)
90+ */
91+ @Override
92+ public void check(final String... items) {
93+ Optional<Pair<String, Integer>> check = Optional.empty();
94+ for (final String item : items) {
95+ String[] val = super.getArrayParameter(item);
96+ for (int j = 0; val != null && j < val.length; j++) {
97+ if (!super.isTarget(j)) {
98+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
99+ } else if (!Objects.toString(val[j], "").isEmpty()) {
100+ int len = Math.min(this.maxlen, Integer.MAX_VALUE - 1);
101+ if (!CheckUtil.isLessByte(val[j], len + 1, this.enc)
102+ || CheckUtil.isLessByte(val[j], this.minlen, this.enc)) {
103+ super.setMessage(item, j, this.mid, this.prm);
104+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
105+ }
106+ }
107+ }
108+ }
109+
110+ check.ifPresent(this::throwKeepCheckException);
111+ }
112+}
--- trunk/framework/pjSvc/src/project/check/range/NumeralRangeCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/range/NumeralRangeCheck.java (revision 179)
@@ -0,0 +1,80 @@
1+package project.check.range;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import core.util.ArrayUtil;
8+import core.util.NumberUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 指定範囲内チェック
13+ *
14+ * @author Tadashi Nakayama
15+ */
16+public final class NumeralRangeCheck extends BaseCheck {
17+
18+ /** 最大数 */
19+ private final long maxval;
20+ /** 最小数 */
21+ private final long minval;
22+ /** メッセージID */
23+ private final String mid;
24+ /** メッセージパラメータ */
25+ private final String[] prm;
26+
27+ /**
28+ * コンストラクタ
29+ *
30+ * @param min 指定最小文字数
31+ * @param max 指定最大文字数
32+ */
33+ public NumeralRangeCheck(final long min, final long max) {
34+ this.minval = min;
35+ this.maxval = max;
36+ this.mid = null;
37+ this.prm = null;
38+ }
39+
40+ /**
41+ * コンストラクタ
42+ *
43+ * @param min 指定最小文字数
44+ * @param max 指定最大文字数
45+ * @param msgId メッセージID
46+ * @param param メッセージパラメータ
47+ */
48+ public NumeralRangeCheck(final long min, final long max,
49+ final String msgId, final String... param) {
50+ this.minval = min;
51+ this.maxval = max;
52+ this.mid = msgId;
53+ this.prm = ArrayUtil.extend(param, String.valueOf(max), String.valueOf(min));
54+ }
55+
56+ /**
57+ * @see online.model.check.ItemCheck#check(java.lang.String...)
58+ */
59+ @Override
60+ public void check(final String... items) {
61+ Optional<Pair<String, Integer>> check = Optional.empty();
62+ for (final String item : items) {
63+ String[] val = super.getArrayParameter(item);
64+ for (int j = 0; val != null && j < val.length; j++) {
65+ if (!super.isTarget(j)) {
66+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
67+ continue;
68+ }
69+ Long num = NumberUtil.toLong(val[j]);
70+ if (num != null && (num.longValue() > this.maxval
71+ || num.longValue() < this.minval)) {
72+ super.setMessage(item, j, this.mid, this.prm);
73+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
74+ }
75+ }
76+ }
77+
78+ check.ifPresent(this::throwKeepCheckException);
79+ }
80+}
--- trunk/framework/pjSvc/src/project/check/range/LengthRangeCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/range/LengthRangeCheck.java (revision 179)
@@ -0,0 +1,79 @@
1+package project.check.range;
2+
3+import java.util.Objects;
4+import java.util.Optional;
5+
6+import online.model.ModelUtil;
7+import project.check.BaseCheck;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 指定文字数範囲内チェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class LengthRangeCheck extends BaseCheck {
18+
19+ /** 最大文字数 */
20+ private final int maxlen;
21+ /** 最小文字数 */
22+ private final int minlen;
23+ /** メッセージID */
24+ private final String mid;
25+ /** メッセージパラメータ */
26+ private final String[] prm;
27+
28+ /**
29+ * コンストラクタ
30+ *
31+ * @param min 指定最小文字数
32+ * @param max 指定最大文字数
33+ */
34+ public LengthRangeCheck(final int min, final int max) {
35+ this.minlen = min;
36+ this.maxlen = max;
37+ this.mid = null;
38+ this.prm = null;
39+ }
40+
41+ /**
42+ * コンストラクタ
43+ *
44+ * @param min 指定最小文字数
45+ * @param max 指定最大文字数
46+ * @param msgId メッセージID
47+ * @param param メッセージパラメータ
48+ */
49+ public LengthRangeCheck(final int min, final int max,
50+ final String msgId, final String... param) {
51+ this.minlen = min;
52+ this.maxlen = max;
53+ this.mid = msgId;
54+ this.prm = ArrayUtil.extend(param, String.valueOf(max), String.valueOf(min));
55+ }
56+
57+ /**
58+ * @see online.model.check.ItemCheck#check(java.lang.String...)
59+ */
60+ @Override
61+ public void check(final String... items) {
62+ Optional<Pair<String, Integer>> check = Optional.empty();
63+ for (final String item : items) {
64+ String[] val = super.getArrayParameter(item);
65+ for (int j = 0; val != null && j < val.length; j++) {
66+ if (!super.isTarget(j)) {
67+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
68+ } else if (Objects.toString(val[j], "").isEmpty()) {
69+ continue;
70+ } else if (val[j].length() > this.maxlen || val[j].length() < this.minlen) {
71+ super.setMessage(item, j, this.mid, this.prm);
72+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
73+ }
74+ }
75+ }
76+
77+ check.ifPresent(this::throwKeepCheckException);
78+ }
79+}
--- trunk/framework/pjSvc/src/project/check/attribute/ZenkakuCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/ZenkakuCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import project.common.CheckUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 全角チェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class ZenkakuCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public ZenkakuCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public ZenkakuCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (!super.isTarget(j)) {
53+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
54+ } else if (!CheckUtil.isZenkaku(val[j])) {
55+ super.setMessage(item, j, this.mid, this.prm);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwKeepCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/attribute/DateCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/DateCheck.java (revision 179)
@@ -0,0 +1,80 @@
1+package project.check.attribute;
2+
3+import java.util.Date;
4+import java.util.Optional;
5+import java.util.stream.Stream;
6+
7+import online.model.ModelUtil;
8+import online.model.check.ItemConvert;
9+import project.check.BaseCheck;
10+import project.common.CheckUtil;
11+import core.util.ArrayUtil;
12+import core.util.DateUtil;
13+import core.util.bean.Pair;
14+
15+/**
16+ * 日付妥当性チェック
17+ *
18+ * @author Tadashi Nakayama
19+ * @version 1.0.0
20+ */
21+public final class DateCheck extends BaseCheck implements ItemConvert<Date> {
22+
23+ /** メッセージID */
24+ private final String mid;
25+ /** メッセージパラメータ */
26+ private final String[] prm;
27+
28+ /**
29+ * コンストラクタ
30+ */
31+ public DateCheck() {
32+ this.mid = null;
33+ this.prm = null;
34+ }
35+
36+ /**
37+ * コンストラクタ
38+ *
39+ * @param msgId メッセージID
40+ * @param param メッセージパラメータ
41+ */
42+ public DateCheck(final String msgId, final String... param) {
43+ this.mid = msgId;
44+ this.prm = ArrayUtil.copyOf(param);
45+ }
46+
47+ /**
48+ * @see online.model.check.ItemCheck#check(java.lang.String...)
49+ */
50+ @Override
51+ public void check(final String... items) {
52+ Optional<Pair<String, Integer>> check = Optional.empty();
53+ for (final String item : items) {
54+ String[] val = super.getArrayParameter(item);
55+ for (int j = 0; val != null && j < val.length; j++) {
56+ if (!super.isTarget(j)) {
57+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
58+ continue;
59+ }
60+ String date = DateUtil.normalizeDate(val[j]);
61+ if (!CheckUtil.isDate(date)) {
62+ super.setMessage(item, j, this.mid, this.prm);
63+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
64+ } else {
65+ val[j] = date;
66+ }
67+ }
68+ }
69+
70+ check.ifPresent(this::throwKeepCheckException);
71+ }
72+
73+ /**
74+ * @see online.model.check.ItemConvert#convert(java.lang.String...)
75+ */
76+ @Override
77+ public Date[] convert(final String... val) {
78+ return Stream.of(val).map(DateUtil::toDate).toArray(Date[]::new);
79+ }
80+}
--- trunk/framework/pjSvc/src/project/check/attribute/MojiReferenceCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/MojiReferenceCheck.java (revision 179)
@@ -0,0 +1,99 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+import java.util.regex.Pattern;
5+
6+import online.model.ModelUtil;
7+import project.check.BaseCheck;
8+import core.util.ArrayUtil;
9+import core.util.MojiUtil;
10+import core.util.bean.Pair;
11+
12+/**
13+ * 入力文字列が変換可能かチェックする。
14+ *
15+ * @author Tadashi Nakayama
16+ * @version 1.0.0
17+ */
18+public final class MojiReferenceCheck extends BaseCheck {
19+
20+ /** 数値文字参照10進 */
21+ private static final Pattern PATTERN_DEC = Pattern.compile("&#[0-9]{2,5};");
22+ /** 数値文字参照16進 */
23+ private static final Pattern PATTERN_HEX = Pattern.compile("&#x[0-9A-Fa-f]{4};");
24+
25+ /** カナチェック */
26+ private final boolean k;
27+ /** 外字チェック */
28+ private final boolean e;
29+ /** メッセージID */
30+ private final String mid;
31+ /** メッセージパラメータ */
32+ private final String[] prm;
33+
34+ /**
35+ * コンストラクタ
36+ */
37+ public MojiReferenceCheck() {
38+ this(true, true);
39+ }
40+
41+ /**
42+ * コンストラクタ
43+ * @param kana 半角カナを含む場合 true
44+ * @param ext ユーザ定義領域を含む場合 true
45+ */
46+ public MojiReferenceCheck(final boolean kana, final boolean ext) {
47+ this.k = kana;
48+ this.e = ext;
49+ this.mid = null;
50+ this.prm = null;
51+ }
52+
53+ /**
54+ * コンストラクタ
55+ *
56+ * @param kana 半角カナを含む場合 true
57+ * @param ext ユーザ定義領域を含む場合 true
58+ * @param msgId メッセージID
59+ * @param param メッセージパラメータ
60+ */
61+ public MojiReferenceCheck(final boolean kana, final boolean ext,
62+ final String msgId, final String... param) {
63+ this.k = kana;
64+ this.e = ext;
65+ this.mid = msgId;
66+ this.prm = ArrayUtil.copyOf(param);
67+ }
68+
69+ /**
70+ * @see online.model.check.ItemCheck#check(java.lang.String...)
71+ */
72+ @Override
73+ public void check(final String... items) {
74+ Optional<Pair<String, Integer>> check = Optional.empty();
75+ for (final String item : items) {
76+ String[] val = super.getArrayParameter(item);
77+ for (int j = 0; val != null && j < val.length; j++) {
78+ if (!super.isTarget(j)) {
79+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
80+ } else if (isMojiReference(val[j])) {
81+ super.setMessage(item, j, this.mid, this.prm);
82+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
83+ }
84+ }
85+ }
86+
87+ check.ifPresent(this::throwKeepCheckException);
88+ }
89+
90+ /**
91+ * 数値文字参照か判断します。
92+ * @param val 対象文字列
93+ * @return 文字参照が存在する場合 true を返す。
94+ */
95+ private boolean isMojiReference(final String val) {
96+ return MojiUtil.isShiftJIS(val, this.k, this.e)
97+ && (PATTERN_DEC.matcher(val).matches() || PATTERN_HEX.matcher(val).matches());
98+ }
99+}
--- trunk/framework/pjSvc/src/project/check/attribute/PostcodeCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/PostcodeCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import project.common.CheckUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 郵便番号チェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class PostcodeCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public PostcodeCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public PostcodeCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (!super.isTarget(j)) {
53+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
54+ } else if (!CheckUtil.isPostcode(val[j])) {
55+ super.setMessage(item, j, this.mid, this.prm);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwKeepCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/attribute/HankakuCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/HankakuCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import project.common.CheckUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 半角文字チェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class HankakuCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public HankakuCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public HankakuCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (!super.isTarget(j)) {
53+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
54+ } else if (!CheckUtil.isHankaku(val[j])) {
55+ super.setMessage(item, j, this.mid, this.prm);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwKeepCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/attribute/LongNumeralCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/LongNumeralCheck.java (revision 179)
@@ -0,0 +1,74 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+import java.util.stream.Stream;
5+
6+import online.model.ModelUtil;
7+import online.model.check.ItemConvert;
8+import project.check.BaseCheck;
9+import project.common.CheckUtil;
10+import core.util.ArrayUtil;
11+import core.util.NumberUtil;
12+import core.util.bean.Pair;
13+
14+/**
15+ * 拡張数値チェック
16+ *
17+ * @author Tadashi Nakayama
18+ * @version 1.0.0
19+ */
20+public final class LongNumeralCheck extends BaseCheck implements ItemConvert<Long> {
21+
22+ /** メッセージID */
23+ private final String mid;
24+ /** メッセージパラメータ */
25+ private final String[] prm;
26+
27+ /**
28+ * コンストラクタ
29+ */
30+ public LongNumeralCheck() {
31+ this.mid = null;
32+ this.prm = null;
33+ }
34+
35+ /**
36+ * コンストラクタ
37+ *
38+ * @param msgId メッセージID
39+ * @param param メッセージパラメータ
40+ */
41+ public LongNumeralCheck(final String msgId, final String... param) {
42+ this.mid = msgId;
43+ this.prm = ArrayUtil.copyOf(param);
44+ }
45+
46+ /**
47+ * @see online.model.check.ItemCheck#check(java.lang.String[])
48+ */
49+ @Override
50+ public void check(final String... items) {
51+ Optional<Pair<String, Integer>> check = Optional.empty();
52+ for (final String item : items) {
53+ String[] val = super.getArrayParameter(item);
54+ for (int j = 0; val != null && j < val.length; j++) {
55+ if (!super.isTarget(j)) {
56+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
57+ } else if (!CheckUtil.isLong(val[j])) {
58+ super.setMessage(item, j, this.mid, this.prm);
59+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
60+ }
61+ }
62+ }
63+
64+ check.ifPresent(this::throwKeepCheckException);
65+ }
66+
67+ /**
68+ * @see online.model.check.ItemConvert#convert(java.lang.String...)
69+ */
70+ @Override
71+ public Long[] convert(final String... val) {
72+ return Stream.of(val).map(NumberUtil::toLong).toArray(Long[]::new);
73+ }
74+}
--- trunk/framework/pjSvc/src/project/check/attribute/MonthCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/MonthCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import project.common.CheckUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 年月妥当性チェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class MonthCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public MonthCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public MonthCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (!super.isTarget(j)) {
53+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
54+ } else if (!CheckUtil.isDateTime(val[j])) {
55+ super.setMessage(item, j, this.mid, this.prm);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwKeepCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/attribute/EmailCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/EmailCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import project.common.CheckUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * メールアドレスチェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class EmailCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public EmailCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public EmailCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (!super.isTarget(j)) {
53+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
54+ } else if (!CheckUtil.isEmailAddress(val[j])) {
55+ super.setMessage(item, j, this.mid, this.prm);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwKeepCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/attribute/NumberCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/NumberCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import project.common.CheckUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 半角数字チェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class NumberCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public NumberCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public NumberCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (!super.isTarget(j)) {
53+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
54+ } else if (!CheckUtil.isNumber(val[j])) {
55+ super.setMessage(item, j, this.mid, this.prm);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwKeepCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/attribute/ZenKatakanaCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/ZenKatakanaCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import project.common.CheckUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 全角カナチェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class ZenKatakanaCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public ZenKatakanaCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public ZenKatakanaCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (!super.isTarget(j)) {
53+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
54+ } else if (!CheckUtil.isZenKatakana(val[j])) {
55+ super.setMessage(item, j, this.mid, this.prm);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwKeepCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/attribute/HanEisuCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/HanEisuCheck.java (revision 179)
@@ -0,0 +1,63 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import project.common.CheckUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 半角英数文字チェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class HanEisuCheck extends BaseCheck {
18+
19+ /** メッセージID */
20+ private final String mid;
21+ /** メッセージパラメータ */
22+ private final String[] prm;
23+
24+ /**
25+ * コンストラクタ
26+ */
27+ public HanEisuCheck() {
28+ this.mid = null;
29+ this.prm = null;
30+ }
31+
32+ /**
33+ * コンストラクタ
34+ *
35+ * @param msgId メッセージID
36+ * @param param メッセージパラメータ
37+ */
38+ public HanEisuCheck(final String msgId, final String... param) {
39+ this.mid = msgId;
40+ this.prm = ArrayUtil.copyOf(param);
41+ }
42+
43+ /**
44+ * @see online.model.check.ItemCheck#check(java.lang.String...)
45+ */
46+ @Override
47+ public void check(final String... items) {
48+ Optional<Pair<String, Integer>> check = Optional.empty();
49+ for (final String item : items) {
50+ String[] val = super.getArrayParameter(item);
51+ for (int j = 0; val != null && j < val.length; j++) {
52+ if (!super.isTarget(j)) {
53+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
54+ } else if (!CheckUtil.isHanEisu(val[j])) {
55+ super.setMessage(item, j, this.mid, this.prm);
56+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
57+ }
58+ }
59+ }
60+
61+ check.ifPresent(this::throwKeepCheckException);
62+ }
63+}
--- trunk/framework/pjSvc/src/project/check/attribute/DecimalCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/DecimalCheck.java (revision 179)
@@ -0,0 +1,87 @@
1+package project.check.attribute;
2+
3+import java.math.BigDecimal;
4+import java.util.Optional;
5+import java.util.stream.Stream;
6+
7+import online.model.ModelUtil;
8+import online.model.check.ItemConvert;
9+import project.check.BaseCheck;
10+import project.common.CheckUtil;
11+import core.util.ArrayUtil;
12+import core.util.NumberUtil;
13+import core.util.bean.Pair;
14+
15+/**
16+ * 小数点指定桁数内チェック
17+ *
18+ * @author Tadashi Nakayama
19+ * @version 1.0.0
20+ */
21+public final class DecimalCheck extends BaseCheck implements ItemConvert<BigDecimal> {
22+
23+ /** 指定桁数 */
24+ private final int number;
25+ /** 指定桁数 */
26+ private final int decimal;
27+ /** メッセージID */
28+ private final String mid;
29+ /** メッセージパラメータ */
30+ private final String[] prm;
31+
32+ /**
33+ * コンストラクタ
34+ * @param num 指定整数部桁数
35+ * @param dec 指定小数部桁数
36+ */
37+ public DecimalCheck(final int num, final int dec) {
38+ this.number = num;
39+ this.decimal = dec;
40+ this.mid = null;
41+ this.prm = null;
42+ }
43+
44+ /**
45+ * コンストラクタ
46+ *
47+ * @param num 指定整数部桁数
48+ * @param dec 指定小数部桁数
49+ * @param msgId メッセージID
50+ * @param param メッセージパラメータ
51+ */
52+ public DecimalCheck(final int num, final int dec, final String msgId, final String... param) {
53+ this.number = num;
54+ this.decimal = dec;
55+ this.mid = msgId;
56+ this.prm = ArrayUtil.extend(param, String.valueOf(num), String.valueOf(dec));
57+ }
58+
59+ /**
60+ * @see online.model.check.ItemCheck#check(java.lang.String...)
61+ */
62+ @Override
63+ public void check(final String... items) {
64+ Optional<Pair<String, Integer>> check = Optional.empty();
65+ for (final String item : items) {
66+ String[] val = super.getArrayParameter(item);
67+ for (int j = 0; val != null && j < val.length; j++) {
68+ if (!super.isTarget(j)) {
69+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
70+ } else if (!CheckUtil.isDecimal(val[j], this.number, this.decimal)) {
71+ super.setMessage(item, j, this.mid, this.prm);
72+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
73+ }
74+ }
75+ }
76+
77+ check.ifPresent(this::throwKeepCheckException);
78+ }
79+
80+ /**
81+ * @see online.model.check.ItemConvert#convert(java.lang.String...)
82+ */
83+ @Override
84+ public BigDecimal[] convert(final String... val) {
85+ return Stream.of(val).map(NumberUtil::toBigDecimal).toArray(BigDecimal[]::new);
86+ }
87+}
--- trunk/framework/pjSvc/src/project/check/attribute/TimeCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/TimeCheck.java (revision 179)
@@ -0,0 +1,86 @@
1+package project.check.attribute;
2+
3+import java.util.Date;
4+import java.util.Objects;
5+import java.util.Optional;
6+import java.util.stream.Stream;
7+
8+import online.model.ModelUtil;
9+import online.model.check.ItemConvert;
10+import project.check.BaseCheck;
11+import core.util.ArrayUtil;
12+import core.util.DateUtil;
13+import core.util.bean.Pair;
14+
15+/**
16+ * 時間チェック
17+ *
18+ * @author Tadashi Nakayama
19+ * @version 1.0.0
20+ */
21+public final class TimeCheck extends BaseCheck implements ItemConvert<Date> {
22+
23+ /** メッセージID */
24+ private final String mid;
25+ /** メッセージパラメータ */
26+ private final String[] prm;
27+
28+ /**
29+ * コンストラクタ
30+ */
31+ public TimeCheck() {
32+ this.mid = null;
33+ this.prm = null;
34+ }
35+
36+ /**
37+ * コンストラクタ
38+ *
39+ * @param msgId メッセージID
40+ * @param param メッセージパラメータ
41+ */
42+ public TimeCheck(final String msgId, final String... param) {
43+ this.mid = msgId;
44+ this.prm = ArrayUtil.copyOf(param);
45+ }
46+
47+ /**
48+ * @see online.model.check.ItemCheck#check(java.lang.String...)
49+ */
50+ @Override
51+ public void check(final String... items) {
52+ Optional<Pair<String, Integer>> check = Optional.empty();
53+ for (final String item : items) {
54+ String[] val = super.getArrayParameter(item);
55+ for (int j = 0; val != null && j < val.length; j++) {
56+ if (!super.isTarget(j)) {
57+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
58+ } else if (!isTime(val[j])) {
59+ super.setMessage(item, j, this.mid, this.prm);
60+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
61+ }
62+ }
63+ }
64+
65+ check.ifPresent(this::throwKeepCheckException);
66+ }
67+
68+ /**
69+ * 時分確認
70+ * @param val 文字列
71+ * @return 時分の場合 true を返す。
72+ */
73+ private boolean isTime(final String val) {
74+ String str = DateUtil.removeSeparator(val);
75+ return Objects.toString(str, "").isEmpty()
76+ || (str.length() % 2 == 0 && str.length() <= 6 && DateUtil.toTime(str) != null);
77+ }
78+
79+ /**
80+ * @see online.model.check.ItemConvert#convert(java.lang.String...)
81+ */
82+ @Override
83+ public Date[] convert(final String... val) {
84+ return Stream.of(val).map(DateUtil::toTime).toArray(Date[]::new);
85+ }
86+}
--- trunk/framework/pjSvc/src/project/check/attribute/HanKatakanaCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/HanKatakanaCheck.java (revision 179)
@@ -0,0 +1,69 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+
5+import online.model.ModelUtil;
6+import project.check.BaseCheck;
7+import project.common.CheckUtil;
8+import core.util.ArrayUtil;
9+import core.util.bean.Pair;
10+
11+/**
12+ * 半角カナチェック
13+ *
14+ * @author Tadashi Nakayama
15+ * @version 1.0.0
16+ */
17+public final class HanKatakanaCheck extends BaseCheck {
18+
19+ /** 正誤反転フラグ 1の時正誤反転 */
20+ private final boolean tfflg;
21+ /** メッセージID */
22+ private final String mid;
23+ /** メッセージパラメータ */
24+ private final String[] prm;
25+
26+ /**
27+ * コンストラクタ
28+ */
29+ public HanKatakanaCheck() {
30+ this.tfflg = false;
31+ this.mid = null;
32+ this.prm = null;
33+ }
34+
35+ /**
36+ * コンストラクタ
37+ *
38+ * @param flg 正誤反転
39+ * @param msgId メッセージID
40+ * @param param メッセージパラメータ
41+ */
42+ public HanKatakanaCheck(final boolean flg, final String msgId, final String... param) {
43+ this.tfflg = flg;
44+ this.mid = msgId;
45+ this.prm = ArrayUtil.copyOf(param);
46+ }
47+
48+ /**
49+ * @see online.model.check.ItemCheck#check(java.lang.String...)
50+ */
51+ @Override
52+ public void check(final String... items) {
53+ Optional<Pair<String, Integer>> check = Optional.empty();
54+ for (final String item : items) {
55+ String[] val = super.getArrayParameter(item);
56+ for (int j = 0; val != null && j < val.length; j++) {
57+ if (!super.isTarget(j)) {
58+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
59+ } else if ((this.tfflg && CheckUtil.hasHanKana(val[j]))
60+ || (!this.tfflg && !CheckUtil.hasHanKana(val[j]))) {
61+ super.setMessage(item, j, this.mid, this.prm);
62+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
63+ }
64+ }
65+ }
66+
67+ check.ifPresent(this::throwKeepCheckException);
68+ }
69+}
--- trunk/framework/pjSvc/src/project/check/attribute/NumeralCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/NumeralCheck.java (revision 179)
@@ -0,0 +1,74 @@
1+package project.check.attribute;
2+
3+import java.util.Optional;
4+import java.util.stream.Stream;
5+
6+import online.model.ModelUtil;
7+import online.model.check.ItemConvert;
8+import project.check.BaseCheck;
9+import project.common.CheckUtil;
10+import core.util.ArrayUtil;
11+import core.util.NumberUtil;
12+import core.util.bean.Pair;
13+
14+/**
15+ * 数値チェック
16+ *
17+ * @author Tadashi Nakayama
18+ * @version 1.0.0
19+ */
20+public final class NumeralCheck extends BaseCheck implements ItemConvert<Integer> {
21+
22+ /** メッセージID */
23+ private final String mid;
24+ /** メッセージパラメータ */
25+ private final String[] prm;
26+
27+ /**
28+ * コンストラクタ
29+ */
30+ public NumeralCheck() {
31+ this.mid = null;
32+ this.prm = null;
33+ }
34+
35+ /**
36+ * コンストラクタ
37+ *
38+ * @param msgId メッセージID
39+ * @param param メッセージパラメータ
40+ */
41+ public NumeralCheck(final String msgId, final String... param) {
42+ this.mid = msgId;
43+ this.prm = ArrayUtil.copyOf(param);
44+ }
45+
46+ /**
47+ * @see online.model.check.ItemCheck#check(java.lang.String...)
48+ */
49+ @Override
50+ public void check(final String... items) {
51+ Optional<Pair<String, Integer>> check = Optional.empty();
52+ for (final String item : items) {
53+ String[] val = super.getArrayParameter(item);
54+ for (int j = 0; val != null && j < val.length; j++) {
55+ if (!super.isTarget(j)) {
56+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
57+ } else if (!CheckUtil.isInteger(val[j])) {
58+ super.setMessage(item, j, this.mid, this.prm);
59+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
60+ }
61+ }
62+ }
63+
64+ check.ifPresent(this::throwKeepCheckException);
65+ }
66+
67+ /**
68+ * @see online.model.check.ItemConvert#convert(java.lang.String...)
69+ */
70+ @Override
71+ public Integer[] convert(final String... val) {
72+ return Stream.of(val).map(NumberUtil::toInteger).toArray(Integer[]::new);
73+ }
74+}
--- trunk/framework/pjSvc/src/project/check/attribute/TimestampCheck.java (nonexistent)
+++ trunk/framework/pjSvc/src/project/check/attribute/TimestampCheck.java (revision 179)
@@ -0,0 +1,75 @@
1+package project.check.attribute;
2+
3+import java.util.Date;
4+import java.util.Optional;
5+import java.util.stream.Stream;
6+
7+import online.model.ModelUtil;
8+import online.model.check.ItemConvert;
9+import project.check.BaseCheck;
10+import project.common.CheckUtil;
11+import core.util.ArrayUtil;
12+import core.util.DateUtil;
13+import core.util.bean.Pair;
14+
15+/**
16+ * 時間チェック
17+ *
18+ * @author Tadashi Nakayama
19+ * @version 1.0.0
20+ */
21+public final class TimestampCheck extends BaseCheck implements ItemConvert<Date> {
22+
23+ /** メッセージID */
24+ private final String mid;
25+ /** メッセージパラメータ */
26+ private final String[] prm;
27+
28+ /**
29+ * コンストラクタ
30+ */
31+ public TimestampCheck() {
32+ this.mid = null;
33+ this.prm = null;
34+ }
35+
36+ /**
37+ * コンストラクタ
38+ *
39+ * @param msgId メッセージID
40+ * @param param メッセージパラメータ
41+ */
42+ public TimestampCheck(final String msgId, final String... param) {
43+ this.mid = msgId;
44+ this.prm = ArrayUtil.copyOf(param);
45+ }
46+
47+ /**
48+ * @see online.model.check.ItemCheck#check(java.lang.String...)
49+ */
50+ @Override
51+ public void check(final String... items) {
52+ Optional<Pair<String, Integer>> check = Optional.empty();
53+ for (final String item : items) {
54+ String[] val = super.getArrayParameter(item);
55+ for (int j = 0; val != null && j < val.length; j++) {
56+ if (!super.isTarget(j)) {
57+ val[j] = ModelUtil.getValueAsString(super.getUniModel(), item, j);
58+ } else if (!CheckUtil.isDateTime(val[j])) {
59+ super.setMessage(item, j, this.mid, this.prm);
60+ check = Optional.of(check.orElse(new Pair<>(item, Integer.valueOf(j))));
61+ }
62+ }
63+ }
64+
65+ check.ifPresent(this::throwKeepCheckException);
66+ }
67+
68+ /**
69+ * @see online.model.check.ItemConvert#convert(java.lang.String...)
70+ */
71+ @Override
72+ public Date[] convert(final String... val) {
73+ return Stream.of(val).map(DateUtil::toDateTime).toArray(Date[]::new);
74+ }
75+}