/** * Sorts the items on their value: the option with the lower value (case insensitive String comparison) will be * placed before the other one. * * @param o1 the first item to be compared. * @param o2 the second item to be compared. * @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or * greater than the second. */ public int compare(ListItem o1, ListItem o2) { return BASE_COMPARATOR.compare(o1.getValue(), o2.getValue()); } });
protected String renderItemsList(List<List<ListItem>> resList) { StringBuffer buff = new StringBuffer(); for (int i = 0; i < resList.size(); i++) { List<ListItem> items = resList.get(i); for (int j = 0; j < items.size(); j++) { ListItem item = items.get(j); buff.append(item.getValue()); if (j < items.size() - 1) { buff.append(" > "); } } if (i < resList.size() - 1) { buff.append("<br />"); } } return buff.toString(); }
/** * {@inheritDoc} * * @see Object#toString() */ @Override public String toString() { return "[" + getId() + ", " + getValue() + ", " + getParent() + "]"; } }
private void indexStaticList(Document luceneDoc, BaseObject baseObject, StaticListClass prop, String propertyName, XWikiContext context) { Map<String, ListItem> possibleValues = prop.getMap(context); String fieldFullName = baseObject.getClassName() + "." + propertyName; for (String value : (List<String>) baseObject.getListValue(propertyName)) { ListItem item = possibleValues.get(value); if (item != null) { // We index the key of the list String fieldName = fieldFullName + ".key"; addFieldToDocument(fieldName, item.getId(), Field.Store.YES, Field.Index.ANALYZED, OBJECT_PROPERTY_BOOST, luceneDoc); // We index the value fieldName = fieldFullName + ".value"; addFieldToDocument(fieldName, item.getValue(), Field.Store.YES, Field.Index.ANALYZED, OBJECT_PROPERTY_BOOST, luceneDoc); // If the key and value are not the same, we index both // The key is always indexed outside the if block, so here we just index the value if (!item.getId().equals(item.getValue())) { addFieldToDocument(fieldFullName, item.getValue(), Field.Store.YES, Field.Index.ANALYZED, OBJECT_PROPERTY_BOOST, luceneDoc); } } addFieldToDocument(fieldFullName, value, Field.Store.YES, Field.Index.ANALYZED, OBJECT_PROPERTY_BOOST, luceneDoc); } }
displayValue = value; } else { displayValue = item.getValue();