| 1 17 18 package com.finalist.jag.taglib; 19 20 21 import com.finalist.jag.*; 22 import com.finalist.jag.taglib.util.RequestUtil; 23 import com.finalist.jaggenerator.Utils; 24 25 import java.util.*; 26 27 28 35 public class WriteTag extends TagSupport { 36 37 38 private String name = null; 39 40 41 private String property = null; 42 43 44 private String display = null; 45 46 47 private String pathEnable = null; 48 49 51 58 public void setName(String name) { 59 this.name = name; 60 } 61 62 69 public void setProperty(String property) { 70 this.property = property; 71 } 72 73 80 public String getName() { 81 return (this.name); 82 } 83 84 91 public String getProperty() { 92 return (this.property); 93 } 94 95 102 public String getDisplay() { 103 return (this.display); 104 } 105 106 113 public void setDisplay(String display) { 114 this.display = display; 115 } 116 117 124 public String getPathenable() { 125 return (this.pathEnable); 126 } 127 128 135 public void setPathenable(String pathEnable) { 136 this.pathEnable = pathEnable; 137 } 138 139 148 public int doStartTag() throws JagException { 149 150 SessionContext session = getPageContext().getSessionContext(); 151 String value = RequestUtil.lookupString(getPageContext(), 152 name, property); 153 154 if (value == null) { 155 throw new JagException("WriteTag: Invalid name field \"" + name 156 + "\" (property=\"" + property + "\")"); 157 } 158 159 if (display != null) { 160 display = display.toLowerCase(); 161 162 if (display.equals("lower")) { 163 value = value.toLowerCase(); 164 } 165 else if (display.equals("upper")) { 166 value = value.toUpperCase(); 167 } 168 else if (display.equals("sentensize")) { 169 if (value.length() > 1) { 170 String tmp = value.substring(0, 1).toUpperCase(); 171 172 value = value.substring(1); 173 value = tmp + value; 174 } else { 175 value = value.toUpperCase(); 176 } 177 } 178 else if (display.equals("desentensize")) { 179 if (value.length() > 1) { 180 String tmp = value.substring(0, 1).toLowerCase(); 181 182 value = value.substring(1); 183 value = tmp + value; 184 } else { 185 value = value.toLowerCase(); 186 } 187 } 188 else if (display.equals("crazy_struts")) { 189 if (value.length() > 1 && 192 Character.isLowerCase(value.charAt(0)) && Character.isUpperCase(value.charAt(1))) { 193 value = Character.toUpperCase(value.charAt(0)) + value.substring(1); 194 } 195 } 196 } 197 198 if ((pathEnable != null) && pathEnable.equals("true")) { 199 value = value.replace('.', '/'); 200 } 201 202 getWriter().print(value); 203 204 return (EVAL_PAGE); 205 } 206 207 } | Popular Tags |