24 |
import java.util.*; |
import java.util.*; |
25 |
import java.io.*; |
import java.io.*; |
26 |
|
|
27 |
public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc, WritableType { |
public class ClassDocImpl |
28 |
|
extends ProgramElementDocImpl |
29 |
|
implements ClassDoc, WritableType, EvaluatorEnvironment { |
30 |
|
|
31 |
private ClassDoc baseClassDoc; |
private ClassDoc baseClassDoc; |
32 |
private ClassDoc[] importedClasses; |
private ClassDoc[] importedClasses; |
388 |
for (int i=0; i<interfaces.length; ++i) { |
for (int i=0; i<interfaces.length; ++i) { |
389 |
interfaces[i]=new ClassDocProxy((String)implementedInterfaces.get(i), rc); |
interfaces[i]=new ClassDocProxy((String)implementedInterfaces.get(i), rc); |
390 |
} |
} |
391 |
|
Arrays.sort(interfaces); |
392 |
rc.setInterfaces(interfaces); |
rc.setInterfaces(interfaces); |
393 |
} |
} |
394 |
else { |
else { |
896 |
} |
} |
897 |
return null; |
return null; |
898 |
} |
} |
899 |
|
|
900 |
|
private Object findFieldValue(String identifier, |
901 |
|
ClassDoc classDoc, |
902 |
|
String fieldName) |
903 |
|
throws UnknownIdentifierException |
904 |
|
{ |
905 |
|
while (classDoc != null) { |
906 |
|
if (classDoc instanceof ClassDocImpl) { |
907 |
|
FieldDoc fieldDoc |
908 |
|
= ((ClassDocImpl)classDoc).getFieldDoc(fieldName); |
909 |
|
if (null != fieldDoc) { |
910 |
|
return fieldDoc.constantValue(); |
911 |
|
} |
912 |
|
} |
913 |
|
else { |
914 |
|
ClassDoc[] interfaces = classDoc.interfaces(); |
915 |
|
if (null != interfaces) { |
916 |
|
for (int i=0; i<interfaces.length; ++i) { |
917 |
|
if (interfaces[i] instanceof ClassDocImpl) { |
918 |
|
FieldDoc fieldDoc |
919 |
|
= ((ClassDocImpl)interfaces[i]).getFieldDoc(fieldName); |
920 |
|
if (null != fieldDoc) { |
921 |
|
return fieldDoc.constantValue(); |
922 |
|
} |
923 |
|
} |
924 |
|
} |
925 |
|
} |
926 |
|
} |
927 |
|
classDoc = classDoc.superclass(); |
928 |
|
} |
929 |
|
throw new UnknownIdentifierException(identifier); |
930 |
|
} |
931 |
|
|
932 |
|
public Object getValue(String identifier) |
933 |
|
throws UnknownIdentifierException |
934 |
|
{ |
935 |
|
int ndx = identifier.lastIndexOf('.'); |
936 |
|
if (ndx >= 0) { |
937 |
|
String className = identifier.substring(0, ndx); |
938 |
|
String fieldName = identifier.substring(ndx + 1); |
939 |
|
|
940 |
|
ClassDoc classDoc = findClass(className); |
941 |
|
if (null != classDoc) { |
942 |
|
return findFieldValue(identifier, classDoc, fieldName); |
943 |
|
} |
944 |
|
else { |
945 |
|
throw new UnknownIdentifierException(identifier); |
946 |
|
} |
947 |
|
} |
948 |
|
else { |
949 |
|
return findFieldValue(identifier, this, identifier); |
950 |
|
} |
951 |
|
} |
952 |
|
|
953 |
|
public boolean isPrimitive() |
954 |
|
{ |
955 |
|
return false; |
956 |
|
} |
957 |
} |
} |
958 |
|
|