KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > rdf > model > impl > ContNodeIteratorImpl


1 /*
2   (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3   [See end of file]
4   $Id: ContNodeIteratorImpl.java,v 1.9 2005/02/21 12:14:30 andy_seaborne Exp $
5 */

6
7 package com.hp.hpl.jena.rdf.model.impl;
8
9 import com.hp.hpl.jena.util.iterator.*;
10 import com.hp.hpl.jena.rdf.model.*;
11
12 import java.util.*;
13
14 /** An internal class not normally of interest to application developers.
15  * An iterator over the nodes in a container.
16  * @author bwm, kers
17  * @version Release='$Name: $' Revision='$Revision: 1.9 $' Date='$Date: 2005/02/21 12:14:30 $'
18  */

19 public class ContNodeIteratorImpl
20   extends WrappedIterator implements NodeIterator{
21     
22     protected Statement stmt = null;
23     protected Container cont;
24     protected int size;
25     protected int index = 0;
26     protected int numDeleted = 0;
27     protected Vector moved = new Vector();
28     
29     /** Creates new ContNodeIteratorImpl */
30     public ContNodeIteratorImpl (Iterator iterator,
31                                 Object JavaDoc object,
32                                 Container cont) {
33         super( iterator );
34         this.cont = cont;
35         this.size = cont.size();
36     }
37
38     public Object JavaDoc next() throws NoSuchElementException {
39         stmt = (Statement) super.next();
40         index += 1;
41         return stmt.getObject();
42     }
43     
44     public RDFNode nextNode() throws NoSuchElementException {
45         return (RDFNode) next();
46     }
47             
48     public void remove() throws NoSuchElementException {
49         if (stmt == null) throw new NoSuchElementException();
50         super.remove();
51         
52         if (index > (size-numDeleted)) {
53             ((ContainerI)cont).remove(((Integer JavaDoc) moved.elementAt(size-index))
54                                                       .intValue(),
55                                        stmt.getObject());
56         } else {
57             cont.remove(stmt);
58             moved.add(new Integer JavaDoc(index));
59         }
60         stmt = null;
61         numDeleted++;
62     }
63     
64 }
65 /*
66  * (c) Copyright 2000, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
67  * All rights reserved.
68  *
69  * Redistribution and use in source and binary forms, with or without
70  * modification, are permitted provided that the following conditions
71  * are met:
72  * 1. Redistributions of source code must retain the above copyright
73  * notice, this list of conditions and the following disclaimer.
74  * 2. Redistributions in binary form must reproduce the above copyright
75  * notice, this list of conditions and the following disclaimer in the
76  * documentation and/or other materials provided with the distribution.
77  * 3. The name of the author may not be used to endorse or promote products
78  * derived from this software without specific prior written permission.
79
80  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
81  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
82  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
83  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
84  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
85  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
86  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
87  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
88  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
89  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90  *
91  * ContNodeIteratorImpl.java
92  *
93  * Created on 12 August 2000, 09:57
94  */

95
Popular Tags