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 import org.netbeans.modules.j2ee.sun.dd.api.CommonDDBean; 32 33 34 43 public class BeanListMapping { 44 45 private static final ResourceBundle bundle = ResourceBundle.getBundle( 47 "org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.Bundle"); 49 private static final String formatPattern = bundle.getString("LBL_SizeOfListText"); 51 private CommonDDBean theBean; 52 private String listPropertyName; 53 private String displayText; 54 private int listSize; 55 56 public BeanListMapping(CommonDDBean bean, String propertyName) { 57 theBean = bean; 58 listPropertyName = propertyName; 59 displayText = null; 60 listSize = 0; 61 } 62 63 public String toString() { 64 if(textOutOfDate()) { 65 buildDisplayText(); 66 } 67 68 return displayText; 69 } 70 71 private void buildDisplayText() { 72 listSize = (theBean != null) ? theBean.size(listPropertyName) : 0; 73 Object [] args = { new Integer (listSize) }; 74 displayText = MessageFormat.format(formatPattern, args); 75 } 76 77 private boolean textOutOfDate() { 78 if(displayText == null) { 80 return true; 81 } 82 83 int newListSize = 0; 84 if(theBean != null) { 85 newListSize = theBean.size(listPropertyName); 86 } 87 88 if(listSize != newListSize) { 89 return true; 90 } 91 92 return false; 93 } 94 95 public CommonDDBean getBean() { 96 return theBean; 97 } 98 99 public String getListPropertyName() { 100 return listPropertyName; 101 } 102 } 103 | Popular Tags |