Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Deprecated.java

00001 package de.fub.bytecode.classfile;
00002 
00003 import  de.fub.bytecode.Constants;
00004 import  java.io.*;
00005 
00006 /**
00007  * This class is derived from <em>Attribute</em> and denotes that this is a
00008  * deprecated method.
00009  * It is instantiated from the <em>Attribute.readAttribute()</em> method.
00010  *
00011  * @version $Id: Deprecated.java,v 1.1.1.1 2002/01/24 03:44:00 pserver Exp $
00012  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00013  * @see     Attribute
00014  */
00015 public final class Deprecated extends Attribute {
00016   private byte[] bytes;
00017 
00018   /**
00019    * @param name_index Index in constant pool to CONSTANT_Utf8
00020    * @param length Content length in bytes
00021    * @param bytes Attribute contents
00022    * @param constant_pool Array of constants
00023    * @param sourcefile_index Index in constant pool to CONSTANT_Utf8
00024    */
00025   public Deprecated(int name_index, int length, byte[] bytes,
00026             ConstantPool constant_pool)
00027   {
00028     super(ATTR_DEPRECATED, name_index, length, constant_pool);
00029     this.bytes = bytes;
00030   }  
00031   /**
00032    * Construct object from file stream.
00033    * @param name_index Index in constant pool to CONSTANT_Utf8
00034    * @param length Content length in bytes
00035    * @param file Input stream
00036    * @param constant_pool Array of constants
00037    * @throw IOException
00038    */
00039   Deprecated(int name_index, int length, DataInputStream file,
00040          ConstantPool constant_pool) throws IOException
00041   {
00042     this(name_index, length, (byte [])null, constant_pool);
00043 
00044     if(length > 0) {
00045       bytes = new byte[length];
00046       file.readFully(bytes);
00047       System.err.println("Deprecated attribute with length > 0");
00048     }
00049   }  
00050   /**
00051    * Initialize from another object. Note that both objects use the same
00052    * references (shallow copy). Use clone() for a physical copy.
00053    */
00054   public Deprecated(Deprecated c) {
00055     this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
00056   }  
00057   /**
00058    * Called by objects that are traversing the nodes of the tree implicitely
00059    * defined by the contents of a Java class. I.e., the hierarchy of methods,
00060    * fields, attributes, etc. spawns a tree of objects.
00061    *
00062    * @param v Visitor object
00063    */
00064   public void accept(Visitor v) {
00065     v.visitDeprecated(this);
00066   }  
00067   /**
00068    * @return deep copy of this attribute
00069    */
00070   public Attribute copy(ConstantPool constant_pool) {
00071     Deprecated c = (Deprecated)clone();
00072 
00073     if(bytes != null)
00074       c.bytes = (byte[])bytes.clone();
00075 
00076     c.constant_pool = constant_pool;
00077     return c;
00078   }  
00079   /**
00080    * Dump source file attribute to file stream in binary format.
00081    *
00082    * @param file Output file stream
00083    * @throw IOException
00084    */ 
00085   public final void dump(DataOutputStream file) throws IOException
00086   {
00087     super.dump(file);
00088 
00089     if(length > 0)
00090       file.write(bytes, 0, length);
00091   }  
00092   /**
00093    * @return data bytes.
00094    */  
00095   public final byte[] getBytes() { return bytes; }  
00096   /**
00097    * @param bytes.
00098    */
00099   public final void setBytes(byte[] bytes) {
00100     this.bytes = bytes;
00101   }  
00102   /**
00103    * @return attribute name
00104    */ 
00105   public final String toString() {
00106     return ATTRIBUTE_NAMES[ATTR_DEPRECATED];
00107   }  
00108 }

Generated at Thu Feb 7 06:44:01 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001