1 28 package net.sf.jasperreports.engine.base; 29 30 import java.io.IOException ; 31 import java.io.ObjectInputStream ; 32 33 import net.sf.jasperreports.engine.JRAbstractObjectFactory; 34 import net.sf.jasperreports.engine.JRAnchor; 35 import net.sf.jasperreports.engine.JRChild; 36 import net.sf.jasperreports.engine.JRConstants; 37 import net.sf.jasperreports.engine.JRExpression; 38 import net.sf.jasperreports.engine.JRExpressionCollector; 39 import net.sf.jasperreports.engine.JRGroup; 40 import net.sf.jasperreports.engine.JRHyperlink; 41 import net.sf.jasperreports.engine.JRHyperlinkHelper; 42 import net.sf.jasperreports.engine.JRHyperlinkParameter; 43 import net.sf.jasperreports.engine.JRTextField; 44 import net.sf.jasperreports.engine.util.JRStyleResolver; 45 import net.sf.jasperreports.engine.xml.JRXmlWriter; 46 47 48 54 public class JRBaseTextField extends JRBaseTextElement implements JRTextField 55 { 56 57 58 61 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 62 63 66 protected boolean isStretchWithOverflow = false; 67 protected byte evaluationTime = JRExpression.EVALUATION_TIME_NOW; 68 protected String pattern; 69 protected Boolean isBlankWhenNull = null; 70 protected byte hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL; 71 protected String linkType; 72 protected byte hyperlinkTarget = JRHyperlink.HYPERLINK_TARGET_SELF; 73 private JRHyperlinkParameter[] hyperlinkParameters; 74 75 78 protected JRGroup evaluationGroup = null; 79 protected JRExpression expression = null; 80 protected JRExpression anchorNameExpression = null; 81 protected JRExpression hyperlinkReferenceExpression = null; 82 protected JRExpression hyperlinkAnchorExpression = null; 83 protected JRExpression hyperlinkPageExpression = null; 84 private JRExpression hyperlinkTooltipExpression; 85 86 90 protected int bookmarkLevel = JRAnchor.NO_BOOKMARK; 91 92 95 protected JRBaseTextField(JRTextField textField, JRBaseObjectFactory factory) 96 { 97 super(textField, factory); 98 99 isStretchWithOverflow = textField.isStretchWithOverflow(); 100 evaluationTime = textField.getEvaluationTime(); 101 pattern = textField.getOwnPattern(); 102 isBlankWhenNull = textField.isOwnBlankWhenNull(); 103 linkType = textField.getLinkType(); 104 hyperlinkTarget = textField.getHyperlinkTarget(); 105 hyperlinkParameters = JRBaseHyperlink.copyHyperlinkParameters(textField, factory); 106 107 evaluationGroup = factory.getGroup(textField.getEvaluationGroup()); 108 expression = factory.getExpression(textField.getExpression()); 109 anchorNameExpression = factory.getExpression(textField.getAnchorNameExpression()); 110 hyperlinkReferenceExpression = factory.getExpression(textField.getHyperlinkReferenceExpression()); 111 hyperlinkAnchorExpression = factory.getExpression(textField.getHyperlinkAnchorExpression()); 112 hyperlinkPageExpression = factory.getExpression(textField.getHyperlinkPageExpression()); 113 hyperlinkTooltipExpression = factory.getExpression(textField.getHyperlinkTooltipExpression()); 114 bookmarkLevel = textField.getBookmarkLevel(); 115 } 116 117 118 121 public boolean isStretchWithOverflow() 122 { 123 return this.isStretchWithOverflow; 124 } 125 126 129 public void setStretchWithOverflow(boolean isStretchWithOverflow) 130 { 131 this.isStretchWithOverflow = isStretchWithOverflow; 132 } 133 134 137 public byte getEvaluationTime() 138 { 139 return this.evaluationTime; 140 } 141 142 145 public String getPattern() 146 { 147 return JRStyleResolver.getPattern(this); 148 } 149 150 public String getOwnPattern() 151 { 152 return this.pattern; 153 } 154 155 158 public void setPattern(String pattern) 159 { 160 this.pattern = pattern; 161 } 162 163 166 public boolean isBlankWhenNull() 167 { 168 return JRStyleResolver.isBlankWhenNull(this); 169 } 170 171 174 public Boolean isOwnBlankWhenNull() 175 { 176 return isBlankWhenNull; 177 } 178 179 182 public void setBlankWhenNull(Boolean isBlank) 183 { 184 this.isBlankWhenNull = isBlank; 185 } 186 187 190 public void setBlankWhenNull(boolean isBlank) 191 { 192 this.isBlankWhenNull = isBlank ? Boolean.TRUE : Boolean.FALSE; 193 } 194 195 198 public byte getHyperlinkType() 199 { 200 return JRHyperlinkHelper.getHyperlinkType(this); 201 } 202 203 206 public byte getHyperlinkTarget() 207 { 208 return this.hyperlinkTarget; 209 } 210 211 214 public JRGroup getEvaluationGroup() 215 { 216 return this.evaluationGroup; 217 } 218 219 222 public JRExpression getExpression() 223 { 224 return this.expression; 225 } 226 227 230 public JRExpression getAnchorNameExpression() 231 { 232 return this.anchorNameExpression; 233 } 234 235 238 public JRExpression getHyperlinkReferenceExpression() 239 { 240 return this.hyperlinkReferenceExpression; 241 } 242 243 246 public JRExpression getHyperlinkAnchorExpression() 247 { 248 return this.hyperlinkAnchorExpression; 249 } 250 251 254 public JRExpression getHyperlinkPageExpression() 255 { 256 return this.hyperlinkPageExpression; 257 } 258 259 262 public JRChild getCopy(JRAbstractObjectFactory factory) 263 { 264 return factory.getTextField(this); 265 } 266 267 270 public void collectExpressions(JRExpressionCollector collector) 271 { 272 collector.collect(this); 273 } 274 275 278 public void writeXml(JRXmlWriter xmlWriter) throws IOException 279 { 280 xmlWriter.writeTextField(this); 281 } 282 283 284 public int getBookmarkLevel() 285 { 286 return bookmarkLevel; 287 } 288 289 290 public String getLinkType() 291 { 292 return linkType; 293 } 294 295 296 public JRHyperlinkParameter[] getHyperlinkParameters() 297 { 298 return hyperlinkParameters; 299 } 300 301 302 private void readObject(ObjectInputStream in) throws IOException , ClassNotFoundException 303 { 304 in.defaultReadObject(); 305 normalizeLinkType(); 306 } 307 308 309 protected void normalizeLinkType() 310 { 311 if (linkType == null) 312 { 313 linkType = JRHyperlinkHelper.getLinkType(hyperlinkType); 314 } 315 hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL; 316 } 317 318 319 public JRExpression getHyperlinkTooltipExpression() 320 { 321 return hyperlinkTooltipExpression; 322 } 323 324 } 325 | Popular Tags |