Revision 44139 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.api/src/main/java/org/gvsig/expressionevaluator/spi/AbstractSymbolTable.java
AbstractSymbolTable.java | ||
---|---|---|
48 | 48 |
protected final List<SymbolTable> symbolTables; |
49 | 49 |
protected Map<String, Object> vars; |
50 | 50 |
protected Map<String, Function> functions; |
51 |
protected Map<String, Function> functionAlias; |
|
51 | 52 |
protected List<Script> scripts; |
52 | 53 |
|
53 | 54 |
public AbstractSymbolTable() { |
... | ... | |
59 | 60 |
this.symbolTables = new ArrayList<>(); |
60 | 61 |
this.vars = null; |
61 | 62 |
this.functions = null; |
63 |
this.functionAlias = null; |
|
62 | 64 |
this.scripts = null; |
63 | 65 |
} |
64 | 66 |
|
... | ... | |
72 | 74 |
throw new IllegalArgumentException("function can't be null"); |
73 | 75 |
} |
74 | 76 |
this.getFunctions().put(function.name().toUpperCase(), function); |
77 |
List<String> aliases = function.aliases(); |
|
78 |
if( aliases == null || aliases.isEmpty() ) { |
|
79 |
return; |
|
80 |
} |
|
81 |
Map<String, Function> theFunctionAlias = this.getFunctionAlias(); |
|
82 |
for (String alias : aliases) { |
|
83 |
if( alias!=null ) { |
|
84 |
theFunctionAlias.put(alias, function); |
|
85 |
} |
|
86 |
} |
|
75 | 87 |
} |
76 | 88 |
|
77 | 89 |
@Override |
... | ... | |
96 | 108 |
return this.functions; |
97 | 109 |
} |
98 | 110 |
|
111 |
protected Map<String, Function> getFunctionAlias() { |
|
112 |
if (this.functionAlias == null) { |
|
113 |
this.functionAlias = new HashMap<>(); |
|
114 |
} |
|
115 |
return this.functionAlias; |
|
116 |
} |
|
117 |
|
|
99 | 118 |
protected List<Script> getScripts() { |
100 | 119 |
if (this.scripts == null) { |
101 | 120 |
this.scripts = new ArrayList<>(); |
... | ... | |
151 | 170 |
return this.functions.get(name); |
152 | 171 |
} |
153 | 172 |
} |
173 |
if (this.functionAlias != null) { |
|
174 |
name = name.toUpperCase(); |
|
175 |
if (this.functionAlias.containsKey(name)) { |
|
176 |
return this.functionAlias.get(name); |
|
177 |
} |
|
178 |
} |
|
154 | 179 |
for (SymbolTable other : this.symbolTables) { |
155 | 180 |
Function fn = other.function(name); |
156 | 181 |
if (fn != null) { |
Also available in: Unified diff