src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/AttributeValueTemplate.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
|
3 * @LastModified: Oct 2017 |
3 */ |
4 */ |
4 /* |
5 /* |
5 * Licensed to the Apache Software Foundation (ASF) under one or more |
6 * Licensed to the Apache Software Foundation (ASF) under one or more |
6 * contributor license agreements. See the NOTICE file distributed with |
7 * contributor license agreements. See the NOTICE file distributed with |
7 * this work for additional information regarding copyright ownership. |
8 * this work for additional information regarding copyright ownership. |
21 * $Id: AttributeValueTemplate.java,v 1.2.4.1 2005/09/01 10:26:57 pvedula Exp $ |
22 * $Id: AttributeValueTemplate.java,v 1.2.4.1 2005/09/01 10:26:57 pvedula Exp $ |
22 */ |
23 */ |
23 |
24 |
24 package com.sun.org.apache.xalan.internal.xsltc.compiler; |
25 package com.sun.org.apache.xalan.internal.xsltc.compiler; |
25 |
26 |
26 import java.util.Enumeration; |
|
27 import java.util.Vector; |
|
28 import java.util.StringTokenizer; |
|
29 import java.util.NoSuchElementException; |
|
30 |
|
31 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; |
27 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; |
32 import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; |
28 import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL; |
33 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; |
29 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; |
34 import com.sun.org.apache.bcel.internal.generic.Instruction; |
30 import com.sun.org.apache.bcel.internal.generic.Instruction; |
35 import com.sun.org.apache.bcel.internal.generic.InstructionList; |
31 import com.sun.org.apache.bcel.internal.generic.InstructionList; |
39 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; |
35 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; |
40 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; |
36 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; |
41 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; |
37 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; |
42 import java.util.Iterator; |
38 import java.util.Iterator; |
43 import java.util.List; |
39 import java.util.List; |
|
40 import java.util.NoSuchElementException; |
|
41 import java.util.StringTokenizer; |
44 |
42 |
45 /** |
43 /** |
46 * @author Jacek Ambroziak |
44 * @author Jacek Ambroziak |
47 * @author Santiago Pericas-Geertsen |
45 * @author Santiago Pericas-Geertsen |
48 */ |
46 */ |
84 * Simple automaton to parse ATVs, delimit expressions and report |
82 * Simple automaton to parse ATVs, delimit expressions and report |
85 * errors. |
83 * errors. |
86 */ |
84 */ |
87 String t = null; |
85 String t = null; |
88 String lookahead = null; |
86 String lookahead = null; |
89 StringBuffer buffer = new StringBuffer(); |
87 StringBuilder buffer = new StringBuilder(); |
90 int state = OUT_EXPR; |
88 int state = OUT_EXPR; |
91 |
89 |
92 while (tokenizer.hasMoreTokens()) { |
90 while (tokenizer.hasMoreTokens()) { |
93 // Use lookahead if available |
91 // Use lookahead if available |
94 if (lookahead != null) { |
92 if (lookahead != null) { |
218 } |
216 } |
219 return _type = Type.String; |
217 return _type = Type.String; |
220 } |
218 } |
221 |
219 |
222 public String toString() { |
220 public String toString() { |
223 final StringBuffer buffer = new StringBuffer("AVT:["); |
221 final StringBuilder buffer = new StringBuilder("AVT:["); |
224 final int count = elementCount(); |
222 final int count = elementCount(); |
225 for (int i = 0; i < count; i++) { |
223 for (int i = 0; i < count; i++) { |
226 buffer.append(elementAt(i).toString()); |
224 buffer.append(elementAt(i).toString()); |
227 if (i < count - 1) |
225 if (i < count - 1) |
228 buffer.append(' '); |
226 buffer.append(' '); |
250 "toString", |
248 "toString", |
251 "()"+STRING_SIG); |
249 "()"+STRING_SIG); |
252 il.append(new NEW(cpg.addClass(STRING_BUFFER_CLASS))); |
250 il.append(new NEW(cpg.addClass(STRING_BUFFER_CLASS))); |
253 il.append(DUP); |
251 il.append(DUP); |
254 il.append(new INVOKESPECIAL(initBuffer)); |
252 il.append(new INVOKESPECIAL(initBuffer)); |
255 // StringBuffer is on the stack |
253 // StringBuilder is on the stack |
256 final Iterator<SyntaxTreeNode> elements = elements(); |
254 final Iterator<SyntaxTreeNode> elements = elements(); |
257 while (elements.hasNext()) { |
255 while (elements.hasNext()) { |
258 final Expression exp = (Expression)elements.next(); |
256 final Expression exp = (Expression)elements.next(); |
259 exp.translate(classGen, methodGen); |
257 exp.translate(classGen, methodGen); |
260 il.append(append); |
258 il.append(append); |