Source code: com/chaoswg/xtc4y/classdesc/Attribute.java
1 //$Header: /cvsroot/xtc4y/xtc4y/src/com/chaoswg/xtc4y/classdesc/Attribute.java,v 1.2 2003/08/25 10:50:14 toggm Exp $
2 /******************************************************************************
3 * XTC4y - eXtreme Testing Collection 4 you *
4 * -------------------------------------------------------------------------- *
5 * URL: http://www.chaoswg.com/xtc4y *
6 * Author: Mike Toggweiler (2.dog@gmx.ch) *
7 * *
8 * Last Updated: $Date: 2003/08/25 10:50:14 $, by $Author: toggm $ *
9 * Version: $Revision: 1.2 $ *
10 * -------------------------------------------------------------------------- *
11 * COPYRIGHT: (c) 2003 by Mike Toggweiler *
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 *****************************************************************************/
18 package com.chaoswg.xtc4y.classdesc;
19
20 import java.util.Vector;
21
22 import java.io.ByteArrayOutputStream;
23 import java.io.DataInputStream;
24 import java.io.DataOutputStream;
25 import java.io.IOException;
26
27 /**
28 * This class describes the information for an attribute.
29 * @author Mike Toggweiler
30 **/
31 public abstract class Attribute {
32
33 /**
34 * Creates a Attribute and initializes it from a DataInputStream
35 * @param dis the DataInputStream to read from
36 * @param cp the constant pool to resolve indices
37 * @param length the length of the attribute information provided
38 * on the DataInputStream
39 **/
40 protected Attribute(DataInputStream dis, ConstantPool cp, int length)
41 throws IOException {
42 //do nothing, dummy implementation
43 }
44
45 /**
46 * Create an empty attribute
47 **/
48 public Attribute() {
49 //do nothing
50 }
51
52 /**
53 * Write the attribute information onto the DataOutputStream, using the
54 * constant pool to register variables. The Attribute name and the
55 * length of the information will already be written. A specific
56 * attribute implementation should overwrite this method.
57 * @param dos the DataOutputStream to write on
58 * @param cp The constant pool to register variables
59 **/
60 protected abstract void writeAttribute(DataOutputStream dos,
61 ConstantPool cp)
62 throws IOException ;
63
64 /**
65 * @return the name of the attribute
66 **/
67 public abstract String getName();
68
69 /**
70 * Write in a readable way
71 **/
72 public String toString() {
73 return getName();
74 }
75 }