package org.securegraph;

import java.util.*;

public enum TextIndexHint {
    /**
     * Tokenize this property and index it for full text search.
     */
    FULL_TEXT((byte) 0x01),
    /**
     * Index this property for exact match searches.
     */
    EXACT_MATCH((byte) 0x02);

    private final byte value;

    TextIndexHint(byte value) {
        this.value = value;
    }

    public static byte toBits(TextIndexHint... indexHints) {
        return toBits(EnumSet.copyOf(Arrays.asList(indexHints)));
    }

    public static byte toBits(Collection<TextIndexHint> hints) {
        byte b = 0;
        for (TextIndexHint hint : hints) {
            b |= hint.value;
        }
        return b;
    }

    public static Set<TextIndexHint> toSet(byte indexHint) {
        Set<TextIndexHint> hints = new HashSet<TextIndexHint>();
        if ((indexHint & FULL_TEXT.value) == FULL_TEXT.value) {
            hints.add(FULL_TEXT);
        }
        if ((indexHint & EXACT_MATCH.value) == EXACT_MATCH.value) {
            hints.add(EXACT_MATCH);
        }
        return hints;
    }

    /**
     * Use this to prevent indexing of this Text property.  The property
     * will not be searchable.
     */
    public static final Set<TextIndexHint> NONE = EnumSet.noneOf(TextIndexHint.class);

    /**
     * The set of indexing hints that trigger all available indexes for
     * a Text property.
     */
    public static final Set<TextIndexHint> ALL = EnumSet.of(FULL_TEXT, EXACT_MATCH);
}

@@ -1074,24 +1074,983 @@
 nts;%0A    %7D%0A%0A
+    public static Set%3CTextIndexHint%3E parse(String str) %7B%0A        if (str == null %7C%7C str.equalsIgnoreCase(%22NONE%22)) %7B%0A            return NONE;%0A        %7D%0A%0A        if (str.equalsIgnoreCase(%22ALL%22)) %7B%0A            return ALL;%0A        %7D%0A%0A        String%5B%5D textIndexHintParts = str.split(%22,%22);%0A        Set%3CTextIndexHint%3E textIndexHints = new HashSet%3CTextIndexHint%3E();%0A        for (String textIndexHintPart : textIndexHintParts) %7B%0A            if (textIndexHintPart.trim().length() == 0) %7B%0A                continue;%0A            %7D%0A            textIndexHints.add(parsePart(textIndexHintPart));%0A        %7D%0A        return textIndexHints;%0A    %7D%0A%0A    private static TextIndexHint parsePart(String part) %7B%0A        part = part.trim();%0A        for (TextIndexHint textIndexHint : TextIndexHint.values()) %7B%0A            if (textIndexHint.name().equalsIgnoreCase(part)) %7B%0A                return textIndexHint;%0A            %7D%0A        %7D%0A        return TextIndexHint.valueOf(part);%0A    %7D%0A%0A
     /**%0A    

add parse method to TextIndexHint