/** * Parses an encoded form spec and initializes all required fields. The * encoded description must be in lower case. * * @param encodedDescription * the FormSpec in an encoded format * @throws IllegalArgumentException * if the string is empty, has no size, or is otherwise invalid */ private void parseAndInitValues(String encodedDescription) { StringTokenizer tokenizer = new StringTokenizer(encodedDescription, ":"); if (!tokenizer.hasMoreTokens()) { throw new IllegalArgumentException("The form spec must not be empty."); } String token = tokenizer.nextToken(); // Check if the first token is an orientation. DefaultAlignment alignment = DefaultAlignment.valueOf(token, isHorizontal()); if (alignment != null) { defaultAlignment = alignment; if (!tokenizer.hasMoreTokens()) { throw new IllegalArgumentException("The form spec must provide a size."); } token = tokenizer.nextToken(); } parseAndInitSize(token); if (tokenizer.hasMoreTokens()) { resizeWeight = decodeResize(tokenizer.nextToken()); } }