本文整理了Java中javax.jcr.Binary.getSize()
方法的一些代码示例,展示了Binary.getSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binary.getSize()
方法的具体详情如下:
包路径:javax.jcr.Binary
类名称:Binary
方法名:getSize
[英]Returns the size of this Binary
value in bytes.
If #dispose() has been called on this Binary
object, then this method will throw the runtime exception java.lang.IllegalStateException.
[中]返回此Binary
值的大小(以字节为单位)。
如果已对此Binary
对象调用了#dispose(),则此方法将抛出运行时异常java。非法国家例外。
代码示例来源:origin: org.onehippo.cms7/hippo-cms-api
@Override
public long getSize() throws RepositoryException {
return binary.getSize();
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
/**
* Delegates to {@link Binary#getSize()} and returns -1 if that fails.
*/
@Override
public long length() {
try {
return binary.getSize();
} catch (RepositoryException e) {
LOG.warn("Error determining length of binary", e);
return -1;
}
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* Delegates to {@link Binary#getSize()} and returns -1 if that fails.
*/
@Override
public long length() {
try {
return binary.getSize();
} catch (RepositoryException e) {
LOG.warn("Error determining length of binary", e);
return -1;
}
}
代码示例来源:origin: ModeShape/modeshape
@Override
public long length() throws SQLException {
try {
return binary.getSize();
} catch (RepositoryException e) {
throw new SQLException(e);
}
}
代码示例来源:origin: org.modeshape/modeshape-jdbc-local
@Override
public long length() throws SQLException {
try {
return binary.getSize();
} catch (RepositoryException e) {
throw new SQLException(e);
}
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core
/**
* @see org.apache.jackrabbit.spi.QValue#getLength()
*/
@Override
public long getLength() throws RepositoryException {
if (PropertyType.BINARY == type) {
return ((Binary) val).getSize();
} else {
return super.getLength();
}
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
protected Long getValue(Value value) throws RepositoryException {
return value.getBinary().getSize();
}
}
代码示例来源:origin: org.jcrom/jcrom
@Override
public long getContentLength() {
long size = this.contentLength;
try {
size = binary != null ? binary.getSize() : this.contentLength;
} catch (RepositoryException e) {
logger.info(e.toString());
}
return size;
}
代码示例来源:origin: org.apache.jackrabbit/oak-core
@Override
protected Long getValue(Value value) throws RepositoryException {
return value.getBinary().getSize();
}
}
代码示例来源:origin: apache/jackrabbit
/**
* @see org.apache.jackrabbit.spi.QValue#getLength()
*/
@Override
public long getLength() throws RepositoryException {
if (PropertyType.BINARY == type) {
return ((Binary) val).getSize();
} else {
return super.getLength();
}
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@Override
protected Long getValue(Value value) throws RepositoryException {
return value.getBinary().getSize();
}
}
代码示例来源:origin: org.apache.jackrabbit/oak-jcr
/**
* Return the length of the specified JCR value object.
*
* @param value The value.
* @return The length of the given value.
* @throws RepositoryException If an error occurs.
*/
private static long getLength(Value value) throws RepositoryException {
if (value.getType() == PropertyType.BINARY) {
return value.getBinary().getSize();
} else {
return value.getString().length();
}
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Convenience method.
*/
protected long getLength() throws RepositoryException {
if (PropertyType.BINARY == type) {
return ((Binary) value).getSize();
}
return value.toString().length();
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
public long getSize() {
int size = 0;
final Property p = renditionData.getValueMap().get(JCR_DATA, Property.class);
try {
return (null != p) ? p.getBinary().getSize() : 0;
} catch (RepositoryException e) {
LOG.error("Failed to get the Rendition binary size in bytes [{}]: ", getPath(), e);
}
return size;
}
}
代码示例来源:origin: org.modeshape/modeshape-sequencer-java
@Override
public boolean execute( Property inputProperty,
Node outputNode,
Context context ) throws Exception {
Binary binaryValue = inputProperty.getBinary();
CheckArg.isNotNull(binaryValue, "binary");
try (InputStream stream = binaryValue.getStream()) {
new JdtRecorder().record(context, stream, binaryValue.getSize(), null, outputNode);
return true;
}
}
}
代码示例来源:origin: ModeShape/modeshape
@Override
public boolean execute( Property inputProperty,
Node outputNode,
Context context ) throws Exception {
Binary binaryValue = inputProperty.getBinary();
CheckArg.isNotNull(binaryValue, "binary");
try (InputStream stream = binaryValue.getStream()) {
new JdtRecorder().record(context, stream, binaryValue.getSize(), null, outputNode);
return true;
}
}
}
代码示例来源:origin: apache/jackrabbit
public void testGetBinary() throws RepositoryException, IOException {
Binary binary = prop.getBinary();
byte[] bytes = new byte[(int) binary.getSize()];
binary.read(bytes, 0);
binary.dispose();
assertEquals(prop.getString(), new String(bytes, "UTF-8"));
}
代码示例来源:origin: ModeShape/modeshape
private void readLargeBinary() throws Exception {
Node commit = session.getNode("/repos/git-modeshape-remote/tree/master/modeshape-jcr/src/test/resources/docs/postgresql-8.4.1-US.pdf");
assertNotNull(commit);
Binary data = commit.getNode("jcr:content").getProperty("jcr:data").getBinary();
long size = data.getSize();
assertTrue(size > 0);
//simply read the stream to make sure it's valid
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos);
IoUtil.write(data.getStream(), bos);
assertEquals("invalid binary stream", size, baos.toByteArray().length);
}
代码示例来源:origin: apache/jackrabbit
public void testGetBinaryFromValue() throws RepositoryException, IOException {
Value v = superuser.getValueFactory().createValue("/a/b/c", PropertyType.PATH);
Binary binary = v.getBinary();
byte[] bytes = new byte[(int) binary.getSize()];
binary.read(bytes, 0);
binary.dispose();
assertEquals(prop.getString(), new String(bytes, "UTF-8"));
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testGetBinaryFromString() throws Exception {
// GIVEN
Object objectValue = "Hallo";
MockValue jcrValue = new MockValue(objectValue);
// WHEN
Binary result = jcrValue.getBinary();
// THEN
assertEquals(5, result.getSize());
}
内容来源于网络,如有侵权,请联系作者删除!