1 18 package org.apache.beehive.netui.tags.databinding.repeater.pad; 19 20 import org.apache.beehive.netui.util.internal.InternalStringBuilder; 21 22 28 public class PadContext { 29 30 private static final String EMPTY_STRING = ""; 31 32 35 static final int DEFAULT_VALUE = -1; 36 37 private int _maxRepeat = DEFAULT_VALUE; 38 private int _minRepeat = DEFAULT_VALUE; 39 private String _padText = EMPTY_STRING; 40 41 46 public PadContext(String padText, int minRepeat, int maxRepeat) { 47 _padText = (padText != null ? padText : EMPTY_STRING); 48 _minRepeat = minRepeat; 49 _maxRepeat = maxRepeat; 50 } 51 52 57 public String getPadText() { 58 return _padText; 59 } 60 61 66 public int getMinRepeat() { 67 return _minRepeat; 68 } 69 70 75 public int getMaxRepeat() { 76 return _maxRepeat; 77 } 78 79 83 public boolean checkMinRepeat(int currCount) { 84 if(_minRepeat == DEFAULT_VALUE) 85 return true; 86 else if(currCount >= _minRepeat) 87 return true; 88 else return false; 89 } 90 91 95 public boolean checkMaxRepeat(int currCount) { 96 if(_maxRepeat == DEFAULT_VALUE) 97 return false; 98 else if(currCount < _maxRepeat) 99 return false; 100 else return true; 101 } 102 103 108 public String toString() { 109 InternalStringBuilder buf = new InternalStringBuilder(32); 110 buf.append("\nPadContext: "); 111 buf.append("padText: " + _padText + "\n"); 112 buf.append("minRepeat: " + _minRepeat + "\n"); 113 buf.append("maxRepeat: " + _maxRepeat + "\n"); 114 return buf.toString(); 115 } 116 } 117 | Popular Tags |