/* * [AppCat.java] * * Summary: constants for Application categories. * * Copyright: (c) 2004-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.9 2007-04-12 tidy with code inspector, move the anchor to details. */ package com.mindprod.prices; import com.mindprod.fastcat.FastCat; /** * constants for Application categories. * * @author Roedy Green, Canadian Mind Products * @version 1.9 2007-04-12 tidy with code inspector, move the anchor to details. * @since 2004 */ public enum AppCat { /** * pure Applet [short name, description, aliases] */ APPLET( "Applet", "applet", "applet", "Java Applet", "applet" ), /** * assembler COM command line utility */ ASMCOM( "ASM com utility", "utility", "utility", "asm command line utility" ), /** * assembler EXE command line utility */ ASMEXE( "ASM exe utility", "utility", "utility", "asm command line utility" ), /** * pure Java application */ APPLICATION( "application", "application", "application", "Java application", "application" ), /** * collection of Website files, utilities, source etc. */ BUNDLE( "bundle", "application", "application", "Bundle of miscellaneous files", "bundle" ), /** * C++ command line utility */ CPPUTILITY( "C++ utility", "utility", "utility", "C++ command line utility" ), /** * C++ command line utility */ CUTILITY( "C utility", "utility", "utility", "C command line utility" ), /** * documentation, no code */ DOCUMENTATION( "documentation", "application", "application", "documentation", "documentation" ), /** * hybrid Applet/application */ HYBRID( "Applet hybrid", "hybrid", "applet", "Java Applet (that can also be run as an application)", "hybrid" ), /** * class library */ JAVA_CLASS_LIBRARY( "class library", "application", "application", "Java class library", "class", "Java class library" ), /** * Java snippets, like JAVA_CLASS_LIBRARY but no jar containing everything. */ JAVA_SNIPPETS( "snippets", "application", "application", "Java snippets" ), /** * Java web Start */ JWS( "Java Web Start", "webstart", "webstart", "Java Web Start application", "jws", "weblet", "webstart", "JWS" ), /** * servlet */ SERVLET( "Servlet", "application", "application", "Java Servlet", "servlet" ); /** * cannot use String... here, only in parm list alternate input names for the alias */ private final String[] aliases; /** * CSS class to use for Camel case name of this project. */ private final String cssClass; /** * not a specific description of the app, but of the app category, e.g. Java Web Start application */ private final String description; /** * where jars stored, last dir leg of name, e.g.. applet */ private final String jarDir; /** * not a specific description of the app, but of the app category, e.g. Java Web Start */ private final String shortName; /** * constructor for an enum constant * * @param shortName for display, not a specific description of the app, but of the app category, e.g. Java Web * Start * @param cssClass CSS class to use for Camel case name of this project. * @param jarDir * @param description long description, of app category e.g. Java Web Start application * @param aliases other names for string input */ AppCat( String shortName, final String cssClass, final String jarDir, final String description, final String... aliases ) { this.shortName = shortName; this.cssClass = cssClass; this.jarDir = jarDir; this.description = description; this.aliases = aliases; } /** * @return array of aliases -- names by which this enum in know in the real world, for input */ String[] getAliases() { return aliases; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the icon *.ico, to be available on the website. * Contains multiple resolutions. * * @return target directory for the icon */ public static String getIcoDir() { return "image/ico"; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the icon *.png, to be available on the website. * large, usually bigger than 50X50 * * @return target directory for the icon */ public static String getIcon128Dir() { return "image/icon128"; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the icon *.png, to be available on the website. * usually under 16x16 for use as a link icon. * * @return target directory for the icon */ public static String getIcon16Dir() { return "image/icon16"; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the icon *.png, to be available on the website. must * be 32x32 * * @return target directory for the icon */ public static String getIcon32Dir() { return "image/icon32"; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the icon *.png, to be available on the website. * * @return target directory for the icon */ public static String getIcon48Dir() { return "image/icon48"; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the icon *.png, to be available on the website. * * @return target directory for the icon */ public static String getIcon64Dir() { return "image/icon64"; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the ASP pad *.xml to be available on the website. i.e * pads. * * @return target directory for the zip */ public static String getPadDir() { return "pad"; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the *.use, to be available on the website. i.e * details. * * @return target directory for the zip */ public static String getPrecisDir() { return "precis"; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the screenshot *.png, to be available on the website. * i.e screenshot. * * @return target directory for the zip */ public static String getScreenshotDir() { return "image/screenshot"; } // you may not redefine valueOf since has been covertly defined in this // class /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the splash *.gif, to be available on the website. i.e * splash. * * @return target directory for the zip */ public static String getSplashDir() { return "image/splash"; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES-relative directory where the distributed zip, to be available on the website. * i.e. zips * * @return target directory for the zip */ public static String getZipDir() { return "zips"; } /** * convert alias string to equivalent canonical enum constant, like valueOf but accepts aliases too, and does not * care about case. * * @param s alias as string * * @return equivalent AppCat enum constant */ public static AppCat valueOfAlias( final String s ) { try { return valueOf( s ); } catch ( IllegalArgumentException e ) { // usual method failed, try looking up alias // This seems long winded, why no HashSet? // Because Java won't let me access a static common // lookup in the enum constructors. for ( AppCat candidateEnum : AppCat.values() ) { for ( String candidateString : candidateEnum.aliases ) { if ( candidateString.equalsIgnoreCase( s ) ) { return candidateEnum; } } } // fell out the bottom of search over all enums and aliases // give up throw new IllegalArgumentException( "unknown Application Category: " + s ); } } /** * dec * * @return short name, mixed case, not a specific description of the app, but of the app category, e.g. Java Web * Start application */ public String decoratedName( final String name ) { if ( cssClass == null ) { return name; } else { final FastCat sb = new FastCat( 5 ); sb.append( "" ); sb.append( name ); sb.append( "" ); return sb.toString(); } } /** * get the CSS class to decorate the name of the program based on its appcat */ public String getCssClass() { return cssClass; } /** * Get LOCAL_WEBROOT_WITH_BACKSLASHES relative directory where the jar, run.html .manual.html manual.txt, go to be * available on the website * * @return target directory for the jar, e.g. applet */ public String getJarDir() { assert jarDir != null : "Undefined jarDir"; return jarDir; } /** * @param signed true if you want the signed version of the description, e.g. e.g. signed Java Web Start * Application * * @return description */ public String getLongCategoryDescription( final boolean signed ) { if ( signed ) { return "signed " + description; } else { return description; } } /** * @return description e.g. Java Web Start application */ public String getLongCategoryDescription() { return description; } /** * @return short name, mixed case, not a specific description of the app, but of the app category, e.g. Java Web * Start application */ public String getShortCategoryName() { return shortName; } }