/** * Creates and returns an instance of <code>ConstantSize</code> from the * given encoded size and unit description. * * @param encodedValueAndUnit * value and unit in string representation * @param horizontal * true for horizontal, false for vertical * @return a <code>ConstantSize</code> for the given value and unit */ public static ConstantSize constant(String encodedValueAndUnit, boolean horizontal) { return ConstantSize.valueOf(encodedValueAndUnit, horizontal); }
/** * Creates and returns an instance of <code>ConstantSize</code> from the * given encoded size and unit description. * * @param encodedValueAndUnit value and unit in string representation * @param horizontal true for horizontal, false for vertical * @return a <code>ConstantSize</code> for the given value and unit */ public static ConstantSize constant(String encodedValueAndUnit, boolean horizontal) { String lowerCase = encodedValueAndUnit.toLowerCase(Locale.ENGLISH); String trimmed = lowerCase.trim(); return ConstantSize.valueOf(trimmed, horizontal); }
/** * Creates and returns an instance of {@code ConstantSize} from the * given encoded size and unit description. * * @param encodedValueAndUnit value and unit in string representation * @param horizontal true for horizontal, false for vertical * @return a {@code ConstantSize} for the given value and unit */ public static ConstantSize constant(String encodedValueAndUnit, boolean horizontal) { String lowerCase = encodedValueAndUnit.toLowerCase(Locale.ENGLISH); String trimmed = lowerCase.trim(); return ConstantSize.valueOf(trimmed, horizontal); }
/** * Decodes and returns an atomic size that is either a constant size or a * component size. * * @param token the encoded size * @return the decoded size either a constant or component size */ private Size parseAtomicSize(String token) { String trimmedToken = token.trim(); if ( trimmedToken.startsWith("'") && trimmedToken.endsWith("'")) { int length = trimmedToken.length(); if (length < 2) { throw new IllegalArgumentException("Missing closing \"'\" for prototype."); } return new PrototypeSize(trimmedToken.substring(1, length - 1)); } Sizes.ComponentSize componentSize = Sizes.ComponentSize.valueOf(trimmedToken); if (componentSize != null) { return componentSize; } return ConstantSize.valueOf(trimmedToken, isHorizontal()); }
/** * Decodes and returns an atomic size that is either a constant size or a * component size. * * @param token the encoded size * @return the decoded size either a constant or component size */ private Size parseAtomicSize(String token) { String trimmedToken = token.trim(); if ( trimmedToken.startsWith("'") && trimmedToken.endsWith("'")) { int length = trimmedToken.length(); if (length < 2) { throw new IllegalArgumentException("Missing closing \"'\" for prototype."); } return new PrototypeSize(trimmedToken.substring(1, length - 1)); } Sizes.ComponentSize componentSize = Sizes.ComponentSize.valueOf(trimmedToken); if (componentSize != null) return componentSize; return ConstantSize.valueOf(trimmedToken, isHorizontal()); }
/** * Decodes and returns an atomic size that is either a constant size or a * component size. * * @param token * the encoded size * @return the decoded size either a constant or component size */ private Size decodeAtomicSize(String token) { Sizes.ComponentSize componentSize = Sizes.ComponentSize.valueOf(token); if (componentSize != null) return componentSize; else return ConstantSize.valueOf(token, isHorizontal()); }