[LIB-4] Output of results to console master
authorgotty <gotty@fb0bcced-7025-49ed-a12f-f98bce993226>
Thu, 16 May 2019 11:12:09 +0000 (11:12 +0000)
committergotty <gotty@fb0bcced-7025-49ed-a12f-f98bce993226>
Thu, 16 May 2019 11:12:09 +0000 (11:12 +0000)
git-svn-id: https://svn.hedgecode.org/xml/hespiff/trunk@170 fb0bcced-7025-49ed-a12f-f98bce993226

src/main/java/org/hedgecode/xml/xspf/XSPFApp.java
src/main/java/org/hedgecode/xml/xspf/XSPFConsole.java [new file with mode: 0644]

index a94e5fd..8bfe893 100644 (file)
@@ -25,6 +25,8 @@ public final class XSPFApp {
 
     public static void main(String[] args) {
 
+        XSPFConsole.init();
+
     }
 
 }
diff --git a/src/main/java/org/hedgecode/xml/xspf/XSPFConsole.java b/src/main/java/org/hedgecode/xml/xspf/XSPFConsole.java
new file mode 100644 (file)
index 0000000..437c01f
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2015-2019. 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.xml.xspf;
+
+import java.util.Calendar;
+
+/**
+ * XSPF API utility class for working with console.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public final class XSPFConsole {
+
+    private static final String[] ASCII_LOGO = {
+            "  _______     _                   _                ",
+            " |   |  _|_ _| |___ ___ ___ ___ _| |___            ",
+            " |     | -_| . | . | -_|  _| . | . | -_|           ",
+            " |     |___|___|_  |___|___|___|___|___|           ",
+            " |___|___|     |___|  _______           _ ___ ___  ",
+            "                     |   |  _|_ ___ ___|_|  _|  _| ",
+            "                     |     | -_|_ -| . | | |_| |_  ",
+            "                     |     |___|___|  _|_|  _|  _| ",
+            "                     |___|___|     |_|   |_| |_|   ",
+            "     __ __ _____ _____ _____    _____ _____ _      ",
+            "    |  |  |   __|  _  |   __|  |  _  |  _  |_|     ",
+            "    |-   -|__   |   __|   __|  |     |   __| |     ",
+            "    |__|__|_____|__|  |__|     |__|__|__|  |_|     "
+    };
+
+    private static final String COPYRIGHT = "Copyright (c) Hedgecode";
+
+    private XSPFConsole() {
+    }
+
+    public static void console(String message) {
+        System.out.println(
+                message == null ? "" : message
+        );
+    }
+
+    public static void empty() {
+        console(null);
+    }
+
+    public static void init() {
+        asciiLogo();
+        empty();
+        copyright();
+        version();
+        empty();
+    }
+
+    private static void asciiLogo() {
+        for (String line : ASCII_LOGO) {
+            console(line);
+        }
+    }
+
+    private static void copyright() {
+        int currentYear = Calendar.getInstance().get(Calendar.YEAR);
+        int inceptionYear = XSPFProperties.getInteger(XSPFProperties.INCEPTION_YEAR, currentYear);
+        String copyright = currentYear > inceptionYear
+                ? String.format("%s-%s %s", inceptionYear, currentYear, COPYRIGHT)
+                : String.format("%s %s", currentYear, COPYRIGHT);
+        console(
+                alignCenter(copyright)
+        );
+    }
+
+    private static void version() {
+        console(
+                alignCenter(
+                        String.format(
+                                "v. %s", XSPFProperties.getString(XSPFProperties.VERSION)
+                        )
+                )
+        );
+    }
+
+    private static String alignCenter(String message) {
+        int indent = (ASCII_LOGO[0].length() + message.length()) / 2;
+        return String.format(
+                "%" + indent + "s",
+                message
+        );
+    }
+
+}