Class FeatureSet

java.lang.Object
adql.parser.feature.FeatureSet
All Implemented Interfaces:
Iterable<LanguageFeature>

public class FeatureSet extends Object implements Iterable<LanguageFeature>
Set of supported ADQL's language features.

With this class it is possible to declare which language features are supported. If a LanguageFeature is not part of this set, it must be considered as unsupported.

(Un-)Support individual features

To support a feature, use the function support(LanguageFeature) while unsupport(LanguageFeature) lets remove a feature from this set.

Warning: Features with type = NULL or which are not declared as optional can never be supported by this set. In such case, support(LanguageFeature) will return false.

Note: You do not have to create any new instance of LanguageFeature. All ADQLObject provides a function for this purpose: ADQLObject.getFeatureDescription(). Unfortunately, this function can not be static. That's why, the library declared a static attribute in every ADQLObject called FEATURE.

Example:

To support the optional function LOWER:

myFeatureSet.support(LowerFunction.FEATURE);

And for the geometric function POLYGON:

myFeatureSet.support(PolygonFunction.FEATURE);

(Un-)Support all available features

It is also possible to support or un-support all optional features with the functions supportAll() and unsupportAll().

Note: The list of all standard optional features can be discovered with getAvailableFeatures().

(Un-)Support a specific type of feature

You can also support or un-support all optional features of a given type with supportAll(String) and unsupportAll(String). You can find all standard types of feature in LanguageFeature as public static attributes whose the name starts with TYPE_.

Example:

To un-support all geometric functions:

myFeatureSet.unsupportAll(LanguageFeature.TYPE_ADQL_GEO);

Warning: Both functions will not work for User Defined Functions that has to be added individually in the FeatureSet.

Since:
2.0
  • Field Details

  • Constructor Details

    • FeatureSet

      public FeatureSet()
      Create a feature set with all available features supported by default.
    • FeatureSet

      public FeatureSet(boolean allSupported)
      Create a feature set will all available features supported or not, depending of the given boolean parameter.
      Parameters:
      allSupported - true to support all available features, false to not support any.
  • Method Details

    • support

      public boolean support(LanguageFeature feature)
      Support the given optional feature.

      Warning: A feature can not be marked as supported in the following cases:

      • it is NULL,
      • no type is specified,
      • it is not optional.

      In any of this cases, this function will do nothing else than returning false.

      Parameters:
      feature - The optional language feature to support.
      Returns:
      true if this set already/from now supporting the given feature, false if the given feature can not be supported.
    • supportAll

      public final boolean supportAll(String type)
      Support all the optional features of the given type.
      Parameters:
      type - The type of language features to support.
      Returns:
      true if all the available features of the given type are already/from now supported by this set, false if the given type is NULL or it does not match any available feature.
      See Also:
    • supportAll

      public final void supportAll()
      Support all available optional features.
      See Also:
    • unsupport

      public boolean unsupport(LanguageFeature feature)
      Un-support the given optional feature.

      Warning: A feature can not be marked as un-supported in the following cases:

      • it is NULL,
      • no type is specified,
      • it is not optional.

      In any of this cases, this function will do nothing else than returning false.

      Parameters:
      feature - The optional language feature to un-support.
      Returns:
      true if this set already/from now un-supporting the given feature, false if the given feature can not be supported any way.
    • unsupportAll

      public final boolean unsupportAll(String type)
      Un-support all the optional features of the given type.
      Parameters:
      type - The type of language features to un-support.
      Returns:
      true if all the available features of the given type are already/from now un-supported by this set, false if the given type is NULL or it does not match any available feature.
      See Also:
    • unsupportAll

      public final void unsupportAll()
      Un-support all available features.
      See Also:
    • isSupporting

      public boolean isSupporting(LanguageFeature feature)
      Tell whether the given optional feature is marked as supported by this set.

      Warning: A feature can not be marked as supported in the following cases:

      • it is NULL,
      • no type is specified,
      • it is not optional.

      In any of this cases, this function will do nothing else than returning false.

      Parameters:
      feature - The optional feature to test.
      Returns:
      true if supported according to this set, false otherwise.
    • getSupportedFeatures

      public Iterator<LanguageFeature> getSupportedFeatures()
      List all features marked in this set as supported.
      Returns:
      An iterator over all supported features.
    • getUnsupportedFeatures

      public Iterator<LanguageFeature> getUnsupportedFeatures()
      List all available features not marked in this set as supported.
      Returns:
      An iterator over all un-supported features.
    • getSupportedFeatures

      public Iterator<LanguageFeature> getSupportedFeatures(String type)
      List only features of the given type that are marked in this set as supported.

      Note: If the given type is NULL or does not match the type of any supported feature, this function will return an empty iterator.

      Parameters:
      type - Type of the features to test.
      Returns:
      An iterator over all supported features of the given type.
    • iterator

      public final Iterator<LanguageFeature> iterator()
      List all features marked as supported in this set.
      Specified by:
      iterator in interface Iterable<LanguageFeature>
      See Also:
    • getSupportedUDFList

      public final Collection<FunctionDef> getSupportedUDFList()
      Get the list of the definition of all declared UDFs.
      Returns:
      List of all supported UDFs.
    • getAvailableFeatures

      public static Iterator<LanguageFeature> getAvailableFeatures()
      List all available language features.
      Returns:
      An iterator over all available features.