Parses the given string as bytes.
The supported expressions are listed under {@link MemorySize}.

@param text The string to parse
@return The parsed size, in bytes.

@throws IllegalArgumentException Thrown, if the expression cannot be parsed.
550860
public static long parseBytes(String text) throws IllegalArgumentException {
		checkNotNull(text, "text");

		final String trimmed = text.trim();
		checkArgument(!trimmed.isEmpty(), "argument is an empty- or whitespace-only string");

		final int len = trimmed.length();
		int pos = 0;

		char current;
		while (pos < len && (current = trimmed.charAt(pos)) >= '0' && current <= '9') {
			pos++;
		}

		final String number = trimmed.substring(0, pos);
		final String unit = trimmed.substring(pos).trim().toLowerCase(Locale.US);

		if (number.isEmpty()) {
			throw new NumberFormatException("text does not start with a number");
		}

		final long value;
		try {
			value = Long.parseLong(number); // this throws a NumberFormatException on overflow
		}
		catch (NumberFormatException e) {
			throw new IllegalArgumentException("The value '" + number +
					"' cannot be re represented as 64bit number (numeric overflow).");
		}

		final long multiplier;
		if (unit.isEmpty()) {
			multiplier = 1L;
		}
		else {
			if (matchesAny(unit, BYTES)) {
				multiplier = 1L;
			}
			else if (matchesAny(unit, KILO_BYTES)) {
				multiplier = 1024L;
			}
			else if (matchesAny(unit, MEGA_BYTES)) {
				multiplier = 1024L * 1024L;
			}
			else if (matchesAny(unit, GIGA_BYTES)) {
				multiplier = 1024L * 1024L * 1024L;
			}
			else if (matchesAny(unit, TERA_BYTES)) {
				multiplier = 1024L * 1024L * 1024L * 1024L;
			}
			else {
				throw new IllegalArgumentException("Memory size unit '" + unit +
						"' does not match any of the recognized units: " + MemoryUnit.getAllUnits());
			}
		}

		final long result = value * multiplier;

		// check for overflow
		if (result / multiplier != value) {
			throw new IllegalArgumentException("The value '" + text +
					"' cannot be re represented as 64bit number of bytes (numeric overflow).");
		}

		return result;
	}
519894
public static String titleize(final String text, final String[] intCaps)
    {
        String str = text.toLowerCase(Locale.ENGLISH).replaceAll("[\\s_]+", SPACE).trim();
        return titleize(str, SPACE, intCaps);
    }
94294
public static VersionNumber parseLastVersionNumber(@Nonnull final String text) {
		return VersionParser.parseLastVersionNumber(Check.notNull(text, "text"));
	}
728773
@Override
    public String encode( String text ) {
        try {
            byte[] hash = SecureHash.getHash(algorithm, text.getBytes());
            String result = Base64.encodeBytes(hash);
            return result.length() < maxLength ? result : result.substring(0, maxLength);
        } catch (NoSuchAlgorithmException e) {
            return text;
        }
    }
1260155
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
    private static SortedSet<MediaType> parse(final String text) {
        final SortedSet<MediaType> list = new TreeSet<>();
        for (final String name
            : new EnglishLowerCase(text).string().split(",")) {
            if (!name.isEmpty()) {
                list.add(new MediaType(name));
            }
        }
        return list;
    }
432371
static BankInfo parse(String text) {
        BankInfo info = new BankInfo();
        if (text == null || text.length() == 0)
            return info;

        String[] cols = text.split("\\|");
        info.setName(getValue(cols, 0));
        info.setLocation(getValue(cols, 1));
        info.setBic(getValue(cols, 2));
        info.setChecksumMethod(getValue(cols, 3));
        info.setRdhAddress(getValue(cols, 4));
        info.setPinTanAddress(getValue(cols, 5));
        info.setRdhVersion(HBCIVersion.byId(getValue(cols, 6)));
        info.setPinTanVersion(HBCIVersion.byId(getValue(cols, 7)));

        return info;
    }
1305919
public void parse(String string) {
    if (string == null) {
      throw new NullPointerException("string is null");
    }
    int bufferSize = Math.max(MIN_BUFFER_SIZE, Math.min(DEFAULT_BUFFER_SIZE, string.length()));
    try {
      parse(new StringReader(string), bufferSize);
    } catch (IOException exception) {
      // StringReader does not throw IOException
      throw new RuntimeException(exception);
    }
  }
