1 28 29 package com.caucho.xsl.java; 30 31 import com.caucho.java.JavaWriter; 32 import com.caucho.xml.QName; 33 import com.caucho.xsl.XslParseException; 34 35 import java.text.DecimalFormatSymbols ; 36 37 40 public class XslDecimalFormat extends XslNode implements XslTopNode { 41 private String _name; 42 private String _decimalSeparator; 43 private String _groupingSeparator; 44 private String _infinity; 45 private String _minusSign; 46 private String _nan; 47 private String _percent; 48 private String _perMille; 49 private String _zeroDigit; 50 private String _digit; 51 private String _patternSeparator; 52 53 56 public String getTagName() 57 { 58 return "xsl:decimal-format"; 59 } 60 61 64 public void addAttribute(QName name, String value) 65 throws XslParseException 66 { 67 if (name.getName().equals("name")) 68 _name = value; 69 else if (name.getName().equals("decimal-separator")) 70 _decimalSeparator = value; 71 else if (name.getName().equals("grouping-separator")) 72 _groupingSeparator = value; 73 else if (name.getName().equals("infinity")) 74 _infinity = value; 75 else if (name.getName().equals("minus-sign")) 76 _minusSign = value; 77 else if (name.getName().equals("NaN")) 78 _nan = value; 79 else if (name.getName().equals("percent")) 80 _percent = value; 81 else if (name.getName().equals("per-mille")) 82 _perMille = value; 83 else if (name.getName().equals("zero-digit")) 84 _zeroDigit = value; 85 else if (name.getName().equals("digit")) 86 _digit = value; 87 else if (name.getName().equals("pattern-separator")) 88 _patternSeparator = value; 89 else 90 super.addAttribute(name, value); 91 } 92 93 96 public void endAttributes() 97 throws XslParseException 98 { 99 } 100 101 104 public void endElement() 105 throws Exception 106 { 107 String name = _name; 108 109 if (name == null) 110 name = "*"; 111 112 DecimalFormatSymbols format = new DecimalFormatSymbols (); 113 114 if (_decimalSeparator != null && _decimalSeparator.length() > 0) 115 format.setDecimalSeparator(_decimalSeparator.charAt(0)); 116 117 if (_groupingSeparator != null && _groupingSeparator.length() > 0) 118 format.setGroupingSeparator(_groupingSeparator.charAt(0)); 119 120 if (_infinity != null) 121 format.setInfinity(_infinity); 122 123 if (_minusSign != null && _minusSign.length() > 0) 124 format.setMinusSign(_minusSign.charAt(0)); 125 126 if (_nan != null) 127 format.setNaN(_nan); 128 129 if (_percent != null && _percent.length() > 0) 130 format.setPercent(_percent.charAt(0)); 131 132 if (_perMille != null && _perMille.length() > 0) 133 format.setPerMill(_perMille.charAt(0)); 134 135 if (_zeroDigit != null && _zeroDigit.length() > 0) 136 format.setZeroDigit(_zeroDigit.charAt(0)); 137 138 if (_digit != null && _digit.length() > 0) 139 format.setDigit(_digit.charAt(0)); 140 141 if (_patternSeparator != null && _patternSeparator.length() > 0) 142 format.setPatternSeparator(_patternSeparator.charAt(0)); 143 144 _gen.addLocale(name, format); 145 } 146 147 152 public void generate(JavaWriter out) 153 throws Exception 154 { 155 } 156 } 157 | Popular Tags |