001package gudusoft.gsqlparser.sqlcmds; 002 003import gudusoft.gsqlparser.ESqlStatementType; 004import gudusoft.gsqlparser.TBaseType; 005 006/** 007 * Represents a SQL command definition with token patterns and statement type. 008 * This class was extracted from TSqlCmds inner class to support the modular 009 * vendor-specific command architecture. 010 * 011 * @since 3.1.0.9 012 */ 013public class TSqlCmd { 014 int token1; 015 String token2, token3, token4, token5, token6, token7, token8, token1Str; 016 public ESqlStatementType sqlstatementtype; 017 018 public TSqlCmd() { 019 token1Str = "***"; 020 } 021 022 /** 023 * The keyword token code of this command's first token. 024 * 025 * <p>Exposed as a public accessor because the field itself is 026 * package-private, and every shipped jar is ProGuard-obfuscated: a 027 * package-private field is renamed, so nothing outside this package can 028 * reach it in a released build. Tests that inspect the command table must 029 * go through this method so they keep working against the obfuscated 030 * jar.</p> 031 * 032 * @return the token code of the command's first token 033 * @since 4.2.6 034 */ 035 public int getToken1() { 036 return token1; 037 } 038 039 /** 040 * The literal text of this command's first token for vendor-specific 041 * commands whose token has no keyword code, or <code>"***"</code> when the 042 * command is keyed by token code instead. 043 * 044 * <p>Public for the same reason as {@link #getToken1()}: the backing field 045 * is package-private and therefore renamed in every shipped 046 * (ProGuard-obfuscated) jar.</p> 047 * 048 * @return the first token's literal text, or "***" if not set 049 * @since 4.2.6 050 */ 051 public String getToken1Str() { 052 return token1Str; 053 } 054 055 public String toString() { 056 String retStr; 057 if (token1 <= TBaseType.rrw_abort) { 058 retStr = TBaseType.getTextByTokenCode(token1); 059 } else { 060 retStr = token1Str; 061 } 062 063 if (token2.trim().length() > 0) { 064 retStr = retStr + " " + token2.replace("*", " "); 065 } 066 if (token3.trim().length() > 0) { 067 retStr = retStr + " " + token3; 068 } 069 if (token4.trim().length() > 0) { 070 retStr = retStr + " " + token4; 071 } 072 if (token5.trim().length() > 0) { 073 retStr = retStr + " " + token5; 074 } 075 if (token6.trim().length() > 0) { 076 retStr = retStr + " " + token6; 077 } 078 if (token7.trim().length() > 0) { 079 retStr = retStr + " " + token7; 080 } 081 if (token8.trim().length() > 0) { 082 retStr = retStr + " " + token8; 083 } 084 return retStr; 085 } 086}