/* * [JDKLocation.java] * * Summary: Generate a reference to Oracle file/dir in the current 32 and 64 bit JDKs. * * 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. */ package com.mindprod.htmlmacros.macro; import com.mindprod.common18.ST; import com.mindprod.fastcat.FastCat; import com.mindprod.htmlmacros.support.Tools; import java.io.File; import static com.mindprod.htmlmacros.support.JDKandJREVersions.*; import static java.lang.System.*; /** * Generate a reference to Oracle file/dir in the current 32 and 64 bit JDKs. * * @author Roedy Green, Canadian Mind Products * @version 1.8 2009-02-06 include go package in ZIP bundle. * @see com.mindprod.htmlmacros.macro.JDK * @see com.mindprod.htmlmacros.support.JDKandJREVersions * @since 2009 */ public final class JDKLocation extends Macro { // declarations /** * how to use the macro */ private static final String USAGE = "\nJDKLocation macro needs {jre-relative-reference without lead / or \\} {description}"; // /declarations // methods /** * Build HTML to describe the J: drive links. * * @return generated HTML */ private static String buildJDriveDescription( File fileBeingDistributed ) { final FastCat sb = new FastCat( 3 ); sb.append( "on your local Windows J: drive." ); return sb.toString(); }// /method /** * guts to Generate reference to a Oracle file in JDK. * * @param desc human description of what it is. * @param ref relative reference to a file the JDK reference e.g
bin/javac.exer
Can use either /s or \s in * the url. Generates
file://localhost/J:/program file/Java/jdk1.8.0_131/bin/javac.exe * * @return HTML expansion for the macro */ private static String expand( String desc, String ref, File fileBeingDistributed ) { ref = ST.trimLeading( ref, "/\\" ); String refWithSlashes = ref.replace( File.separatorChar, '/' ); String refWithBackSlashes = ref.replace( '/', File.separatorChar ); // now without leand / final FastCat sb = new FastCat( 35 ); sb.append( "\n" ); sb.append( "
", desc ); sb.append( " :
\n" ); } sb.append( "\n" ); return sb.toString(); }// /method /** * Expands: Generate a reference * to a Oracle file in the JDKs * * @param parms first is description, second the reference lib/rt.jar Can use either slashes or backslashes in the * @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( "F" ); } if ( parms.length != 2 ) { throw new IllegalArgumentException( USAGE ); } String ref = parms[ 0 ]; String desc = parms[ 1 ]; return expand( desc, ref, fileBeingDistributed ); }// /method // /methods }