//# 2 errors, 259 messages
//#
/*
    //#BookmarkPlugin.java:1:1: class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
 * 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 java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.business.BookmarkManager;
import org.apache.roller.weblogger.business.WebloggerFactory;
import org.apache.roller.weblogger.business.plugins.entry.WeblogEntryPlugin;
import org.apache.roller.weblogger.pojos.WeblogBookmark;
import org.apache.roller.weblogger.pojos.WeblogBookmarkFolder;
import org.apache.roller.weblogger.pojos.WeblogEntry;
import org.apache.roller.weblogger.pojos.Weblog;


/**
 * Automatically insert links into entry text based on users bookmarks.
 */
public class BookmarkPlugin implements WeblogEntryPlugin {
    
    private static Log mLogger = LogFactory.getLog(BookmarkPlugin.class);
    //#BookmarkPlugin.java:45: method: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init
    //#BookmarkPlugin.java:45: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin]
    //#output(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.getDescription()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.getName()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.init(Lorg/apache/roller/weblogger/pojos/Weblog;)V
    //#output(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.lookInFolders(Ljava/lang/String;Ljava/util/Collection;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.matchBookmarks(Ljava/lang/String;Lorg/apache/roller/weblogger/pojos/WeblogBookmarkFolder;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__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.BookmarkPlugin__static_init): mLogger
    //#output(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): org/apache/roller/weblogger/business/plugins/entry/WeblogEntryPlugin.__Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin]
    //#post(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): org/apache/roller/weblogger/business/plugins/entry/WeblogEntryPlugin.__Descendant_Table[org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.getDescription()Ljava/lang/String; == &getDescription
    //#post(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.getName()Ljava/lang/String; == &getName
    //#post(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.init(Lorg/apache/roller/weblogger/pojos/Weblog;)V == &init
    //#post(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.lookInFolders(Ljava/lang/String;Ljava/util/Collection;)Ljava/lang/String; == &lookInFolders
    //#post(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.matchBookmarks(Ljava/lang/String;Lorg/apache/roller/weblogger/pojos/WeblogBookmarkFolder;)Ljava/lang/String; == &matchBookmarks
    //#post(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): __Dispatch_Table.render(Lorg/apache/roller/weblogger/pojos/WeblogEntry;Ljava/lang/String;)Ljava/lang/String; == &render
    //#post(org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init): init'ed(mLogger)
    //#BookmarkPlugin.java:45: end of method: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin__static_init
    
