File: NativeCollections.java

package info (click to toggle)
castor 1.3.2-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 44,976 kB
  • sloc: java: 206,032; xml: 95,088; sql: 14,460; sh: 365; makefile: 10
file content (60 lines) | stat: -rw-r--r-- 2,930 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import java.util.Collection;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Vector;

/**
 * Test native access to collection arrays.  Create some killers to ensure that they're used.
 * @author gblock
 */
public class NativeCollections {
	public Testable[] arrayOfNT;
	public Vector vectorOfNT;
	public Hashtable hashtableOfNT;
	public Collection collectionOfNT;
	public Set setOfNT;
	public Map mapOfNT;
	
	public Testable[] getArrayOfNT() { throw new RuntimeException(); }
	public void setArrayOfNT(Testable[] arr) { throw new RuntimeException(); }
	public Vector getVectorOfNT() { throw new RuntimeException(); }
	public void setVectorOfNT(Vector v) { throw new RuntimeException(); }
	public Hashtable getHashtableOfNT() { throw new RuntimeException(); }
	public void setHashtableOfNT(Hashtable ht) { throw new RuntimeException(); }
	public Collection getCollectionOfNT() { throw new RuntimeException(); }
	public void setCollectionOfNT(Collection c) { throw new RuntimeException(); }
	public Set getSetOfNT() { throw new RuntimeException(); }
	public void setSetOfNT(Set set) { throw new RuntimeException(); }
	public void setOfNT(Set set) { throw new RuntimeException(); }
	public void getMapOfNT() { throw new RuntimeException(); }
	public void setMapOfNT(Map map) { throw new RuntimeException(); }
	
	public void validate() {
		if (arrayOfNT==null) throw new RuntimeException("arrayOfNT was not set");
		if (arrayOfNT.length!=1) throw new RuntimeException("arrayOfNT is not 1 long.");
		if (vectorOfNT==null||vectorOfNT.size()!=1) throw new RuntimeException("vectorOfNT is not 1 long.");
		if (collectionOfNT==null||collectionOfNT.size()<1) throw new RuntimeException("collectionOfNT is not 1 long.");
		if (setOfNT==null||setOfNT.size()<1) throw new RuntimeException("setOfNT is empty.");
		if (hashtableOfNT==null||hashtableOfNT.size()!=1) throw new RuntimeException("hashtableOfNT is not 1 long.");
		if (hashtableOfNT.get("test")==null) throw new RuntimeException("hashtableOfNT missing value for key 'test'");
		if (mapOfNT==null||mapOfNT.size()<1) throw new RuntimeException("mapOfNT is empty.");
		if (mapOfNT.get("test")==null) throw new RuntimeException("mapOfNT missing value for key 'test'");
		
		// Validate contents.
		for (int i=0; i<arrayOfNT.length; i++) {
			arrayOfNT[i].validate();
		}
		Iterator it = vectorOfNT.iterator();
		while (it.hasNext()) { ((Testable)it.next()).validate(); }
		it = collectionOfNT.iterator();
		while (it.hasNext()) { ((Testable)it.next()).validate(); }
		it = setOfNT.iterator();
		while (it.hasNext()) { ((Testable)it.next()).validate(); }
		it = hashtableOfNT.values().iterator();
		while (it.hasNext()) { ((Testable)it.next()).validate(); }
		it = mapOfNT.values().iterator();
		while (it.hasNext()) { ((Testable)it.next()).validate(); }
	}
}