Example usage for java.lang.reflect Modifier PRIVATE

List of usage examples for java.lang.reflect Modifier PRIVATE

Introduction

In this page you can find the example usage for java.lang.reflect Modifier PRIVATE.

Prototype

int PRIVATE

To view the source code for java.lang.reflect Modifier PRIVATE.

Click Source Link

Document

The int value representing the private modifier.

Usage

From source file:org.gvnix.flex.ui.FormTemplateTests.java

@Test
public void testFormWithTextFieldSingleValidation() throws SAXException, IOException {
    ActionScriptType entityType = new ActionScriptType("com.foo.Person");
    StringTemplate listViewTemplate = templateGroup.getInstanceOf("org/gvnix/flex/roo/addon/ui/entity_form");
    listViewTemplate.setAttribute("entityType", entityType);
    listViewTemplate.setAttribute("flexScaffoldMetadata", flexScaffoldMetadata);

    List<FieldMetadata> elegibleFields = new ArrayList<FieldMetadata>();
    AnnotationMetadataBuilder annotation = new AnnotationMetadataBuilder(
            new JavaType("javax.validation.constraints.NotNull"), Collections.EMPTY_LIST);
    FieldMetadata field = new FieldMetadataBuilder("MID:person#1", Modifier.PRIVATE,
            Collections.singletonList(annotation), new JavaSymbolName("name"), JavaType.STRING_OBJECT).build();
    elegibleFields.add(field);/*from  ww w  .  j  ava2  s.  c o  m*/
    listViewTemplate.setAttribute("fields", FlexUIMetadataProvider.wrapFields(elegibleFields));

    String result = listViewTemplate.toString();
    log.debug(result);

    assertTrue(result.contains("mx:StringValidator"));
    assertTrue(result.contains("s:TextInput"));

    ByteArrayInputStream stream = new ByteArrayInputStream(result.getBytes("UTF-8"));
    XmlUtils.getDocumentBuilder().parse(stream);
}

From source file:org.gvnix.addon.gva.security.providers.safe.SafeSecurityProviderExtLoadWSS4JMetadata.java

public SafeSecurityProviderExtLoadWSS4JMetadata(String identifier, JavaType aspectName,
        PhysicalTypeMetadata governorPhysicalTypeMetadata) {
    super(identifier, aspectName, governorPhysicalTypeMetadata);

    // Helper itd generation
    this.helper = new ItdBuilderHelper(this, governorPhysicalTypeMetadata,
            builder.getImportRegistrationResolver());

    // Adding Fields
    builder.addField(getField("LOGGER", "Logger.getLogger(ExtLoadWSS4JOutInterceptor.class)",
            new JavaType("org.apache.log4j.Logger"), Modifier.PRIVATE + Modifier.STATIC + Modifier.FINAL));
    builder.addField(getField(TRACEABILITY, null, JAVA_TYPE_STRING, Modifier.PRIVATE));

    // Creating constructors
    builder.addConstructor(getExtLoadWSS4JConst());
    builder.addConstructor(getExtLoadWSS4JConstWithParam());

    // Creating methods
    builder.addMethod(getSetterMethod(TRACEABILITY, JAVA_TYPE_STRING));
    builder.addMethod(getHandleMessageMethod());

    // Create a representation of the desired output ITD
    itdTypeDetails = builder.build();/*  ww  w.  j a v a 2s.  c  o m*/
}

From source file:org.springframework.flex.roo.addon.ui.FormTemplateTests.java

