You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2005/04/19 21:33:12 UTC
svn commit: r161953 - in
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: ItemId.java
NodeId.java PropertyId.java
Author: jukka
Date: Tue Apr 19 12:33:10 2005
New Revision: 161953
URL: http://svn.apache.org/viewcvs?view=rev&rev=161953
Log:
JCR-73: Improved ItemId, NodeId, and PropertyId javadocs.
Modified:
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemId.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemId.java?view=diff&r1=161952&r2=161953
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemId.java Tue Apr 19 12:33:10 2005
@@ -25,10 +25,15 @@
*/
public abstract class ItemId implements Serializable {
+ /** Serialization UID of this class. */
static final long serialVersionUID = -9147603369595196078L;
+ /** Memorized hash code. */
protected int hash;
+ /**
+ * Creates an empty item ID instance.
+ */
protected ItemId() {
hash = 0;
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java?view=diff&r1=161952&r2=161953
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java Tue Apr 19 12:33:10 2005
@@ -21,10 +21,17 @@
*/
public class NodeId extends ItemId {
+ /** Serial version UID of this class. */
static final long serialVersionUID = 7026219091360041109L;
+ /** UUID of the identified node */
protected final String uuid;
+ /**
+ * Creates a node identifier instance for the identified node.
+ *
+ * @param uuid node UUID
+ */
public NodeId(String uuid) {
if (uuid == null) {
throw new IllegalArgumentException("uuid can not be null");
@@ -33,14 +40,21 @@
}
/**
- * {@inheritDoc}
+ * Returns <code>true</code> as this class represents a node identifier,
+ * not a property identifier.
*
* @return always <code>true</code>
+ * @see ItemId#denotesNode()
*/
public boolean denotesNode() {
return true;
}
+ /**
+ * Returns the UUID of the identified node.
+ *
+ * @return node UUID
+ */
public String getUUID() {
return uuid;
}
@@ -57,7 +71,7 @@
* as a <code>NodeId</code>.
* @see #toString()
*/
- public static NodeId valueOf(String s) {
+ public static NodeId valueOf(String s) throws IllegalArgumentException {
if (s == null) {
throw new IllegalArgumentException("invalid NodeId literal");
}
@@ -66,6 +80,15 @@
//-------------------------------------------< java.lang.Object overrides >
+ /**
+ * Compares node identifiers for equality.
+ *
+ * @param obj other object
+ * @return <code>true</code> if the given object is a node identifier
+ * instance that identifies the same node as this identifier,
+ * <code>false</code> otherwise
+ * @see Object#equals(Object)
+ */
public boolean equals(Object obj) {
if (this == obj) {
return true;
@@ -77,10 +100,23 @@
return false;
}
+ /**
+ * Returns the node UUID.
+ *
+ * @return node UUID
+ * @see Object#toString()
+ */
public String toString() {
return uuid;
}
+ /**
+ * Returns the hash code of the node UUID. The computed hash code
+ * is memorized for better performance.
+ *
+ * @return hash code
+ * @see Object#hashCode()
+ */
public int hashCode() {
// NodeId is immutable, we can store the computed hash code value
if (hash == 0) {
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java?view=diff&r1=161952&r2=161953
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java Tue Apr 19 12:33:10 2005
@@ -17,15 +17,27 @@
package org.apache.jackrabbit.core;
/**
- * <code>PropertyId</code> uniquely identifies a property in the repository.
+ * Property identifier. An instance of this class identifies a single
+ * property using the UUID of the parent node and the qualified name of
+ * the property. Once created a property identifier instance is immutable.
*/
public class PropertyId extends ItemId {
+ /** Serial version UID of this class. */
static final long serialVersionUID = -3726624437800567892L;
+ /** UUID of the parent node. */
private final String parentUUID;
+
+ /** Qualified name of the property. */
private final QName propName;
+ /**
+ * Creates a property identifier instance for the identified property.
+ *
+ * @param parentUUID UUID of the parent node
+ * @param propName qualified name of the property
+ */
public PropertyId(String parentUUID, QName propName) {
if (parentUUID == null) {
throw new IllegalArgumentException("parentUUID can not be null");
@@ -38,26 +50,38 @@
}
/**
- * {@inheritDoc}
+ * Returns <code>false</code> as this class represents a property
+ * identifier, not a node identifier.
*
* @return always <code>false</code>
+ * @see ItemId#denotesNode()
*/
public boolean denotesNode() {
return false;
}
+ /**
+ * Returns the UUID of the parent node.
+ *
+ * @return node UUID
+ */
public String getParentUUID() {
return parentUUID;
}
+ /**
+ * Returns the qualified name of the property.
+ *
+ * @return qualified name
+ */
public QName getName() {
return propName;
}
/**
- * Returns a <code>PropertyId</code> holding the value of the specified
- * string. The string must be in the format returned by the
- * <code>PropertyId.toString()</code> method.
+ * Returns a property identifier instance holding the value of the
+ * specified string. The string must be in the format returned by the
+ * {@link #toString() toString()} method of this class.
*
* @param s a <code>String</code> containing the <code>PropertyId</code>
* representation to be parsed.
@@ -66,7 +90,7 @@
* as a <code>PropertyId</code>.
* @see #toString()
*/
- public static PropertyId valueOf(String s) {
+ public static PropertyId valueOf(String s) throws IllegalArgumentException {
if (s == null) {
throw new IllegalArgumentException("invalid PropertyId literal");
}
@@ -82,6 +106,15 @@
//-------------------------------------------< java.lang.Object overrides >
+ /**
+ * Compares property identifiers for equality.
+ *
+ * @param obj other object
+ * @return <code>true</code> if the given object is a property identifier
+ * instance that identifies the same property as this identifier,
+ * <code>false</code> otherwise
+ * @see Object#equals(Object)
+ */
public boolean equals(Object obj) {
if (this == obj) {
return true;
@@ -94,10 +127,24 @@
return false;
}
+ /**
+ * Returns a string representation of this property identifier.
+ *
+ * @return property identifier string
+ * @see Object#toString()
+ */
public String toString() {
return parentUUID + "/" + propName.toString();
}
+ /**
+ * Returns the hash code of this property identifier. The hash code
+ * is computed from the parent node UUID and the property name. The
+ * hash code is memorized for performance.
+ *
+ * @return hash code
+ * @see Object#hashCode()
+ */
public int hashCode() {
// PropertyId is immutable, we can store the computed hash code value
int h = hash;