stefan 2004/07/16 09:36:49
Modified: proposals/jcrri/src/org/apache/slide/jcr/core/observation
EventListenerIteratorImpl.java EventState.java
EventStateCollection.java
FilteredEventIterator.java
ObservationManagerFactory.java
Log:
jcrri
Revision Changes Path
1.3 +47 -35
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/EventListenerIteratorImpl.java
Index: EventListenerIteratorImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/EventListenerIteratorImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EventListenerIteratorImpl.java 2 Jul 2004 16:24:37 -0000 1.2
+++ EventListenerIteratorImpl.java 16 Jul 2004 16:36:49 -0000 1.3
@@ -24,11 +24,11 @@
package org.apache.slide.jcr.core.observation;
-import javax.jcr.observation.EventListenerIterator;
-import javax.jcr.observation.EventListener;
import javax.jcr.Ticket;
-import java.util.Iterator;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.EventListenerIterator;
import java.util.Collection;
+import java.util.Iterator;
import java.util.NoSuchElementException;
/**
@@ -43,7 +43,9 @@
*/
private final Ticket ticket;
- /** Iterator over [EMAIL PROTECTED] EventConsumer} instances */
+ /**
+ * Iterator over [EMAIL PROTECTED] EventConsumer} instances
+ */
private final Iterator consumers;
/**
@@ -52,7 +54,9 @@
*/
private EventListener next;
- /** Current position */
+ /**
+ * Current position
+ */
private long pos = 0;
/**
@@ -64,54 +68,62 @@
* is <code>null</code>.
*/
EventListenerIteratorImpl(Ticket ticket, Collection consumers) {
- if (ticket == null) throw new NullPointerException("ticket");
- if (consumers == null) throw new NullPointerException("consumers");
- this.ticket = ticket;
- this.consumers = consumers.iterator();
- fetchNext();
+ if (ticket == null) {
+ throw new NullPointerException("ticket");
+ }
+ if (consumers == null) {
+ throw new NullPointerException("consumers");
+ }
+ this.ticket = ticket;
+ this.consumers = consumers.iterator();
+ fetchNext();
}
/**
* @see javax.jcr.observation.EventListenerIterator#nextEventListener()
*/
public EventListener nextEventListener() {
- if (next == null) throw new NoSuchElementException();
- EventListener l = next;
- fetchNext();
- pos++;
- return l;
+ if (next == null) {
+ throw new NoSuchElementException();
+ }
+ EventListener l = next;
+ fetchNext();
+ pos++;
+ return l;
}
/**
* @see javax.jcr.RangeIterator#skip(int)
*/
public void skip(int skipNum) {
- while (skipNum-- > 0) {
- next();
- }
+ while (skipNum-- > 0) {
+ next();
+ }
}
/**
* Always returns <code>-1</code>.
+ *
* @return <code>-1</code>.
*/
public long getSize() {
- return -1;
+ return -1;
}
/**
* @see javax.jcr.RangeIterator#getPos()
*/
public long getPos() {
- return pos;
+ return pos;
}
/**
* Remove is not supported on this Iterator.
- * @exception UnsupportedOperationException
+ *
+ * @throws UnsupportedOperationException
*/
public void remove() {
- throw new UnsupportedOperationException("EventListenerIterator.remove()");
+ throw new UnsupportedOperationException("EventListenerIterator.remove()");
}
/**
@@ -122,14 +134,14 @@
* @return <tt>true</tt> if the consumers has more elements.
*/
public boolean hasNext() {
- return (next != null);
+ return (next != null);
}
/**
* @see Iterator#next()
*/
public Object next() {
- return nextEventListener();
+ return nextEventListener();
}
/**
@@ -139,15 +151,15 @@
* <code>EventListener</code>s
*/
private void fetchNext() {
- EventConsumer consumer;
- next = null;
- while (next == null && consumers.hasNext()) {
- consumer = (EventConsumer)consumers.next();
- // only return EventConsumers that belong to our ticket
- if (consumer.getTicket().equals(ticket)) {
- next = consumer.getEventListener();
- }
+ EventConsumer consumer;
+ next = null;
+ while (next == null && consumers.hasNext()) {
+ consumer = (EventConsumer) consumers.next();
+ // only return EventConsumers that belong to our ticket
+ if (consumer.getTicket().equals(ticket)) {
+ next = consumer.getEventListener();
+ }
- }
+ }
}
}
1.3 +128 -112
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/EventState.java
Index: EventState.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/EventState.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EventState.java 2 Jul 2004 16:24:37 -0000 1.2
+++ EventState.java 16 Jul 2004 16:36:49 -0000 1.3
@@ -26,8 +26,8 @@
import org.apache.slide.jcr.core.QName;
-import javax.jcr.observation.EventType;
import javax.jcr.Ticket;
+import javax.jcr.observation.EventType;
/**
* The <code>EventState</code> class encapsulates the ticket
@@ -38,40 +38,52 @@
*/
class EventState {
- /** The [EMAIL PROTECTED] javax.jcr.observation.EventType} of this event. */
+ /**
+ * The [EMAIL PROTECTED] javax.jcr.observation.EventType} of this event.
+ */
private final long type;
- /** The UUID of the parent node associated with this event. */
+ /**
+ * The UUID of the parent node associated with this event.
+ */
private final String parentUUID;
- /** The qualified name of the child item associated with this event. */
+ /**
+ * The qualified name of the child item associated with this event.
+ */
private final QName childName;
- /** The the ticket that caused this event. */
+ /**
+ * The the ticket that caused this event.
+ */
private final Ticket ticket;
- /** Cached String representation of this <code>EventState</code>. */
+ /**
+ * Cached String representation of this <code>EventState</code>.
+ */
private String stringValue;
- /** Cached hashCode value for this <code>Event</code>. */
+ /**
+ * Cached hashCode value for this <code>Event</code>.
+ */
private int hashCode;
/**
* Creates a new <code>EventState</code> instance.
*
- * @param type the [EMAIL PROTECTED] javax.jcr.observation.EventType} of this
- * event.
+ * @param type the [EMAIL PROTECTED] javax.jcr.observation.EventType} of
this
+ * event.
* @param parentUUID the uuid of the parent node associated with this event.
- * @param childName the qualified name of the child item associated with
- * this event.
- * @param ticket the [EMAIL PROTECTED] javax.jcr.Ticket} that
- * caused this event.
+ * @param childName the qualified name of the child item associated with
+ * this event.
+ * @param ticket the [EMAIL PROTECTED] javax.jcr.Ticket} that
+ * caused this event.
*/
private EventState(long type, String parentUUID, QName childName, Ticket
ticket) {
- this.type = type;
- this.parentUUID = parentUUID;
- this.childName = childName;
- this.ticket = ticket;
+ this.type = type;
+ this.parentUUID = parentUUID;
+ this.childName = childName;
+ this.ticket = ticket;
}
//-----------------< factory methods >--------------------------------------
@@ -81,18 +93,18 @@
* [EMAIL PROTECTED] javax.jcr.observation.EventType#CHILD_NODE_ADDED}.
*
* @param parentUUID the uuid of the parent node associated with
- * this <code>EventState</code>.
- * @param childName the qualified name of the child node that was added.
- * @param ticket the ticket that added the node.
+ * this <code>EventState</code>.
+ * @param childName the qualified name of the child node that was added.
+ * @param ticket the ticket that added the node.
* @return an <code>EventState</code> instance.
*/
public static EventState ChildNodeAdded(String parentUUID,
- QName childName,
- Ticket ticket) {
- return new EventState(EventType.CHILD_NODE_ADDED,
- parentUUID,
- childName,
- ticket);
+ QName childName,
+ Ticket ticket) {
+ return new EventState(EventType.CHILD_NODE_ADDED,
+ parentUUID,
+ childName,
+ ticket);
}
/**
@@ -100,18 +112,18 @@
* [EMAIL PROTECTED] javax.jcr.observation.EventType#CHILD_NODE_REMOVED}.
*
* @param parentUUID the uuid of the parent node associated with
- * this <code>EventState</code>.
- * @param childName the qualified name of the child node that was removed.
- * @param ticket the ticket that removed the node.
+ * this <code>EventState</code>.
+ * @param childName the qualified name of the child node that was removed.
+ * @param ticket the ticket that removed the node.
* @return an <code>EventState</code> instance.
*/
public static EventState ChildNodeRemoved(String parentUUID,
- QName childName,
- Ticket ticket) {
- return new EventState(EventType.CHILD_NODE_REMOVED,
- parentUUID,
- childName,
- ticket);
+ QName childName,
+ Ticket ticket) {
+ return new EventState(EventType.CHILD_NODE_REMOVED,
+ parentUUID,
+ childName,
+ ticket);
}
/**
@@ -119,18 +131,18 @@
* [EMAIL PROTECTED] javax.jcr.observation.EventType#PROPERTY_ADDED}.
*
* @param parentUUID the uuid of the parent node associated with
- * this <code>EventState</code>.
- * @param childName the qualified name of the property that was added.
- * @param ticket the ticket that added the property.
+ * this <code>EventState</code>.
+ * @param childName the qualified name of the property that was added.
+ * @param ticket the ticket that added the property.
* @return an <code>EventState</code> instance.
*/
public static EventState PropertyAdded(String parentUUID,
- QName childName,
- Ticket ticket) {
- return new EventState(EventType.PROPERTY_ADDED,
- parentUUID,
- childName,
- ticket);
+ QName childName,
+ Ticket ticket) {
+ return new EventState(EventType.PROPERTY_ADDED,
+ parentUUID,
+ childName,
+ ticket);
}
/**
@@ -138,18 +150,18 @@
* [EMAIL PROTECTED] javax.jcr.observation.EventType#PROPERTY_REMOVED}.
*
* @param parentUUID the uuid of the parent node associated with
- * this <code>EventState</code>.
- * @param childName the qualified name of the property that was removed.
- * @param ticket the ticket that removed the property.
+ * this <code>EventState</code>.
+ * @param childName the qualified name of the property that was removed.
+ * @param ticket the ticket that removed the property.
* @return an <code>EventState</code> instance.
*/
public static EventState PropertyRemoved(String parentUUID,
- QName childName,
- Ticket ticket) {
- return new EventState(EventType.PROPERTY_REMOVED,
- parentUUID,
- childName,
- ticket);
+ QName childName,
+ Ticket ticket) {
+ return new EventState(EventType.PROPERTY_REMOVED,
+ parentUUID,
+ childName,
+ ticket);
}
/**
@@ -157,49 +169,51 @@
* [EMAIL PROTECTED] javax.jcr.observation.EventType#PROPERTY_CHANGED}.
*
* @param parentUUID the uuid of the parent node associated with
- * this <code>EventState</code>.
- * @param childName the qualified name of the property that changed.
- * @param ticket the ticket that changed the property.
+ * this <code>EventState</code>.
+ * @param childName the qualified name of the property that changed.
+ * @param ticket the ticket that changed the property.
* @return an <code>EventState</code> instance.
*/
public static EventState PropertyChanged(String parentUUID,
- QName childName,
- Ticket ticket) {
- return new EventState(EventType.PROPERTY_CHANGED,
- parentUUID,
- childName,
- ticket);
+ QName childName,
+ Ticket ticket) {
+ return new EventState(EventType.PROPERTY_CHANGED,
+ parentUUID,
+ childName,
+ ticket);
}
/**
* @see javax.jcr.observation.Event#getType()
*/
public long getType() {
- return type;
+ return type;
}
/**
* Returns the uuid of the parent node.
+ *
* @return the uuid of the parent node.
*/
public String getParentUUID() {
- return parentUUID;
+ return parentUUID;
}
/**
* Returns the [EMAIL PROTECTED] QName} of the
* [EMAIL PROTECTED] javax.jcr.Item} associated with this event.
+ *
* @return the <code>QName</code> associated with this event.
*/
public QName getChildItemQName() {
- return childName;
+ return childName;
}
/**
* @see javax.jcr.observation.Event#getUserId()
*/
public String getUserId() {
- return ticket.getUserId();
+ return ticket.getUserId();
}
/**
@@ -210,40 +224,42 @@
* <code>EventState</code>.
*/
Ticket getTicket() {
- return ticket;
+ return ticket;
}
/**
* Returns a String representation of this <code>EventState</code>.
+ *
* @return a String representation of this <code>EventState</code>.
*/
public String toString() {
- if (stringValue == null) {
- StringBuffer sb = new StringBuffer();
- sb.append("EventState: ").append(valueOf(type));
- sb.append(", Parent: ").append(parentUUID);
- sb.append(", Child: ").append(childName);
- sb.append(", UserId: ").append(ticket.getUserId());
- stringValue = sb.toString();
- }
- return stringValue;
+ if (stringValue == null) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("EventState: ").append(valueOf(type));
+ sb.append(", Parent: ").append(parentUUID);
+ sb.append(", Child: ").append(childName);
+ sb.append(", UserId: ").append(ticket.getUserId());
+ stringValue = sb.toString();
+ }
+ return stringValue;
}
/**
* Returns a hashCode for this <code>EventState</code>.
+ *
* @return a hashCode for this <code>EventState</code>.
*/
public int hashCode() {
- int h = hashCode;
- if (h == 0) {
- h = 37;
- h = 37*h + (int)type;
- h = 37*h + parentUUID.hashCode();
- h = 37*h + childName.hashCode();
- h = 37*h + ticket.hashCode();
- hashCode = h;
- }
- return hashCode;
+ int h = hashCode;
+ if (h == 0) {
+ h = 37;
+ h = 37 * h + (int) type;
+ h = 37 * h + parentUUID.hashCode();
+ h = 37 * h + childName.hashCode();
+ h = 37 * h + ticket.hashCode();
+ hashCode = h;
+ }
+ return hashCode;
}
/**
@@ -255,17 +271,17 @@
* <code>EventState</code>; <code>false</code> otherwise.
*/
public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (obj instanceof EventState) {
- EventState other = (EventState) obj;
- return this.type == other.type
- && this.parentUUID.equals(other.parentUUID)
- && this.childName.equals(other.childName)
- && this.ticket.equals(other.ticket);
- }
- return false;
+ if (obj == this) {
+ return true;
+ }
+ if (obj instanceof EventState) {
+ EventState other = (EventState) obj;
+ return this.type == other.type
+ && this.parentUUID.equals(other.parentUUID)
+ && this.childName.equals(other.childName)
+ && this.ticket.equals(other.ticket);
+ }
+ return false;
}
/**
@@ -275,19 +291,19 @@
* @return a String representation of <code>eventType</code>.
*/
public static String valueOf(long eventType) {
- if (eventType == EventType.CHILD_NODE_ADDED) {
- return "ChildNodeAdded";
- } else if (eventType == EventType.CHILD_NODE_REMOVED) {
- return "ChildNodeRemoved";
- } else if (eventType == EventType.PROPERTY_ADDED) {
- return "PropertyAdded";
- } else if (eventType == EventType.PROPERTY_CHANGED) {
- return "PropertyChanged";
- } else if (eventType == EventType.PROPERTY_REMOVED) {
- return "PropertyRemoved";
- } else {
- return "UnknownEventType";
- }
+ if (eventType == EventType.CHILD_NODE_ADDED) {
+ return "ChildNodeAdded";
+ } else if (eventType == EventType.CHILD_NODE_REMOVED) {
+ return "ChildNodeRemoved";
+ } else if (eventType == EventType.PROPERTY_ADDED) {
+ return "PropertyAdded";
+ } else if (eventType == EventType.PROPERTY_CHANGED) {
+ return "PropertyChanged";
+ } else if (eventType == EventType.PROPERTY_REMOVED) {
+ return "PropertyRemoved";
+ } else {
+ return "UnknownEventType";
+ }
}
}
1.3 +71 -60
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/EventStateCollection.java
Index: EventStateCollection.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/EventStateCollection.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EventStateCollection.java 2 Jul 2004 16:24:37 -0000 1.2
+++ EventStateCollection.java 16 Jul 2004 16:36:49 -0000 1.3
@@ -24,12 +24,16 @@
package org.apache.slide.jcr.core.observation;
-import org.apache.slide.jcr.core.state.*;
import org.apache.log4j.Logger;
+import org.apache.slide.jcr.core.state.ItemState;
+import org.apache.slide.jcr.core.state.NodeState;
+import org.apache.slide.jcr.core.state.PropertyState;
import javax.jcr.RepositoryException;
import javax.jcr.Ticket;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
/**
* The <code>EventStateCollection</code> class implements how [EMAIL PROTECTED]
EventState}
@@ -41,13 +45,19 @@
*/
final public class EventStateCollection {
- /** Logger instance for this class */
+ /**
+ * Logger instance for this class
+ */
private static Logger log = Logger.getLogger(EventStateCollection.class);
- /** List of events */
+ /**
+ * List of events
+ */
private final List events = new ArrayList();
- /** The ticket that created these events */
+ /**
+ * The ticket that created these events
+ */
private final Ticket ticket;
/**
@@ -56,7 +66,7 @@
* @param ticket the ticket that created these events.
*/
public EventStateCollection(Ticket ticket) {
- this.ticket = ticket;
+ this.ticket = ticket;
}
/**
@@ -64,70 +74,71 @@
* instance.
*
* @param state the transient <code>ItemState</code> for whom
- * to create [EMAIL PROTECTED] EventState}s.
+ * to create [EMAIL PROTECTED] EventState}s.
* @throws RepositoryException if an error occurs.
*/
public void createEventStates(ItemState state)
- throws RepositoryException {
- int status = state.getStatus();
+ throws RepositoryException {
+ int status = state.getStatus();
- if (status == ItemState.STATUS_EXISTING_MODIFIED ||
- status == ItemState.STATUS_NEW) {
+ if (status == ItemState.STATUS_EXISTING_MODIFIED ||
+ status == ItemState.STATUS_NEW) {
- if (state.isNode()) {
+ if (state.isNode()) {
- // 1) check added properties
- NodeState currentNode = (NodeState)state;
- List addedProperties = currentNode.getAddedPropertyEntries();
- for (Iterator it = addedProperties.iterator(); it.hasNext(); ) {
- NodeState.PropertyEntry prop =
(NodeState.PropertyEntry)it.next();
- events.add(EventState.PropertyAdded(currentNode.getUUID(),
- prop.getName(),
- ticket));
- }
-
- // 2) check removed properties
- List removedProperties = currentNode.getRemovedPropertyEntries();
- for (Iterator it = removedProperties.iterator(); it.hasNext(); ) {
- NodeState.PropertyEntry prop =
(NodeState.PropertyEntry)it.next();
- events.add(EventState.PropertyRemoved(currentNode.getUUID(),
- prop.getName(),
- ticket));
- }
-
- // 3) check for added nodes
- List addedNodes = currentNode.getAddedChildNodeEntries();
- for (Iterator it = addedNodes.iterator(); it.hasNext(); ) {
- NodeState.ChildNodeEntry child =
(NodeState.ChildNodeEntry)it.next();
- events.add(EventState.ChildNodeAdded(currentNode.getUUID(),
- child.getName(),
- ticket));
- }
-
- // 4) check for removed nodes
- List removedNodes = currentNode.getRemovedChildNodeEntries();
- for (Iterator it = removedNodes.iterator(); it.hasNext(); ) {
- NodeState.ChildNodeEntry child =
(NodeState.ChildNodeEntry)it.next();
- events.add(EventState.ChildNodeRemoved(currentNode.getUUID(),
- child.getName(),
- ticket));
- }
- } else {
- // only add property changed event if property is existing
- if (state.getStatus() == ItemState.STATUS_EXISTING_MODIFIED) {
- events.add(EventState.PropertyChanged(state.getParentUUID(),
- ((PropertyState)state).getName(),
- ticket));
- }
- }
- }
+ // 1) check added properties
+ NodeState currentNode = (NodeState) state;
+ List addedProperties = currentNode.getAddedPropertyEntries();
+ for (Iterator it = addedProperties.iterator(); it.hasNext();) {
+ NodeState.PropertyEntry prop = (NodeState.PropertyEntry) it.next();
+ events.add(EventState.PropertyAdded(currentNode.getUUID(),
+ prop.getName(),
+ ticket));
+ }
+
+ // 2) check removed properties
+ List removedProperties = currentNode.getRemovedPropertyEntries();
+ for (Iterator it = removedProperties.iterator(); it.hasNext();) {
+ NodeState.PropertyEntry prop = (NodeState.PropertyEntry) it.next();
+ events.add(EventState.PropertyRemoved(currentNode.getUUID(),
+ prop.getName(),
+ ticket));
+ }
+
+ // 3) check for added nodes
+ List addedNodes = currentNode.getAddedChildNodeEntries();
+ for (Iterator it = addedNodes.iterator(); it.hasNext();) {
+ NodeState.ChildNodeEntry child = (NodeState.ChildNodeEntry)
it.next();
+ events.add(EventState.ChildNodeAdded(currentNode.getUUID(),
+ child.getName(),
+ ticket));
+ }
+
+ // 4) check for removed nodes
+ List removedNodes = currentNode.getRemovedChildNodeEntries();
+ for (Iterator it = removedNodes.iterator(); it.hasNext();) {
+ NodeState.ChildNodeEntry child = (NodeState.ChildNodeEntry)
it.next();
+ events.add(EventState.ChildNodeRemoved(currentNode.getUUID(),
+ child.getName(),
+ ticket));
+ }
+ } else {
+ // only add property changed event if property is existing
+ if (state.getStatus() == ItemState.STATUS_EXISTING_MODIFIED) {
+ events.add(EventState.PropertyChanged(state.getParentUUID(),
+ ((PropertyState) state).getName(),
+ ticket));
+ }
+ }
+ }
}
/**
* Returns an iterator over [EMAIL PROTECTED] EventState} instance.
+ *
* @return an iterator over [EMAIL PROTECTED] EventState} instance.
*/
Iterator iterator() {
- return events.iterator();
+ return events.iterator();
}
}
1.2 +53 -41
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/FilteredEventIterator.java
Index: FilteredEventIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/FilteredEventIterator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FilteredEventIterator.java 1 Jul 2004 18:30:08 -0000 1.1
+++ FilteredEventIterator.java 16 Jul 2004 16:36:49 -0000 1.2
@@ -26,88 +26,100 @@
import org.apache.log4j.Logger;
-import javax.jcr.observation.EventIterator;
-import javax.jcr.observation.Event;
import javax.jcr.RepositoryException;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventIterator;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
- *
* @author Marcel Reutegger
*/
class FilteredEventIterator implements EventIterator {
- /** Logger instance for this class */
+ /**
+ * Logger instance for this class
+ */
private static final Logger log
- = Logger.getLogger(FilteredEventIterator.class);
+ = Logger.getLogger(FilteredEventIterator.class);
- /** The actual [EMAIL PROTECTED] EventState}s fired by the workspace
(unfiltered) */
+ /**
+ * The actual [EMAIL PROTECTED] EventState}s fired by the workspace (unfiltered)
+ */
private final Iterator actualEvents;
- /** For filtering the [EMAIL PROTECTED] javax.jcr.observation.Event}s. */
+ /**
+ * For filtering the [EMAIL PROTECTED] javax.jcr.observation.Event}s.
+ */
private final EventFilter filter;
- /** The next [EMAIL PROTECTED] javax.jcr.observation.Event} in this iterator */
+ /**
+ * The next [EMAIL PROTECTED] javax.jcr.observation.Event} in this iterator
+ */
private Event next;
- /** Current position */
+ /**
+ * Current position
+ */
private long pos = 0;
/**
* Creates a new <code>FilteredEventIterator</code>.
*
- * @param c an unmodifiable Collection of
- * [EMAIL PROTECTED] javax.jcr.observation.Event}s.
+ * @param c an unmodifiable Collection of
+ * [EMAIL PROTECTED] javax.jcr.observation.Event}s.
* @param filter only event that pass the filter will be
- * dispatched to the event listener.
+ * dispatched to the event listener.
*/
public FilteredEventIterator(EventStateCollection c, EventFilter filter) {
- actualEvents = c.iterator();
- this.filter = filter;
- fetchNext();
+ actualEvents = c.iterator();
+ this.filter = filter;
+ fetchNext();
}
/**
* @see Iterator#next()
*/
public Object next() {
- if (next == null) throw new NoSuchElementException();
- Event e = next;
- fetchNext();
- pos++;
- return e;
+ if (next == null) {
+ throw new NoSuchElementException();
+ }
+ Event e = next;
+ fetchNext();
+ pos++;
+ return e;
}
/**
* @see EventIterator#nextEvent()
*/
public Event nextEvent() {
- return (Event)next();
+ return (Event) next();
}
/**
* @see javax.jcr.RangeIterator#skip(int)
*/
public void skip(int skipNum) {
- while (skipNum-- > 0) {
- next();
- }
+ while (skipNum-- > 0) {
+ next();
+ }
}
/**
* Always returns <code>-1</code>.
+ *
* @return <code>-1</code>.
*/
public long getSize() {
- return -1;
+ return -1;
}
/**
* @see javax.jcr.RangeIterator#getPos()
*/
public long getPos() {
- return pos;
+ return pos;
}
/**
@@ -115,7 +127,7 @@
* Always throws a <code>UnsupportedOperationException</code>.
*/
public void remove() {
- throw new UnsupportedOperationException("EventIterator.remove()");
+ throw new UnsupportedOperationException("EventIterator.remove()");
}
/**
@@ -126,7 +138,7 @@
* @return <tt>true</tt> if the iterator has more elements.
*/
public boolean hasNext() {
- return (next != null);
+ return (next != null);
}
/**
@@ -135,17 +147,17 @@
* that is allowed by the [EMAIL PROTECTED] EventFilter}.
*/
private void fetchNext() {
- EventState state;
- next = null;
- while (next == null && actualEvents.hasNext()) {
- state = (EventState)actualEvents.next();
- try {
- next = filter.blocks(state) ? null : new
EventImpl(filter.getTicket(),
- filter.getItemManager(),
- state);
- } catch (RepositoryException e) {
- log.error("Exception while applying filter.", e);
- }
- }
+ EventState state;
+ next = null;
+ while (next == null && actualEvents.hasNext()) {
+ state = (EventState) actualEvents.next();
+ try {
+ next = filter.blocks(state) ? null : new EventImpl(filter.getTicket(),
+ filter.getItemManager(),
+ state);
+ } catch (RepositoryException e) {
+ log.error("Exception while applying filter.", e);
+ }
+ }
}
}
1.4 +0 -0
jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/ObservationManagerFactory.java
Index: ObservationManagerFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/jcrri/src/org/apache/slide/jcr/core/observation/ObservationManagerFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]