You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by st...@apache.org on 2004/11/04 15:34:55 UTC
svn commit: rev 56594 - in incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core: . nodetype state state/obj state/xml util
Author: stefan
Date: Thu Nov 4 06:34:52 2004
New Revision: 56594
Modified:
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Path.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/QName.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/NodeState.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java
incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/ChildrenCollector.java
Log:
minor fixes and javadoc comments
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/ItemImpl.java Thu Nov 4 06:34:52 2004
@@ -136,8 +136,13 @@
protected void finalize() throws Throwable {
if (state != null) {
- state.removeListener(this);
+ try {
+ state.removeListener(this);
+ } catch (Throwable t) {
+ // ignore
+ }
}
+ super.finalize();
}
protected void checkItemState() throws InvalidItemStateException {
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/NodeId.java Thu Nov 4 06:34:52 2004
@@ -79,7 +79,7 @@
public int hashCode() {
// NodeId is immutable, we can store the computed hash code value
if (hash == 0) {
- hash = 1609 * uuid.hashCode();
+ hash = uuid.hashCode();
}
return hash;
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Path.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Path.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/Path.java Thu Nov 4 06:34:52 2004
@@ -51,7 +51,7 @@
private final PathElement[] elements;
- private int hashCode;
+ private int hash;
private String string;
/**
@@ -61,7 +61,7 @@
*/
private Path(PathElement[] elements) {
this.elements = elements;
- hashCode = 0;
+ hash = 0;
}
//------------------------------------------------------< factory methods >
@@ -472,13 +472,16 @@
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
- if (hashCode == 0) {
- hashCode = 1;
+ // Path is immutable, we can store the computed hash code value
+ int h = hash;
+ if (h == 0) {
+ h = 17;
for (int i = 0; i < elements.length; i++) {
- hashCode = 43 * hashCode + elements[i].hashCode();
+ h = 37 * h + elements[i].hashCode();
}
+ hash = h;
}
- return hashCode;
+ return h;
}
/**
@@ -767,7 +770,10 @@
public int hashCode() {
// @todo treat index==0 as index==1?
- return 73 * index + name.hashCode();
+ int h = 17;
+ h = 37 * h + index;
+ h = 37 * h + name.hashCode();
+ return h;
}
public boolean equals(Object obj) {
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/PropertyId.java Thu Nov 4 06:34:52 2004
@@ -95,9 +95,13 @@
public int hashCode() {
// PropertyId is immutable, we can store the computed hash code value
- if (hash == 0) {
- hash = 577 * parentUUID.hashCode() + 43 * propName.hashCode();
+ int h = hash;
+ if (h == 0) {
+ h = 17;
+ h = 37 * h + parentUUID.hashCode();
+ h = 37 * h + propName.hashCode();
+ hash = h;
}
- return hash;
+ return h;
}
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/QName.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/QName.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/QName.java Thu Nov 4 06:34:52 2004
@@ -237,10 +237,14 @@
public int hashCode() {
// QName is immutable, we can store the computed hash code value
- if (hash == 0) {
- hash = namespaceURI.hashCode() + 313 * localName.hashCode();
+ int h = hash;
+ if (h == 0) {
+ h = 17;
+ h = 37 * h + namespaceURI.hashCode();
+ h = 37 * h + localName.hashCode();
+ hash = h;
}
- return hash;
+ return h;
}
/**
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeDefId.java Thu Nov 4 06:34:52 2004
@@ -99,6 +99,7 @@
}
public int hashCode() {
+ // id is already the computed hash code
return id;
}
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java Thu Nov 4 06:34:52 2004
@@ -1319,8 +1319,14 @@
}
public int hashCode() {
+ int h = 17;
// ignore weight
- return set.hashCode();
+ Iterator i = set.iterator();
+ while (i.hasNext()) {
+ Object obj = i.next();
+ h = 37 * h + (obj != null ? obj.hashCode() : 0);
+ }
+ return h;
}
public boolean equals(Object obj) {
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/nodetype/PropDefId.java Thu Nov 4 06:34:52 2004
@@ -88,6 +88,7 @@
}
public int hashCode() {
+ // id is already the computed hash code
return id;
}
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/NodeState.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/NodeState.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/NodeState.java Thu Nov 4 06:34:52 2004
@@ -783,7 +783,7 @@
public int hashCode() {
// PropertyEntry is immutable, we can store the computed hash code value
if (hash == 0) {
- hash = 191 * name.hashCode();
+ hash = name.hashCode();
}
return hash;
}
@@ -840,10 +840,15 @@
public int hashCode() {
// ChildNodeEntry is immutable, we can store the computed hash code value
- if (hash == 0) {
- hash = 6547 * name.hashCode() + 7877 * uuid.hashCode() + 2897 * index;
+ int h = hash;
+ if (h == 0) {
+ h = 17;
+ h = 37 * h + name.hashCode();
+ h = 37 * h + uuid.hashCode();
+ h = 37 * h + index;
+ hash = h;
}
- return hash;
+ return h;
}
}
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/obj/ObjectPersistenceManager.java Thu Nov 4 06:34:52 2004
@@ -32,7 +32,10 @@
import java.util.*;
/**
- * <code>ObjectPersistenceManager</code> ...
+ * <code>ObjectPersistenceManager</code> is a <code>FileSystem</code>-based
+ * <code>PersistenceManager</code> that persists <code>ItemState</code>
+ * and <code>NodeReferences</code> objects using a simple custom serialization
+ * format.
*/
public class ObjectPersistenceManager implements BLOBStore, PersistenceManager {
@@ -639,7 +642,7 @@
/**
* @see PersistenceManager#load(NodeReferences)
*/
- public void load(NodeReferences refs)
+ public synchronized void load(NodeReferences refs)
throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
@@ -676,7 +679,7 @@
/**
* @see PersistenceManager#store(NodeReferences)
*/
- public void store(NodeReferences refs) throws ItemStateException {
+ public synchronized void store(NodeReferences refs) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
@@ -702,7 +705,7 @@
/**
* @see PersistenceManager#destroy(NodeReferences)
*/
- public void destroy(NodeReferences refs) throws ItemStateException {
+ public synchronized void destroy(NodeReferences refs) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
@@ -723,9 +726,9 @@
}
/**
- * @see PersistenceManager#exists(org.apache.jackrabbit.core.ItemId id)
+ * @see PersistenceManager#exists(ItemId id)
*/
- public boolean exists(ItemId id) throws ItemStateException {
+ public synchronized boolean exists(ItemId id) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
@@ -752,7 +755,7 @@
/**
* @see PersistenceManager#referencesExist(NodeId targetId)
*/
- public boolean referencesExist(NodeId targetId) throws ItemStateException {
+ public synchronized boolean referencesExist(NodeId targetId) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/state/xml/XMLPersistenceManager.java Thu Nov 4 06:34:52 2004
@@ -35,7 +35,9 @@
import java.util.*;
/**
- * <code>XMLPersistenceManager</code> ...
+ * <code>XMLPersistenceManager</code> is a <code>FileSystem</code>-based
+ * <code>PersistenceManager</code> that persists <code>ItemState</code>
+ * and <code>NodeReferences</code> objects in XML format.
*/
public class XMLPersistenceManager implements PersistenceManager {
@@ -750,7 +752,7 @@
/**
* @see PersistenceManager#load(NodeReferences)
*/
- public void load(NodeReferences refs)
+ public synchronized void load(NodeReferences refs)
throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
@@ -807,7 +809,7 @@
/**
* @see PersistenceManager#store(NodeReferences)
*/
- public void store(NodeReferences refs) throws ItemStateException {
+ public synchronized void store(NodeReferences refs) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
@@ -849,7 +851,7 @@
/**
* @see PersistenceManager#destroy(NodeReferences)
*/
- public void destroy(NodeReferences refs) throws ItemStateException {
+ public synchronized void destroy(NodeReferences refs) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
@@ -870,9 +872,9 @@
}
/**
- * @see PersistenceManager#exists(org.apache.jackrabbit.core.ItemId id)
+ * @see PersistenceManager#exists(ItemId id)
*/
- public boolean exists(ItemId id) throws ItemStateException {
+ public synchronized boolean exists(ItemId id) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
@@ -899,7 +901,7 @@
/**
* @see PersistenceManager#referencesExist(NodeId targetId)
*/
- public boolean referencesExist(NodeId targetId) throws ItemStateException {
+ public synchronized boolean referencesExist(NodeId targetId) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/ChildrenCollector.java
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/ChildrenCollector.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/util/ChildrenCollector.java Thu Nov 4 06:34:52 2004
@@ -39,7 +39,7 @@
* @param children where the matching children should be added
* @param collectNodes true, if child nodes should be collected; otherwise false
* @param collectProperties true, if child properties should be collected; otherwise false
- * @param maxLevel umber of hierarchy levels to traverse
+ * @param maxLevel number of hierarchy levels to traverse
* (e.g. 1 for direct children only, 2 for children and their children, and so on)
*/
public ChildrenCollector(Collection children, boolean collectNodes, boolean collectProperties, int maxLevel) {