/* * [GoogleRegisteredSearch.java] * * Summary: Expands HTML GoogleRegisteredSearch macro. * * 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-12-21 initial version */ package com.mindprod.htmlmacros.macro; import com.mindprod.fastcat.FastCat; import static com.mindprod.htmlmacros.macro.Global.configuration; import static java.lang.System.*; /** * Expands HTML GoogleRegisteredSearch macro. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2010-12-21 initial version * @see GoogleAdjustableSearch * @see GoogleCannedSearch * @since 2010 */ public final class GoogleRegisteredSearch extends Macro { /** * how to use the macro */ private static final String USAGE = "\nUsage: GoogleRegisteredSearch label cseCode charcount"; /** * Generate a simple ggogle search referral. cse = Google Custom Search Engine * * @param parms GoogleAdjustableSearch label cse chars * @param quiet true if want output suppressed. * @param verbose @return expanded macro */ public String expandMacro( String[] parms, final boolean quiet, final boolean verbose ) { if ( !quiet ) { // indicate we handled an Book macro on the console out.print( "G" ); } if ( parms.length != 3 ) { throw new IllegalArgumentException( USAGE ); } if ( configuration.isKindle() ) { return ""; } else { // canned searches created at https://cse.google.com/cse/all final String cseAccount = configuration.getAccountForGoogleCSE(); // e.g 005260666645288681202 final String label = parms[ 0 ]; // e.g. "Search Apache" final String cseCode = parms[ 1 ]; // e.g rz3xtljafve final int chars = Integer.parseInt( parms[ 2 ] ); // e.g. 69 final int unique = getUniqueOnPage(); final FastCat sb = new FastCat( 20 ); sb.append( "
\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "
\n" ); sb.append( "\n" ); return sb.toString(); } } }