001package jmri; 002 003import java.util.Arrays; 004import java.util.List; 005import jmri.profile.ProfileManager; 006 007/** 008 * Meta data concerning the JMRI application. 009 * <p> 010 * Meta data is static information concerning the JMRI application. This class 011 * provides a single container for listing and storing JMRI meta data. 012 * 013 * <hr> 014 * This file is part of JMRI. 015 * <p> 016 * JMRI is free software; you can redistribute it and/or modify it under the 017 * terms of version 2 of the GNU General Public License as published by the Free 018 * Software Foundation. See the "COPYING" file for a copy of this license. 019 * <p> 020 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY 021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 022 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 023 * 024 * @author Randall Wood Copyright (C) 2011 025 */ 026public interface Metadata { 027 028 String JMRIVERSION = "JMRIVERSION"; // NOI18N 029 String JMRIVERCANON = "JMRIVERCANON"; // NOI18N 030 String JMRIVERMAJOR = "JMRIVERMAJOR"; // NOI18N 031 String JMRIVERMINOR = "JMRIVERMINOR"; // NOI18N 032 String JMRIVERTEST = "JMRIVERTEST"; // NOI18N 033 String JVMVERSION = "JVMVERSION"; // NOI18N 034 String JVMVENDOR = "JVMVENDOR"; // NOI18N 035 String ACTIVEPROFILE = "activeProfile"; // NOI18N 036 String COPYRIGHT = "copyright"; // NOI18N 037 038 /** 039 * Return the value of the named meta data, or any valid system property. 040 * 041 * @param name name of meta data or property to return 042 * @return String value of requested data or null 043 */ 044 static String getBySystemName(String name) { 045 if (name.equalsIgnoreCase(JMRIVERSION)) { 046 return jmri.Version.name(); 047 } else if (name.equalsIgnoreCase(JMRIVERCANON)) { 048 return jmri.Version.getCanonicalVersion(); 049 } else if (name.equalsIgnoreCase(JMRIVERMAJOR)) { 050 return Integer.toString(jmri.Version.major); 051 } else if (name.equalsIgnoreCase(JMRIVERMINOR)) { 052 return Integer.toString(jmri.Version.minor); 053 } else if (name.equalsIgnoreCase(JMRIVERTEST)) { 054 return Integer.toString(jmri.Version.test); 055 } else if (name.equalsIgnoreCase(JVMVERSION)) { 056 return System.getProperty("java.version", "<unknown>"); // NOI18N 057 } else if (name.equalsIgnoreCase(JVMVENDOR)) { 058 return System.getProperty("java.vendor", "<unknown>"); // NOI18N 059 } else if (name.equalsIgnoreCase(ACTIVEPROFILE)) { 060 return ProfileManager.getDefault().getActiveProfileName(); 061 } else if (name.equalsIgnoreCase(COPYRIGHT)) { 062 return jmri.Version.getCopyright(); 063 } 064 // returns null if name is not a system property 065 return System.getProperty(name); 066 } 067 068 /** 069 * An array of known meta data names. 070 * 071 * @return String[] 072 */ 073 static String[] getSystemNameArray() { 074 String[] names = {JMRIVERSION, 075 JMRIVERCANON, 076 JMRIVERMAJOR, 077 JMRIVERMINOR, 078 JMRIVERTEST, 079 JVMVERSION, 080 JVMVENDOR, 081 ACTIVEPROFILE, 082 COPYRIGHT}; 083 return names; 084 } 085 086 /** 087 * Get the list of known meta-data names. 088 * @return the list of names 089 */ 090 static List<String> getSystemNameList() { 091 return Arrays.asList(Metadata.getSystemNameArray()); 092 } 093 094}