KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > enhancer > classfile > AnnotatedClassAttribute


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package com.sun.jdo.api.persistence.enhancer.classfile;
26
27 import java.io.*;
28
29 /**
30  * AnnotatedClassAttribute represents a class level attribute
31  * class file which identifies the level of annotation of the class.
32  */

33
34 public class AnnotatedClassAttribute extends ClassAttribute {
35
36   /* The expected attribute name */
37     public final static String JavaDoc expectedAttrName = "filter.annotatedClass";//NOI18N
38

39   /* The expected attribute version */
40   public final static short expectedAttrVersion = 1;
41
42   /* Bit mask indicating that the class was filter generated */
43   public final static short generatedFlag = 0x1;
44
45   /* Bit mask indicating that the class was filter annotated */
46   public final static short annotatedFlag = 0x2;
47
48   /* Bit mask indicating that the class was "repackaged" or similarly
49    * modified */

50   public final static short modifiedFlag = 0x4;
51
52   /* The version of the attribute */
53   private short attrVersion;
54
55   /* Flags associated with the annotation */
56   private short annotationFlags;
57
58   /* The modification date of the class file at the time of modification */
59   private long classModTime;
60
61   /* The date of the annotation */
62   private long classAnnotationTime;
63
64   /* public accessors */
65
66   public short getVersion() {
67     return attrVersion;
68   }
69
70   public void setVersion(short version) {
71     attrVersion = version;
72   }
73
74   public short getFlags() {
75     return annotationFlags;
76   }
77
78   public void setFlags(short flags) {
79     annotationFlags = flags;
80   }
81
82   public long getModTime() {
83     return classModTime;
84   }
85
86   public void setModTime(long time) {
87     classModTime = time;
88   }
89
90   public long getAnnotationTime() {
91     return classAnnotationTime;
92   }
93
94   public void setAnnotationTime(long time) {
95     classAnnotationTime = time;
96   }
97
98   /**
99    * Constructor
100    */

101   public AnnotatedClassAttribute(
102     ConstUtf8 nameAttr, short version, short annFlags,
103     long modTime, long annTime) {
104     super(nameAttr);
105     attrVersion = version;
106     annotationFlags = annFlags;
107     classModTime = modTime;
108     classAnnotationTime = annTime;
109   }
110
111   /* package local methods */
112
113   static AnnotatedClassAttribute read(
114     ConstUtf8 attrName, DataInputStream data, ConstantPool pool)
115     throws IOException {
116     short version = data.readShort();
117     short annFlags = data.readShort();
118     long modTime = data.readLong();
119     long annTime = data.readLong();
120     return new AnnotatedClassAttribute(attrName, version, annFlags,
121                     modTime, annTime);
122   }
123
124   void write(DataOutputStream out) throws IOException {
125     out.writeShort(attrName().getIndex());
126     out.writeShort(20);
127     out.writeShort(attrVersion);
128     out.writeShort(annotationFlags);
129     out.writeLong(classModTime);
130     out.writeLong(classAnnotationTime);
131   }
132
133   void print(PrintStream out, int indent) {
134     ClassPrint.spaces(out, indent);
135     out.println("version: " + attrVersion);//NOI18N
136
out.println(" flags: " + annotationFlags);//NOI18N
137
out.println(" modTime: " + classModTime);//NOI18N
138
out.println(" annTime: " + classAnnotationTime);//NOI18N
139
}
140 }
141
Popular Tags