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