01: /*
02: *
03: *
04: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: */
26:
27: package com.sun.satsa.jcrmic.classfile.attributes;
28:
29: import java.io.DataInputStream;
30: import java.io.IOException;
31: import java.io.PrintWriter;
32:
33: import com.sun.satsa.jcrmic.classfile.constants.JConstantPool;
34:
35: /**
36: * This class is the base class for all Java class file attributes.
37: * It also contain a factory method to create an attribute object
38: * based on the attribute type.
39: */
40:
41: public class JAttribute {
42:
43: /**
44: * Constant pool reference.
45: */
46: protected JConstantPool cp;
47:
48: /**
49: * Constructor.
50: * @param cp constant pool reference
51: */
52: JAttribute(JConstantPool cp) {
53: this .cp = cp;
54: }
55:
56: /**
57: * Factory method for attribute object creation.
58: * @param cp constant pool reference
59: * @param index constant pool index for attribute name
60: * @return attribute object
61: */
62: public static final JAttribute create(JConstantPool cp, int index) {
63:
64: String name = cp.getConstantUtf8(index).getString();
65: if (name.equals("Exceptions"))
66: return new JExceptionsAttr(cp);
67: return new JAttribute(cp);
68: }
69:
70: /**
71: * Resolves the attribute.
72: */
73: public void resolve() {
74: }
75:
76: /**
77: * Parses the attribute definition.
78: * @param dis input stream
79: * @throws IOException if I/O exception occurs
80: */
81: public void parse(DataInputStream dis) throws IOException {
82: int length = dis.readInt();
83: dis.skipBytes(length);
84: }
85: }
|