View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors.
8    *
9    * Unless otherwise indicated, all code in ModeShape is licensed
10   * to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   * 
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.jcr;
25  
26  import java.util.NoSuchElementException;
27  import javax.jcr.Node;
28  import javax.jcr.NodeIterator;
29  import net.jcip.annotations.Immutable;
30  import org.modeshape.common.util.CheckArg;
31  
32  /**
33   * A concrete {@link NodeIterator} that is always empty.
34   */
35  @Immutable
36  class JcrEmptyNodeIterator implements NodeIterator {
37  
38      /**
39       * {@inheritDoc}
40       * 
41       * @see javax.jcr.NodeIterator#nextNode()
42       */
43      public Node nextNode() {
44          throw new NoSuchElementException();
45      }
46  
47      /**
48       * {@inheritDoc}
49       * 
50       * @see javax.jcr.RangeIterator#getPosition()
51       */
52      public long getPosition() {
53          return 0;
54      }
55  
56      /**
57       * {@inheritDoc}
58       * 
59       * @see javax.jcr.RangeIterator#getSize()
60       */
61      public long getSize() {
62          return 0;
63      }
64  
65      /**
66       * {@inheritDoc}
67       * 
68       * @see javax.jcr.RangeIterator#skip(long)
69       */
70      public void skip( long skipNum ) {
71          CheckArg.isNonNegative(skipNum, "skipNum");
72          if (skipNum == 0L) return;
73          throw new NoSuchElementException();
74      }
75  
76      /**
77       * {@inheritDoc}
78       * 
79       * @see java.util.Iterator#hasNext()
80       */
81      public boolean hasNext() {
82          return false;
83      }
84  
85      /**
86       * {@inheritDoc}
87       * 
88       * @see java.util.Iterator#next()
89       */
90      public Object next() {
91          throw new NoSuchElementException();
92      }
93  
94      /**
95       * {@inheritDoc}
96       * 
97       * @see java.util.Iterator#remove()
98       */
99      public void remove() {
100         throw new UnsupportedOperationException();
101     }
102 
103 }