private void parseAnnotations()

in ti/phase2/jars/compiler-xdoclet/src/java/org/apache/ti/compiler/xdoclet/internal/typesystem/impl/declaration/AnnotationInterfaceParser.java [118:185]


    private void parseAnnotations() {
        String annotationsSource = ANNOTATIONS_CLASSNAME.replace('.', '/') + ".java";
        InputStream in = DeclarationImpl.class.getClassLoader().getResourceAsStream(annotationsSource);
        assert in != null : "annotations source not found: " + annotationsSource;
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));

        try {
            HashMap enums = new HashMap();  // String enumTypeName -> HashSet values
            StreamTokenizer tok = getJavaTokenizer(reader);


            String interfaceQualifier = null;
            String packageName = null;

            while (tok.nextToken() != StreamTokenizer.TT_EOF) {
                switch (tok.ttype) {
                    case StreamTokenizer.TT_WORD:
                        String str = tok.sval;

                        if (packageName == null && str.equals("package")) {
                            packageName = assertWord(tok);
                        } else if (str.equals("public")) {
                            str = assertWord(tok);

                            if (str.equals("interface")) {
                                interfaceQualifier = assertWord(tok) + '.';
                                assertChar(tok, '{');
                            } else if (str.equals("@interface")) {
                                AnnotationTypeDeclarationImpl ann =
                                        readAnnotation(tok, interfaceQualifier, packageName, enums);
                                _annotations.put(ann.getIntermediateName(), ann);
                            } else if (str.equals("enum")) {
                                readEnum(tok, enums);
                            }
                        } else if (str.charAt(0) == '@') {
                            if (tok.nextToken() == '(') {
                                ignoreAnnotation(tok);
                            } else {
                                tok.pushBack();
                            }
                        }
                        break;

                    case StreamTokenizer.TT_NUMBER:
                        break;

                    default:
                        char c = (char) tok.ttype;
                        if (c == '}') {
                            assert interfaceQualifier != null;
                            interfaceQualifier = null;
                        }
                }
            }
        }
        catch (IOException e) {
            e.printStackTrace();
            assert false : e;
        }
        finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
                assert false : e;
            }
        }
    }