Пример #1
0
 /// <summary>
 /// Gets the numeric identifier associated with the given character
 /// sequence.
 /// </summary>
 /// <remarks>
 /// Character sequence matching uses the case-insensitive
 /// invariant culture.
 /// </remarks>
 /// <param name="token">
 /// The character sequence for which to retrieve the associated
 /// numeric identifier.
 /// </param>
 /// <returns>
 /// The numeric identifier associated with the given character sequence;
 /// -1 if a match is not found.
 /// </returns>
 public static int GetTokenIdForValue(string token)
 {
     return(m_TokenValueMap.get(token, -1));
 }
Пример #2
0
 /// <summary>
 /// Gets the numeric code associated with the given command token.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Please note that character sequence matching uses the
 /// case-insensitive invariant culture.
 /// </para>
 /// <para>
 /// A <c>command token</c> is deemed to be an SQL token whose presence
 /// or abscense, while parsing or interpreting a charater sequence
 /// denoting an HSQLDB database command, is so commonly tested along
 /// with a long chain of other values that the complexity of an O(1)
 /// hash lookup combined with a numeric switch statement has been
 /// deemed worth the potential performance gain (avoid O(n) string
 /// equality tests), not to mention less cumbersome to maintain and
 /// debug than long equivalent if-then-else chains.
 /// </para>
 /// <para>
 /// In part, since C# provides the ability to switch on string values,
 /// this is somewhat a legacy concern from Java. However, the
 /// complexity of switching on string values versus switching on
 /// integral values is, although at worst O(n) in both cases, very
 /// likely to be higher by some constant term when switching on string
 /// equality, regardless of language compiler optimizations or the
 /// presence or absence of machine instructions designed to optimize
 /// switch-like conditional constructs to O(1) complexity when possible.
 /// As such, this classification is exposed to support efficient O(1)
 /// lookup of an integral command token code in combination with an
 /// integral switch statement when parsing or interpreting a character
 /// sequence denoting an SQL command.
 /// </para>
 /// </remarks>
 /// <param name="token">The token.</param>
 /// <returns>
 /// The numeric code for the given character sequence;
 /// -1 if the given value is not a command token.
 /// </returns>
 public static int GetCommandTokenIdForValue(string token)
 {
     return(m_CommandTokenIdentifierMap.get(token, -1));
 }