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