setSize(parseSize(next)); if (nextIndex < token.length) { setResizeWeight(parseResizeWeight(token[nextIndex]));
/** * Parses an encoded form specification and initializes all required fields. * The encoded description must be in lower case. * * @param encodedDescription the FormSpec in an encoded format * * @throws NullPointerException if {@code encodedDescription} is {@code null} * @throws IllegalArgumentException if {@code encodedDescription} * is empty, whitespace, has no size, or is otherwise invalid */ private void parseAndInitValues(String encodedDescription) { checkNotBlank(encodedDescription, "The encoded form specification must not be null, empty or whitespace."); String[] token = TOKEN_SEPARATOR_PATTERN.split(encodedDescription); checkArgument(token.length > 0, "The form spec must not be empty."); int nextIndex = 0; String next = token[nextIndex++]; // Check if the first token is an orientation. DefaultAlignment alignment = DefaultAlignment.valueOf(next, isHorizontal()); if (alignment != null) { setDefaultAlignment(alignment); checkArgument(token.length > 1, "The form spec must provide a size."); next = token[nextIndex++]; } setSize(parseSize(next)); if (nextIndex < token.length) { setResizeWeight(parseResizeWeight(token[nextIndex])); } }