/* * [JDK.java] * * Summary: Expand JDK reference to some sort of version. * * Copyright: (c) 2009-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.8 2009-02-06 include go package in ZIP bundle. * macro JDK micro --> 0
jdk1.8.0_131 * 0
J:\Program Files\Java\jdk_1.7.0
* file://localhost/J:/Program * Files/Java/jdk_1.7.0 * 1.9 2014-08-04 addend trailing \ to path variables to idicate they are dirs. */ package com.mindprod.htmlmacros.macro; import com.mindprod.htmlmacros.support.VersionFlavour; import java.io.File; import static com.mindprod.common18.Build.INTELLIJ_DIR; import static com.mindprod.common18.Build.INTELLIJ_FULL_VERSION; import static com.mindprod.common18.Build.JET_FULL_VERSION; import static com.mindprod.common18.Build.JET_PROFILE_VERSION; import static com.mindprod.htmlmacros.support.JDKandJREVersions.*; import static java.lang.System.*; /** * Expand JDK reference to some sort of version. * * @author Roedy Green, Canadian Mind Products * @version 1.9 2014-08-04 addend trailing \ to path variables to idicate they are dirs. * @see com.mindprod.htmlmacros.macro.JRE * @see com.mindprod.htmlmacros.support.JDKandJREVersions * @see JDKLocation * @since 2009 */ public final class JDK extends Macro { // declarations /** how to use the macro */ /** * how to use the macro */ private static final String USAGE = "\nJDK macro needs a flavour, e.g. macro version fullversion micro dir path url"; // /declarations // methods /** * guts to Generate reference to the JDK. * * @param flavour enumeration for type of version wanted * * @return expanded to the type of JDK version wanted */ private static String expand( final VersionFlavour flavour, final File fileBeingProcessed ) { switch ( flavour ) { case macroversion: // 1.8 return "" + JDK_MACRO_VERSION + ""; // 1.8.0 case version: return "" + JDK_VERSION + ""; case fullversion: // 1.8.0_131 return "" + JDK_FULL_VERSION + ""; case recommendedversion: // 1.8.0_131 return "" + RECOMMENDED_JDK_FULL_VERSION + ""; case microversion: // 0 return "" + JDK_MICRO_VERSION + ""; case releaseversion: // 0 return "" + JDK_RELEASE_VERSION + ""; case dir: // jdk1.8.0_131 return "" + JDK_DIR + ""; case path: // J:\Program Files\Java\jdk1.8.0_131 return Path.decorate( JDK_PATH, false, /* is dir even though has no trailing / */ fileBeingProcessed ); case path32: // J:\Program Files (x86)\java\jdk1.8.0_131 return Path.decorate( JDK_PATH32, false, /* is dir even though has no trailing / */ fileBeingProcessed ); case defaultpath: // default dir where JDK installed // J:\Program Files  (x86)\java\jdk1.8.0_131 return Path.decorate( JDK_DEFAULT_PATH, false, /* is dir even though has no trailing / */ fileBeingProcessed ); case url: return "" + JDK_URL + ""; case url32: return "" + JDK_URL32 + ""; case jetprofileversion: // 1.7.0_55 return "" + JET_PROFILE_VERSION + ""; case jetversion: return "" + JET_FULL_VERSION + ""; case jetfullversion: // jet10.0-pro-x8 return "" + JET_FULL_VERSION + ""; case ideadir: return "" + INTELLIJ_DIR + ""; case ideafullversion: return "" + INTELLIJ_FULL_VERSION + ""; // old versions case oldmacroversion: // 1.8 return "" + OLD_JDK_MACRO_VERSION + ""; // 1.8.0 case oldversion: return "" + OLD_JDK_VERSION + ""; case oldfullversion: // 1.8.0_131 return "" + OLD_JDK_FULL_VERSION + ""; case oldmicroversion: // 0 return "" + OLD_JDK_MICRO_VERSION + ""; case oldreleaseversion: // 0 return "" + OLD_JDK_RELEASE_VERSION + ""; case olddir: // jdk1.8.0_131 return "" + OLD_JDK_DIR + ""; case oldpath: // J:\Program Files\Java\jdk1.8.0_131 return Path.decorate( OLD_JDK_PATH, false, /* is dir even though has no trailing / */ fileBeingProcessed ); case oldpath32: // J:\Program Files (x86)\java\jdk1.8.0_131 return Path.decorate( OLD_JDK_PATH32, false, /* is dir even though has no trailing / */ fileBeingProcessed ); case olddefaultpath: // default dir where JDK installed // J:\Program Files  (x86)\java\jdk1.8.0_131 return Path.decorate( OLD_JDK_DEFAULT_PATH, false, /* is dir even though has no trailing / */ fileBeingProcessed ); case oldurl: return "" + OLD_JDK_URL + ""; case oldurl32: return "" + OLD_JDK_URL32 + ""; default: throw new IllegalArgumentException( "JDK unknown flavour" ); } }// /method /** * Expands: Generate a reference to a Oracle * file in * the JR. see samples of use in mindprod\jgloss\registry.html * * @param parms first is description, second the reference lib/rt.jar Can use either /s or \s in the * url. Generates file://localhost/J:/Program Files/jdk1.5.0_03/lib/rt.jar * @param quiet true if want output suppressed. * @param verbose @return expanded macro HTML */ public String expandMacro( String[] parms, final boolean quiet, final boolean verbose ) { if ( !quiet ) { out.print( "J" ); } if ( parms.length != 1 ) { throw new IllegalArgumentException( USAGE ); } String f = parms[ 0 ]; VersionFlavour flavour; try { // will throw IllegalArgumentException if no match flavour = VersionFlavour.valueOf( VersionFlavour.class, f ); } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException( "macro JDK invalid parameter: " + f ); } return expand( flavour, fileBeingProcessed ); }// /method // /methods }