1 5 package com.opensymphony.webwork.config; 6 7 import java.util.HashSet ; 8 import java.util.Iterator ; 9 import java.util.Set ; 10 11 12 21 public class DelegatingConfiguration extends Configuration { 22 24 Configuration[] configList; 25 26 28 33 public DelegatingConfiguration(Configuration[] aConfigList) { 34 configList = aConfigList; 35 } 36 37 39 45 public void setImpl(String name, Object value) throws IllegalArgumentException , UnsupportedOperationException { 46 IllegalArgumentException e = null; 49 50 for (int i = 0; i < configList.length; i++) { 51 try { 52 configList[i].getImpl(name); 53 54 configList[i].setImpl(name, value); 56 57 return; 59 } catch (IllegalArgumentException ex) { 60 e = ex; 61 62 } 64 } 65 66 throw e; 67 } 68 69 75 public Object getImpl(String name) throws IllegalArgumentException { 76 IllegalArgumentException e = null; 78 79 for (int i = 0; i < configList.length; i++) { 80 try { 81 return configList[i].getImpl(name); 82 } catch (IllegalArgumentException ex) { 83 e = ex; 84 85 } 87 } 88 89 throw e; 90 } 91 92 99 public boolean isSetImpl(String aName) { 100 for (int i = 0; i < configList.length; i++) { 101 if (configList[i].isSetImpl(aName)) { 102 return true; 103 } 104 } 105 106 return false; 107 } 108 109 115 public Iterator listImpl() { 116 boolean workedAtAll = false; 117 118 Set settingList = new HashSet (); 119 UnsupportedOperationException e = null; 120 121 for (int i = 0; i < configList.length; i++) { 122 try { 123 Iterator list = configList[i].listImpl(); 124 125 while (list.hasNext()) { 126 settingList.add(list.next()); 127 } 128 129 workedAtAll = true; 130 } catch (UnsupportedOperationException ex) { 131 e = ex; 132 133 } 135 } 136 137 if (!workedAtAll) { 138 throw (e == null) ? new UnsupportedOperationException () : e; 139 } else { 140 return settingList.iterator(); 141 } 142 } 143 } 144 | Popular Tags |