|
1 |
| -/* |
2 |
| - * JBoss, Home of Professional Open Source. |
3 |
| - * Copyright 2010, Red Hat, Inc., and individual contributors |
4 |
| - * as indicated by the @author tags. See the copyright.txt file in the |
5 |
| - * distribution for a full listing of individual contributors. |
6 |
| - * |
7 |
| - * This is free software; you can redistribute it and/or modify it |
8 |
| - * under the terms of the GNU Lesser General Public License as |
9 |
| - * published by the Free Software Foundation; either version 2.1 of |
10 |
| - * the License, or (at your option) any later version. |
11 |
| - * |
12 |
| - * This software is distributed in the hope that it will be useful, |
13 |
| - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
| - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 |
| - * Lesser General Public License for more details. |
16 |
| - * |
17 |
| - * You should have received a copy of the GNU Lesser General Public |
18 |
| - * License along with this software; if not, write to the Free |
19 |
| - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
20 |
| - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. |
21 |
| - */ |
22 |
| - |
23 |
| -package org.jboss.staxmapper; |
24 |
| - |
25 |
| -import java.util.Iterator; |
26 |
| -import java.util.NoSuchElementException; |
27 |
| - |
28 |
| -/** |
29 |
| - * @author <a href="mailto:[email protected]">David M. Lloyd</a> |
30 |
| - */ |
31 |
| -final class Spliterator implements Iterator<String> { |
32 |
| - private final String subject; |
33 |
| - private final char delimiter; |
34 |
| - private int i; |
35 |
| - |
36 |
| - Spliterator(final String subject, final char delimiter) { |
37 |
| - this.subject = subject; |
38 |
| - this.delimiter = delimiter; |
39 |
| - i = 0; |
40 |
| - } |
41 |
| - |
42 |
| - static Spliterator over(String subject, char delimiter) { |
43 |
| - return new Spliterator(subject, delimiter); |
44 |
| - } |
45 |
| - |
46 |
| - public boolean hasNext() { |
47 |
| - return i != -1; |
48 |
| - } |
49 |
| - |
50 |
| - public String next() { |
51 |
| - final int i = this.i; |
52 |
| - if (i == -1) { |
53 |
| - throw new NoSuchElementException(); |
54 |
| - } |
55 |
| - int n = subject.indexOf(delimiter, i); |
56 |
| - try { |
57 |
| - return n == -1 ? subject.substring(i) : subject.substring(i, n); |
58 |
| - } finally { |
59 |
| - this.i = n == -1 ? -1 : n + 1; |
60 |
| - } |
61 |
| - } |
62 |
| - |
63 |
| - public void remove() { |
64 |
| - throw new UnsupportedOperationException(); |
65 |
| - } |
66 |
| -} |
| 1 | +/* |
| 2 | + * JBoss, Home of Professional Open Source. |
| 3 | + * Copyright 2010, Red Hat, Inc., and individual contributors |
| 4 | + * as indicated by the @author tags. See the copyright.txt file in the |
| 5 | + * distribution for a full listing of individual contributors. |
| 6 | + * |
| 7 | + * This is free software; you can redistribute it and/or modify it |
| 8 | + * under the terms of the GNU Lesser General Public License as |
| 9 | + * published by the Free Software Foundation; either version 2.1 of |
| 10 | + * the License, or (at your option) any later version. |
| 11 | + * |
| 12 | + * This software is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | + * Lesser General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Lesser General Public |
| 18 | + * License along with this software; if not, write to the Free |
| 19 | + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 20 | + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. |
| 21 | + */ |
| 22 | + |
| 23 | +package org.jboss.staxmapper; |
| 24 | + |
| 25 | +import java.util.Iterator; |
| 26 | +import java.util.NoSuchElementException; |
| 27 | + |
| 28 | +/** |
| 29 | + * @author <a href="mailto:[email protected]">David M. Lloyd</a> |
| 30 | + */ |
| 31 | +final class Spliterator implements Iterator<String> { |
| 32 | + private final String subject; |
| 33 | + private final char delimiter; |
| 34 | + private int i; |
| 35 | + |
| 36 | + Spliterator(final String subject, final char delimiter) { |
| 37 | + this.subject = subject; |
| 38 | + this.delimiter = delimiter; |
| 39 | + i = 0; |
| 40 | + } |
| 41 | + |
| 42 | + static Spliterator over(String subject, char delimiter) { |
| 43 | + return new Spliterator(subject, delimiter); |
| 44 | + } |
| 45 | + |
| 46 | + @Override |
| 47 | + public boolean hasNext() { |
| 48 | + return i != -1; |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public String next() { |
| 53 | + final int i = this.i; |
| 54 | + if (i == -1) { |
| 55 | + throw new NoSuchElementException(); |
| 56 | + } |
| 57 | + int n = subject.indexOf(delimiter, i); |
| 58 | + try { |
| 59 | + return n == -1 ? subject.substring(i) : subject.substring(i, n); |
| 60 | + } finally { |
| 61 | + this.i = n == -1 ? -1 : n + 1; |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public void remove() { |
| 67 | + throw new UnsupportedOperationException(); |
| 68 | + } |
| 69 | +} |
0 commit comments