1 /* |
1 /* |
2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
201 |
201 |
202 /** Get the string value of an annotation argument, which is given by the |
202 /** Get the string value of an annotation argument, which is given by the |
203 * expression <i>name</i>=<i>value</i>. |
203 * expression <i>name</i>=<i>value</i>. |
204 */ |
204 */ |
205 String getStringValue(JCExpression e) { |
205 String getStringValue(JCExpression e) { |
206 if (e.getTag() == JCTree.ASSIGN) { |
206 if (e.hasTag(JCTree.Tag.ASSIGN)) { |
207 JCAssign a = (JCAssign) e; |
207 JCAssign a = (JCAssign) e; |
208 JCExpression rhs = a.rhs; |
208 JCExpression rhs = a.rhs; |
209 if (rhs.getTag() == JCTree.LITERAL) { |
209 if (rhs.hasTag(JCTree.Tag.LITERAL)) { |
210 JCLiteral l = (JCLiteral) rhs; |
210 JCLiteral l = (JCLiteral) rhs; |
211 return (String) l.value; |
211 return (String) l.value; |
212 } |
212 } |
|
213 } else if (e.hasTag(JCTree.Tag.LITERAL)) { |
|
214 JCLiteral l = (JCLiteral) e; |
|
215 return (String) l.value; |
213 } |
216 } |
214 throw new IllegalArgumentException(e.toString()); |
217 throw new IllegalArgumentException(e.toString()); |
215 } |
218 } |
216 |
219 |
217 /** The file for the tree. Used to locate errors. */ |
220 /** The file for the tree. Used to locate errors. */ |