1 16 package org.apache.taglibs.string; 17 18 import javax.servlet.jsp.JspException ; 19 import org.apache.taglibs.string.util.StringW; 20 import org.apache.commons.lang.math.NumberUtils; 21 22 50 public class WordWrapTag extends StringTagSupport { 51 52 private String delimiter; 53 private String width; 54 private String split; 55 private boolean delimiterInside; 56 57 public WordWrapTag() { 58 super(); 59 } 60 61 66 public String getWidth() { 67 return this.width; 68 } 69 70 75 public void setWidth(String width) { 76 this.width = width; 77 } 78 79 80 85 public String getDelimiter() { 86 return this.delimiter; 87 } 88 89 94 public void setDelimiter(String delimiter) { 95 this.delimiter = delimiter; 96 } 97 98 99 104 public String getSplit() { 105 return this.split; 106 } 107 108 113 public void setSplit(String split) { 114 this.split = split; 115 } 116 117 122 public boolean getDelimiterInside() { 123 return this.delimiterInside; 124 } 125 126 131 public void setDelimiterInside(boolean delimiterInside) { 132 this.delimiterInside = delimiterInside; 133 } 134 135 public String changeString(String text) throws JspException { 136 return StringW.wordWrap(text, NumberUtils.stringToInt(width), delimiter, split, delimiterInside ); 137 } 138 139 public void initAttributes() { 140 141 this.width = "80"; 142 143 this.delimiter = "\n"; 144 145 this.split = "-"; 146 147 this.delimiterInside = true; 148 } 149 150 } 151 | Popular Tags |