1 // Decompiled by DJ v3.10.10.93 Copyright 2007 Atanas Neshkov Date: 8/25/2008 3:01:07 PM
2 // Home Page: http://members.fortunecity.com/neshkov/dj.html http://www.neshkov.com/dj.html - Check often for new version!
3 // Decompiler options: packimports(3)
4 // Source File Name: SingleValueInstanceFactory.java
5
6 package net.sf.beanrunner.factory.impl;
7
8
9 import java.util.*;
10
11 import net.sf.beanrunner.factory.InstanceFactory;
12
13 public class SingleValueInstanceFactory
14 implements InstanceFactory
15 {
16 private List list = new ArrayList();
17
18 public SingleValueInstanceFactory(Object v)
19 {
20 list.add(v);
21 }
22
23 /**
24 * A package friendly constructor. Prefer the constructor that takes an arg.
25 */
26 SingleValueInstanceFactory() {
27 // EMPTY
28 }
29 /**
30 * Set a new return value. If one has already been set, override it.
31 * @param value the value to set
32 */
33 void setValue(Object value){
34 list.clear();
35 list.add(value);
36 }
37
38
39 public Iterator iterator()
40 throws Exception
41 {
42 if(list.size() != 1) {
43 throw new IllegalStateException("Must have one and only one value");
44 }
45 return list.iterator();
46 }
47
48 }