1 28 package net.sf.jasperreports.engine.design; 29 30 import java.io.IOException ; 31 import java.io.ObjectInputStream ; 32 import java.util.ArrayList ; 33 import java.util.Iterator ; 34 import java.util.List ; 35 36 import net.sf.jasperreports.engine.JRAbstractObjectFactory; 37 import net.sf.jasperreports.engine.JRAnchor; 38 import net.sf.jasperreports.engine.JRChild; 39 import net.sf.jasperreports.engine.JRConstants; 40 import net.sf.jasperreports.engine.JRDefaultStyleProvider; 41 import net.sf.jasperreports.engine.JRExpression; 42 import net.sf.jasperreports.engine.JRExpressionCollector; 43 import net.sf.jasperreports.engine.JRGroup; 44 import net.sf.jasperreports.engine.JRHyperlink; 45 import net.sf.jasperreports.engine.JRHyperlinkHelper; 46 import net.sf.jasperreports.engine.JRHyperlinkParameter; 47 import net.sf.jasperreports.engine.JRTextField; 48 import net.sf.jasperreports.engine.util.JRStyleResolver; 49 import net.sf.jasperreports.engine.xml.JRXmlWriter; 50 51 53 54 58 public class JRDesignTextField extends JRDesignTextElement implements JRTextField 59 { 60 61 62 65 private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; 66 67 70 protected boolean isStretchWithOverflow = false; 71 protected byte evaluationTime = JRExpression.EVALUATION_TIME_NOW; 72 protected String pattern = null; 73 protected Boolean isBlankWhenNull = null; 74 protected byte hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL; 75 protected String linkType; 76 protected byte hyperlinkTarget = JRHyperlink.HYPERLINK_TARGET_SELF; 77 private List hyperlinkParameters; 78 79 82 protected JRGroup evaluationGroup = null; 83 protected JRExpression expression = null; 84 protected JRExpression anchorNameExpression = null; 85 protected JRExpression hyperlinkReferenceExpression = null; 86 protected JRExpression hyperlinkAnchorExpression = null; 87 protected JRExpression hyperlinkPageExpression = null; 88 private JRExpression hyperlinkTooltipExpression; 89 90 94 protected int bookmarkLevel = JRAnchor.NO_BOOKMARK; 95 96 97 100 public JRDesignTextField() 101 { 102 super(null); 103 104 hyperlinkParameters = new ArrayList (); 105 } 106 107 110 public JRDesignTextField(JRDefaultStyleProvider defaultStyleProvider) 111 { 112 super(defaultStyleProvider); 113 114 hyperlinkParameters = new ArrayList (); 115 } 116 117 118 121 public boolean isStretchWithOverflow() 122 { 123 return this.isStretchWithOverflow; 124 } 125 126 129 public byte getEvaluationTime() 130 { 131 return this.evaluationTime; 132 } 133 134 137 public String getPattern() 138 { 139 return JRStyleResolver.getPattern(this); 140 } 141 142 public String getOwnPattern() 143 { 144 return this.pattern; 145 } 146 147 150 public boolean isBlankWhenNull() 151 { 152 return JRStyleResolver.isBlankWhenNull(this); 153 } 154 155 158 public Boolean isOwnBlankWhenNull() 159 { 160 return isBlankWhenNull; 161 } 162 163 166 public byte getHyperlinkType() 167 { 168 return JRHyperlinkHelper.getHyperlinkType(this); 169 } 170 171 174 public byte getHyperlinkTarget() 175 { 176 return this.hyperlinkTarget; 177 } 178 179 182 public JRGroup getEvaluationGroup() 183 { 184 return this.evaluationGroup; 185 } 186 187 190 public JRExpression getExpression() 191 { 192 return this.expression; 193 } 194 195 198 public JRExpression getAnchorNameExpression() 199 { 200 return this.anchorNameExpression; 201 } 202 203 206 public JRExpression getHyperlinkReferenceExpression() 207 { 208 return this.hyperlinkReferenceExpression; 209 } 210 211 214 public JRExpression getHyperlinkAnchorExpression() 215 { 216 return this.hyperlinkAnchorExpression; 217 } 218 219 222 public JRExpression getHyperlinkPageExpression() 223 { 224 return this.hyperlinkPageExpression; 225 } 226 227 230 public void setStretchWithOverflow(boolean isStretch) 231 { 232 this.isStretchWithOverflow = isStretch; 233 } 234 235 238 public void setEvaluationTime(byte evaluationTime) 239 { 240 this.evaluationTime = evaluationTime; 241 } 242 243 246 public void setPattern(String pattern) 247 { 248 this.pattern = pattern; 249 } 250 251 254 public void setBlankWhenNull(boolean isBlank) 255 { 256 this.isBlankWhenNull = isBlank ? Boolean.TRUE : Boolean.FALSE; 257 } 258 259 262 public void setBlankWhenNull(Boolean isBlank) 263 { 264 this.isBlankWhenNull = isBlank; 265 } 266 267 273 public void setHyperlinkType(byte hyperlinkType) 274 { 275 setLinkType(JRHyperlinkHelper.getLinkType(hyperlinkType)); 276 } 277 278 281 public void setHyperlinkTarget(byte hyperlinkTarget) 282 { 283 this.hyperlinkTarget = hyperlinkTarget; 284 } 285 286 289 public void setEvaluationGroup(JRGroup evaluationGroup) 290 { 291 this.evaluationGroup = evaluationGroup; 292 } 293 294 297 public void setExpression(JRExpression expression) 298 { 299 this.expression = expression; 300 } 301 302 305 public void setAnchorNameExpression(JRExpression anchorNameExpression) 306 { 307 this.anchorNameExpression = anchorNameExpression; 308 } 309 310 313 public void setHyperlinkReferenceExpression(JRExpression hyperlinkReferenceExpression) 314 { 315 this.hyperlinkReferenceExpression = hyperlinkReferenceExpression; 316 } 317 318 321 public void setHyperlinkAnchorExpression(JRExpression hyperlinkAnchorExpression) 322 { 323 this.hyperlinkAnchorExpression = hyperlinkAnchorExpression; 324 } 325 326 329 public void setHyperlinkPageExpression(JRExpression hyperlinkPageExpression) 330 { 331 this.hyperlinkPageExpression = hyperlinkPageExpression; 332 } 333 334 337 public JRChild getCopy(JRAbstractObjectFactory factory) 338 { 339 return factory.getTextField(this); 340 } 341 342 345 public void collectExpressions(JRExpressionCollector collector) 346 { 347 collector.collect(this); 348 } 349 350 353 public void writeXml(JRXmlWriter xmlWriter) throws IOException 354 { 355 xmlWriter.writeTextField(this); 356 } 357 358 359 public int getBookmarkLevel() 360 { 361 return bookmarkLevel; 362 } 363 364 365 371 public void setBookmarkLevel(int bookmarkLevel) 372 { 373 this.bookmarkLevel = bookmarkLevel; 374 } 375 376 377 public String getLinkType() 378 { 379 return linkType; 380 } 381 382 383 392 public void setLinkType(String type) 393 { 394 this.linkType = type; 395 } 396 397 398 public JRHyperlinkParameter[] getHyperlinkParameters() 399 { 400 JRHyperlinkParameter[] parameters; 401 if (hyperlinkParameters.isEmpty()) 402 { 403 parameters = null; 404 } 405 else 406 { 407 parameters = new JRHyperlinkParameter[hyperlinkParameters.size()]; 408 hyperlinkParameters.toArray(parameters); 409 } 410 return parameters; 411 } 412 413 414 419 public List getHyperlinkParametersList() 420 { 421 return hyperlinkParameters; 422 } 423 424 425 430 public void addHyperlinkParameter(JRHyperlinkParameter parameter) 431 { 432 hyperlinkParameters.add(parameter); 433 } 434 435 436 441 public void removeHyperlinkParameter(JRHyperlinkParameter parameter) 442 { 443 hyperlinkParameters.remove(parameter); 444 } 445 446 447 456 public void removeHyperlinkParameter(String parameterName) 457 { 458 for (Iterator it = hyperlinkParameters.iterator(); it.hasNext();) 459 { 460 JRHyperlinkParameter parameter = (JRHyperlinkParameter) it.next(); 461 if (parameter.getName() != null && parameter.getName().equals(parameterName)) 462 { 463 it.remove(); 464 } 465 } 466 } 467 468 469 private void readObject(ObjectInputStream in) throws IOException , ClassNotFoundException 470 { 471 in.defaultReadObject(); 472 normalizeLinkType(); 473 } 474 475 476 protected void normalizeLinkType() 477 { 478 if (linkType == null) 479 { 480 linkType = JRHyperlinkHelper.getLinkType(hyperlinkType); 481 } 482 hyperlinkType = JRHyperlink.HYPERLINK_TYPE_NULL; 483 } 484 485 486 public JRExpression getHyperlinkTooltipExpression() 487 { 488 return hyperlinkTooltipExpression; 489 } 490 491 492 498 public void setHyperlinkTooltipExpression(JRExpression hyperlinkTooltipExpression) 499 { 500 this.hyperlinkTooltipExpression = hyperlinkTooltipExpression; 501 } 502 503 } 504 | Popular Tags |