Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 28 package net.sf.jasperreports.engine.xml; 29 30 import java.util.Collection ; 31 32 import net.sf.jasperreports.engine.JRExpression; 33 import net.sf.jasperreports.engine.design.JRDesignGroup; 34 import net.sf.jasperreports.engine.design.JRDesignTextField; 35 import net.sf.jasperreports.engine.design.JasperDesign; 36 37 import org.xml.sax.Attributes ; 38 39 40 44 public class JRTextFieldFactory extends JRBaseFactory 45 { 46 47 48 51 private static final String ATTRIBUTE_isStretchWithOverflow = "isStretchWithOverflow"; 52 private static final String ATTRIBUTE_evaluationTime = "evaluationTime"; 53 private static final String ATTRIBUTE_evaluationGroup = "evaluationGroup"; 54 private static final String ATTRIBUTE_pattern = "pattern"; 55 private static final String ATTRIBUTE_isBlankWhenNull = "isBlankWhenNull"; 56 private static final String ATTRIBUTE_hyperlinkType = "hyperlinkType"; 57 private static final String ATTRIBUTE_hyperlinkTarget = "hyperlinkTarget"; 58 private static final String ATTRIBUTE_bookmarkLevel = "bookmarkLevel"; 59 60 61 64 public Object createObject(Attributes atts) 65 { 66 JRXmlLoader xmlLoader = (JRXmlLoader)digester.peek(digester.getCount() - 1); 67 Collection groupEvaluatedTextFields = xmlLoader.getGroupEvaluatedTextFields(); 68 JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2); 69 70 JRDesignTextField textField = new JRDesignTextField(jasperDesign); 71 72 String isStretchWithOverflow = atts.getValue(ATTRIBUTE_isStretchWithOverflow); 73 if (isStretchWithOverflow != null && isStretchWithOverflow.length() > 0) 74 { 75 textField.setStretchWithOverflow(Boolean.valueOf(isStretchWithOverflow).booleanValue()); 76 } 77 78 Byte evaluationTime = (Byte )JRXmlConstants.getEvaluationTimeMap().get(atts.getValue(ATTRIBUTE_evaluationTime)); 79 if (evaluationTime != null) 80 { 81 textField.setEvaluationTime(evaluationTime.byteValue()); 82 } 83 if (textField.getEvaluationTime() == JRExpression.EVALUATION_TIME_GROUP) 84 { 85 groupEvaluatedTextFields.add(textField); 86 87 String groupName = atts.getValue(ATTRIBUTE_evaluationGroup); 88 if (groupName != null) 89 { 90 JRDesignGroup group = new JRDesignGroup(); 91 group.setName(groupName); 92 textField.setEvaluationGroup(group); 93 } 94 } 95 96 textField.setPattern(atts.getValue(ATTRIBUTE_pattern)); 97 98 String isBlankWhenNull = atts.getValue(ATTRIBUTE_isBlankWhenNull); 99 if (isBlankWhenNull != null && isBlankWhenNull.length() > 0) 100 { 101 textField.setBlankWhenNull(Boolean.valueOf(isBlankWhenNull)); 102 } 103 104 String hyperlinkType = atts.getValue(ATTRIBUTE_hyperlinkType); 105 if (hyperlinkType != null) 106 { 107 textField.setLinkType(hyperlinkType); 108 } 109 110 Byte hyperlinkTarget = (Byte )JRXmlConstants.getHyperlinkTargetMap().get(atts.getValue(ATTRIBUTE_hyperlinkTarget)); 111 if (hyperlinkTarget != null) 112 { 113 textField.setHyperlinkTarget(hyperlinkTarget.byteValue()); 114 } 115 116 String bookmarkLevelAttr = atts.getValue(ATTRIBUTE_bookmarkLevel); 117 if (bookmarkLevelAttr != null) 118 { 119 textField.setBookmarkLevel(Integer.parseInt(bookmarkLevelAttr)); 120 } 121 122 return textField; 123 } 124 125 126 } 127
| Popular Tags
|