1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.common; 26 27 import java.util.List ; 28 import java.util.ResourceBundle ; 29 import java.text.MessageFormat ; 30 31 42 public class ListMapping { 43 44 private static final ResourceBundle bundle = ResourceBundle.getBundle( 46 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.Bundle"); 48 private static final String formatPattern = bundle.getString("LBL_SizeOfListText"); 50 private List theList; 51 private String displayText; 52 private int listSize; 53 54 public ListMapping(List l) { 55 theList = l; 56 displayText = null; 57 listSize = 0; 58 } 59 60 public String toString() { 61 if(textOutOfDate()) { 62 buildDisplayText(); 63 } 64 65 return displayText; 66 } 67 68 private void buildDisplayText() { 69 listSize = (theList != null) ? theList.size() : 0; 70 Object [] args = { new Integer (listSize) }; 71 displayText = MessageFormat.format(formatPattern, args); 72 } 73 74 private boolean textOutOfDate() { 75 if(displayText == null) { 77 return true; 78 } 79 80 int newListSize = 0; 81 if(theList != null) { 82 newListSize = theList.size(); 83 } 84 85 if(listSize != newListSize) { 86 return true; 87 } 88 89 return false; 90 } 91 92 public List getList() { 93 return theList; 94 } 95 } 96 | Popular Tags |