Exemple #1
0
  /**
   * Construct a new SortOption object using the definition from the configuration
   *
   * @param number the number of the sort option as given in the config file
   * @param definition definition from the configuration
   * @throws SortException if sort error
   */
  public SortOption(int number, String definition) throws SortException {
    this.number = number;

    String rx = "(\\w+):([\\w\\.\\*]+):(\\w+):?(\\w*)";
    Pattern pattern = Pattern.compile(rx);
    Matcher matcher = pattern.matcher(definition);

    if (!matcher.matches()) {
      throw new SortException(
          "Sort Order configuration is not valid: webui.itemlist.sort-option."
              + number
              + " = "
              + definition);
    }

    name = matcher.group(1);
    metadata = matcher.group(2);
    type = matcher.group(3);

    // If the option is configured to be hidden, then set the visible flag to false
    // otherwise, flag it as visible (true)
    if (matcher.groupCount() > 3 && "hide".equalsIgnoreCase(matcher.group(4))) {
      visible = false;
    } else {
      visible = true;
    }

    generateMdBits();
  }
Exemple #2
0
 /**
  * Construct a new SortOption object with the given parameters
  *
  * @param number the number of the sort option as given in the config file
  * @param name sort option name
  * @param md the metadata field to sort on
  * @param type the type of data we are sorting by
  * @throws SortException if sort error
  */
 public SortOption(int number, String name, String md, String type) throws SortException {
   this.name = name;
   this.type = type;
   this.metadata = md;
   this.number = number;
   this.visible = true;
   generateMdBits();
 }