001    package sysModel.classFile.constantPool.visitors;
002    
003    import sysModel.classFile.constantPool.APoolInfo;
004    import sysModel.classFile.constantPool.DoublePoolInfo;
005    import sysModel.classFile.constantPool.LongPoolInfo;
006    
007    /**
008     * Return the size of the info in the constant pool. Double and long use two entries, all others use one.
009     *
010     * @author Mathias Ricken
011     */
012    public class GetPoolInfoSizeVisitor extends ADefaultPoolInfoVisitor<Integer, Object> {
013        /**
014         * Singleton constructor.
015         */
016        private GetPoolInfoSizeVisitor() {
017        }
018    
019        /**
020         * Singleton instance.
021         */
022        private static GetPoolInfoSizeVisitor _instance = new GetPoolInfoSizeVisitor();
023    
024        /**
025         * Singleton accessor.
026         *
027         * @return singleton
028         */
029        public static GetPoolInfoSizeVisitor singleton() {
030            return _instance;
031        }
032    
033        /**
034         * All other cases return 1.
035         *
036         * @param host one-slot host
037         * @param o    not used
038         *
039         * @return 1
040         */
041        public Integer defaultCase(APoolInfo host, Object o) {
042            return new Integer(1);
043        }
044    
045        /**
046         * Returns 2
047         *
048         * @param host long info
049         * @param o    not used
050         *
051         * @return 2
052         */
053        public Integer longCase(LongPoolInfo host, Object o) {
054            return new Integer(2);
055        }
056    
057        /**
058         * Returns 2.
059         *
060         * @param host double info
061         * @param o    not used
062         *
063         * @return 2
064         */
065        public Integer doubleCase(DoublePoolInfo host, Object o) {
066            return new Integer(2);
067        }
068    }