@Test
public void testFormWithTextFieldSingleValidation() throws SAXException, IOException {
    ActionScriptType entityType = new ActionScriptType("com.foo.Person");
    StringTemplate listViewTemplate = templateGroup
            .getInstanceOf("org/springframework/flex/roo/addon/ui/entity_form");
    listViewTemplate.setAttribute("entityType", entityType);
    listViewTemplate.setAttribute("flexScaffoldMetadata", flexScaffoldMetadata);

    List<FieldMetadata> elegibleFields = new ArrayList<FieldMetadata>();
    AnnotationMetadataBuilder annotation = new AnnotationMetadataBuilder(
            new JavaType("javax.validation.constraints.NotNull"), Collections.EMPTY_LIST);
    FieldMetadata field = new FieldMetadataBuilder("MID:person#1", Modifier.PRIVATE,
            Collections.singletonList(annotation), new JavaSymbolName("name"), JavaType.STRING_OBJECT).build();
    elegibleFields.add(field);/* ww  w . ja va  2  s  . c  o  m*/
    listViewTemplate.setAttribute("fields", FlexUIMetadataProvider.wrapFields(elegibleFields));

    String result = listViewTemplate.toString();
    log.debug(result);

    assertTrue(result.contains("mx:StringValidator"));
    assertTrue(result.contains("s:TextInput"));

    ByteArrayInputStream stream = new ByteArrayInputStream(result.getBytes("UTF-8"));
    XmlUtils.getDocumentBuilder().parse(stream);
}

From source file:pl.burningice.plugins.image.ast.AbstractImageContainerTransformation.java

protected FieldNode getTransientsField(ClassNode node) {
    FieldNode transientFields = node.getDeclaredField("transients");

    if (transientFields != null) {
        return transientFields;
    }//ww  w . j a  v a2  s.  c  om

    transientFields = new FieldNode("transients", Modifier.PRIVATE | Modifier.STATIC, new ClassNode(List.class),
            new ClassNode(node.getClass()), new ListExpression());
    node.addField(transientFields);
    addGetter(transientFields, node, Modifier.PUBLIC | Modifier.STATIC);
    addSetter(transientFields, node, Modifier.PUBLIC | Modifier.STATIC);
    return transientFields;
}

From source file:pl.burningice.plugins.image.ast.FileImageContainerTransformation.java

public FieldNode getTransientsField(ClassNode node) {
    FieldNode transientFields = node.getDeclaredField("transients");

    if (transientFields != null) {
        return transientFields;
    }//from  ww w  .j  av  a2  s .  c o m

    transientFields = new FieldNode("transients", Modifier.PRIVATE | Modifier.STATIC, new ClassNode(List.class),
            new ClassNode(node.getClass()), new ListExpression());
    node.addField(transientFields);
    addGetter(transientFields, node, Modifier.PUBLIC | Modifier.STATIC);
    addSetter(transientFields, node, Modifier.PUBLIC | Modifier.STATIC);
    return transientFields;
}

From source file:org.ops4j.gaderian.strategy.TestStrategyFactory.java

public void testBuildImplementationClass() {
    ClassFactory factory = createMock(ClassFactory.class);

    ClassFab cf = createMock(ClassFab.class);

    MethodFab mf = createMock(MethodFab.class);

    ServiceImplementationFactoryParameters fp = createMock(ServiceImplementationFactoryParameters.class);

    expect(fp.getServiceInterface()).andReturn(ToStringStrategy.class);
    final StrategyParameter param = new StrategyParameter();
    expect(fp.getFirstParameter()).andReturn(param);
    expect(factory.newClass("NewClass", Object.class)).andReturn(cf);

    cf.addInterface(ToStringStrategy.class);
    cf.addField("_registry", StrategyRegistry.class);

    Capture<Class[]> classCapture = new Capture<Class[]>();
    cf.addConstructor(capture(classCapture), (Class[]) eq(null), eq("_registry = $1;"));

    expect(cf.addMethod(Modifier.PRIVATE,
            new MethodSignature(ToStringStrategy.class, "_getStrategy", new Class[] { Object.class }, null),
            "return (org.ops4j.gaderian.strategy.ToStringStrategy) _registry.getStrategy($1.getClass());"))
                    .andReturn(mf);//  ww w .ja v a2s . co m

    expect(cf.addMethod(Modifier.PUBLIC,
            new MethodSignature(String.class, "toString", new Class[] { Object.class }, null),
            "return ($r) _getStrategy($1).toString($$);")).andReturn(mf);

    expect(fp.getServiceId()).andReturn("foo.Bar");

    ClassFabUtils.addToStringMethod(cf, StrategyMessages.toString("foo.Bar", ToStringStrategy.class));
    expectLastCall().andReturn(mf);

    expect(cf.createClass()).andReturn(String.class);

    replayAllRegisteredMocks();

    StrategyFactory f = new StrategyFactory();
    f.setClassFactory(factory);

    f.buildImplementationClass(fp, "NewClass");

    verifyAllRegisteredMocks();

    Class[] value = classCapture.getValue();
    assertNotNull(value);
    assertEquals("unexpected constructor length", 1, value.length);

}

From source file:pl.burningice.plugins.image.ast.AbstractImageContainerTransformation.java

protected FieldNode getHasManyField(ClassNode node) {
    FieldNode hasManyField = node.getDeclaredField("hasMany");

    if (hasManyField != null) {
        return hasManyField;
    }//from w ww.  j  a  v a  2 s .  c  o  m

    hasManyField = new FieldNode("hasMany", Modifier.PRIVATE | Modifier.STATIC, new ClassNode(Map.class),
            new ClassNode(node.getClass()), new MapExpression());

    node.addField(hasManyField);
    addGetter(hasManyField, node, Modifier.PUBLIC | Modifier.STATIC);
    addSetter(hasManyField, node, Modifier.PUBLIC | Modifier.STATIC);
    return hasManyField;
}

From source file:com.hihframework.core.utils.ReflectUtil.java

public static final Method[] getPrivateMethods(Object obj, String prefix) {
    return getMethods(obj, Modifier.PRIVATE, prefix);
}

From source file:com.googlecode.xtecuannet.framework.catalina.manager.tomcat.constants.Constants.java

public static List<Field> getOnlyFields(Class clazz) {

    List<Field> salida = new ArrayList<Field>(0);

    Field[] all = clazz.getDeclaredFields();

    for (int i = 0; i < all.length; i++) {
        Field field = all[i];//w w  w .  ja  v a  2s  .co  m

        logger.debug(Modifier.toString(field.getModifiers()) + "-" + field.getModifiers());
        if (field.getModifiers() == Modifier.PRIVATE) {

            salida.add(field);
        }
    }

    return salida;
}

From source file:org.gvnix.addon.gva.security.providers.safe.SafeSecurityProviderMetadata.java

