⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pagexrefmanager.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
package org.jahia.content;import java.util.*;import org.jahia.utils.JahiaConsole;/** * Title:        Jahia * Description:  The purpose of this class is to provide a cross reference * system between pages and pages, in order to know which pages reference * a specific page . This is necessary since currently this information is defined * only by template developpers and is useful for the HTML cache system when a * container modification is done. This class allows lookups such as : "which * pages access this page ?" * Copyright:    Copyright (c) 2002 * Company:      Jahia Ltd * @author Serge Huber * @version 1.0 */public class PageXRefManager {    private static final String NAME_SEPARATOR = "_";    private static PageXRefManager theObject = null;    protected PageXRefManager() {        JahiaConsole.println("PageXRefManager",                             "Initializing...");    }    /**     * Returns a singleton instance of this service     * Note : this is a synchronized access method so it might affect performance     * if a lot of threads must access it simultaneously.     * @returns the singleton instance.     */    public static synchronized PageXRefManager getInstance()    {        if (theObject == null) {            theObject = new PageXRefManager();        }        return theObject;    } // end getInstance    /**     * Retrieves a list of pageIDs that contain references to a specific     * page     * @param siteName name of the site for which to use this xref cache     * @param targetPageID the target pageID for which to send xrefs.     * @returns a Set of Integers containing pageIDs that reference the target     * page.     */    public Set getPageIDs(String siteName, int targetPageID) {        /*        JahiaConsole.println("PageXRefManager.getPageIDs",                             "Getting page ids for page " + Integer.toString(targetPageID));        */        PageKey pageKey = new PageKey(siteName, targetPageID);        Set objectRefs = CrossReferenceManager.getInstance().getObjectXRefs(pageKey);        Set pageIDs = new TreeSet();        if (objectRefs == null) {            JahiaConsole.println("PageXRefManager.getPageIDs",                                 "No references found for page " + targetPageID);            return pageIDs;        }        Iterator objectRefIter = objectRefs.iterator();        while (objectRefIter.hasNext()) {            Object ref = objectRefIter.next();            if (ref instanceof ObjectKey) {                ObjectKey refKey = (ObjectKey) ref;                if (PageKey.PAGE_TYPE.equals(refKey.getType())) {                    PageKey pageRefKey = (PageKey) refKey;                    Integer pageID = new Integer(pageRefKey.getPageID());                    pageIDs.add(pageID);                } else {                    JahiaConsole.println("PageXRefManager.getPageIDs",                                         "Expected page type in cross reference list, ignoring value...  ");                }            } else {                JahiaConsole.println("PageXRefManager.getPageIDs",                                     "Invalid key object in cross reference list, ignoring... ");            }        }        return pageIDs;    }    /**     * Adds or updates a cross reference between an target and     * a page reference     * @param siteName the site name for which we are managing xrefs     * @param targetPageID the target page ID for which to add a xref     * @param refPageID the page that has the xref to the target page     */    public void setPageID(String siteName, int targetPageID, int refPageID) {        /*        JahiaConsole.println("PageXRefManager.setPageID",                             "Target=" + Integer.toString(targetPageID) +                             ", refPageID=" + Integer.toString(refPageID));		*/                                     //JahiaConsole.println("PageXRefManager","siteName =" + siteName);                             //JahiaConsole.println("PageXRefManager","targetPageID =" + targetPageID);                             //JahiaConsole.println("PageXRefManager","refPageID =" + refPageID);                             PageKey pageKey = new PageKey(siteName, targetPageID);        PageKey refPageKey = new PageKey(siteName, refPageID);        CrossReferenceManager.getInstance().setObjectXRef(pageKey, refPageKey);    }    /**     * Removes all the cross references for a specified page     * @param siteName the site name for which we are managing xrefs     * @param targetPageID the target page ID for which to add a xref     */    public void removePage(String siteName, int targetPageID) {        PageKey pageKey = new PageKey(siteName, targetPageID);        CrossReferenceManager.getInstance().removeObjectXRefs(pageKey);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -