Errai 3.0.1-SNAPSHOT

org.jboss.errai.codegen.util
Class PrivateAccessUtil

java.lang.Object
  extended by org.jboss.errai.codegen.util.PrivateAccessUtil

public class PrivateAccessUtil
extends Object

Utility class with methods that generate code to access private, default access ("package private"), and protected methods and fields in arbitrary classes. Each generator allows the choice of generating Java Reflection code (for use on the server side) or JSNI code (for use on the client side).

Author:
Mike Brock, Jonathan Fuerth, Christian Sadilek

Constructor Summary
PrivateAccessUtil()
           
 
Method Summary
static void addPrivateAccessStubs(PrivateAccessType accessType, String type, ClassStructureBuilder<?> classBuilder, MetaField f)
          Generates methods for accessing a private field using either JSNI or Java Reflection.
static void addPrivateAccessStubs(PrivateAccessType accessType, String accessorType, ClassStructureBuilder<?> classBuilder, MetaField f, Modifier[] modifiers)
          Generates methods for accessing a private field using either JSNI or Java Reflection.
static void addPrivateAccessStubs(String accessorType, ClassStructureBuilder<?> classBuilder, MetaConstructor m)
          Generates methods for accessing a nonpublic constructor using either JSNI or Java Reflection.
static void addPrivateAccessStubs(String type, ClassStructureBuilder<?> classBuilder, MetaField f)
           
static void addPrivateAccessStubs(String accessorType, ClassStructureBuilder<?> classBuilder, MetaMethod m)
          Generates methods for accessing a nonpublic method using either JSNI or Java Reflection.
static void addPrivateAccessStubs(String accessorType, ClassStructureBuilder<?> classBuilder, MetaMethod m, Modifier[] modifiers)
          Generates methods for accessing a nonpublic method using either JSNI or Java Reflection.
static String condensify(String packagePrefix)
           
static String getPrivateFieldInjectorName(MetaField field)
           
static String getPrivateMethodName(MetaMethod method)
           
static void registerPrivateMemberAccessor(String type, PrivateMemberAccessor accessor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrivateAccessUtil

public PrivateAccessUtil()
Method Detail

registerPrivateMemberAccessor

public static void registerPrivateMemberAccessor(String type,
                                                 PrivateMemberAccessor accessor)

addPrivateAccessStubs

public static void addPrivateAccessStubs(String type,
                                         ClassStructureBuilder<?> classBuilder,
                                         MetaField f)

addPrivateAccessStubs

public static void addPrivateAccessStubs(PrivateAccessType accessType,
                                         String type,
                                         ClassStructureBuilder<?> classBuilder,
                                         MetaField f)
Generates methods for accessing a private field using either JSNI or Java Reflection. The generated methods will be private and static.

Parameters:
accessType - Whether to generate a read method, a write method, or both.
type - The type of accessors to use (ie. "reflection" or "jsni").
classBuilder - The class builder to add the generated methods to.
f - The field the generated accessors read and write.

addPrivateAccessStubs

public static void addPrivateAccessStubs(PrivateAccessType accessType,
                                         String accessorType,
                                         ClassStructureBuilder<?> classBuilder,
                                         MetaField f,
                                         Modifier[] modifiers)
Generates methods for accessing a private field using either JSNI or Java Reflection. The generated methods will be private.

Parameters:
accessType - Whether to generate a read method, a write method, or both.
accessorType - The type of accessors to use (ie. "reflection" or "jsni").
classBuilder - The class builder to add the generated methods to.
f - The field the generated accessors read and write.
modifiers - The modifiers on the generated method, for example Modifier.Final or Modifier.Synchronized. Never specify Modifier.JSNI; it is added automatically when needed.

addPrivateAccessStubs

public static void addPrivateAccessStubs(String accessorType,
                                         ClassStructureBuilder<?> classBuilder,
                                         MetaConstructor m)
Generates methods for accessing a nonpublic constructor using either JSNI or Java Reflection. The generated method will be private and static. The name of the generated method can be discovered by calling getPrivateMethodName(MetaMethod).

Parameters:
accessorType - The type of accessors to use (ie. "reflection" or "jsni").
classBuilder - The class builder to add the generated method to.
m - The constructor the generated method will invoke

addPrivateAccessStubs

public static void addPrivateAccessStubs(String accessorType,
                                         ClassStructureBuilder<?> classBuilder,
                                         MetaMethod m)
Generates methods for accessing a nonpublic method using either JSNI or Java Reflection. The generated method will be private and static. The name of the generated method can be discovered by calling getPrivateMethodName(MetaMethod).

Parameters:
accessorType - The type of accessors to use (ie. "reflection" or "jsni").
classBuilder - The class builder to add the generated method to.
m - The nonpublic method the generated method will invoke

addPrivateAccessStubs

public static void addPrivateAccessStubs(String accessorType,
                                         ClassStructureBuilder<?> classBuilder,
                                         MetaMethod m,
                                         Modifier[] modifiers)
Generates methods for accessing a nonpublic method using either JSNI or Java Reflection. The generated method will be private and static.

Parameters:
accessorType - The type of accessors to use (ie. "reflection" or "jsni").
classBuilder - The class builder to add the generated method to.
m - The method the generated accessors read and write.
modifiers - The modifiers on the generated method, for example Modifier.Final or Modifier.Synchronized. Never specify Modifier.JSNI; it is added automatically when needed.

condensify

public static String condensify(String packagePrefix)

getPrivateFieldInjectorName

public static String getPrivateFieldInjectorName(MetaField field)

getPrivateMethodName

public static String getPrivateMethodName(MetaMethod method)

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.