/** * Constructs a parser for the given encoded column/row specification, * the given LayoutMap, and orientation. * * @param source the raw encoded column or row specification * as provided by the user * @param description describes the source, e.g. "column specification" * @param layoutMap maps layout variable names to ColumnSpec and * RowSpec objects * @param horizontal {@code true} for columns, {@code false} for rows * * @throws NullPointerException if {@code source} is {@code null} */ private FormSpecParser( String source, String description, LayoutMap layoutMap, boolean horizontal) { FormUtils.assertNotNull(source, description); FormUtils.assertNotNull(layoutMap, "LayoutMap"); this.layoutMap = layoutMap; this.source = this.layoutMap.expand(source, horizontal); }
/** * Parses the encoded row specifications and returns a RowSpec object * that represents the string. Variables are expanded using the given * LayoutMap. * * @param encodedRowSpec the encoded column specification * @param layoutMap expands layout row variables * * @return a RowSpec instance for the given specification * @throws NullPointerException if {@code encodedRowSpec} or * {@code layoutMap} is {@code null} * * @see #decodeSpecs(String, LayoutMap) * * @since 1.2 */ public static RowSpec decode(String encodedRowSpec, LayoutMap layoutMap) { FormUtils.assertNotBlank(encodedRowSpec, "encoded row specification"); FormUtils.assertNotNull(layoutMap, "LayoutMap"); String trimmed = encodedRowSpec.trim(); String lower = trimmed.toLowerCase(Locale.ENGLISH); return decodeExpanded(layoutMap.expand(lower, false)); }
/** * Parses the encoded column specifications and returns a ColumnSpec object * that represents the string. Variables are expanded using the given * LayoutMap. * * @param encodedColumnSpec the encoded column specification * @param layoutMap expands layout column variables * * @return a ColumnSpec instance for the given specification * @throws NullPointerException if {@code encodedColumnSpec} or * {@code layoutMap} is {@code null} * * @see #decodeSpecs(String, LayoutMap) * * @since 1.2 */ public static ColumnSpec decode(String encodedColumnSpec, LayoutMap layoutMap) { FormUtils.assertNotBlank(encodedColumnSpec, "encoded column specification"); FormUtils.assertNotNull(layoutMap, "LayoutMap"); String trimmed = encodedColumnSpec.trim(); String lower = trimmed.toLowerCase(Locale.ENGLISH); return decodeExpanded(layoutMap.expand(lower, true)); }