Search in sources :

Example 6 with QuotedStringTokenizer

use of org.jabref.logic.util.strings.QuotedStringTokenizer in project jabref by JabRef.

the class GroupsParser method automaticKeywordGroupFromString.

private static AbstractGroup automaticKeywordGroupFromString(String string) {
    if (!string.startsWith(MetadataSerializationConfiguration.AUTOMATIC_KEYWORD_GROUP_ID)) {
        throw new IllegalArgumentException("KeywordGroup cannot be created from \"" + string + "\".");
    }
    QuotedStringTokenizer tok = new QuotedStringTokenizer(string.substring(MetadataSerializationConfiguration.AUTOMATIC_KEYWORD_GROUP_ID.length()), MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR);
    String name = StringUtil.unquote(tok.nextToken(), MetadataSerializationConfiguration.GROUP_QUOTE_CHAR);
    GroupHierarchyType context = GroupHierarchyType.getByNumberOrDefault(Integer.parseInt(tok.nextToken()));
    String field = StringUtil.unquote(tok.nextToken(), MetadataSerializationConfiguration.GROUP_QUOTE_CHAR);
    Character delimiter = tok.nextToken().charAt(0);
    Character hierarchicalDelimiter = tok.nextToken().charAt(0);
    AutomaticKeywordGroup newGroup = new AutomaticKeywordGroup(name, context, field, delimiter, hierarchicalDelimiter);
    addGroupDetails(tok, newGroup);
    return newGroup;
}
Also used : AutomaticKeywordGroup(org.jabref.model.groups.AutomaticKeywordGroup) QuotedStringTokenizer(org.jabref.logic.util.strings.QuotedStringTokenizer) GroupHierarchyType(org.jabref.model.groups.GroupHierarchyType)

Aggregations

QuotedStringTokenizer (org.jabref.logic.util.strings.QuotedStringTokenizer)6 GroupHierarchyType (org.jabref.model.groups.GroupHierarchyType)3 ParseException (org.jabref.logic.importer.ParseException)2 AutomaticKeywordGroup (org.jabref.model.groups.AutomaticKeywordGroup)2 ExplicitGroup (org.jabref.model.groups.ExplicitGroup)2 AutomaticPersonsGroup (org.jabref.model.groups.AutomaticPersonsGroup)1 KeywordGroup (org.jabref.model.groups.KeywordGroup)1 RegexKeywordGroup (org.jabref.model.groups.RegexKeywordGroup)1 SearchGroup (org.jabref.model.groups.SearchGroup)1 WordKeywordGroup (org.jabref.model.groups.WordKeywordGroup)1