/* * [Index.java] * * Summary: Inserts a letter or master index into a glossary. * * Copyright: (c) 2014-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 2014-08-02 initial version */ package com.mindprod.htmlmacros.macro; import com.mindprod.htmlmacros.support.Indexing; import static java.lang.System.*; /** * Inserts a letter or master index into a glossary. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2014-08-02 initial version * @since 2014-08-02 */ @SuppressWarnings( { "UnusedDeclaration" } ) public final class Index extends Macro { // declarations /** * how to use the macro */ private static final String USAGE = "\nIndex macro needs [letter] or [master]"; // /declarations // methods /** * generate index, usually not needed as built in to Head macro. * * @param parms glossary or master * @param quiet true if want output suppressed. * @param verbose @return expanded macro text */ public String expandMacro( final String[] parms, final boolean quiet, final boolean verbose ) { if ( !quiet ) { out.print( "I" ); } if ( parms.length != 1 ) { throw new IllegalArgumentException( USAGE ); } switch ( parms[ 0 ] ) { case "letter": return Indexing.LETTERINDEX.buildJumpToIndex(); case "master": return Indexing.MASTERINDEX.buildJumpToIndex(); default: throw new IllegalArgumentException( "\nUnrecogised option " + parms[ 0 ] + USAGE ); } } // /method // /methods }