📄 crossreferencemanager.java
字号:
/* Generated by Together */package org.jahia.content;import java.util.*;import org.jahia.utils.JahiaConsole;/** * This class is the main object cross reference class. Basically it uses a * hashtable to group object reference this way : * * objectref -> set of objectrefs * * This way we can easily determine for a given object where it is referenced. * ObjectRefs may be of any kind that's a subclass of the ObjectKey class. * @author Serge Huber */public class CrossReferenceManager { private Hashtable crossRefTable; private static final String KEY_SEPARATOR = "-"; private static CrossReferenceManager theObject = null; protected CrossReferenceManager() { JahiaConsole.println("CrossReferenceManager", "Initializing..."); crossRefTable = new Hashtable(); } /** * 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 CrossReferenceManager getInstance() { if (theObject == null) { theObject = new CrossReferenceManager(); } return theObject; } // end getInstance /** * Retrieve a set of object references, basically all the objects that * reference the object passed in parameter * @param objectKey an ObjectKey type object that identifies the object for * which to retrieve the set of references * @returns a set of ObjectKey objects that are the objects that reference * the object passed in parameter */ public Set getObjectXRefs(ObjectKey objectKey) { /* JahiaConsole.println("CrossReferenceManager.getObjectXRefs", "Retrieving xrefs for object " + objectKey.getKey() ); */ return (Set) crossRefTable.get(objectKey.getKey()); } /** * Adds a cross reference between the two objects passed in parameter. The * first object key is used as the key in the lookup table. * @param objectKey the key for the object to add a cross reference to * @param objectXRef another key for the object that references the first * object */ public void setObjectXRef(ObjectKey objectKey, ObjectKey objectXRef) { /* JahiaConsole.println("CrossReferenceManager.setObjectXRef", "Setting xref for object " + objectKey.getKey() + " to " + objectXRef.getKey() + " ..." ); */ Set curXRefSet; if (!crossRefTable.containsKey(objectKey.getKey())) { curXRefSet = new TreeSet(new ObjectKeyComparator()); } else { curXRefSet = (Set) crossRefTable.get(objectKey.getKey()); } if (!curXRefSet.contains(objectXRef)) { curXRefSet.add(objectXRef); } crossRefTable.put(objectKey.getKey(), curXRefSet); } /** * Removes all cross references for an object. * @param objectKey the key for the object whose references are to be * deleted. */ public void removeObjectXRefs(ObjectKey objectKey) { // JahiaConsole.println("CrossReferenceManager.removeObjectXRefs", // "Removing xrefs for object " + objectKey.getKey()); crossRefTable.remove(objectKey.getKey()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -