1 9 package org.jboss.portal.server.theme; 10 11 import java.util.ArrayList ; 12 import java.util.Collections ; 13 import java.util.Iterator ; 14 15 19 public class Region 20 { 21 22 private String name; 23 private boolean sorted; 24 private ArrayList items; 25 26 public Region(String name) 27 { 28 if (name == null) 29 { 30 throw new NullPointerException (); 31 } 32 this.name = name; 33 sorted = false; 34 } 35 36 public String getName() 37 { 38 return name; 39 } 40 41 public void add(Item item) 42 { 43 if (items == null) 44 { 45 items = new ArrayList (); 46 } 47 items.add(item); 48 } 49 50 public boolean isEmpty() 51 { 52 if (items == null) 53 { 54 return true; 55 } 56 else 57 { 58 return items.isEmpty(); 59 } 60 } 61 62 public Iterator items() 63 { 64 if (items == null) 65 { 66 return Collections.EMPTY_LIST.iterator(); 67 } 68 if (!sorted) 69 { 70 Collections.sort(items); 71 sorted = true; 72 } 73 return items.iterator(); 74 } 75 } 76 | Popular Tags |