/* * [EE.java] * * Summary: Generate a reference to Oracle EE documentation both online and on local hard disk. * * 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.fastcat.FastCat; import com.mindprod.htmlmacros.support.Tools; import java.io.File; import static java.lang.System.*; /** * Generate a reference to Oracle EE documentation both online and on local hard disk. * * @author Roedy Green, Canadian Mind Products * @version 1.8 2009-02-06 include go package in ZIP bundle. * @since 2009 */ public final class EE extends Macro { /** * how to use the macro */ private static final String USAGE = "\nEE macro needs reference without /api/, description"; /** * Build HTML to describe the J: drive links. * * @return generated HTML */ private String buildJDriveDescription() { final FastCat sb = new FastCat( 3 ); sb.append( "on your local Windows J: drive" ); return sb.toString(); } /** * guts to Generate reference to a Oracle EE HTML document. * * @param ref reference e.g javax/servlet/http/HttpServlet.htm /s or \s. Generates * http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServlet.html * @param desc human description of what it is. * * @return expanded-href both to online and local. */ private String expand( String ref, String desc ) { char firstChar = ref.charAt( 0 ); if ( firstChar == '/' || firstChar == File.separatorChar ) { ref = ref.substring( 1 ); } String refWithSlashes = ref.replace( File.separatorChar, '/' ); String refWithBackSlashes = ref.replace( '/', File.separatorChar ); final FastCat sb = new FastCat( 12 ); sb.append( "\n
" ); sb.append( desc ); sb.append( " : available:
\n" ); return sb.toString(); } /** * Expands: <!-- macro EE "HttpServlet docs" --> "javax/servlet/http/HttpServlet.html" --> * Generate a reference to a Oracle EE HTML document * * @param parms first is description, second the reference javax/servlet/http/HttpServlet.html Can use * either /s or \s in the url. Generates http://java.sun.com/j2ee/1 * .4/docs/api/javax/servlet/http/HttpServlet.html * @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( "E" ); } if ( parms.length != 2 ) { throw new IllegalArgumentException( USAGE ); } String ref = parms[ 0 ]; String desc = parms[ 1 ]; return expand( ref, desc ); } }