KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > yworks > yguard > obf > classfile > AnnotationInfo


1 /*
2  * AnnotationInfo.java
3  *
4  * Created on April 20, 2005, 4:18 PM
5  */

6
7 package com.yworks.yguard.obf.classfile;
8
9 import java.io.DataInput JavaDoc;
10 import java.io.DataOutput JavaDoc;
11
12 public class AnnotationInfo
13 {
14   // Constants -------------------------------------------------------------
15

16   
17   // Fields ----------------------------------------------------------------
18
protected int u2typeIndex;
19   private int u2elementCount;
20   private ElementValuePairInfo[] elementValuePairs;
21   
22   
23   // Class Methods ---------------------------------------------------------
24
public static AnnotationInfo create(DataInput JavaDoc din) throws java.io.IOException JavaDoc
25   {
26     if (din == null) throw new NullPointerException JavaDoc("DataInput cannot be null!");
27     AnnotationInfo an = new AnnotationInfo();
28     an.read(din);
29     return an;
30   }
31   
32   protected ElementValuePairInfo[] getElementValuePairs(){
33     return elementValuePairs;
34   }
35   
36   // Instance Methods ------------------------------------------------------
37
private AnnotationInfo()
38   {}
39
40   protected void markUtf8RefsInInfo(ConstantPool pool) {
41     pool.getCpEntry(u2typeIndex).incRefCount();
42     for (int i = 0; i < u2elementCount; i++){
43       elementValuePairs[i].markUtf8RefsInInfo(pool);
44     }
45   }
46   
47   private void read(DataInput JavaDoc din) throws java.io.IOException JavaDoc
48   {
49     u2typeIndex = din.readUnsignedShort();
50     u2elementCount = din.readUnsignedShort();
51     elementValuePairs = new ElementValuePairInfo[u2elementCount];
52     for (int i = 0; i < u2elementCount; i++)
53     {
54       elementValuePairs[i] = ElementValuePairInfo.create(din);
55     }
56   }
57   
58   /** Export the representation to a DataOutput stream. */
59   public void write(DataOutput JavaDoc dout) throws java.io.IOException JavaDoc
60   {
61     dout.writeShort(u2typeIndex);
62     dout.writeShort(u2elementCount);
63     for (int i = 0; i < u2elementCount; i++)
64     {
65       elementValuePairs[i].write(dout);
66     }
67   }
68 }
69
Popular Tags