    protected String name = "Bookmark Linker";
    protected String description = "Automatically uses your Bookmarks to " +
            "create links.  Simply use the Name of a Bookmark and it will be " +
            "converted into a hyperlink using the Bookmark's URL.";
    
    
    public BookmarkPlugin() {
    //#BookmarkPlugin.java:53: method: void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin()
    //#input(void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin()): mLogger
    //#input(void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin()): this
    //#output(void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin()): this.description
    //#output(void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin()): this.name
    //#pre[1] (void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin()): mLogger != null
    //#post(void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin()): this.description == &"Automatically uses your Bookmarks to create links.  Simply use the Nam ... rk and it will be converted into a hyperlink using the Bookmark's URL."
    //#post(void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin()): this.name == &"Bookmark Linker"
        mLogger.debug("BookmarkPlugin instantiated.");
    //#BookmarkPlugin.java:54: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    }
    //#BookmarkPlugin.java:55: end of method: void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin()
    
    
    public String getName() {
        return name;
    //#BookmarkPlugin.java:59: method: String org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.getName()
    //#input(String getName()): this
    //#input(String getName()): this.name
    //#output(String getName()): return_value
    //#pre[2] (String getName()): init'ed(this.name)
    //#post(String getName()): return_value == this.name
    //#post(String getName()): init'ed(return_value)
    //#BookmarkPlugin.java:59: end of method: String org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.getName()
    }
    
    
    public String getDescription() {
        return StringEscapeUtils.escapeJavaScript(description);
    //#BookmarkPlugin.java:64: method: String org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.getDescription()
    //#BookmarkPlugin.java:64: Warning: method not available
    //#    -- call on String org.apache.commons.lang.StringEscapeUtils:escapeJavaScript(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String getDescription()
    //#    unanalyzed callee: String org.apache.commons.lang.StringEscapeUtils:escapeJavaScript(String)
    //#input(String getDescription()): this
    //#input(String getDescription()): this.description
    //#output(String getDescription()): return_value
    //#pre[2] (String getDescription()): init'ed(this.description)
    //#post(String getDescription()): init'ed(return_value)
    //#BookmarkPlugin.java:64: end of method: String org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.getDescription()
    }
    
    
    public void init(Weblog website) throws WebloggerException {}
    //#BookmarkPlugin.java:68: method: void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.init(Weblog)
    //#BookmarkPlugin.java:68: end of method: void org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.init(Weblog)
    
    
    public String render(WeblogEntry entry, String str) {
        String text = str;
    //#BookmarkPlugin.java:72: method: String org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.render(WeblogEntry, String)
    //#BookmarkPlugin.java:72: Warning: suspicious precondition
    //#    the precondition for org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String render(WeblogEntry, String)
    //#    suspicious precondition index: [4]
    //#    Attribs:  Soft
    //#input(String render(WeblogEntry, String)): "" title=""._tainted
    //#input(String render(WeblogEntry, String)): ""._tainted
    //#input(String render(WeblogEntry, String)): "">"._tainted
    //#input(String render(WeblogEntry, String)): "(<a(?:\s.*?)??.>)|(<a(?:\s.*?)??>)|(<.a(?:\s.*?)??>)|(?:\b)("._tainted
    //#input(String render(WeblogEntry, String)): ")(?:\b)"._tainted
    //#input(String render(WeblogEntry, String)): "<.a>"._tainted
    //#input(String render(WeblogEntry, String)): "<a href=""._tainted
    //#input(String render(WeblogEntry, String)): "Failed to substitute for bookmark ["._tainted
    //#input(String render(WeblogEntry, String)): "] due to regular expression characters."._tainted
    //#input(String render(WeblogEntry, String)): entry
    //#input(String render(WeblogEntry, String)): mLogger
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/BookmarkManager.__Descendant_Table[org/apache/roller/weblogger/business/BookmarkManager]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/BookmarkManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/BookmarkManager.__Descendant_Table[others]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/BookmarkManager.__Dispatch_Table.getRootFolder(Lorg/apache/roller/weblogger/pojos/Weblog;)Lorg/apache/roller/weblogger/pojos/WeblogBookmarkFolder;
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/GuiceWebloggerProvider.__Dispatch_Table.getWeblogger()Lorg/apache/roller/weblogger/business/Weblogger;
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/WebloggerImpl]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/Weblogger]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[others]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/Weblogger.__Dispatch_Table.getBookmarkManager()Lorg/apache/roller/weblogger/business/BookmarkManager;
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.__Tag
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.bookmarkManager
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.bookmarkManager.__Tag
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.bookmarkManager.strategy
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.bookmarkManager.strategy.__Tag
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.bookmarkManager.strategy.emf
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.bookmarkManager.strategy.threadLocalEntityManager
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerImpl.__Dispatch_Table.getBookmarkManager()Lorg/apache/roller/weblogger/business/BookmarkManager;
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerProvider.__Descendant_Table[org/apache/roller/weblogger/business/GuiceWebloggerProvider]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerProvider.__Descendant_Table[org/apache/roller/weblogger/business/WebloggerProvider]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerProvider.__Descendant_Table[others]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/WebloggerProvider.__Dispatch_Table.getWeblogger()Lorg/apache/roller/weblogger/business/Weblogger;
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.__Dispatch_Table.getRootFolder(Lorg/apache/roller/weblogger/pojos/Weblog;)Lorg/apache/roller/weblogger/pojos/WeblogBookmarkFolder;
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Descendant_Table[others]
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Dispatch_Table.getNamedQuery(Ljava/lang/String;)Ljavax/persistence/Query;
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.javax.persistence.FlushModeType.COMMIT
    //#input(String render(WeblogEntry, String)): org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.__Dispatch_Table.getBookmarkManager()Lorg/apache/roller/weblogger/business/BookmarkManager;
    //#input(String render(WeblogEntry, String)): str
    //#input(String render(WeblogEntry, String)): str._tainted
    //#input(String render(WeblogEntry, String)): this
    //#output(String render(WeblogEntry, String)): java.lang.String:toString(...)._tainted
    //#output(String render(WeblogEntry, String)): return_value
    //#new obj(String render(WeblogEntry, String)): java.lang.String:toString(...)
    //#pre[1] (String render(WeblogEntry, String)): (soft) entry != null
    //#pre[2] (String render(WeblogEntry, String)): (soft) mLogger != null
    //#pre[3] (String render(WeblogEntry, String)): (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
    //#pre[4] (String render(WeblogEntry, String)): (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag in {org/apache/roller/weblogger/business/GuiceWebloggerProvider, org/apache/roller/weblogger/business/WebloggerProvider}
    //#pre[5] (String render(WeblogEntry, String)): (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance != null
    //#pre[6] (String render(WeblogEntry, String)): (soft) str != null
    //#presumption(String render(WeblogEntry, String)): bMgr.__Tag in {org/apache/roller/weblogger/business/BookmarkManager, org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl}
    //#presumption(String render(WeblogEntry, String)): bMgr.strategy != null
    //#presumption(String render(WeblogEntry, String)): bMgr.strategy.__Tag == org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy
    //#presumption(String render(WeblogEntry, String)): bMgr.strategy.emf != null
    //#presumption(String render(WeblogEntry, String)): bMgr.strategy.threadLocalEntityManager != null
    //#presumption(String render(WeblogEntry, String)): getWeblogger(...).__Tag in {org/apache/roller/weblogger/business/Weblogger, org/apache/roller/weblogger/business/WebloggerImpl, org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl}
    //#presumption(String render(WeblogEntry, String)): getWeblogger(...).bookmarkManager != null
    //#presumption(String render(WeblogEntry, String)): org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders(...)@77 != null
    //#presumption(String render(WeblogEntry, String)): org.apache.roller.weblogger.pojos.WeblogEntry:getWebsite(...)@75 != null
    //#post(String render(WeblogEntry, String)): init'ed(java.lang.String:toString(...)._tainted)
    //#post(String render(WeblogEntry, String)): return_value != null
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getBookmarks
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.Set:iterator
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:org.apache.roller.weblogger.pojos.WeblogBookmark:getDescription
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:org.apache.roller.weblogger.pojos.WeblogBookmark:getUrl
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:org.apache.roller.weblogger.pojos.WeblogBookmark:getName
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.regex.Pattern:compile
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.regex.Pattern:matcher
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.lang.String:length
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.lang.StringBuffer
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.regex.Matcher:find
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.regex.Matcher:group
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.regex.Matcher:appendReplacement
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.regex.Matcher:appendTail
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.lang.StringBuffer:toString
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.lang.String:toString
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.Collection:iterator
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.util.Set:isEmpty
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:lookInFolders
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:getWeblogger
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:javax.persistence.EntityTransaction:begin
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:javax.persistence.EntityManager:createNamedQuery
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:javax.persistence.Query:setFlushMode
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:javax.persistence.Query:setParameter
    //#unanalyzed(String render(WeblogEntry, String)): Effects-of-calling:javax.persistence.Query:getSingleResult
        try {
            BookmarkManager bMgr = WebloggerFactory.getWeblogger().getBookmarkManager();
            WeblogBookmarkFolder rootFolder = bMgr.getRootFolder(entry.getWebsite());
    //#BookmarkPlugin.java:75: Warning: method not available
    //#    -- call on Weblog org.apache.roller.weblogger.pojos.WeblogEntry:getWebsite()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String render(WeblogEntry, String)
    //#    unanalyzed callee: Weblog org.apache.roller.weblogger.pojos.WeblogEntry:getWebsite()
            text = matchBookmarks(text, rootFolder);
    //#BookmarkPlugin.java:76: ?precondition failure
    //#    org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.matchBookmarks: folder != null
    //#    severity: MEDIUM
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String render(WeblogEntry, String)
    //#    basic block: bb_2
    //#    assertion: getRootFolder(...) != null
    //#    callee: String org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.matchBookmarks(String, WeblogBookmarkFolder)
    //#    callee assertion: folder != null
    //#    callee file: BookmarkPlugin.java
    //#    callee precondition index: [1]
    //#    callee srcpos: 112
    //#    VN: getRootFolder(...)
    //#    Expected: Inverse{null}
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
            text = lookInFolders(text, rootFolder.getFolders());
    //#BookmarkPlugin.java:77: Warning: method not available
    //#    -- call on Set org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String render(WeblogEntry, String)
    //#    unanalyzed callee: Set org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders()
        } catch (WebloggerException e) {
            // nothing much I can do, go with default "Weblog" value
            // could be WebloggerException or NullPointerException
            mLogger.warn(e);
    //#BookmarkPlugin.java:81: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:warn(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String render(WeblogEntry, String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:warn(Object)
        }
        return text;
    //#BookmarkPlugin.java:83: end of method: String org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.render(WeblogEntry, String)
    }
    
    
    /**
     * Recursively travel down Folder tree, attempting
     * to match up Bookmarks in each Folder.
     *
     * @param text
     * @param folders
     * @return
     */
    private String lookInFolders(String text, Collection folders) {
        
        Iterator it = folders.iterator();
    //#BookmarkPlugin.java:97: method: String org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.lookInFolders(String, Collection)
    //#input(String lookInFolders(String, Collection)): "" title=""._tainted
    //#input(String lookInFolders(String, Collection)): ""._tainted
    //#input(String lookInFolders(String, Collection)): "">"._tainted
    //#input(String lookInFolders(String, Collection)): "(<a(?:\s.*?)??.>)|(<a(?:\s.*?)??>)|(<.a(?:\s.*?)??>)|(?:\b)("._tainted
    //#input(String lookInFolders(String, Collection)): ")(?:\b)"._tainted
    //#input(String lookInFolders(String, Collection)): "<.a>"._tainted
    //#input(String lookInFolders(String, Collection)): "<a href=""._tainted
    //#input(String lookInFolders(String, Collection)): "Failed to substitute for bookmark ["._tainted
    //#input(String lookInFolders(String, Collection)): "] due to regular expression characters."._tainted
    //#input(String lookInFolders(String, Collection)): folders
    //#input(String lookInFolders(String, Collection)): mLogger
    //#input(String lookInFolders(String, Collection)): text
    //#input(String lookInFolders(String, Collection)): text._tainted
    //#input(String lookInFolders(String, Collection)): this
    //#output(String lookInFolders(String, Collection)): java.lang.String:toString(...)._tainted
    //#output(String lookInFolders(String, Collection)): return_value
    //#new obj(String lookInFolders(String, Collection)): java.lang.String:toString(...)
    //#pre[1] (String lookInFolders(String, Collection)): folders != null
    //#pre[2] (String lookInFolders(String, Collection)): (soft) mLogger != null
    //#pre[3] (String lookInFolders(String, Collection)): (soft) text != null
    //#presumption(String lookInFolders(String, Collection)): java.util.Iterator:next(...)@99 != null
    //#presumption(String lookInFolders(String, Collection)): org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders(...)@102 != null
    //#presumption(String lookInFolders(String, Collection)): org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders(...)@103 != null
    //#post(String lookInFolders(String, Collection)): init'ed(java.lang.String:toString(...)._tainted)
    //#post(String lookInFolders(String, Collection)): (soft) return_value != null
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getBookmarks
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.Set:iterator
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:org.apache.roller.weblogger.pojos.WeblogBookmark:getDescription
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:org.apache.roller.weblogger.pojos.WeblogBookmark:getUrl
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:org.apache.roller.weblogger.pojos.WeblogBookmark:getName
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.regex.Pattern:compile
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.regex.Pattern:matcher
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.lang.String:length
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.lang.StringBuffer
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.regex.Matcher:find
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.regex.Matcher:group
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.regex.Matcher:appendReplacement
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.regex.Matcher:appendTail
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.lang.StringBuffer:toString
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.lang.String:toString
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.Collection:iterator
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:java.util.Set:isEmpty
    //#unanalyzed(String lookInFolders(String, Collection)): Effects-of-calling:lookInFolders
    //#test_vector(String lookInFolders(String, Collection)): java.util.Iterator:hasNext(...)@98: {0}, {1}
    //#test_vector(String lookInFolders(String, Collection)): java.util.Set:isEmpty(...)@102: {1}, {0}
        while (it.hasNext()) {
            WeblogBookmarkFolder folder = (WeblogBookmarkFolder)it.next();
            text = matchBookmarks(text, folder);
            
            if (!folder.getFolders().isEmpty()) {
    //#BookmarkPlugin.java:102: Warning: method not available
    //#    -- call on Set org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String lookInFolders(String, Collection)
    //#    unanalyzed callee: Set org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders()
                lookInFolders(text, folder.getFolders());
    //#BookmarkPlugin.java:103: Warning: method not available
    //#    -- call on Set org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String lookInFolders(String, Collection)
    //#    unanalyzed callee: Set org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getFolders()
            }
        }
        
        return text;
    //#BookmarkPlugin.java:107: end of method: String org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.lookInFolders(String, Collection)
    }
    
    
    private String matchBookmarks(String text,WeblogBookmarkFolder folder) {
        Iterator bookmarks = folder.getBookmarks().iterator();
    //#BookmarkPlugin.java:112: method: String org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.matchBookmarks(String, WeblogBookmarkFolder)
    //#BookmarkPlugin.java:112: Warning: method not available
    //#    -- call on Set org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getBookmarks()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String matchBookmarks(String, WeblogBookmarkFolder)
    //#    unanalyzed callee: Set org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getBookmarks()
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): "" title=""._tainted
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): ""._tainted
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): "">"._tainted
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): "(<a(?:\s.*?)??.>)|(<a(?:\s.*?)??>)|(<.a(?:\s.*?)??>)|(?:\b)("._tainted
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): ")(?:\b)"._tainted
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): "<.a>"._tainted
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): "<a href=""._tainted
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): "Failed to substitute for bookmark ["._tainted
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): "] due to regular expression characters."._tainted
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): folder
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): mLogger
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): text
    //#input(String matchBookmarks(String, WeblogBookmarkFolder)): text._tainted
    //#output(String matchBookmarks(String, WeblogBookmarkFolder)): java.lang.String:toString(...)._tainted
    //#output(String matchBookmarks(String, WeblogBookmarkFolder)): return_value
    //#new obj(String matchBookmarks(String, WeblogBookmarkFolder)): java.lang.String:toString(...)
    //#pre[1] (String matchBookmarks(String, WeblogBookmarkFolder)): folder != null
    //#pre[2] (String matchBookmarks(String, WeblogBookmarkFolder)): (soft) mLogger != null
    //#pre[3] (String matchBookmarks(String, WeblogBookmarkFolder)): (soft) text != null
    //#presumption(String matchBookmarks(String, WeblogBookmarkFolder)): java.util.Iterator:next(...)@115 != null
    //#presumption(String matchBookmarks(String, WeblogBookmarkFolder)): java.util.regex.Pattern:compile(...)@130 != null
    //#presumption(String matchBookmarks(String, WeblogBookmarkFolder)): java.util.regex.Pattern:matcher(...)@130 != null
    //#presumption(String matchBookmarks(String, WeblogBookmarkFolder)): org.apache.roller.weblogger.pojos.WeblogBookmarkFolder:getBookmarks(...)@112 != null
    //#post(String matchBookmarks(String, WeblogBookmarkFolder)): init'ed(java.lang.String:toString(...)._tainted)
    //#post(String matchBookmarks(String, WeblogBookmarkFolder)): return_value == &java.lang.String:toString(...)
    //#test_vector(String matchBookmarks(String, WeblogBookmarkFolder)): java.util.Iterator:hasNext(...)@114: {0}, {1}
    //#test_vector(String matchBookmarks(String, WeblogBookmarkFolder)): java.util.regex.Matcher:find(...)@133: {0}, {1}
    //#test_vector(String matchBookmarks(String, WeblogBookmarkFolder)): java.util.regex.Matcher:group(...)@134: Addr_Set{null}, Inverse{null}
    //#test_vector(String matchBookmarks(String, WeblogBookmarkFolder)): java.util.regex.Matcher:group(...)@136: Addr_Set{null}, Inverse{null}
    //#test_vector(String matchBookmarks(String, WeblogBookmarkFolder)): java.util.regex.Matcher:group(...)@139: Addr_Set{null}, Inverse{null}
    //#test_vector(String matchBookmarks(String, WeblogBookmarkFolder)): java.util.regex.Matcher:group(...)@142: Addr_Set{null}, Inverse{null}
    //#test_vector(String matchBookmarks(String, WeblogBookmarkFolder)): org.apache.roller.weblogger.pojos.WeblogBookmark:getDescription(...)@116: Inverse{null}, Addr_Set{null}
        String workingText = text;
        while (bookmarks.hasNext()) {
            WeblogBookmark bookmark = (WeblogBookmark)bookmarks.next();
            String bkDescription = bookmark.getDescription();
    //#BookmarkPlugin.java:116: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogBookmark:getDescription()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String matchBookmarks(String, WeblogBookmarkFolder)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogBookmark:getDescription()
            if (bkDescription == null) bkDescription = "";
            String bookmarkLink = "<a href=\"" +
    //#BookmarkPlugin.java:118: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogBookmark:getUrl()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String matchBookmarks(String, WeblogBookmarkFolder)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogBookmark:getUrl()
    //#BookmarkPlugin.java:118: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogBookmark:getName()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String matchBookmarks(String, WeblogBookmarkFolder)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogBookmark:getName()
                    bookmark.getUrl() + "\" title=\"" +
                    bkDescription + "\">" +
                    bookmark.getName() + "</a>";
            try {
                // Replace all occurrences of bookmark name that don't occur within the bounds of an anchor tag
                // Notes:
                // - use reluctant quantifiers on the tags to avoid gobbling more than desired
                // - use non-capturing groups for boundaries to avoid replacing the boundary as well as the bookmark name.
                // - we depend on the numbering of the specific groups in this expression in the replacement code below.
                // TODO: should escape the bookmark name
                String regEx = "(<a(?:\\s.*?)??/>)|(<a(?:\\s.*?)??>)|(</a(?:\\s.*?)??>)|(?:\\b)(" + bookmark.getName() + ")(?:\\b)";
    //#BookmarkPlugin.java:129: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogBookmark:getName()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String matchBookmarks(String, WeblogBookmarkFolder)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogBookmark:getName()
                Matcher m = Pattern.compile(regEx).matcher(workingText);
                StringBuffer textBuf = new StringBuffer(workingText.length());
                int inLink = 0;
                while (m.find()) {
                    if (m.group(1) != null) {
                        // self-closed anchor tag <a  ... /> -- ignore
                    } else if (m.group(2) != null) {
                        // matched opening anchor tag <a ...>
                        inLink++;
    //#BookmarkPlugin.java:138: ?overflow
    //#    inLink in -2_147_483_649..4_294_967_294
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String matchBookmarks(String, WeblogBookmarkFolder)
    //#    basic block: bb_11
    //#    assertion: inLink in -2_147_483_649..4_294_967_294
    //#    VN: inLink + 1
    //#    Expected: {-2_147_483_648..4_294_967_295, Invalid}
    //#    Bad: {4_294_967_296}
    //#    Attribs:  Int  Bad singleton  Bad > Exp
                    } else if (m.group(3) != null) {
                        // closing anchor tag </a>, but ignore nonmatching ones
                        if (inLink > 0) inLink--;
                    } else if (m.group(4) != null) {
                        // matched the bookmark -- replace, but only if not within a link tag.
                        if (inLink == 0) m.appendReplacement(textBuf, bookmarkLink);
                    }
                    // Any remaining case indicates a bug.  One could add an else with assertion here.  Conservatively don't substitute.
                }
                m.appendTail(textBuf);
                workingText = textBuf.toString();
            } catch (PatternSyntaxException e) {
                // Can happen since we don't escape pattern the bookmark name to protect pattern characters.
                mLogger.warn("Failed to substitute for bookmark [" + bookmark.getName() + "] due to regular expression characters.");
    //#BookmarkPlugin.java:152: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.WeblogBookmark:getName()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String matchBookmarks(String, WeblogBookmarkFolder)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.WeblogBookmark:getName()
    //#BookmarkPlugin.java:152: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:warn(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
    //#    method: String matchBookmarks(String, WeblogBookmarkFolder)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:warn(Object)
            }
        }
        return workingText.toString();
    //#BookmarkPlugin.java:155: end of method: String org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin.matchBookmarks(String, WeblogBookmarkFolder)
    }
    
}
    //#BookmarkPlugin.java:: end of class: org.apache.roller.weblogger.business.plugins.entry.BookmarkPlugin
