Selects the phrase for the given keyword.

@param keyword a phrase selection keyword.
@return the string containing the formatted select message.
@throws IllegalArgumentException when the given keyword is not a "pattern identifier"
544229
public final String format(String keyword) {
        //Check for the validity of the keyword
        if (!PatternProps.isIdentifier(keyword)) {
            throw new IllegalArgumentException("Invalid formatting argument.");
        }
        // If no pattern was applied, throw an exception
        if (msgPattern == null || msgPattern.countParts() == 0) {
            throw new IllegalStateException("Invalid format error.");
        }

        // Get the appropriate sub-message.
        int msgStart = findSubMessage(msgPattern, 0, keyword);
        if (!msgPattern.jdkAposMode()) {
            int msgLimit = msgPattern.getLimitPartIndex(msgStart);
            return msgPattern.getPatternString().substring(msgPattern.getPart(msgStart).getLimit(),
                                                           msgPattern.getPatternIndex(msgLimit));
        }
        // JDK compatibility mode: Remove SKIP_SYNTAX.
        StringBuilder result = null;
        int prevIndex = msgPattern.getPart(msgStart).getLimit();
        for (int i = msgStart;;) {
            MessagePattern.Part part = msgPattern.getPart(++i);
            MessagePattern.Part.Type type = part.getType();
            int index = part.getIndex();
            if (type == MessagePattern.Part.Type.MSG_LIMIT) {
                if (result == null) {
                    return pattern.substring(prevIndex, index);
                } else {
                    return result.append(pattern, prevIndex, index).toString();
                }
            } else if (type == MessagePattern.Part.Type.SKIP_SYNTAX) {
                if (result == null) {
                    result = new StringBuilder();
                }
                result.append(pattern, prevIndex, index);
                prevIndex = part.getLimit();
            } else if (type == MessagePattern.Part.Type.ARG_START) {
                if (result == null) {
                    result = new StringBuilder();
                }
                result.append(pattern, prevIndex, index);
                prevIndex = index;
                i = msgPattern.getLimitPartIndex(i);
                index = msgPattern.getPart(i).getLimit();
                MessagePattern.appendReducedApostrophes(pattern, prevIndex, index, result);
                prevIndex = index;
            }
        }
    }
888333
public void selectWord(int position)
	{
		if (text.length() == 0)
			return;

		selectingText = true;

		selectionCursor.jumpTo(position);
		selectionCursor.jumpToNextSpace(true);
		if (Character.isWhitespace(text.charAt(selectionCursor.index)))
			selectionCursor.shiftRight();

		cursor.jumpTo(position);
		cursor.jumpToNextSpace(false);
	}
1260913
private String getSurrogateKeyForTaggedOption(
            final String rawOptionString,   // the raw option string provided by the user, including the prefix and option name
            final String rawArgumentValue,  // the raw argument value provided by the user
            final String tagString          // the tag string that has been peeled off of the raw option string, including logical name and any attributes
    )
    {
        final String surrogateKey = makeSurrogateKey(rawOptionString, rawArgumentValue);
        if (null != tagSurrogates.put(surrogateKey, Pair.of(tagString, rawArgumentValue))) {
            throw new CommandLineException.BadArgumentValue(
                    String.format("The argument value: \"%s %s\" was duplicated on the command line", rawOptionString, rawArgumentValue));
        }
        return surrogateKey;
    }
703077
public void addKeyword(String keyword) {
        if (taxonomy.concepts.containsKey(keyword)) {
            throw new IllegalArgumentException(String.format("Concept %s already exists.", keyword));
        }

        taxonomy.concepts.put(keyword, this);

        if (synset == null) {
            synset = new TreeSet<>();
        }

        synset.add(keyword);
    }
2118
public void setKeyword(String keyword) {
    if(keyword != null) {
      keyword = keyword.trim();
    }
    this.keyword = keyword;
  }
1068904
public CommandArgs<K, V> add(CommandKeyword keyword) {

        LettuceAssert.notNull(keyword, "CommandKeyword must not be null");
        singularArguments.add(ProtocolKeywordArgument.of(keyword));
        return this;
    }
1002506
def defined_annotation_keywords(self) -> Set[str]:
        """"""
        return (
            set(self.annotation_pattern) |
            set(self.annotation_url) |
            set(self.annotation_list)
        )
294192
static String removeKeyword(String clause, String keyword) {
    keyword = keyword + " ";
    if (clause.regionMatches(true, 0, keyword, 0, keyword.length())) {
      return clause.substring(keyword.length());
    }
    return clause;
  }
690359
public java.lang.String getOnselect() {
        return (java.lang.String) getStateHelper().eval(PropertyKeys.onselect);

    }
