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

📄 objectkey.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
/* Generated by Together */package org.jahia.content;import java.util.*;import org.jahia.utils.JahiaConsole;/** * The purpose of this class is to construct ContentObject references that can * be used both externally and internally to references Jahia content objects * such as fields, containers, pages and other objects... * * The tentative format of this key is (subject to change in order to comply * with existing norms) : * * jahia://sitename/type/name/parameter1/parameter2/... * * parameters are string values that can be anything allowed in standard URI * encoding. They are also optional. Last parameter should no include a trailing * "/" character. Parameters are also order, that is to say that order of * insertion is preserved throughout all class operations. * * @author Serge Huber */public class ObjectKey {    protected String key;    private static final String URI_PREFIX = "jahia://";    private static final String KEY_SEPARATOR = "/";    public static final String OBJECT_TYPE = "object";    private String type = OBJECT_TYPE;    private String name;    private Vector parameters = new Vector();    /**     * Object constructor method.     * @param siteName the site on which this object lives     * @param type a String specifying the object type. Normally this is used     * mostly by children of this class but could be used for some "hacks".     * @param name an identifier specifying the name of the object. This name     * must be UNIQUE within a type.     */    public ObjectKey(String siteName,                     String type,                     String name) {        key = URI_PREFIX + siteName + KEY_SEPARATOR + type + KEY_SEPARATOR +              name;        this.name = name;        this.type = type;    }    /**     * Object constructor with added parameter possibility.     * @param siteName the site on which this object lives     * @param type a String specifying the object type. Normally this is used     * mostly by children of this class but could be used for some "hacks".     * @param name an identifier specifying the name of the object. This name     * must be UNIQUE within a type.     * @param parameters a Vector of String parameters that can be added to an     * object key. This is offered as a generic extension mechanism for object     * keys to be useful in lots of different scenarios and to encourage their     * usage.     */    public ObjectKey(String siteName,                     String type,                     String name,                     Vector parameters) {        key = URI_PREFIX + siteName + KEY_SEPARATOR + type + KEY_SEPARATOR +              name;        Enumeration paramEnum = parameters.elements();        while (paramEnum.hasMoreElements()) {            Object curParam = paramEnum.nextElement();            if (curParam instanceof String) {                String paramStr = (String) curParam;                key += KEY_SEPARATOR + paramStr;                parameters.add(paramStr);            } else {                JahiaConsole.println("ObjectKey.constructor",                                     "Non string parameters not allowed, ignoring param...");            }        }        this.name = name;        this.type = type;    }    /* --- ACCESSOR METHODS ------------------------------------------------- */    public String getKey(){        return key;    }    public void setKey(String key){        this.key = key;    }    public String getType(){        return this.type;    }    public void setType(String type){        this.type = type;    }    public String getName() {        return this.name;    }    /**     * Adds a new parameter to the current vector of parameters     * @param newParam the new string parameter to add to the current vector     * @returns true if insertion was successful, false otherwise (ie if the     * vector already contains such a parameter)     */    public boolean setParameter(String newParam) {        if (parameters.contains(newParam)) {            return false;        }        parameters.add(newParam);        key += KEY_SEPARATOR + newParam;        return true;    }    /**     * Tests the parameter vector for existence of the passed parameter string     * @param param the String parameter to test for     */    public boolean containsParameter(String param) {        return parameters.contains(param);    }    /**     * Retrieves an Enumeration of the parameter vector, mostly to retrieve all     * the parameters at once.     * @returns an Enumeration of String object that represent the key's     * parameters     */    public Enumeration getParameters() {        return parameters.elements();    }    /**     * Retrieve a specific parameter, indexed by a number.     * @param index the index (0-based) of the parameter to retrieve in the     * vector.     * @returns the String parameter at the specified vector position.     * @throws ArrayIndexOutOfBoundsException if the index refers to an position     * that doesn't exist in the vector     */    public String getParameterAt(int index)    throws ArrayIndexOutOfBoundsException {        return (String) parameters.elementAt(index);    }    /**     * Redefinition of the equality comparison, since ObjectKey objects are     * very likely to be used as keys in Hashtables, or other ordered sets,     * maps or lists.     * @param obj the Object to compare this object to.     * @returns true if the object is an instance of the ObjectKey class and     * the value of the key is the same, false otherwise.     */    public boolean equals(Object obj) {        JahiaConsole.println("ObjectKey.equals", "Starting...");        if (obj instanceof ObjectKey) {            ObjectKey destObj = (ObjectKey) obj;            if (this.key.equals(destObj.getKey())) {                return true;            } else {                return false;            }        } else {            return false;        }    }}

⌨️ 快捷键说明

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