public SafeSecurityProviderMetadata(String identifier, JavaType aspectName,
        PhysicalTypeMetadata governorPhysicalTypeMetadata) {
    super(identifier, aspectName, governorPhysicalTypeMetadata);

    // Helper itd generation
    this.helper = new ItdBuilderHelper(this, governorPhysicalTypeMetadata,
            builder.getImportRegistrationResolver());

    this.governorsPackage = governorPhysicalTypeMetadata.getType().getPackage();
    // Imports// w w w.  java  2  s.co m
    helper.getFinalTypeName(
            new JavaType("org.springframework.security.authentication.encoding.PlaintextPasswordEncoder"));

    // Adding Fields
    builder.addField(getField("logger", "Logger.getLogger(SafeProvider.class.getName())",
            new JavaType("org.apache.log4j.Logger"), Modifier.PRIVATE + Modifier.STATIC, null));

    builder.addField(getField("passwordEncoder", "new PlaintextPasswordEncoder()",
            new JavaType("org.springframework.security.authentication.encoding.PasswordEncoder"),
            Modifier.PRIVATE, null));

    builder.addField(getField("saltSource", null,
            new JavaType("org.springframework.security.authentication.dao.SaltSource"), Modifier.PRIVATE,
            null));

    builder.addField(getField("applicationId", null, JAVA_TYPE_STRING, Modifier.PRIVATE, null));

    builder.addField(getField("environment", null, JAVA_TYPE_STRING, Modifier.PRIVATE, null));

    builder.addField(getField("prop", null, new JavaType(JAVA_UTIL_PROPERTIES), Modifier.PUBLIC, null));

    builder.addField(getField("loader", null, new JavaType("java.lang.ClassLoader"), Modifier.PUBLIC, null));

    builder.addField(getField("stream", null, new JavaType("java.io.InputStream"), Modifier.PUBLIC, null));

    builder.addField(getField("mapRoles", "true", JavaType.BOOLEAN_PRIMITIVE, Modifier.PRIVATE, null));

    builder.addField(getField("active", null, JavaType.BOOLEAN_PRIMITIVE, Modifier.PRIVATE, null));

    builder.addField(
            getField("filtrarPorAplicacion", null, JavaType.BOOLEAN_PRIMITIVE, Modifier.PRIVATE, null));

    // Adding Field annotations
    List<AnnotationMetadataBuilder> autenticationAnnotations = new ArrayList<AnnotationMetadataBuilder>();

    // Add @Autowired annotation
    AnnotationMetadataBuilder autowiredAnnotation = new AnnotationMetadataBuilder(
            new JavaType("org.springframework.beans.factory.annotation.Autowired"));
    autenticationAnnotations.add(autowiredAnnotation);

    builder.addField(getField("safeAutenticacionClient", null,
            new JavaType("es.gva.dgm.ayf.war.definitions.v2u00.AutenticacionArangiPortType"), Modifier.PRIVATE,
            autenticationAnnotations));

    builder.addField(getField("safeAutorizacionClient", null,
            new JavaType("es.gva.dgm.ayf.war.definitions.v2u00.AutorizacionPortType"), Modifier.PRIVATE,
            autenticationAnnotations));

    // Creating getters and setters
    builder.addMethod(getGetterMethod("saltSource",
            new JavaType("org.springframework.security.authentication.dao.SaltSource")));
    builder.addMethod(getSetterMethod("saltSource",
            new JavaType("org.springframework.security.authentication.dao.SaltSource")));
    builder.addMethod(getGetterMethod("passwordEncoder",
            new JavaType("org.springframework.security.authentication.encoding.PasswordEncoder")));
    builder.addMethod(getSetterMethod("passwordEncoder",
            new JavaType("org.springframework.security.authentication.encoding.PasswordEncoder")));
    builder.addMethod(getGetterMethod("applicationId", JAVA_TYPE_STRING));
    builder.addMethod(getSetterMethod("applicationId", JAVA_TYPE_STRING));
    builder.addMethod(getGetterMethod("environment", JAVA_TYPE_STRING));
    builder.addMethod(getSetterMethod("environment", JAVA_TYPE_STRING));
    builder.addMethod(getGetterMethod("mapRoles", JavaType.BOOLEAN_PRIMITIVE));
    builder.addMethod(getSetterMethod("mapRoles", JavaType.BOOLEAN_PRIMITIVE));
    builder.addMethod(getGetterMethod("active", JavaType.BOOLEAN_PRIMITIVE));
    builder.addMethod(getSetterMethod("active", JavaType.BOOLEAN_PRIMITIVE));
    builder.addMethod(getGetterMethod("filtrarPorAplicacion", JavaType.BOOLEAN_PRIMITIVE));
    builder.addMethod(getSetterMethod("filtrarPorAplicacion", JavaType.BOOLEAN_PRIMITIVE));

    // Creating methods
    builder.addMethod(getAdditionalAuthenticationChecksMethod());
    builder.addMethod(getRetrieveUserMethod());
    builder.addMethod(getConvertWSInfoToUserMethod());
    builder.addMethod(getConvertWSInfoToUserTodasAplicacionesMethod());
    builder.addMethod(getConvertToApplicationRolMethod());

    // Create a representation of the desired output ITD
    itdTypeDetails = builder.build();
}