Class ResourceDefinition

java.lang.Object
org.apache.sis.storage.sql.ResourceDefinition

public final class ResourceDefinition extends Object
Definition of a resource (table, view or query) to include in a SQLStore.
Since:
1.1
Version:
1.1
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.opengis.util.GenericName
    The table name or the query name.
    (package private) final String
    The SQL query to execute for the resource, or null if the resource is a table or view.
    private static org.opengis.util.NameSpace
    The namespace for table names, created when first needed.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    ResourceDefinition(org.opengis.util.GenericName name, String query)
    Creates a new definition.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if this definition is equal to the given object.
    org.opengis.util.GenericName
    Returns the name of the table, view or query to access as a resource.
    Returns the SQL query to execute for the resource, or empty if the resource is a table or a view.
    int
    Returns a hash code value for this resource definition.
    query(String name, String query)
    Creates a resource definition for a SQL query.
    table(String tablePattern)
    Creates a resource definition for a table or a view in any catalog and schema of the database.
    table(String catalog, String schemaPattern, String tablePattern)
    Creates a resource definition for a table or a view in the database.
    Returns a string representation of this resource definition.
    (package private) static ResourceDefinition[]
    wrap(org.opengis.util.GenericName[] tableNames, Map<?,?> queries)
    Wraps the given table names and queries in an array of resource definitions.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • tableNS

      private static volatile org.opengis.util.NameSpace tableNS
      The namespace for table names, created when first needed. Used for specifying the name separator, which is '.'.
    • name

      private final org.opengis.util.GenericName name
      The table name or the query name. This field has two meanings, depending on whether query is null or not:
      • If query is null, then this is the fully qualified name (including catalog and schema) of the table to include in the store. It may contain LIKE wildcard characters, in which case all tables matching the pattern will be included.
      • If query is non-null, then this is an arbitrary name to assign to the resource which will contain the query result.
      See Also:
    • query

      final String query
      The SQL query to execute for the resource, or null if the resource is a table or view.
      See Also:
  • Constructor Details

    • ResourceDefinition

      private ResourceDefinition(org.opengis.util.GenericName name, String query)
      Creates a new definition.
  • Method Details

    • wrap

      static ResourceDefinition[] wrap(org.opengis.util.GenericName[] tableNames, Map<?,?> queries)
      Wraps the given table names and queries in an array of resource definitions.
    • table

      public static ResourceDefinition table(String tablePattern)
      Creates a resource definition for a table or a view in any catalog and schema of the database. The table name can contain SQL wildcard characters: '_' matches any single character and '%' matches any sequence of characters.
      Parameters:
      tablePattern - pattern (with '_' and '%' wildcards) of a table.
      Returns:
      resource definition for the named table.
    • table

      public static ResourceDefinition table(String catalog, String schemaPattern, String tablePattern)
      Creates a resource definition for a table or a view in the database. The table name can be any of the followings:
      • catalog.schemaPattern.tablePattern
      • schemaPattern.tablePattern
      • tablePattern
      The schema and table names (but not the catalog) can contain SQL wildcard characters: '_' matches any single character and '%' matches any sequence of characters.
      Parameters:
      catalog - name of a catalog as it is stored in the database, or null for any catalog.
      schemaPattern - pattern (with '_' and '%' wildcards) of a schema, or null for any schema.
      tablePattern - pattern (with '_' and '%' wildcards) of a table.
      Returns:
      resource definition for the named table.
    • query

      public static ResourceDefinition query(String name, String query)
      Creates a resource definition for a SQL query. Each column in the query should have a distinct name, using SQL AS keyword if needed. It is caller's responsibility to ensure that the given query is not subject to SQL injection vulnerability.
      Parameters:
      name - name of the resource.
      query - the SQL query to execute.
      Returns:
      resource definition for the given SQL query.
    • getName

      public org.opengis.util.GenericName getName()
      Returns the name of the table, view or query to access as a resource. There is small differences in the way it is used depending on whether the resource is a table or a query:
      • If the resource is a table or a view, then this is the fully qualified name (including catalog and schema) of the table or view to include in the store. It may contain LIKE wildcard characters, in which case all tables matching the pattern will be included.
      • If the resource is a query, then this is an arbitrary name to assign to the resource which will contain the query result.
      Returns:
      the name of the table, view or query.
    • getQuery

      public Optional<String> getQuery()
      Returns the SQL query to execute for the resource, or empty if the resource is a table or a view.
      Returns:
      the SQL query to execute for the resource.
    • equals

      public boolean equals(Object obj)
      Returns true if this definition is equal to the given object.
      Overrides:
      equals in class Object
      Parameters:
      obj - another object, or null.
      Returns:
      true if the other object is a resource definition equals to this one.
    • hashCode

      public int hashCode()
      Returns a hash code value for this resource definition.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value.
    • toString

      public String toString()
      Returns a string representation of this resource definition.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this resource definition.