EMMA Coverage Report (generated Fri Jul 28 01:51:09 CEST 2006)
[all classes][org.jtiger.framework]

COVERAGE SUMMARY FOR SOURCE FILE [ReadOnlyArrayFactory.java]

nameclass, %method, %block, %line, %
ReadOnlyArrayFactory.java100% (4/4)100% (24/24)100% (204/204)100% (48/48)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ReadOnlyArrayFactory100% (1/1)100% (3/3)100% (25/25)100% (8/8)
ReadOnlyArrayFactory (): void 100% (1/1)100% (3/3)100% (2/2)
newReadOnlyArray (List): ReadOnlyArray 100% (1/1)100% (11/11)100% (3/3)
newReadOnlyArray (Object []): ReadOnlyArray 100% (1/1)100% (11/11)100% (3/3)
     
class ReadOnlyArrayFactory$ListReadOnlyArray100% (1/1)100% (8/8)100% (64/64)100% (16/16)
ReadOnlyArrayFactory$ListReadOnlyArray (List): void 100% (1/1)100% (6/6)100% (3/3)
clone (): ReadOnlyArray 100% (1/1)100% (4/4)100% (1/1)
equals (Object): boolean 100% (1/1)100% (20/20)100% (5/5)
get (int): Object 100% (1/1)100% (17/17)100% (3/3)
hashCode (): int 100% (1/1)100% (4/4)100% (1/1)
iterator (): Iterator 100% (1/1)100% (4/4)100% (1/1)
length (): int 100% (1/1)100% (4/4)100% (1/1)
toString (): String 100% (1/1)100% (5/5)100% (1/1)
     
class ReadOnlyArrayFactory$ReadOnlyArrayImpl100% (1/1)100% (9/9)100% (71/71)100% (17/17)
ReadOnlyArrayFactory$ReadOnlyArrayImpl (Object []): void 100% (1/1)100% (6/6)100% (3/3)
access$000 (ReadOnlyArrayFactory$ReadOnlyArrayImpl): Object [] 100% (1/1)100% (3/3)100% (1/1)
clone (): ReadOnlyArray 100% (1/1)100% (8/8)100% (1/1)
equals (Object): boolean 100% (1/1)100% (20/20)100% (5/5)
get (int): Object 100% (1/1)100% (17/17)100% (3/3)
hashCode (): int 100% (1/1)100% (4/4)100% (1/1)
iterator (): Iterator 100% (1/1)100% (5/5)100% (1/1)
length (): int 100% (1/1)100% (4/4)100% (1/1)
toString (): String 100% (1/1)100% (4/4)100% (1/1)
     
