Example usage for java.lang Package getAnnotations

List of usage examples for java.lang Package getAnnotations

Introduction

In this page you can find the example usage for java.lang Package getAnnotations.

Prototype

public Annotation[] getAnnotations() 

Source Link

Usage

From source file:Main.java

public static void main(String args[]) {

    // create a package object for java.lang package
    Package pack = Package.getPackage("java.io");
    for (Annotation at : pack.getAnnotations()) {
        System.out.println(at);/*from   w w w  .j ava 2 s .co  m*/
    }

}

From source file:org.castor.jaxb.reflection.PackageAnnotationProcessingServiceTest.java

/**
 * Test method for {@link org.castor.jaxb.annoproc.BaseAnnotationProcessingService#processAnnotations(org.castor.jaxb.reflection.info.Info, 
 * java.lang.annotation.Annotation[])}./*from  w  ww .j  av  a 2s  . c  o  m*/
 */
@Test
public final void testProcessAnnotations() {
    Class<USAddress> clazz = USAddress.class;
    Package pack = clazz.getPackage();
    Annotation[] annotations = pack.getAnnotations();
    JaxbPackageNature packageInfo = new JaxbPackageNature(new PackageInfo(pack.getName()));
    paps.processAnnotations(packageInfo, annotations);
    Assert.assertEquals(XmlAccessType.PROPERTY, packageInfo.getAccessType());
}

From source file:org.castor.jaxb.reflection.ClassInfoBuilder.java

/**
 * Build the {@link PackageInfo} for a {@link Package}.
 * /*  w w  w.j  av a 2  s .com*/
 * @param pkg
 *            the Package to describe
 * @return the PackageInfo build
 */
private PackageInfo buildPackageInfo(final Package pkg) {
    PackageInfo packageInfo = createPackageInfo(pkg.getName());
    OoPackageNature ooPackageNature = new OoPackageNature(packageInfo);
    ooPackageNature.setPackage(pkg);
    packageAnnotationProcessingService.processAnnotations(new JaxbPackageNature(packageInfo),
            pkg.getAnnotations());
    return packageInfo;
}