Use common library to read file content.
[javainspect.git] / src / main / java / eu / svjatoslav / inspector / java / methods / Annotation.java
1 /*
2  * JavaInspect - Utility to visualize java software
3  * Copyright (C) 2013-2020, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of version 3 of the GNU Lesser General Public License
7  * or later as published by the Free Software Foundation.
8  */
9
10 package eu.svjatoslav.inspector.java.methods;
11
12 import eu.svjatoslav.commons.string.tokenizer.InvalidSyntaxException;
13 import eu.svjatoslav.commons.string.tokenizer.Tokenizer;
14 import eu.svjatoslav.commons.string.tokenizer.TokenizerMatch;
15
16 public class Annotation {
17
18     private String name;
19
20     public Annotation(final Tokenizer tokenizer) throws InvalidSyntaxException {
21
22         name = tokenizer.getNextToken().token;
23
24         if (!tokenizer.consumeIfNextToken("("))
25             return;
26
27         int depth = 1;
28
29         while (true) {
30             final TokenizerMatch token = tokenizer.getNextToken();
31
32             if (token == null)
33                 return;
34
35             if ("(".equals(token.token))
36                 depth++;
37             if (")".equals(token.token))
38                 depth--;
39
40             if (depth == 0)
41                 return;
42         }
43
44     }
45
46 }