Class VendorNameMatcher

Object
gudusoft.gsqlparser.resolver2.matcher.VendorNameMatcher
All Implemented Interfaces:
INameMatcher

public class VendorNameMatcher extends Object implements INameMatcher
Vendor-specific name matcher using IdentifierService.

This implementation provides database vendor-specific identifier normalization and comparison by delegating to IdentifierService.

Key features:

  • Vendor-specific case folding (Oracle: UPPER, PostgreSQL: LOWER, etc.)
  • Proper handling of quoted vs unquoted identifiers
  • Support for different object types (tables, columns, schemas)
  • High-performance static caching via IdentifierService

Usage example:

 // Create matcher for Oracle
 VendorNameMatcher matcher = new VendorNameMatcher(EDbVendor.dbvoracle);

 // Normalize column name
 String normalized = matcher.normalize("\"Column1\"");  // Returns "Column1" (quoted preserved)
 String normalized2 = matcher.normalize("column1");     // Returns "COLUMN1" (unquoted folded)

 // Compare names
 boolean match = matcher.matches("COL1", "col1");  // Returns true (both normalize to COL1)
 
Since:
3.1.0.9
See Also:
  • Constructor Details

    • VendorNameMatcher

      public VendorNameMatcher(EDbVendor vendor)
      Create a vendor name matcher with default object type (column).
      Parameters:
      vendor - the database vendor
    • VendorNameMatcher

      public VendorNameMatcher(EDbVendor vendor, ESQLDataObjectType defaultObjectType)
      Create a vendor name matcher with specified default object type.
      Parameters:
      vendor - the database vendor
      defaultObjectType - the default object type for normalization/comparison
  • Method Details

    • matches

      public boolean matches(String name1, String name2)
      Description copied from interface: INameMatcher
      Check if two names match according to the matching rules.
      Specified by:
      matches in interface INameMatcher
      Parameters:
      name1 - First name
      name2 - Second name
      Returns:
      true if names match
    • matches

      public boolean matches(String name1, String name2, ESQLDataObjectType objectType)
      Check if two names match according to vendor rules for a specific object type.
      Parameters:
      name1 - first name
      name2 - second name
      objectType - the object type (table, column, etc.)
      Returns:
      true if names match according to vendor rules
    • matchesPattern

      public boolean matchesPattern(String name, String pattern)
      Description copied from interface: INameMatcher
      Check if a name is a valid match for a pattern. Used for prefix matching, wildcard matching, etc.
      Specified by:
      matchesPattern in interface INameMatcher
      Parameters:
      name - The name to test
      pattern - The pattern to match against
      Returns:
      true if name matches pattern
    • normalize

      public String normalize(String name)
      Description copied from interface: INameMatcher
      Normalize a name according to matching rules. E.g., convert to uppercase for Oracle, lowercase for PostgreSQL unquoted.
      Specified by:
      normalize in interface INameMatcher
      Parameters:
      name - Name to normalize
      Returns:
      Normalized name
    • normalize

      public String normalize(String name, ESQLDataObjectType objectType)
      Normalize a name according to vendor rules for a specific object type.
      Parameters:
      name - the name to normalize
      objectType - the object type (table, column, etc.)
      Returns:
      normalized name
    • normalizeQualifiedName

      public String normalizeQualifiedName(String qualifiedName, ESQLDataObjectType objectType)
      Normalize a qualified name (e.g., schema.table.column).

      This method properly normalizes each part of a multi-part identifier according to vendor rules.

      Parameters:
      qualifiedName - the qualified name
      objectType - the final object type
      Returns:
      normalized qualified name
    • isCaseSensitive

      public boolean isCaseSensitive()
      Description copied from interface: INameMatcher
      Check if the matcher is case-sensitive
      Specified by:
      isCaseSensitive in interface INameMatcher
    • getVendor

      public EDbVendor getVendor()
      Get the database vendor.
      Returns:
      the vendor
    • getDefaultObjectType

      Get the default object type.
      Returns:
      the default object type
    • withObjectType

      Create a new matcher with a different default object type.
      Parameters:
      objectType - the new default object type
      Returns:
      new VendorNameMatcher instance
    • toString

      public String toString()
      Overrides:
      toString in class Object