/* * [OnOracle.java] * * Summary: Generate a reference to Oracle online documentation. * * Copyright: (c) 2010-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.0 2010-11-23 initial versions, similar to old Oracle macro. */ package com.mindprod.htmlmacros.macro; import com.mindprod.entities.EntifyStrings; import static java.lang.System.*; /** * Generate a reference to Oracle online documentation. *

* * @author Roedy Green, Canadian Mind Products * @version 1.0 2017-03-23 initial versions * @noinspection WeakerAccess, UnusedDeclaration, WeakerAccess * @since 2017-03-23 */ public final class OnOracle extends Macro { /** * used to compose string to decorate links */ static final String ORACLES = "Oracle’s "; /** * true to use main harness for debugging. */ private static final boolean DEBUGGING = false; /** * how to use OnOracle macro * References can be http://... or api/ */ private static final String USAGE = "\nOnOracle macro needs reference description"; /** * name of class we are linking to */ private static String className; /** * extra descriptive in for about what we are linking to. */ private static String freeform; /** * name of method we are linking to */ private static String methodName; /** * method parms we are linking to */ private static String methodParms; /** * name of package we are linking to */ private static String packageName; /** * guts to Generate reference to a Oracle HTML document. * * @param ref usually a fully qualified referenced to sun or oracle site, * @param desc human description of what it is. * @param notes additional notes * * @return expand href both to online and local. * @noinspection WeakerAccess */ public String expand( String ref, String desc, final String notes ) { Possibility.setFileBeingProcessedAndFileBeingDistributed( fileBeingProcessed, fileBeingDistributed ); // figure out which pattern we have. for ( Possibility p : Possibility.values() ) { if ( p.isDnaMatch( ref ) ) { return p.expand( ref, desc, notes ); } } throw new IllegalArgumentException( "OnOracle unrecognised link pattern" ); } /** * typical use: <!-- macro Oracle http://docs.oracle.com/javase/1.5 * .0/docs/guide/javaws/developersguide/cdinstall.03.06.htm "CD install" -->
* link to Sun or Oracle site. * * @param parms link desc , not entified. * @param quiet true if want output suppressed. * @param verbose @return expanded macro HTML */ public final String expandMacro( String[] parms, final boolean quiet, final boolean verbose ) { if ( !quiet ) { out.print( "O" ); } if ( !( 2 <= parms.length && parms.length <= 3 ) ) { throw new IllegalArgumentException( USAGE ); } String ref = parms[ 0 ]; if ( !( ref.startsWith( "http://" ) || ref.startsWith( "https://" ) || ref.equals( "broken" ) ) ) { throw new IllegalArgumentException( "OnOracle required fully qualified reference starting with http: or https:" ); } final String desc = EntifyStrings.entifyHTML( parms[ 1 ] ); final String notes = ( parms.length > 2 ) ? parms[ 2 ] : ""; return expand( ref, desc, notes ); } }