24 |
import java.util.*; |
import java.util.*; |
25 |
import java.io.*; |
import java.io.*; |
26 |
import gnu.classpath.tools.gjdoc.expr.EvaluatorEnvironment; |
import gnu.classpath.tools.gjdoc.expr.EvaluatorEnvironment; |
27 |
|
import gnu.classpath.tools.gjdoc.expr.IllegalExpressionException; |
28 |
import gnu.classpath.tools.gjdoc.expr.UnknownIdentifierException; |
import gnu.classpath.tools.gjdoc.expr.UnknownIdentifierException; |
29 |
|
|
30 |
public class ClassDocImpl |
public class ClassDocImpl |
956 |
|
|
957 |
private Object findFieldValue(String identifier, |
private Object findFieldValue(String identifier, |
958 |
ClassDoc classDoc, |
ClassDoc classDoc, |
959 |
String fieldName) |
String fieldName, |
960 |
throws UnknownIdentifierException |
Set visitedFields) |
961 |
|
throws UnknownIdentifierException, IllegalExpressionException |
962 |
{ |
{ |
963 |
while (classDoc != null) { |
while (classDoc != null) { |
964 |
if (classDoc instanceof ClassDocImpl) { |
if (classDoc instanceof ClassDocImpl) { |
965 |
FieldDoc fieldDoc |
FieldDocImpl fieldDoc |
966 |
= ((ClassDocImpl)classDoc).getFieldDoc(fieldName); |
= (FieldDocImpl)((ClassDocImpl)classDoc).getFieldDoc(fieldName); |
967 |
if (null != fieldDoc) { |
if (visitedFields.contains(fieldDoc)) { |
968 |
return fieldDoc.constantValue(); |
throw new CircularExpressionException("Circular reference detected"); |
969 |
|
} |
970 |
|
else if (null != fieldDoc) { |
971 |
|
return fieldDoc.constantValue(visitedFields); |
972 |
} |
} |
973 |
} |
} |
974 |
else { |
else { |
976 |
if (null != _interfaces) { |
if (null != _interfaces) { |
977 |
for (int i=0; i<_interfaces.length; ++i) { |
for (int i=0; i<_interfaces.length; ++i) { |
978 |
if (_interfaces[i] instanceof ClassDocImpl) { |
if (_interfaces[i] instanceof ClassDocImpl) { |
979 |
FieldDoc fieldDoc |
FieldDocImpl fieldDoc |
980 |
= ((ClassDocImpl)_interfaces[i]).getFieldDoc(fieldName); |
= (FieldDocImpl)((ClassDocImpl)_interfaces[i]).getFieldDoc(fieldName); |
981 |
if (null != fieldDoc) { |
if (visitedFields.contains(fieldDoc)) { |
982 |
return fieldDoc.constantValue(); |
throw new CircularExpressionException("Circular reference detected"); |
983 |
|
} |
984 |
|
else if (null != fieldDoc) { |
985 |
|
return fieldDoc.constantValue(visitedFields); |
986 |
} |
} |
987 |
} |
} |
988 |
} |
} |
993 |
throw new UnknownIdentifierException(identifier); |
throw new UnknownIdentifierException(identifier); |
994 |
} |
} |
995 |
|
|
996 |
public Object getValue(String identifier) |
public Object getValue(String identifier, Set visitedFields) |
997 |
throws UnknownIdentifierException |
throws UnknownIdentifierException, IllegalExpressionException |
998 |
{ |
{ |
999 |
int ndx = identifier.lastIndexOf('.'); |
int ndx = identifier.lastIndexOf('.'); |
1000 |
if (ndx >= 0) { |
if (ndx >= 0) { |
1003 |
|
|
1004 |
ClassDoc _classDoc = findClass(_className); |
ClassDoc _classDoc = findClass(_className); |
1005 |
if (null != _classDoc) { |
if (null != _classDoc) { |
1006 |
return findFieldValue(identifier, _classDoc, _fieldName); |
return findFieldValue(identifier, _classDoc, _fieldName, visitedFields); |
1007 |
} |
} |
1008 |
else { |
else { |
1009 |
throw new UnknownIdentifierException(identifier); |
throw new UnknownIdentifierException(identifier); |
1010 |
} |
} |
1011 |
} |
} |
1012 |
else { |
else { |
1013 |
return findFieldValue(identifier, this, identifier); |
return findFieldValue(identifier, this, identifier, visitedFields); |
1014 |
} |
} |
1015 |
} |
} |
1016 |
|
|