Search in sources :

Example 1 with GroupHierarchyType

use of org.jabref.model.groups.GroupHierarchyType in project jabref by JabRef.

the class GroupsParser method automaticPersonsGroupFromString.

private static AbstractGroup automaticPersonsGroupFromString(String string) {
    if (!string.startsWith(MetadataSerializationConfiguration.AUTOMATIC_PERSONS_GROUP_ID)) {
        throw new IllegalArgumentException("KeywordGroup cannot be created from \"" + string + "\".");
    }
    QuotedStringTokenizer tok = new QuotedStringTokenizer(string.substring(MetadataSerializationConfiguration.AUTOMATIC_PERSONS_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);
    AutomaticPersonsGroup newGroup = new AutomaticPersonsGroup(name, context, field);
    addGroupDetails(tok, newGroup);
    return newGroup;
}
Also used : QuotedStringTokenizer(org.jabref.logic.util.strings.QuotedStringTokenizer) GroupHierarchyType(org.jabref.model.groups.GroupHierarchyType) AutomaticPersonsGroup(org.jabref.model.groups.AutomaticPersonsGroup)

Example 2 with GroupHierarchyType

use of org.jabref.model.groups.GroupHierarchyType in project jabref by JabRef.

the class GroupsParser method keywordGroupFromString.

/**
     * Parses s and recreates the KeywordGroup from it.
     *
     * @param s The String representation obtained from
     *          KeywordGroup.toString()
     */
private static KeywordGroup keywordGroupFromString(String s, Character keywordSeparator) throws ParseException {
    if (!s.startsWith(MetadataSerializationConfiguration.KEYWORD_GROUP_ID)) {
        throw new IllegalArgumentException("KeywordGroup cannot be created from \"" + s + "\".");
    }
    QuotedStringTokenizer tok = new QuotedStringTokenizer(s.substring(MetadataSerializationConfiguration.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);
    String expression = StringUtil.unquote(tok.nextToken(), MetadataSerializationConfiguration.GROUP_QUOTE_CHAR);
    boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
    boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
    KeywordGroup newGroup;
    if (regExp) {
        newGroup = new RegexKeywordGroup(name, context, field, expression, caseSensitive);
    } else {
        newGroup = new WordKeywordGroup(name, context, field, expression, caseSensitive, keywordSeparator, false);
    }
    addGroupDetails(tok, newGroup);
    return newGroup;
}
Also used : AutomaticKeywordGroup(org.jabref.model.groups.AutomaticKeywordGroup) KeywordGroup(org.jabref.model.groups.KeywordGroup) RegexKeywordGroup(org.jabref.model.groups.RegexKeywordGroup) WordKeywordGroup(org.jabref.model.groups.WordKeywordGroup) QuotedStringTokenizer(org.jabref.logic.util.strings.QuotedStringTokenizer) GroupHierarchyType(org.jabref.model.groups.GroupHierarchyType) RegexKeywordGroup(org.jabref.model.groups.RegexKeywordGroup) WordKeywordGroup(org.jabref.model.groups.WordKeywordGroup)

Example 3 with GroupHierarchyType

use of org.jabref.model.groups.GroupHierarchyType 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)3 GroupHierarchyType (org.jabref.model.groups.GroupHierarchyType)3 AutomaticKeywordGroup (org.jabref.model.groups.AutomaticKeywordGroup)2 AutomaticPersonsGroup (org.jabref.model.groups.AutomaticPersonsGroup)1 KeywordGroup (org.jabref.model.groups.KeywordGroup)1 RegexKeywordGroup (org.jabref.model.groups.RegexKeywordGroup)1 WordKeywordGroup (org.jabref.model.groups.WordKeywordGroup)1