Revision 43809 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/AbstractLexicalAnalyzer.java
AbstractLexicalAnalyzer.java | ||
---|---|---|
7 | 7 |
import java.util.Locale; |
8 | 8 |
import java.util.Map; |
9 | 9 |
import java.util.Stack; |
10 |
import org.gvsig.tools.lang.Cloneable; |
|
10 | 11 |
|
11 | 12 |
public abstract class AbstractLexicalAnalyzer implements LexicalAnalyzer { |
12 | 13 |
|
13 |
protected class Buffer { |
|
14 |
protected class Buffer implements Cloneable {
|
|
14 | 15 |
|
15 | 16 |
StringBuilder builder; |
16 | 17 |
|
... | ... | |
18 | 19 |
this.builder = new StringBuilder(); |
19 | 20 |
} |
20 | 21 |
|
22 |
@Override |
|
23 |
public Buffer clone() throws CloneNotSupportedException { |
|
24 |
Buffer other = (Buffer) super.clone(); |
|
25 |
other.builder = new StringBuilder(builder); |
|
26 |
return other; |
|
27 |
} |
|
28 |
|
|
21 | 29 |
public void clear() { |
22 | 30 |
builder.delete(0, builder.length()); |
23 | 31 |
} |
... | ... | |
38 | 46 |
|
39 | 47 |
protected static final char EOF = 0; |
40 | 48 |
|
41 |
private final NumberFormat nf;
|
|
42 |
private final ParsePosition nfPos;
|
|
43 |
private final Stack<Integer> states;
|
|
49 |
private NumberFormat nf; |
|
50 |
private ParsePosition nfPos; |
|
51 |
private Stack<Integer> states; |
|
44 | 52 |
private String source; |
45 | 53 |
private int position; |
46 | 54 |
|
47 |
protected final Buffer buffer;
|
|
48 |
protected final DefaultToken token;
|
|
49 |
protected final Map<String, Integer> tokens;
|
|
55 |
protected Buffer buffer; |
|
56 |
protected DefaultToken token; |
|
57 |
protected Map<String, Integer> tokens; |
|
50 | 58 |
|
51 | 59 |
public AbstractLexicalAnalyzer(String source) { |
52 | 60 |
this.position = 0; |
... | ... | |
66 | 74 |
} |
67 | 75 |
|
68 | 76 |
@Override |
77 |
public LexicalAnalyzer clone() throws CloneNotSupportedException { |
|
78 |
AbstractLexicalAnalyzer other = (AbstractLexicalAnalyzer) super.clone(); |
|
79 |
other.nf = NumberFormat.getInstance(Locale.UK); |
|
80 |
other.nfPos = new ParsePosition(0); |
|
81 |
other.buffer = buffer.clone(); |
|
82 |
other.token = (DefaultToken) token.clone(); |
|
83 |
other.states = new Stack<>(); |
|
84 |
other.states.addAll(states); |
|
85 |
other.tokens = new HashMap<>(tokens); |
|
86 |
return other; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
69 | 90 |
public void setSource(String source) { |
70 | 91 |
this.source = source; |
71 | 92 |
this.position = 0; |
Also available in: Unified diff