All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.basex.query.util.collation.CollationOptions Maven / Gradle / Ivy

There is a newer version: 11.3
Show newest version
package org.basex.query.util.collation;

import java.util.*;
import java.util.Map.Entry;

import org.basex.core.*;
import org.basex.util.options.*;

/**
 * Collation options.
 *
 * @author BaseX Team 2005-22, BSD License
 * @author Christian Gruen
 */
abstract class CollationOptions extends Options {
  /**
   * Parses the specified options and returns the faulty key.
   * @param args arguments
   * @return error message
   * @throws BaseXException database exception
   */
  abstract Collation get(HashMap args) throws BaseXException;

  /**
   * Assigns the specified options.
   * @param args arguments
   * @throws BaseXException database exception
   */
  void assign(final HashMap args) throws BaseXException {
    for(final Entry entry : args.entrySet()) {
      assign(entry.getKey(), entry.getValue());
    }
  }

  /**
   * Creates an error for an invalid option.
   * @param option option
   * @return error
   */
  protected BaseXException error(final Option option) {
    return new BaseXException("Invalid \"%\" value: \"%\".", option, get(option));
  }

  /** Initialization of locales. */
  protected static final class Locales {
    /** Private constructor. */
    private Locales() { }

    /** Available locales, indexed by language code. */
    static final HashMap MAP = new HashMap<>();
    static {
      for(final Locale l : Locale.getAvailableLocales()) MAP.put(l.toString().replace('_', '-'), l);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy