001    package edu.rice.cs.cunit.classFile.constantPool.visitors;
002    
003    import edu.rice.cs.cunit.classFile.constantPool.APoolInfo;
004    import edu.rice.cs.cunit.classFile.constantPool.IntegerPoolInfo;
005    
006    /**
007     * Check that the host is a Integer info.
008     *
009     * @author Mathias Ricken
010     */
011    public class CheckIntegerVisitor extends ADefaultPoolInfoVisitor<IntegerPoolInfo, Object> {
012        /**
013         * Singleton constructor.
014         */
015        private CheckIntegerVisitor() {
016        }
017    
018        /**
019         * Singleton instance.
020         */
021        private static CheckIntegerVisitor _instance = new CheckIntegerVisitor();
022    
023        /**
024         * Singleton accessor.
025         *
026         * @return singleton
027         */
028        public static CheckIntegerVisitor singleton() {
029            return _instance;
030        }
031    
032        /**
033         * All other cases throw.
034         *
035         * @param host non-Long host
036         * @param o    not used
037         *
038         * @return nothing
039         */
040        public IntegerPoolInfo defaultCase(APoolInfo host, Object o) {
041            throw new ClassFormatError("Info is of type " + host.getClass().getName() + ", needs to be IntPoolInfo");
042        }
043    
044        /**
045         * Return host.
046         *
047         * @param host Integer host
048         * @param o    not used
049         *
050         * @return host
051         */
052        public IntegerPoolInfo intCase(IntegerPoolInfo host, Object o) {
053            return host;
054        }
055    }