1269132
@ArgumentsChecked
	@Throws(IllegalNullArgumentException.class)
	private static String format(@Nonnull final Class<? extends Annotation> annotation) {
		if (annotation == null) {
			throw new IllegalNullArgumentException("annotation");
		}
		return String.format(MESSAGE_WITH_ANNOTATION, annotation.getName());
	}
672164
java.util.regex.Pattern getPattern(
            @Nonnull AnnotationValue<?> annotationMetadata,
            boolean isOptional) {
        final Optional<String> regexp = annotationMetadata.get("regexp", String.class);
        final String pattern;

        if (isOptional) {
            pattern = regexp.orElse(".*");
        } else {
            pattern = regexp
                    .orElseThrow(() -> new ValidationException("No pattern specified"));
        }

        final Pattern.Flag[] flags = annotationMetadata.get("flags", Pattern.Flag[].class).orElse(ZERO_FLAGS);
        if (isOptional && pattern.equals(".*") && flags.length == 0) {
            return null;
        }

        int computedFlag = 0;
        for (Pattern.Flag flag : flags) {
            computedFlag = computedFlag | flag.getValue();
        }

        final PatternKey key = new PatternKey(pattern, computedFlag);
        java.util.regex.Pattern regex = COMPUTED_PATTERNS.get(key);
        if (regex == null) {
            try {
                if (computedFlag != 0) {
                    regex = java.util.regex.Pattern.compile(pattern, computedFlag);
                } else {
                    regex = java.util.regex.Pattern.compile(pattern);
                }
            } catch (PatternSyntaxException e) {
                throw new IllegalArgumentException("Invalid regular expression", e);
            }
            COMPUTED_PATTERNS.put(key, regex);
        }
        return regex;
    }
25218
public SelectBuilder format(final String _pattern)
    {
        addPoint();
        this.bldr.append("format[").append(_pattern).append("]");
        return this;
    }
1208229
public static String[] getArgs(final String patternString, final String sourceString, final String[] keywordPrecedence) {

        log.debug("Util getArgs String[] with pattern: " + patternString + " and sourceStr: "
                + sourceString);

        String[] rtn = null;

        ArrayList<String> argsList = null;

        String patternCopy = new String(patternString);
        if (keywordPrecedence != null && StringUtils.startsWithAny(patternString, keywordPrecedence)){
            //
            for (String s : keywordPrecedence){


                patternCopy = StringUtils.removeStart(patternCopy, s);
            }

            patternCopy = "(?:" + StringUtils.join(keywordPrecedence, "|") + ")" + patternCopy;
        }


        final Pattern pattern = Pattern.compile(patternCopy);
        final Matcher matcher = pattern.matcher(sourceString);

        final int groupCount = matcher.groupCount();

        // TODO - this doesn't work if we're not doing strict matching
        if (matcher.find()) {

            for (int i = 1; i <= groupCount; i++) {
                final String arg = matcher.group(i);

                if (arg != null) {
                    if (argsList == null) {
                        argsList = new ArrayList<String>();
                    }
                    argsList.add(arg);
                }
            }
        }

        if (argsList != null) {
            rtn = argsList.toArray(new String[argsList.size()]);

            if (log.isDebugEnabled()) {

                final StringBuilder buf = new StringBuilder();
                buf.append("returning args: ");

                for (final String s : argsList) {

                    buf.append("[").append(s).append("] ");
                }

                log.debug(buf.toString());
            }

        }

        return rtn;
    }
66811
public void setPattern(String pattern) {
        if (pattern == null || pattern.length() <= 0) {
            throw new IllegalArgumentException(
                    "Pattern to search for can not be null or of length 0");
        }
        pattern_.text_ = pattern;
        initialize();
    }
333392
public void setKeyword(java.util.Collection<KeywordFilter> keyword) {
        if (keyword == null) {
            this.keyword = null;
            return;
        }

        this.keyword = new java.util.ArrayList<KeywordFilter>(keyword);
    }
1302459
String getUriStringForRank(StatementRank rank) {
		switch (rank) {
		case NORMAL:
			return Vocabulary.WB_NORMAL_RANK;
		case PREFERRED:
			return Vocabulary.WB_PREFERRED_RANK;
		case DEPRECATED:
			return Vocabulary.WB_DEPRECATED_RANK;
		default:
			throw new IllegalArgumentException();
		}
	}
1267426
public static Keyword keyword(Object o) {
        if (o instanceof Keyword)
            return (Keyword) o;
        else if (o instanceof String) {
            String s = (String) o;
            if (s.charAt(0) == ':')
                return new KeywordImpl(s.substring(1));
            else
                return new KeywordImpl(s);
        }
        else throw new IllegalArgumentException("Cannot make keyword from " + o.getClass().getSimpleName());
    }