1061524
public synchronized void setText(String text) {
        setLines(splitIntoMultipleLines(text));
        this.labelSize = getBounds(lines, labelSize);
        invalidate();
    }
777702
private static long parse(final String argument) throws NumberFormatException {
		if (argument.endsWith("gb")) {
			return Long.parseLong(argument.substring(0, argument.length() - "gb".length()).trim()) * GB;
		} else if (argument.endsWith("mb")) {
			return Long.parseLong(argument.substring(0, argument.length() - "mb".length()).trim()) * MB;
		} else if (argument.endsWith("kb")) {
			return Long.parseLong(argument.substring(0, argument.length() - "kb".length()).trim()) * KB;
		} else if (argument.endsWith("bytes")) {
			return Long.parseLong(argument.substring(0, argument.length() - "bytes".length()).trim());
		} else {
			return Long.parseLong(argument.trim());
		}
	}
1124822
public void setAsText(String text) throws IllegalArgumentException {
        if (text == null || text.equals("")) {
            setValue(null);
            return;
        }
        Enum<?> value = Enum.valueOf(enumClass, text);
        setValue(value);
    }
1120853
public static String parseString(InputStream inputStream, final int size) throws IOException {
        if (0 == size) {
            return "";
        }

        byte[] buffer = new byte[size];
        int numberOfReadsBytes = inputStream.read(buffer, 0, size);
        assert numberOfReadsBytes == size;

        return new String(buffer, "UTF-8");
    }
1191939
public Document parseString(String text) throws SAXException {
        try {
            return parse(new InputSource(new StringReader(text)));
        } catch (IOException e) {
            throw new RuntimeException("unexpected world exception while reading memory stream", e);
        }
    }
370138
public String encryptText(String text)
	throws Exception
	{
		return toByteText(this.encrypt(text.getBytes(IO.CHARSET)));

	}
1369713
@Pure
	@SuppressWarnings("checkstyle:cyclomaticcomplexity")
	public static AttributeValueImpl parse(String text) {
		final AttributeValueImpl value = new AttributeValueImpl(text);
		if (text != null && !text.isEmpty()) {
			Object binValue;
			for (final AttributeType type : AttributeType.values()) {
				try {
					binValue = null;
					switch (type) {
					case BOOLEAN:
						binValue = value.getBoolean();
						break;
					case DATE:
						binValue = value.getDate();
						break;
					case ENUMERATION:
						binValue = value.getEnumeration();
						break;
					case INET_ADDRESS:
						binValue = value.getInetAddress();
						break;
					case INTEGER:
						binValue = value.getInteger();
						break;
					case OBJECT:
						binValue = value.getJavaObject();
						break;
					case POINT:
						binValue = parsePoint((String) value.value, true);
						break;
					case POINT3D:
						binValue = parsePoint3D((String) value.value, true);
						break;
					case POLYLINE:
						binValue = parsePolyline((String) value.value, true);
						break;
					case POLYLINE3D:
						binValue = parsePolyline3D((String) value.value, true);
						break;
					case REAL:
						binValue = value.getReal();
						break;
					case STRING:
						binValue = value.getString();
						break;
					case TIMESTAMP:
						binValue = value.getTimestamp();
						break;
					case TYPE:
						binValue = value.getJavaClass();
						break;
					case URI:
						binValue = parseURI((String) value.value);
						break;
					case URL:
						binValue = value.getURL();
						break;
					case UUID:
						binValue = parseUUID((String) value.value);
						break;
					default:
						//
					}
					if (binValue != null) {
						return new AttributeValueImpl(type, binValue);
					}
				} catch (Throwable exception) {
					//
				}
			}
		}
		return value;
	}
1009080
public int getWidth(String text) {
        int total = 0;
        if (fastWinansi) {
            int len = text.length();
            for (int k = 0; k < len; ++k) {
                char char1 = text.charAt(k);
                if (char1 < 128 || (char1 >= 160 && char1 <= 255))
                    total += widths[char1];
                else
                    total += widths[PdfEncodings.winansi.get(char1)];
            }
            return total;
        }
        else {
            byte mbytes[] = convertToBytes(text);
            for (int k = 0; k < mbytes.length; ++k)
                total += widths[0xff & mbytes[k]];
        }
        return total;
    }
1257157
public <T> T parse(String text, Class<T> clazz) {
        return gson.fromJson(text, clazz);
    }
1157365
public <V> V convertFrom(final char[] text) {
        if (text == null) return null;
        return (V) convertFrom(text, 0, text.length);
    }