1 18 19 package org.apache.struts.webapp.tiles.portal; 20 21 import java.util.ArrayList ; 22 import java.util.Iterator ; 23 import java.util.List ; 24 25 26 32 public class PortalCatalog 33 { 34 35 protected List tiles = new ArrayList (); 36 37 protected List tileLabels = new ArrayList (); 38 39 44 public void setTiles( List list) 45 { 46 setTiles(list, list); 47 } 48 49 54 public void addTiles( List list) 55 { 56 addTiles( list, list); 57 } 58 59 67 public void setTiles( List list, List labels) 68 throws ArrayIndexOutOfBoundsException 69 { 70 if( labels == null ) 72 labels = list; 73 if( list.size() != labels.size() ) 75 { System.out.println( "Error : list and labels size must be the same." ); 77 throw new java.lang.ArrayIndexOutOfBoundsException ( "List of tiles and list of labels must be of the same size" ); 78 } 79 this.tiles = list; 80 tileLabels = labels; 81 } 82 83 91 public void addTiles( List list, List labels) 92 throws ArrayIndexOutOfBoundsException 93 { 94 if( labels == null ) 96 labels = list; 97 if(tiles== null) 99 { 100 setTiles(list, labels); 101 return; 102 } 103 104 if( list.size() != labels.size() ) 105 { System.out.println( "Error : list and labels size must be the same." ); 107 throw new java.lang.ArrayIndexOutOfBoundsException ( "List of tiles and list of labels must be of the same size" ); 108 } 109 tiles.addAll(list); 110 tileLabels.addAll(labels); 111 } 112 113 116 public List getTiles( ) 117 { 118 return tiles; 119 } 120 121 124 public List getTilesLabels( ) 125 { 126 return tileLabels; 127 } 128 129 133 public String getTileLabel( Object key ) 134 { 135 int index = tiles.indexOf( key ); 136 if(index==-1) 137 return null; 138 return (String )tileLabels.get(index); 139 } 140 141 145 public List getTileLabels( List Keys ) 146 { 147 List listLabels = new ArrayList (); 148 149 Iterator i = Keys.iterator(); 150 while(i.hasNext()) 151 { 152 Object key = i.next(); 153 listLabels.add( getTileLabel(key) ); 154 } return listLabels; 156 } 157 158 169 public List getTiles( String keys[] ) 170 { 171 List list = new ArrayList (); 172 173 for(int i=0;i<keys.length;i++) 175 { 176 String key = keys[i]; 177 if( key.indexOf( '@' )>0 ) 178 { } 180 if( tiles.contains( key ) ) 181 { list.add( key ); 183 } 184 } return list; 186 } 187 188 191 protected void setTileLabels( List list) 192 { 193 this.tileLabels = list; 194 } 195 198 protected void addTileLabels( List list) 199 { 200 if(tileLabels== null) 201 { 202 setTileLabels(list); 203 return; 204 } 205 tileLabels.addAll(list); 206 } 207 208 } 209 | Popular Tags |