[LIB-13] Entity of PGN Tag
authorgotty <gotty@hedgecode.org>
Wed, 15 Jan 2020 01:17:48 +0000 (04:17 +0300)
committergotty <gotty@hedgecode.org>
Wed, 15 Jan 2020 01:17:48 +0000 (04:17 +0300)
src/main/java/org/hedgecode/chess/scanner/entity/PGNTag.java [new file with mode: 0644]

diff --git a/src/main/java/org/hedgecode/chess/scanner/entity/PGNTag.java b/src/main/java/org/hedgecode/chess/scanner/entity/PGNTag.java
new file mode 100644 (file)
index 0000000..6a6661e
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2019-2020. Developed by Hedgecode.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hedgecode.chess.scanner.entity;
+
+/**
+ * PGNTag
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public enum PGNTag {
+
+    EVENT         ( "Event",        true,        PGNTag.QUESTION      ),
+    SITE          ( "Site",         true,        PGNTag.QUESTION      ),
+    DATE          ( "Date",         true,        PGNTag.QUESTION_DATE ),
+    ROUND         ( "Round",        true,        PGNTag.QUESTION      ),
+    WHITE         ( "White",        true,        PGNTag.QUESTION      ),
+    BLACK         ( "Black",        true,        PGNTag.QUESTION      ),
+    WHITE_TITLE   ( "WhiteTitle",   false,       PGNTag.HYPHEN        ),
+    BLACK_TITLE   ( "BlackTitle",   false,       PGNTag.HYPHEN        ),
+    WHITE_ELO     ( "WhiteElo",     false,       PGNTag.HYPHEN        ),
+    BLACK_ELO     ( "BlackElo",     false,       PGNTag.HYPHEN        ),
+    WHITE_USCF    ( "WhiteUSCF",    false,       PGNTag.HYPHEN        ),
+    BLACK_USCF    ( "BlackUSCF",    false,       PGNTag.HYPHEN        ),
+    WHITE_NA      ( "WhiteNA",      false,       PGNTag.HYPHEN        ),
+    BLACK_NA      ( "BlackNA",      false,       PGNTag.HYPHEN        ),
+    WHITE_TYPE    ( "WhiteType",    false,       PGNTag.HYPHEN        ),
+    BLACK_TYPE    ( "BlackType",    false,       PGNTag.HYPHEN        ),
+    EVENT_DATE    ( "EventDate",    false,       PGNTag.QUESTION_DATE ),
+    EVENT_SPONSOR ( "EventSponsor", false,       PGNTag.EMPTY         ),
+    SECTION       ( "Section",      false,       PGNTag.EMPTY         ),
+    STAGE         ( "Stage",        false,       PGNTag.EMPTY         ),
+    BOARD         ( "Board",        false,       PGNTag.EMPTY         ),
+    OPENING       ( "Opening",      false,       PGNTag.EMPTY         ),
+    VARIATION     ( "Variation",    false,       PGNTag.EMPTY         ),
+    SUBVARIATION  ( "SubVariation", false,       PGNTag.EMPTY         ),
+    ECO           ( "ECO",          false,       PGNTag.EMPTY         ),
+    NIC           ( "NIC",          false,       PGNTag.EMPTY         ),
+    TIME          ( "Time",         false,       PGNTag.QUESTION_TIME ),
+    UTC_DATE      ( "UTCDate",      false,       PGNTag.QUESTION_DATE ),
+    UTC_TIME      ( "UTCTime",      false,       PGNTag.QUESTION_TIME ),
+    TIME_CONTROL  ( "TimeControl",  false,       PGNTag.QUESTION      ),
+    SETUP         ( "SetUp",        false,       PGNTag.ZERO          ),
+    FEN           ( "FEN",          false,       PGNTag.EMPTY         ),
+    TERMINATION   ( "Termination",  false,       PGNTag.EMPTY         ),
+    ANNOTATOR     ( "Annotator",    false,       PGNTag.EMPTY         ),
+    MODE          ( "Mode",         false,       PGNTag.EMPTY         ),
+    PLY_COUNT     ( "PlyCount",     false,       PGNTag.EMPTY         ),
+    RESULT        ( "Result",       true,        PGNTag.NON_RESULT    );
+
+    public static final String EMPTY = "";
+    public static final String HYPHEN = "-";
+    public static final String ZERO = "0";
+    public static final String QUESTION = "?";
+    public static final String QUESTION_DATE = "????.??.??";
+    public static final String QUESTION_TIME = "??:??:??";
+    public static final String NON_RESULT = "*";
+
+    public static final String TAG_FORMAT = "[%s \"%s\"]";
+
+    private String tagName;
+    private boolean isRequired;
+    private String defaultValue;
+
+    PGNTag(String name, boolean required, String defValue) {
+        tagName = name;
+        isRequired = required;
+        defaultValue = defValue;
+    }
+
+    public String getName() {
+        return tagName;
+    }
+
+    public boolean isRequired() {
+        return isRequired;
+    }
+
+    public String defaultValue() {
+        return defaultValue;
+    }
+
+}