[prev in list] [next in list] [prev in thread] [next in thread]
List: slide-dev
Subject: cvs commit: jakarta-slide/src/share/org/apache/slide/structure StructureIterator.java
From: luetzkendorf () apache ! org
Date: 2005-03-30 8:02:44
Message-ID: 20050330080244.44775.qmail () minotaur ! apache ! org
[Download RAW message or body]
luetzkendorf 2005/03/30 00:02:44
Added: src/share/org/apache/slide/structure StructureIterator.java
Log:
added
Revision Changes Path
1.1 jakarta-slide/src/share/org/apache/slide/structure/StructureIterator.java
Index: StructureIterator.java
===================================================================
// vi: set ts=3 sw=3:
package org.apache.slide.structure;
import java.util.Enumeration;
import java.util.NoSuchElementException;
import java.util.Stack;
import org.apache.slide.common.ServiceAccessException;
import org.apache.slide.common.SlideToken;
import org.apache.slide.event.VetoException;
import org.apache.slide.security.AccessDeniedException;
/**
* @author Stefan Lützkendorf
*/
public class StructureIterator
{
private Structure structure;
private SlideToken token;
private ObjectNode next = null;
private Stack stack = new Stack();
public StructureIterator(Structure structure, SlideToken token, String uri)
throws ServiceAccessException, ObjectNotFoundException, VetoException,
LinkedObjectNotFoundException, AccessDeniedException
{
this(structure, token, structure.retrieve(token, uri));
}
public StructureIterator(Structure structure, SlideToken token, ObjectNode root)
throws ServiceAccessException, ObjectNotFoundException, VetoException
{
this.structure = structure;
this.token = token;
this.next = root;
try {
stack.push(structure.getChildren(token, root));
} catch (LinkedObjectNotFoundException e) {
// can not happen
e.printStackTrace();
}
}
public boolean hasNext()
throws ServiceAccessException, ObjectNotFoundException, VetoException
{
if (this.next != null) {
return true;
}
if (this.stack.empty()) {
return false;
}
Enumeration e = (Enumeration)this.stack.peek();
while (e != null && !e.hasMoreElements()) {
this.stack.pop();
if (this.stack.empty()) {
return false;
}
e = (Enumeration)this.stack.peek();
}
try {
if (e != null) {
this.next = (ObjectNode)e.nextElement();
this.stack.push(this.structure.getChildren(this.token, this.next));
return true;
}
} catch (LinkedObjectNotFoundException ex) {
// can't happen
}
return false;
}
public ObjectNode nextNode()
throws ServiceAccessException, ObjectNotFoundException, VetoException
{
if (hasNext()) {
ObjectNode node = (ObjectNode)this.next;
this.next = null;
return node;
} else {
throw new NoSuchElementException();
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic