001    package edu.rice.cs.cunit.classFile.constantPool;
002    
003    import edu.rice.cs.cunit.classFile.constantPool.visitors.IPoolInfoVisitor;
004    
005    import java.io.DataInputStream;
006    import java.io.IOException;
007    import java.util.ArrayList;
008    
009    /**
010     * Represents Unicode data in the constant pool.
011     *
012     * @author Mathias Ricken
013     */
014    public class UnicodePoolInfo extends AUTFPoolInfo {
015        /**
016         * Constructor.
017         *
018         * @param s data
019         */
020        public UnicodePoolInfo(String s, ConstantPool cp) {
021            super(CONSTANT_Utf8_Unicode, s, cp);
022        }
023    
024        /**
025         * Constructor reading from a stream.
026         *
027         * @param dis input stream
028         * @param cp  constant pool
029         *
030         * @throws IOException
031         */
032        public UnicodePoolInfo(DataInputStream dis, ConstantPool cp) throws IOException {
033            super(CONSTANT_Utf8_Unicode, dis, cp);
034        }
035    
036        /**
037         * Return a human-readable version of this constant pool object.
038         *
039         * @return string
040         */
041        public String toStringVerbose() {
042            return "CONSTANT_Utf8_Unicode: String = " + _strValue;
043        }
044    
045        /**
046         * Compare this object and another one.
047         *
048         * @param obj other object
049         *
050         * @return true if the same
051         */
052        public boolean equals(Object obj) {
053            return (obj instanceof UnicodePoolInfo) &&
054                (((UnicodePoolInfo)obj)._strValue.equals(_strValue));
055        }
056    
057        /**
058         * Execute a visitor.
059         *
060         * @param visitor visitor
061         * @param data    visitor-specific parameter
062         *
063         * @return visitor-specific return value
064         */
065        public <R, D> R execute(IPoolInfoVisitor<R, D> visitor, D data) {
066            return visitor.unicodeCase(this, data);
067        }
068    }