private static ASTAnnotation getRootExpr(final String annotationExpr) throws Exception { return getRootExpr(annotationExpr, null, false); }
/** * Create annotation. * * @param annotationExpr the annotation expression * @param cl the classloader to use * @return new annotation instance * @throws Exception for any error */ public static Object createAnnotation(String annotationExpr, ClassLoader cl) throws Exception { return createAnnotation(getRootExpr(annotationExpr), null, cl); }
/** * Create annotation. * * @param annotationExpr the annotation expression * @param annotation the annotation class * @return new annotation instance * @throws Exception for any error */ public static Object createAnnotation(final String annotationExpr, final Class<?> annotation) throws Exception { return createAnnotation(getRootExpr(annotationExpr), annotation, null); }
public static Object createAnnotation(final String annotationExpr, final Class annotation) throws Exception { return createAnnotation(getRootExpr(annotationExpr), annotation, null); }
public static Object createAnnotation(String annotationExpr, ClassLoader cl) throws Exception { return createAnnotation(getRootExpr(annotationExpr), null, cl); }
/** * Create annotation. * * @param annotationExpr the annotation expression * @param annotation the annotation class * @param properties the properties to use for replacement * @return new annotation instance * @throws Exception for any error */ public static Object createAnnotation(final String annotationExpr, final Class<?> annotation, Properties properties) throws Exception { return createAnnotation(getRootExpr(annotationExpr, properties), annotation, null); }
/** * Create annotation. * * @param annotationExpr the annotation expression * @param annotation the annotation class * @param replace should we replace possible properties in expression * @return new annotation instance * @throws Exception for any error */ public static Object createAnnotation(final String annotationExpr, final Class<?> annotation, boolean replace) throws Exception { return createAnnotation(getRootExpr(annotationExpr, null, replace), annotation, null); }
/** * Create annotation. * * @param annotationExpr the annotation expression * @param cl the classloader to use * @param replace should we replace possible properties in expression * @return new annotation instance * @throws Exception for any error */ public static Object createAnnotation(String annotationExpr, ClassLoader cl, boolean replace) throws Exception { return createAnnotation(getRootExpr(annotationExpr, null, replace), null, cl); }
/** * Create annotation. * * @param annotationExpr the annotation expression * @param cl the classloader to use * @param properties the properties to use for replacement * @return new annotation instance * @throws Exception for any error */ public static Object createAnnotation(String annotationExpr, ClassLoader cl, Properties properties) throws Exception { return createAnnotation(getRootExpr(annotationExpr, properties), null, cl); } }
private static ASTAnnotation getRootExpr(final String annotationExpr, final Properties properties, final Boolean replace) throws Exception { try { return AccessController.doPrivileged(new PrivilegedExceptionAction<ASTAnnotation>() { public ASTAnnotation run() throws Exception { String expr; if (properties != null && properties.isEmpty() == false) expr = StringPropertyReplacer.replaceProperties(annotationExpr, properties); else if (replace != null && replace) expr = StringPropertyReplacer.replaceProperties(annotationExpr); else expr = annotationExpr; AnnotationParser parser = new AnnotationParser(new StringReader(expr)); ASTStart start = parser.Start(); return (ASTAnnotation)start.jjtGetChild(0); } }); } catch (PrivilegedActionException e) { throw new RuntimeException("Error getting root expression " + annotationExpr, e.getException()); } }