Last batch of fixes from AutoRefactor (or me) for a while.
AutoRefactor successfully goes through the whole SDK now.
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | final public void addValue(final String valueString) { |
| | | public final void addValue(final String valueString) { |
| | | if (valueString != null) { |
| | | clearValues(); |
| | | super.addValue(valueString); |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | final public void setPresent(final boolean isPresent) { |
| | | public final void setPresent(final boolean isPresent) { |
| | | addValue(String.valueOf(isPresent)); |
| | | } |
| | | |
| | |
| | | * limit is greater than the upper limit. |
| | | */ |
| | | public final void setUpperLimit(String upperLimit) { |
| | | if (upperLimit == null) { |
| | | setUpperLimit((Long) null); |
| | | } else { |
| | | setUpperLimit(SizeUnit.parseValue(upperLimit, SizeUnit.BYTES)); |
| | | } |
| | | setUpperLimit(upperLimit != null ? SizeUnit.parseValue(upperLimit, SizeUnit.BYTES) : null); |
| | | } |
| | | |
| | | /** |
| | |
| | | BYTES(1L, "b", "bytes"), |
| | | |
| | | /** A gibi-byte unit. */ |
| | | GIBI_BYTES(1024 * 1024 * 1024, "gib", "gibibytes"), |
| | | GIBI_BYTES(1024L * 1024 * 1024, "gib", "gibibytes"), |
| | | |
| | | /** A giga-byte unit. */ |
| | | GIGA_BYTES(1000 * 1000 * 1000, "gb", "gigabytes"), |
| | | GIGA_BYTES(1000L * 1000 * 1000, "gb", "gigabytes"), |
| | | |
| | | /** A kibi-byte unit. */ |
| | | KIBI_BYTES(1024L, "kib", "kibibytes"), |
| | |
| | | KILO_BYTES(1000L, "kb", "kilobytes"), |
| | | |
| | | /** A mebi-byte unit. */ |
| | | MEBI_BYTES(1024 * 1024, "mib", "mebibytes"), |
| | | MEBI_BYTES(1024L * 1024, "mib", "mebibytes"), |
| | | |
| | | /** A mega-byte unit. */ |
| | | MEGA_BYTES(1000 * 1000, "mb", "megabytes"), |
| | | MEGA_BYTES(1000L * 1000, "mb", "megabytes"), |
| | | |
| | | /** A tebi-byte unit. */ |
| | | TEBI_BYTES(1024L * 1024 * 1024 * 1024, "tib", "tebibytes"), |
| | |
| | | { "gb", SizeUnit.GIGA_BYTES }, |
| | | { "gib", SizeUnit.GIBI_BYTES }, |
| | | { "tb", SizeUnit.TERA_BYTES }, |
| | | { "tib", SizeUnit.TEBI_BYTES } }; |
| | | { "tib", SizeUnit.TEBI_BYTES }, |
| | | }; |
| | | } |
| | | |
| | | @Test(dataProvider = "stringToSizeLimitData") |
| | |
| | | { "1000kb", 1000000L }, |
| | | { "1000 kilobytes", 1000000L }, |
| | | { "1000 KILOBYTES", 1000000L }, |
| | | { "1000 KB", 1000000L } }; |
| | | { "1000 KB", 1000000L }, |
| | | }; |
| | | } |
| | | |
| | | @Test(dataProvider = "parseValueData") |
| | |
| | | { SizeUnit.BYTES, 1L }, |
| | | { SizeUnit.KILO_BYTES, 1000L }, |
| | | { SizeUnit.KIBI_BYTES, 1024L }, |
| | | { SizeUnit.MEGA_BYTES, (long) 1000 * 1000 }, |
| | | { SizeUnit.MEBI_BYTES, (long) 1024 * 1024 }, |
| | | { SizeUnit.GIGA_BYTES, (long) 1000 * 1000 * 1000 }, |
| | | { SizeUnit.GIBI_BYTES, (long) 1024 * 1024 * 1024 }, |
| | | { SizeUnit.TERA_BYTES, (long) 1000 * 1000 * 1000 * 1000 }, |
| | | { SizeUnit.TEBI_BYTES, (long) 1024 * 1024 * 1024 * 1024 } |
| | | { SizeUnit.MEGA_BYTES, 1000L * 1000 }, |
| | | { SizeUnit.MEBI_BYTES, 1024L * 1024 }, |
| | | { SizeUnit.GIGA_BYTES, 1000L * 1000 * 1000 }, |
| | | { SizeUnit.GIBI_BYTES, 1024L * 1024 * 1024 }, |
| | | { SizeUnit.TERA_BYTES, 1000L * 1000 * 1000 * 1000 }, |
| | | { SizeUnit.TEBI_BYTES, 1024L * 1024 * 1024 * 1024 }, |
| | | }; |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | if ((length % 2) != 0) { |
| | | if (length % 2 != 0) { |
| | | final LocalizableMessage message = ERR_HEX_DECODE_INVALID_LENGTH.get(hexBuffer); |
| | | throw DecodeException.error(message); |
| | | } |
| | |
| | | // This character is escaped. |
| | | if (isHexDigit(c)) { |
| | | // Unicode characters. |
| | | if (!(reader.remaining() > 0)) { |
| | | if (reader.remaining() <= 0) { |
| | | final LocalizableMessage msg = |
| | | ERR_ATTR_SYNTAX_DN_ESCAPED_HEX_VALUE_INVALID |
| | | .get(reader.getString()); |
| | |
| | | // The encoded value must have length that is a multiple of four |
| | | // bytes. |
| | | final int length = base64.length(); |
| | | if ((length % 4) != 0) { |
| | | if (length % 4 != 0) { |
| | | final LocalizableMessage message = ERR_BASE64_DECODE_INVALID_LENGTH.get(base64); |
| | | throw new LocalizedIllegalArgumentException(message); |
| | | } |
| | |
| | | // only digits and periods, but not consecutive periods. |
| | | boolean lastWasPeriod = false; |
| | | |
| | | while (reader.remaining() > 0 && (c = reader.read()) != ' ' && c != ')' |
| | | && !(c == '\'' && enclosingQuote)) { |
| | | while (reader.remaining() > 0 |
| | | && (c = reader.read()) != ' ' |
| | | && c != ')' |
| | | && (c != '\'' || !enclosingQuote)) { |
| | | if (c == '.') { |
| | | if (lastWasPeriod) { |
| | | throw DecodeException.error( |
| | |
| | | } |
| | | } else if (isAlpha(c)) { |
| | | // This must be an attribute description. In this case, we will |
| | | // only accept alphabetic characters, numeric digits, and the |
| | | // hyphen. |
| | | while (reader.remaining() > 0 && (c = reader.read()) != ' ' && c != ')' |
| | | && !(c == '\'' && enclosingQuote)) { |
| | | // only accept alphabetic characters, numeric digits, and the hyphen. |
| | | while (reader.remaining() > 0 |
| | | && (c = reader.read()) != ' ' |
| | | && c != ')' |
| | | && (c != '\'' || !enclosingQuote)) { |
| | | if (length == 0 && !isAlpha(c)) { |
| | | throw DecodeException.error( |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID1.get(c, reader.pos() - 1)); |
| | |
| | | } |
| | | if (isDigit(c)) { |
| | | boolean lastWasPeriod = false; |
| | | while ((c = reader.read()) != ' ' && c != '{' && !(c == '\'' && enclosingQuote)) { |
| | | while ((c = reader.read()) != ' ' |
| | | && c != '{' |
| | | && (c != '\'' || !enclosingQuote)) { |
| | | if (c == '.') { |
| | | if (lastWasPeriod) { |
| | | throw DecodeException.error( |
| | |
| | | } |
| | | } else if (isAlpha(c)) { |
| | | // This must be an attribute description. In this case, we will |
| | | // only accept alphabetic characters, numeric digits, and the |
| | | // hyphen. |
| | | while ((c = reader.read()) != ' ' && c != ')' && c != '{' |
| | | && !(c == '\'' && enclosingQuote)) { |
| | | // only accept alphabetic characters, numeric digits, and the hyphen. |
| | | while ((c = reader.read()) != ' ' |
| | | && c != ')' |
| | | && c != '{' |
| | | && (c != '\'' || !enclosingQuote)) { |
| | | if (length == 0 && !isAlpha(c)) { |
| | | throw DecodeException.error( |
| | | ERR_ATTR_SYNTAX_ILLEGAL_CHAR_IN_STRING_OID1.get(c, reader.pos() - 1)); |