use of org.jabref.model.groups.SearchGroup in project jabref by JabRef.
the class GroupTreeNodeViewModel method getDescription.
public String getDescription() {
AbstractGroup group = node.getGroup();
String shortDescription = "";
boolean showDynamic = true;
if (group instanceof ExplicitGroup) {
shortDescription = GroupDescriptions.getShortDescriptionExplicitGroup((ExplicitGroup) group);
} else if (group instanceof KeywordGroup) {
shortDescription = GroupDescriptions.getShortDescriptionKeywordGroup((KeywordGroup) group, showDynamic);
} else if (group instanceof SearchGroup) {
shortDescription = GroupDescriptions.getShortDescription((SearchGroup) group, showDynamic);
} else {
shortDescription = GroupDescriptions.getShortDescriptionAllEntriesGroup();
}
return "<html>" + shortDescription + "</html>";
}
use of org.jabref.model.groups.SearchGroup in project jabref by JabRef.
the class GroupSerializerTest method serializeSingleSearchGroup.
@Test
public void serializeSingleSearchGroup() {
SearchGroup group = new SearchGroup("myExplicitGroup", GroupHierarchyType.INDEPENDENT, "author=harrer", true, true);
List<String> serialization = groupSerializer.serializeTree(GroupTreeNode.fromGroup(group));
assertEquals(Collections.singletonList("0 SearchGroup:myExplicitGroup;0;author=harrer;1;1;1;;;;"), serialization);
}
use of org.jabref.model.groups.SearchGroup in project jabref by JabRef.
the class GroupSerializerTest method serializeSingleSearchGroupWithRegex.
@Test
public void serializeSingleSearchGroupWithRegex() {
SearchGroup group = new SearchGroup("myExplicitGroup", GroupHierarchyType.INCLUDING, "author=\"harrer\"", true, false);
List<String> serialization = groupSerializer.serializeTree(GroupTreeNode.fromGroup(group));
assertEquals(Collections.singletonList("0 SearchGroup:myExplicitGroup;2;author=\"harrer\";1;0;1;;;;"), serialization);
}
use of org.jabref.model.groups.SearchGroup in project jabref by JabRef.
the class GroupsParser method searchGroupFromString.
/**
* Parses s and recreates the SearchGroup from it.
*
* @param s The String representation obtained from
* SearchGroup.toString(), or null if incompatible
*/
private static AbstractGroup searchGroupFromString(String s) {
if (!s.startsWith(MetadataSerializationConfiguration.SEARCH_GROUP_ID)) {
throw new IllegalArgumentException("SearchGroup cannot be created from \"" + s + "\".");
}
QuotedStringTokenizer tok = new QuotedStringTokenizer(s.substring(MetadataSerializationConfiguration.SEARCH_GROUP_ID.length()), MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR);
String name = tok.nextToken();
int context = Integer.parseInt(tok.nextToken());
String expression = tok.nextToken();
boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
// fields; these are ignored now, all fields are always searched
return new SearchGroup(StringUtil.unquote(name, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR), GroupHierarchyType.getByNumberOrDefault(context), StringUtil.unquote(expression, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR), caseSensitive, regExp);
}
Aggregations