001 package sysModel.classFile.constantPool.visitors; 002 003 import sysModel.classFile.constantPool.APoolInfo; 004 import sysModel.classFile.constantPool.ClassPoolInfo; 005 006 /** 007 * Check that the host is a class info. 008 * 009 * @author Mathias Ricken 010 */ 011 public class CheckClassVisitor extends ADefaultPoolInfoVisitor<ClassPoolInfo, Object> { 012 /** 013 * Singleton constructor. 014 */ 015 private CheckClassVisitor() { 016 } 017 018 /** 019 * Singleton instance. 020 */ 021 private static CheckClassVisitor _instance = new CheckClassVisitor(); 022 023 /** 024 * Singleton accessor. 025 * 026 * @return singleton 027 */ 028 public static CheckClassVisitor 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 ClassPoolInfo defaultCase(APoolInfo host, Object o) { 041 throw new ClassFormatError("Info is of type " + host.getClass().getName() + ", needs to be ClassPoolInfo"); 042 } 043 044 /** 045 * Return host. 046 * 047 * @param host class host 048 * @param o not used 049 * 050 * @return host 051 */ 052 public ClassPoolInfo classCase(ClassPoolInfo host, Object o) { 053 return host; 054 } 055 }