/** * Return all the configured sort options. * * @return a set of the configured sort options * @throws SortException if sort error */ public static Set<SortOption> getSortOptions() throws SortException { if (SortOption.sortOptionsSet == null) { throw new SortException("Sort options not loaded"); } return SortOption.sortOptionsSet; }
ExceptionThrowingStubSortClient implements Sorter { void sort(List<String> list) { throw new SortException("Testing the exception handling"); } }
/** * Tell the class to generate the metadata bits * * @throws SortException if sort error */ private void generateMdBits() throws SortException { try { mdBits = interpretField(metadata, null); } catch (IOException e) { throw new SortException(e); } }
/** * 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(); }