class ReadOnlyArrayFactory$ReadOnlyArrayImpl$IteratorImpl100% (1/1)100% (4/4)100% (44/44)100% (7/7)
ReadOnlyArrayFactory$ReadOnlyArrayImpl$IteratorImpl (ReadOnlyArrayFactory$Rea... 100% (1/1)100% (6/6)100% (2/2)
hasNext (): boolean 100% (1/1)100% (11/11)100% (1/1)
next (): Object 100% (1/1)100% (23/23)100% (3/3)
remove (): void 100% (1/1)100% (4/4)100% (1/1)

1/*
2 * JTiger Unit Testing Framework for J2SE 1.5
3 * Copyright (C) 2005 Tony Morris
4 *
5 * This software is licenced under the
6 * Common Public Licence version 1.0
7 * http://www.opensource.org/licenses/cpl1.0.php
8 *
9 * You received a copy of this licence with this software.
10 */
11package org.jtiger.framework;
12 
13import java.util.Arrays;
14import java.util.Iterator;
15import java.util.NoSuchElementException;
16import java.util.List;
17 
18/**
19 * Returns instances of {@link ReadOnlyArray} which are backed by a raw array that cannot be modified.
20 *
21 * @deprecated Use {@link SequenceFactory} instead.
22 * @see SequenceFactory
23 * @author %javadoc.author.tag%
24 * @version %version%<br/>
25 *          <i>Build Number %build.number%</i><br/>
26 *          <i>Build Time %build.time% CET (GMT + 1)</i>
27 */
28@Deprecated
29public final class ReadOnlyArrayFactory
30{
31    private ReadOnlyArrayFactory()
32    {
33 
34    }
35 
36    /**
37     * Returns a new instance of {@link ReadOnlyArray}.
38     *
39     * @deprecated Use {@link SequenceFactory#newSequence} instead.
40     * @param a The array that backs the returned {@link ReadOnlyArray}.
41     * @return A new instance of {@link ReadOnlyArray}.
42     * @throws NullPointerException If <code>a</code> is <code>null</code>.
43     */
44    @Deprecated
45    public static <E> ReadOnlyArray<E> newReadOnlyArray(final E... a) throws NullPointerException
46    {
47        if(a == null)
48        {
49            throw new NullPointerException();
50        }
51 
52        return new ReadOnlyArrayImpl<E>(a);
53    }
54 
55    /**
56     * Returns a new instance of {@link ReadOnlyArray}.
57     *
58     * @param l The {@link List} that backs the returned {@link ReadOnlyArray}.
59     * @return A new instance of {@link ReadOnlyArray}.
60     * @throws NullPointerException If <code>l</code> is <code>null</code>.
61     */
62    public static <E> ReadOnlyArray<E> newReadOnlyArray(final List<E> l) throws NullPointerException
63    {
64        if(l == null)
65        {
66            throw new NullPointerException();
67        }
68 
69        return new ListReadOnlyArray<E>(l);
70    }
71 
72    private static final class ReadOnlyArrayImpl<E> implements ReadOnlyArray<E>
73    {
74        private static final long serialVersionUID = 2L;
75 
76        private final E[] a;
77 
78        ReadOnlyArrayImpl(final E... a)
79        {
80            this.a = a;
81        }
82 
83        public E get(final int index) throws ArrayIndexOutOfBoundsException
84        {
85            if(index < 0 || index >= a.length)
86            {
87                throw new ArrayIndexOutOfBoundsException(index);
88            }
89            
90            return a[index];
91        }
92 
93        public int length()
94        {
95            return a.length;
96        }
97 
98        public Iterator<E> iterator()
99        {
100            return new IteratorImpl();
101        }
102 
103        @Override
104        public String toString()
105        {
106            return Arrays.toString(a);
107        }
108 
109        @Override
110        public boolean equals(final Object o)
111        {
112            if(this == o)
113            {
114                return true;
115            }
116 
117            if(o == null || o.getClass() != ReadOnlyArrayImpl.class)
118            {
119                return false;
120            }
121 
122            return Arrays.equals(((ReadOnlyArrayImpl)o).a, a);
123        }
124 
125        @Override
126        public int hashCode()
127        {
128            return Arrays.hashCode(a);
129        }
130 
131        public ReadOnlyArray<E> clone()
132        {
133            return new ReadOnlyArrayImpl<E>(a.clone());
134        }
135 
136        private final class IteratorImpl implements Iterator<E>
137        {
138            private int counter;
139 
140            IteratorImpl()
141            {
142 
143            }
144 
145            public boolean hasNext()
146            {
147                return counter < a.length;
148            }
149 
150            public E next()
151            {
152                if(counter < a.length)
153                {
154                    return a[counter++];
155                }
156                else
157                {
158                    throw new NoSuchElementException();
159                }
160            }
161 
162            public void remove()
163            {
164                throw new UnsupportedOperationException();
165            }
166        }
167    }
168 
169    private static final class ListReadOnlyArray<E> implements ReadOnlyArray<E>
170    {
171        private static final long serialVersionUID = 2L;
172 
173        private List<E> l;
174 
175        ListReadOnlyArray(final List<E> l)
176        {
177            this.l = l;
178        }
179 
180        public E get(final int index) throws ArrayIndexOutOfBoundsException
181        {
182            if(index < 0 || index >= l.size())
183            {
184                throw new ArrayIndexOutOfBoundsException(index);
185            }
186 
187            return l.get(index);
188        }
189 
190        public int length()
191        {
192            return l.size();
193        }
194 
195        public ReadOnlyArray<E> clone()
196        {
197            return newReadOnlyArray(l);
198        }
199 
200        public Iterator<E> iterator()
201        {
202            return l.iterator();
203        }
204 
205        @Override
206        public String toString()
207        {
208            return Arrays.toString(l.toArray());
209        }
210 
211        @Override
212        public boolean equals(final Object o)
213        {
214            if(this == o)
215            {
216                return true;
217            }
218 
219            if(o == null || o.getClass() != ListReadOnlyArray.class)
220            {
221                return false;
222            }
223 
224            return ((ListReadOnlyArray)o).l.equals(l);
225        }
226 
227        @Override
228        public int hashCode()
229        {
230            return l.hashCode();
231        }
232    }
233}

[all classes][org.jtiger.framework]
EMMA 2.0.5312 (C) Vladimir Roubtsov