001 package edu.rice.cs.cunit.classFile.constantPool; 002 003 import edu.rice.cs.cunit.classFile.constantPool.visitors.IPoolInfoVisitor; 004 005 import java.io.DataOutputStream; 006 import java.io.IOException; 007 008 /** 009 * Represents an empty slot in the constant pool. 010 * 011 * @author Mathias Ricken 012 */ 013 public class EmptyPoolInfo extends APoolInfo { 014 /** 015 * Singleton constructor. 016 */ 017 private EmptyPoolInfo() { 018 super(-1, null); 019 } 020 021 /** 022 * Singleton instance. 023 */ 024 private static EmptyPoolInfo _instance = new EmptyPoolInfo(); 025 026 /** 027 * Singleton accessor. 028 * 029 * @return singleton 030 */ 031 public static EmptyPoolInfo singleton() { 032 return _instance; 033 } 034 035 /** 036 * Write this constant pool object into the stream, including the type byte. 037 * 038 * @param dos stream 039 * 040 * @throws java.io.IOException 041 */ 042 public void write(DataOutputStream dos) throws IOException { 043 // do nothing 044 } 045 046 /** 047 * Resolve constant pool objects. This makes sure that the object links match the index links. 048 */ 049 public void resolve() { 050 // do nothing 051 } 052 053 /** 054 * Reindex constant pool indices. This makes sure the index links match the object links. 055 */ 056 public void reindex() { 057 // do nothing 058 } 059 060 /** 061 * Return a human-readable version of this constant pool object. 062 * 063 * @return string 064 */ 065 public String toString() { 066 return "Empty constant pool info"; 067 } 068 069 /** 070 * Return a human-readable version of this constant pool object. 071 * 072 * @return string 073 */ 074 public String toStringVerbose() { 075 return toString(); 076 } 077 078 /** 079 * Return a hash code. 080 * 081 * @return hash code 082 */ 083 public int hashCode() { 084 return 0; 085 } 086 087 /** 088 * Compare this object and another one. 089 * 090 * @param obj other object 091 * 092 * @return true if the same 093 */ 094 public boolean equals(Object obj) { 095 return obj instanceof EmptyPoolInfo; 096 } 097 098 /** 099 * Execute a visitor. 100 * 101 * @param visitor visitor 102 * @param data visitor-specific parameter 103 * 104 * @return visitor-specific return value 105 */ 106 public <R, D> R execute(IPoolInfoVisitor<R, D> visitor, D data) { 107 return visitor.emptyCase(this, data); 108 } 109 }