Class OpenSearchTemplateUtils

java.lang.Object
org.opengis.cite.cat30.util.OpenSearchTemplateUtils

public class OpenSearchTemplateUtils extends Object
Provides various utility methods for processing OpenSearch URL templates.
  • Constructor Details

    • OpenSearchTemplateUtils

      public OpenSearchTemplateUtils()
  • Method Details

    • getTemplateParameterName

      public static QName getTemplateParameterName(String param, Node contextNode)
      Returns the qualified name of the given OpenSearch URL template parameter.
      Parameters:
      param - A parameter in a URL template (e.g. "searchTerms", "geo:box?").
      contextNode - The context node; this is used to perform a namespace lookup if necessary.
      Returns:
      A QName representing the name of the template parameter.
    • filterURLTemplatesByParam

      public static List<Node> filterURLTemplatesByParam(List<Node> urlTemplates, QName paramName)
      Filters a list of OpenSearch URL templates to include only those that contain the specified parameter.
      Parameters:
      urlTemplates - A list of (Element) nodes representing URL templates.
      paramName - The qualified name of a template parameter.
      Returns:
      A new list containing templates with the specified parameter.
    • buildRequestURI

      public static URI buildRequestURI(Element urlElem, Map<QName,String> values)
      Builds a request URI by processing a URL template according to the given parameter substitution values. The default value is used if there is no replacement value for a parameter.
      Parameters:
      urlElem - An Element node that represents a query endpoint (osd:Url).
      values - A Map containing replacement values for template parameters.
      Returns:
      A URI representing the resulting request URI.
    • getDefaultParamValue

      public static String getDefaultParamValue(List<TemplateParamInfo> paramList, QName paramName)
      Returns the default value of the specified template parameter.
      Parameters:
      paramList - A list of TemplateParamInfo objects describing the declared template parameters.
      paramName - The qualified name of a template parameter.
      Returns:
      A String representing the default value (possibly an empty string).
    • updateOpenSearchParameter

      public static void updateOpenSearchParameter(TemplateParamInfo paramInfo, Element urlElem)
      Updates the type and default value of a standard OpenSearch parameter.
      Parameters:
      paramInfo - A TemplateParamInfo object describing a standard OpenSearch parameter.
      urlElem - An Element node (osd:Url) that defines an OpenSearch request containing the parameter.
      See Also:
    • getQueryParameters

      public static Map<QName,String> getQueryParameters(Node query)
      Extracts the actual parameters from an OpenSearch query specification.
      Parameters:
      query - A Node representing an osd:Query element.
      Returns:
      A Map containing the query parameters, where the key is the (qualified) parameter name.