View Javadoc
1 /* 2 * ConfigurationAdapter.java 3 * 4 * Created on March 27, 2003, 1:10 AM 5 */ 6 7 package com.mlw.vlh.adapter; 8 9 import java.util.ArrayList; 10 import java.util.HashMap; 11 import java.util.Iterator; 12 import java.util.Map; 13 14 import com.mlw.vlh.ValueList; 15 import com.mlw.vlh.ValueListAdapter; 16 import com.mlw.vlh.ValueListInfo; 17 import com.mlw.vlh.impl.DefaultValueList; 18 19 /*** 20 * 21 * @author Matthew Wilson 22 */ 23 public class ConfigurationAdapter implements ValueListAdapter 24 { 25 private Map adapters = null; 26 27 /*** Creates a new instance of ConfigurationAdapter 28 */ 29 public ConfigurationAdapter(Map adapters) 30 { 31 if( adapters == null ) throw new NullPointerException("A non-null Map is required to construct a ConfigurationAdapter."); 32 this.adapters = new HashMap(adapters.size()); 33 for( Iterator iter = adapters.keySet().iterator(); iter.hasNext();) 34 { 35 String name = (String)iter.next(); 36 ValueListAdapter adapter = (ValueListAdapter)adapters.get(name); 37 38 this.adapters.put( name, 39 new AdapterInfo( 40 adapter.getClass().getName(), 41 (DO_SORT == (adapter.getAdapterType() & DO_SORT)), 42 (DO_FILTER == (adapter.getAdapterType() & DO_FILTER)), 43 (DO_PAGE == (adapter.getAdapterType() & DO_PAGE)) 44 ) 45 ); 46 } 47 } 48 49 /*** @see com.mlw.vlh.ValueListAdapter.getAdapterType() 50 */ 51 public int getAdapterType() 52 { 53 return DO_SORT | DO_FILTER | DO_PAGE; 54 } 55 56 /*** @see com.mlw.vlh.ValueListAdapter.getValueList(ValueListInfo info) 57 */ 58 public ValueList getValueList(ValueListInfo info) 59 { 60 return new DefaultValueList(new ArrayList(adapters.values()), info); 61 } 62 63 public class AdapterInfo 64 { 65 66 /*** Holds value of property clazz. */ 67 private String clazz; 68 69 /*** Holds value of property sort. */ 70 private boolean sort; 71 72 /*** Holds value of property filter. */ 73 private boolean filter; 74 75 /*** Holds value of property page. */ 76 private boolean page; 77 78 public AdapterInfo(String clazz, boolean sort, boolean filter, boolean page) 79 { 80 this.clazz = clazz; 81 this.sort = sort; 82 this.filter = filter; 83 this.page = page; 84 } 85 86 /*** Getter for property clazz. 87 * @return Value of property clazz. 88 */ 89 public String getClazz() 90 { 91 return this.clazz; 92 } 93 94 /*** Getter for property sort. 95 * @return Value of property sort. 96 */ 97 public boolean isSort() 98 { 99 return this.sort; 100 } 101 102 /*** Getter for property filter. 103 * @return Value of property filter. 104 */ 105 public boolean isFilter() 106 { 107 return this.filter; 108 } 109 110 111 /*** Getter for property page. 112 * @return Value of property page. 113 */ 114 public boolean isPage() 115 { 116 return this.page; 117 } 118 119 } 120 }

This page was automatically generated by Maven