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

📄 qname.java

📁 jsr170接口的java实现。是个apache的开源项目。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /**     * rep:versionStorage     */    public static final QName REP_VERSIONSTORAGE = new QName(NS_REP_URI, "versionStorage");    /**     * rep:versionStorage     */    public static final QName REP_NODETYPES = new QName(NS_REP_URI, "nodeTypes");    /**     * nt:unstructured     */    public static final QName NT_UNSTRUCTURED = new QName(NS_NT_URI, "unstructured");    /**     * nt:base     */    public static final QName NT_BASE = new QName(NS_NT_URI, "base");    /**     * nt:hierarchyNode     */    public static final QName NT_HIERARCHYNODE = new QName(NS_NT_URI, "hierarchyNode");    /**     * nt:resource     */    public static final QName NT_RESOURCE = new QName(NS_NT_URI, "resource");    /**     * nt:file     */    public static final QName NT_FILE = new QName(NS_NT_URI, "file");    /**     * nt:folder     */    public static final QName NT_FOLDER = new QName(NS_NT_URI, "folder");    /**     * nt:query     */    public static final QName NT_QUERY = new QName(NS_NT_URI, "query");    /**     * mix:referenceable     */    public static final QName MIX_REFERENCEABLE = new QName(NS_MIX_URI, "referenceable");    /**     * mix:referenceable     */    public static final QName MIX_LOCKABLE = new QName(NS_MIX_URI, "lockable");    /**     * mix:versionable     */    public static final QName MIX_VERSIONABLE = new QName(NS_MIX_URI, "versionable");    /**     * nt:versionHistory     */    public static final QName NT_VERSIONHISTORY = new QName(NS_NT_URI, "versionHistory");    /**     * nt:version     */    public static final QName NT_VERSION = new QName(NS_NT_URI, "version");    /**     * nt:versionLabels     */    public static final QName NT_VERSIONLABELS = new QName(NS_NT_URI, "versionLabels");    /**     * nt:versionedChild     */    public static final QName NT_VERSIONEDCHILD = new QName(NS_NT_URI, "versionedChild");    /**     * nt:frozenNode     */    public static final QName NT_FROZENNODE = new QName(NS_NT_URI, "frozenNode");    /**     * nt:nodeType     */    public static final QName NT_NODETYPE = new QName(NS_NT_URI, "nodeType");    /**     * nt:propertyDefinition     */    public static final QName NT_PROPERTYDEFINITION = new QName(NS_NT_URI, "propertyDefinition");    /**     * nt:childNodeDefinition     */    public static final QName NT_CHILDNODEDEFINITION = new QName(NS_NT_URI, "childNodeDefinition");    //------------------------------------------< system view name constants >    /**     * sv:node     */    public static final QName SV_NODE = new QName(NS_SV_URI, "node");    /**     * sv:property     */    public static final QName SV_PROPERTY = new QName(NS_SV_URI, "property");    /**     * sv:value     */    public static final QName SV_VALUE = new QName(NS_SV_URI, "value");    /**     * sv:type     */    public static final QName SV_TYPE = new QName(NS_SV_URI, "type");    /**     * sv:name     */    public static final QName SV_NAME = new QName(NS_SV_URI, "name");    /** Serialization UID of this class. */    static final long serialVersionUID = -2712313010017755368L;    public static final QName[] EMPTY_ARRAY = new QName[0];    /** The memorized hash code of this qualified name. */    private transient int hash;    /** The memorized string representation of this qualified name. */    private transient String string;    /** The internalized namespace URI of this qualified name. */    private final String namespaceURI;    /** The local part of this qualified name. */    private final String localName;    /**     * Creates a new qualified name with the given namespace URI and     * local part.     * <p/>     * Note that the format of the local part is not validated. The format     * can be checked by calling {@link NameFormat#checkFormat(String)}.     *     * @param namespaceURI namespace uri     * @param localName local part     * @throws IllegalArgumentException if <code>localName</code> is invalid.     */    public QName(String namespaceURI, String localName) {        if (namespaceURI == null) {            throw new IllegalArgumentException("invalid namespaceURI specified");        }        // an empty localName is valid though (e.g. the root node name)        if (localName == null) {            throw new IllegalArgumentException("invalid localName specified");        }        // internalize namespaceURI to improve performance of QName comparisons.        // Please note that we do *not* internalize localName since this could        // blow perm space for large repositories        this.namespaceURI = namespaceURI.intern();        this.localName = localName;        hash = 0;    }    //------------------------------------------------------< factory methods >    /**     * Parses the given prefixed JCR name into a qualified name using the     * given namespace resolver.     *     * @param rawName prefixed JCR name     * @param resolver namespace resolver     * @return qualified name     * @throws IllegalNameException if the given name is not a valid JCR name     * @throws UnknownPrefixException if the JCR name prefix does not resolve     * @deprecated Use {@link NameFormat#parse(String, NamespaceResolver)} instead.     */    public static QName fromJCRName(String rawName, NamespaceResolver resolver)            throws IllegalNameException, UnknownPrefixException {        return NameFormat.parse(rawName, resolver);    }    /**     * Returns a <code>QName</code> holding the value of the specified     * string. The string must be in the format returned by the     * <code>QName.toString()</code> method, i.e.     * <p/>     * <code><b>{</b>namespaceURI<b>}</b>localName</code>     *     * @param s a <code>String</code> containing the <code>QName</code>     *          representation to be parsed.     * @return the <code>QName</code> represented by the argument     * @throws IllegalArgumentException if the specified string can not be parsed     *                                  as a <code>QName</code>.     * @see #toString()     */    public static QName valueOf(String s) throws IllegalArgumentException {        if ("".equals(s) || s == null) {            throw new IllegalArgumentException("invalid QName literal");        }        if (s.charAt(0) == '{') {            int i = s.indexOf('}');            if (i == -1) {                throw new IllegalArgumentException("invalid QName literal");            }            if (i == s.length() - 1) {                throw new IllegalArgumentException("invalid QName literal");            } else {                return new QName(s.substring(1, i), s.substring(i + 1));            }        } else {            throw new IllegalArgumentException("invalid QName literal");        }    }    //------------------------------------------------------< utility methods >    /**     * Checks if <code>jcrName</code> is a valid JCR-style name.     *     * @param jcrName the name to be checked     * @throws IllegalNameException If <code>jcrName</code> is not a valid     * JCR-style name.     * @deprecated Use {@link NameFormat#checkFormat(String)} instead.     */    public static void checkFormat(String jcrName) throws IllegalNameException {        NameFormat.checkFormat(jcrName);    }    //-------------------------------------------------------< public methods >    /**     * Returns the local part of the qualified name.     *     * @return local name     */    public String getLocalName() {        return localName;    }    /**     * Returns the namespace URI of the qualified name.     *     * @return namespace URI     */    public String getNamespaceURI() {        return namespaceURI;    }    /**     * Returns the qualified name in the prefixed JCR name format.     * The namespace URI is mapped to a prefix using the given     * namespace resolver.     *     * @param resolver namespace resolver     * @return prefixed name     * @throws NoPrefixDeclaredException if the namespace can not be resolved     * @deprecated Use {@link NameFormat#format(QName, NamespaceResolver)}     * instead.     */    public String toJCRName(NamespaceResolver resolver)            throws NoPrefixDeclaredException {        return NameFormat.format(this, resolver);    }    /**     * Appends the qualified name in the prefixed JCR name format to the given     * string buffer. The namespace URI is mapped to a prefix using the given     * namespace resolver.     *     * @param resolver namespace resolver     * @param buf      string buffer where the prefixed JCR name should be     *                 appended to     * @throws NoPrefixDeclaredException if the namespace can not be resolved     * @see #toJCRName(NamespaceResolver)     * @deprecated Use {@link NameFormat#format(QName, NamespaceResolver, StringBuffer)}     * instead.     */    public void toJCRName(NamespaceResolver resolver, StringBuffer buf)            throws NoPrefixDeclaredException {        NameFormat.format(this, resolver, buf);    }    //---------------------------------------------------------------< Object >    /**     * Returns the string representation of this <code>QName</code> in the     * following format:     * <p/>     * <code><b>{</b>namespaceURI<b>}</b>localName</code>     *     * @return the string representation of this <code>QName</code>.     * @see #valueOf(String)     * @see Object#toString()     */    public String toString() {        // QName is immutable, we can store the string representation        if (string == null) {            string = '{' + namespaceURI + '}' + localName;        }        return string;    }    /**     * Compares two qualified names for equality. Returns <code>true</code>     * if the given object is a qualified name and has the same namespace URI     * and local part as this qualified name.     *     * @param obj the object to compare this qualified name with     * @return <code>true</code> if the object is equal to this qualified name,     *         <code>false</code> otherwise     * @see Object#equals(Object)     */    public boolean equals(Object obj) {        if (this == obj) {            return true;        }        if (obj instanceof QName) {            QName other = (QName) obj;            // we can use == operator for namespaceURI since it is internalized            return namespaceURI == other.namespaceURI                    && localName.equals(other.localName);        }        return false;    }    /**     * Returns the hash code of this qualified name. The hash code is     * computed from the namespace URI and local part of the qualified     * name and memorized for better performance.     *     * @return hash code     * @see Object#hashCode()     */    public int hashCode() {        // QName is immutable, we can store the computed hash code value        int h = hash;        if (h == 0) {            h = 17;            h = 37 * h + namespaceURI.hashCode();            h = 37 * h + localName.hashCode();            hash = h;        }        return h;    }    //------------------------------------------------------------< Cloneable >    /**     * Creates a clone of this qualified name.     * Overriden in order to make <code>clone()</code> public.     *     * @return a clone of this instance     * @throws CloneNotSupportedException never thrown     * @see Object#clone()     */    public Object clone() throws CloneNotSupportedException {        // QName is immutable, no special handling required        return super.clone();    }    //-----------------------------------------------------------< Comparable >    /**     * Compares two qualified names.     *     * @param o the object to compare this qualified name with     * @return comparison result     * @throws ClassCastException if the given object is not a qualified name     * @see Comparable#compareTo(Object)     */    public int compareTo(Object o) {        if (this == o) {            return 0;        }        QName other = (QName) o;        // we can use == operator for namespaceURI since it is internalized        if (namespaceURI == other.namespaceURI) {            return localName.compareTo(other.localName);        } else {            return namespaceURI.compareTo(other.namespaceURI);        }    }    //-------------------------------------------------< Serializable support >    /**     * Creates a new <code>QName</code> instance using the proper constructor     * during deserialization in order to make sure that internalized strings     * are used where appropriate.     */    private Object readResolve() {        return new QName(namespaceURI, localName);    }}

⌨️ 快捷键说明

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