//# 0 errors, 102 messages
//#
/*
    //#GoogleLinkPlugin.java:1:1: class: org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.business.plugins.entry;

import org.apache.roller.weblogger.business.plugins.entry.SearchPluginBase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.business.plugins.entry.WeblogEntryPlugin;

import java.text.MessageFormat;
import java.util.regex.Pattern;

/**
 * Google Link Plugin.  This plugin provides a convenient way to write google search links.
 * <p/>
 * The plugin will replace strings of the form <code>google:"link text"{search text}</code> with a link that performs a
 * Google search.  The link will have the visible text "link text" and an href for the Google search.  You may omit the
 * <code>{search text}</code> portion, and the link text will be used as the search text.   You can also use an
 * exclamation point (<code>!</code>) instead of the colon (<code>:</code>), to get a lucky (&quot;I'm feeling
 * lucky&quot;) search, which takes the user directly to the highest ranked Google match.
 *
 * @author <a href="mailto:anil@busybuddha.org">Anil Gangolli</a>
 * @version 2.1
 */
public class GoogleLinkPlugin extends SearchPluginBase implements WeblogEntryPlugin {
    private static final String version = "2.1";
    private static final Pattern pattern = Pattern.compile("google([:!])\"(.*?)\"(?:\\{(.*?)\\})?");
    //#GoogleLinkPlugin.java:43: method: org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/GoogleLinkPlugin]
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.encodeSearchText(Ljava/lang/String;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getDescription()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getLinkFormat()Ljava/text/MessageFormat;
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getLogger()Lorg/apache/commons/logging/Log;
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getLuckyLinkFormat()Ljava/text/MessageFormat;
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getName()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getPattern()Ljava/util/regex/Pattern;
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getVersion()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.init(Lorg/apache/roller/weblogger/pojos/Weblog;)V
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.render(Lorg/apache/roller/weblogger/pojos/WeblogEntry;Ljava/lang/String;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): linkFormat
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): luckyLinkFormat
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): mLogger
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): new MessageFormat(GoogleLinkPlugin__static_init#1) num objects
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): new MessageFormat(GoogleLinkPlugin__static_init#2) num objects
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.__Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/GoogleLinkPlugin]
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): org/apache/roller/weblogger/business/plugins/entry/WeblogEntryPlugin.__Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/GoogleLinkPlugin]
    //#output(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): pattern
    //#new obj(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): new MessageFormat(GoogleLinkPlugin__static_init#1)
    //#new obj(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): new MessageFormat(GoogleLinkPlugin__static_init#2)
    //#presumption(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): org.apache.commons.logging.LogFactory:getFactory(...)@47 != null
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/GoogleLinkPlugin] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.__Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/GoogleLinkPlugin] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): org/apache/roller/weblogger/business/plugins/entry/WeblogEntryPlugin.__Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/GoogleLinkPlugin] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.encodeSearchText(Ljava/lang/String;)Ljava/lang/String; == &org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.encodeSearchText
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getDescription()Ljava/lang/String; == &getDescription
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getLinkFormat()Ljava/text/MessageFormat; == &getLinkFormat
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getLogger()Lorg/apache/commons/logging/Log; == &getLogger
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getLuckyLinkFormat()Ljava/text/MessageFormat; == &getLuckyLinkFormat
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getName()Ljava/lang/String; == &getName
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getPattern()Ljava/util/regex/Pattern; == &getPattern
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.getVersion()Ljava/lang/String; == &getVersion
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.init(Lorg/apache/roller/weblogger/pojos/Weblog;)V == &org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.init
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): __Dispatch_Table.render(Lorg/apache/roller/weblogger/pojos/WeblogEntry;Ljava/lang/String;)Ljava/lang/String; == &org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.render
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): linkFormat == &new MessageFormat(GoogleLinkPlugin__static_init#1)
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): luckyLinkFormat == &new MessageFormat(GoogleLinkPlugin__static_init#2)
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): init'ed(mLogger)
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): init'ed(pattern)
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): new MessageFormat(GoogleLinkPlugin__static_init#1) num objects == 1
    //#post(org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init): new MessageFormat(GoogleLinkPlugin__static_init#2) num objects == 1
    private static final MessageFormat linkFormat = new MessageFormat("<a href=\"http://www.google.com/search?ie=UTF-8&q={3}\">{2}</a>");
    private static final MessageFormat luckyLinkFormat = new MessageFormat("<a href=\"http://www.google.com/search?ie=UTF-8&q={3}&btnI=on\">{2}</a>");

    private static final Log mLogger = LogFactory.getFactory().getInstance(GoogleLinkPlugin.class);
    //#GoogleLinkPlugin.java:47: Warning: method not available
    //#    -- call on LogFactory org.apache.commons.logging.LogFactory:getFactory()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin
    //#    method: org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init
    //#    unanalyzed callee: LogFactory org.apache.commons.logging.LogFactory:getFactory()
    //#GoogleLinkPlugin.java:47: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getInstance(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin
    //#    method: org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getInstance(Class)
    //#GoogleLinkPlugin.java:47: end of method: org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin__static_init

    public GoogleLinkPlugin() {
    //#GoogleLinkPlugin.java:49: method: void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()
    //#GoogleLinkPlugin.java:49: Warning: suspicious precondition
    //#    the precondition for this.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin
    //#    method: void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()
    //#    suspicious precondition index: [1]
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): __Dispatch_Table.getLogger()Lorg/apache/commons/logging/Log;
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): mLogger
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.__Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/GoogleLinkPlugin]
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.__Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase]
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.__Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/WikipediaLinkPlugin]
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.__Descendant_Table[others]
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.__Dispatch_Table.getLogger()Lorg/apache/commons/logging/Log;
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): org/apache/roller/weblogger/business/plugins/entry/WikipediaLinkPlugin.__Dispatch_Table.getLogger()Lorg/apache/commons/logging/Log;
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): org/apache/roller/weblogger/business/plugins/entry/WikipediaLinkPlugin.mLogger
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): this
    //#input(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): this.__Tag
    //#output(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): this.__Tag
    //#output(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): this.baseVersion
    //#output(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): this.mLogger
    //#pre[1] (void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): this.__Tag in {org/apache/roller/weblogger/business/plugins/entry/GoogleLinkPlugin, org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase, org/apache/roller/weblogger/business/plugins/entry/WikipediaLinkPlugin}
    //#post(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): this.__Tag == old this.__Tag
    //#post(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): this.__Tag in {org/apache/roller/weblogger/business/plugins/entry/GoogleLinkPlugin, org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase, org/apache/roller/weblogger/business/plugins/entry/WikipediaLinkPlugin}
    //#post(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): this.baseVersion == &"2.1"
    //#post(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): init'ed(this.mLogger)
    //#unanalyzed(void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()): Effects-of-calling:getLogger
    }
    //#GoogleLinkPlugin.java:50: end of method: void org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin()

    public String getName() {
        return "Google Links";
    //#GoogleLinkPlugin.java:53: method: String org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getName()
    //#output(String getName()): return_value
    //#post(String getName()): return_value == &"Google Links"
    //#GoogleLinkPlugin.java:53: end of method: String org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getName()
    }

    public String getDescription() {
        return "Replace google:&quot;link text&quot;{search text} with a link that performs a google search.  With ! instead of :," + "creates a &quot;I\\'m feeling lucky&quot; search.  With {search text} omitted, uses link text as the value of the search text.";
    //#GoogleLinkPlugin.java:57: method: String org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getDescription()
    //#output(String getDescription()): return_value
    //#post(String getDescription()): return_value == &"Replace google:&amp;quot;link text&amp;quot;{search text} with a link that per ... {search text} omitted, uses link text as the value of the search text."
    //#GoogleLinkPlugin.java:57: end of method: String org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getDescription()
    }

    public String getVersion() {
        return version;
    //#GoogleLinkPlugin.java:61: method: String org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getVersion()
    //#output(String getVersion()): return_value
    //#post(String getVersion()): return_value == &"2.1"
    //#GoogleLinkPlugin.java:61: end of method: String org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getVersion()
    }

    public Pattern getPattern() {
        return pattern;
    //#GoogleLinkPlugin.java:65: method: Pattern org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getPattern()
    //#input(Pattern getPattern()): pattern
    //#output(Pattern getPattern()): return_value
    //#post(Pattern getPattern()): init'ed(return_value)
    //#GoogleLinkPlugin.java:65: end of method: Pattern org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getPattern()
    }

    public MessageFormat getLinkFormat() {
        return linkFormat;
    //#GoogleLinkPlugin.java:69: method: MessageFormat org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getLinkFormat()
    //#input(MessageFormat getLinkFormat()): linkFormat
    //#output(MessageFormat getLinkFormat()): return_value
    //#post(MessageFormat getLinkFormat()): return_value == &new MessageFormat(GoogleLinkPlugin__static_init#1)
    //#GoogleLinkPlugin.java:69: end of method: MessageFormat org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getLinkFormat()
    }

    public MessageFormat getLuckyLinkFormat() {
        return luckyLinkFormat;
    //#GoogleLinkPlugin.java:73: method: MessageFormat org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getLuckyLinkFormat()
    //#input(MessageFormat getLuckyLinkFormat()): luckyLinkFormat
    //#output(MessageFormat getLuckyLinkFormat()): return_value
    //#post(MessageFormat getLuckyLinkFormat()): return_value == &new MessageFormat(GoogleLinkPlugin__static_init#2)
    //#GoogleLinkPlugin.java:73: end of method: MessageFormat org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getLuckyLinkFormat()
    }

    public Log getLogger() {
        return mLogger;
    //#GoogleLinkPlugin.java:77: method: Log org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getLogger()
    //#input(Log getLogger()): mLogger
    //#output(Log getLogger()): return_value
    //#post(Log getLogger()): init'ed(return_value)
    //#GoogleLinkPlugin.java:77: end of method: Log org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin.getLogger()
    }
}
    //#GoogleLinkPlugin.java:: end of class: org.apache.roller.weblogger.business.plugins.entry.GoogleLinkPlugin
