277 |
public String toString() { return name(); } |
public String toString() { return name(); } |
278 |
|
|
279 |
public Object constantValue() { |
public Object constantValue() { |
280 |
|
return constantValue(new HashSet()); |
281 |
|
} |
282 |
|
|
283 |
|
public Object constantValue(Set visitedFields) { |
284 |
if (!isStatic() |
if (!isStatic() |
285 |
|| !isFinal() |
|| !isFinal() |
286 |
|| (!type().isPrimitive() && !"java.lang.String".equals(type().qualifiedTypeName())) |
|| (!type().isPrimitive() && !"java.lang.String".equals(type().qualifiedTypeName())) |
292 |
} |
} |
293 |
else { |
else { |
294 |
if (!constantValueEvaluated) { |
if (!constantValueEvaluated) { |
295 |
|
|
296 |
|
visitedFields.add(this); |
297 |
|
|
298 |
String expression = "(" + type().typeName() + ")(" + valueLiteral + ")"; |
String expression = "(" + type().typeName() + ")(" + valueLiteral + ")"; |
299 |
try { |
try { |
300 |
this.constantValue = Evaluator.evaluate(expression, |
this.constantValue = Evaluator.evaluate(expression, |
301 |
|
visitedFields, |
302 |
(ClassDocImpl)containingClass()); |
(ClassDocImpl)containingClass()); |
303 |
} |
} |
304 |
|
catch (CircularExpressionException e) { |
305 |
|
// FIXME: This should use the error reporter |
306 |
|
System.err.println("WARNING: Cannot resolve expression for field " + containingClass.qualifiedTypeName() + "." + name() + ": " + e.getMessage()); |
307 |
|
} |
308 |
catch (IllegalExpressionException ignore) { |
catch (IllegalExpressionException ignore) { |
309 |
} |
} |
310 |
constantValueEvaluated = true; |
constantValueEvaluated = true; |