001 package sysModel.classFile.constantPool.visitors; 002 003 import sysModel.classFile.constantPool.APoolInfo; 004 import sysModel.classFile.constantPool.ASCIIPoolInfo; 005 import sysModel.classFile.constantPool.AUTFPoolInfo; 006 import sysModel.classFile.constantPool.UnicodePoolInfo; 007 008 /** 009 * Check that the host is a UTF info. 010 * 011 * @author Mathias Ricken 012 */ 013 public class CheckUTFVisitor extends ADefaultPoolInfoVisitor<AUTFPoolInfo, Object> { 014 /** 015 * Singleton constructor. 016 */ 017 private CheckUTFVisitor() { 018 } 019 020 /** 021 * Singleton instance. 022 */ 023 private static CheckUTFVisitor _instance = new CheckUTFVisitor(); 024 025 /** 026 * Singleton accessor. 027 * 028 * @return singleton 029 */ 030 public static CheckUTFVisitor singleton() { 031 return _instance; 032 } 033 034 /** 035 * All other cases throw. 036 * 037 * @param host non-UTF host 038 * @param o not used 039 * 040 * @return nothing 041 */ 042 public AUTFPoolInfo defaultCase(APoolInfo host, Object o) { 043 throw new ClassFormatError("Info is of type " + host.getClass().getName() + ", needs to be AUTFPoolInfo"); 044 } 045 046 /** 047 * Return host. 048 * 049 * @param host UTF host 050 * @param o not used 051 * 052 * @return host 053 */ 054 public AUTFPoolInfo asciizCase(ASCIIPoolInfo host, Object o) { 055 return host; 056 } 057 058 /** 059 * Return host. 060 * 061 * @param host UTF host 062 * @param o not used 063 * 064 * @return host 065 */ 066 public AUTFPoolInfo unicodeCase(UnicodePoolInfo host, Object o) { 067 return host; 068 } 069 }