2 * Copyright (c) 2015-2019. Developed by Hedgecode.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.hedgecode.xml.xspf;
19 import java.util.Calendar;
22 * XSPF API utility class for working with console.
24 * @author Dmitry Samoshin aka gotty
26 public final class XSPFConsole {
28 private static final String[] ASCII_LOGO = {
30 " | | _|_ _| |___ ___ ___ ___ _| |___ ",
31 " | | -_| . | . | -_| _| . | . | -_| ",
32 " | |___|___|_ |___|___|___|___|___| ",
33 " |___|___| |___| _______ _ ___ ___ ",
34 " | | _|_ ___ ___|_| _| _| ",
35 " | | -_|_ -| . | | |_| |_ ",
36 " | |___|___| _|_| _| _| ",
37 " |___|___| |_| |_| |_| ",
38 " __ __ _____ _____ _____ _____ _____ _ ",
39 " | | | __| _ | __| | _ | _ |_| ",
40 " |- -|__ | __| __| | | __| | ",
41 " |__|__|_____|__| |__| |__|__|__| |_| "
44 private static final String COPYRIGHT = "Copyright (c) Hedgecode";
46 private XSPFConsole() {
49 public static void console(String message) {
51 message == null ? "" : message
55 public static void empty() {
59 public static void init() {
67 private static void asciiLogo() {
68 for (String line : ASCII_LOGO) {
73 private static void copyright() {
74 int currentYear = Calendar.getInstance().get(Calendar.YEAR);
75 int inceptionYear = XSPFProperties.getInteger(XSPFProperties.INCEPTION_YEAR, currentYear);
76 String copyright = currentYear > inceptionYear
77 ? String.format("%s-%s %s", inceptionYear, currentYear, COPYRIGHT)
78 : String.format("%s %s", currentYear, COPYRIGHT);
80 alignCenter(copyright)
84 private static void version() {
88 "v. %s", XSPFProperties.getString(XSPFProperties.VERSION)
94 private static String alignCenter(String message) {
95 int indent = (ASCII_LOGO[0].length() + message.length()) / 2;