public static long getContentLength()

in src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java [142:160]


    public static long getContentLength(final @NotNull Property property) throws RepositoryException {
        if (property.isMultiple()) {
            return -1;
        }

        long length = -1;
        if (property.getType() == PropertyType.BINARY) {
            // we're interested in the number of bytes, not the
            // number of characters
            try {
                length = property.getLength();
            } catch (final ValueFormatException vfe) {
                LOGGER.debug("Length of Property {} cannot be retrieved, ignored ({})", property.getPath(), vfe);
            }
        } else {
            length = property.getString().getBytes(StandardCharsets.UTF_8).length;
        }
        return length;
    }