Clob (record)

Represents a character large object.

Conceptually you can consider it as a set of characters (an RTF or XML document, for example), though in fact it wraps three pieces of information:

  • the set of characters

  • a name

  • a mime type

API

Clob.java
record Clob {
  Clob(String name, String primaryType, String subType, char[] chars)
  Clob(String name, String mimeTypeBase, char[] chars)
  Clob(String name, MimeType mimeType, char[] chars)
  Clob(String name, String primaryType, String subType, CharSequence chars)
  Clob(String name, String mimeTypeBase, CharSequence chars)
  Clob(String name, MimeType mimeType, CharSequence chars)
  Clob of(String name, CommonMimeType mimeType, CharSequence content)     (1)
  Try<Clob> tryRead(String name, CommonMimeType mimeType, DataSource dataSource, Charset charset)     (2)
  Try<Clob> tryRead(String name, CommonMimeType mimeType, File file, Charset charset)     (3)
  Try<Clob> tryReadUtf8(String name, CommonMimeType mimeType, File file)     (4)
  Clob flatMap(UnaryOperator<Clob> mapper)     (5)
  Blob toBlob(Charset charset)     (6)
  Blob toBlobUtf8()     (7)
  void writeCharsTo(Writer wr)
  void writeTo(File file, Charset charset)     (8)
  void writeToUtf8(File file)     (9)
  String asString()
  boolean equals(Object o)
  int hashCode()
  String toString()
}
1 of(String, CommonMimeType, CharSequence)

Returns a new Clob of given name , mimeType and content .

2 tryRead(String, CommonMimeType, DataSource, Charset)

Returns a new Clob of given name , mimeType and content from dataSource , wrapped with a Try .

3 tryRead(String, CommonMimeType, File, Charset)

Shortcut for tryRead(name, mimeType, DataSource.ofFile(file), charset)

4 tryReadUtf8(String, CommonMimeType, File)

Shortcut for #tryRead(String, org.apache.causeway.applib.value.NamedWithMimeType.CommonMimeType, File, Charset) using StandardCharsets#UTF_8 .

5 flatMap(UnaryOperator)

Allows fluent chaining of Clob operators.

6 toBlob(Charset)

Converts to a Blob , using given Charset for the underlying String to byte[] conversion.

7 toBlobUtf8()

Shortcut for #toBlob(Charset) using StandardCharsets#UTF_8 .

8 writeTo(File, Charset)

Writes this Clob to the file represented by the specified File object.

9 writeToUtf8(File)

Shortcut for #writeTo(File, Charset) using StandardCharsets#UTF_8 .

Members

of(String, CommonMimeType, CharSequence)

Returns a new Clob of given name , mimeType and content .

name may or may not include the desired filename extension, as it is guaranteed, that the resulting Clob has the appropriate extension as constraint by the given mimeType .

For more fine-grained control use one of the Clob constructors directly.

tryRead(String, CommonMimeType, DataSource, Charset)

Returns a new Clob of given name , mimeType and content from dataSource , wrapped with a Try .

name may or may not include the desired filename extension, as it is guaranteed, that the resulting Clob has the appropriate extension as constraint by the given mimeType .

For more fine-grained control use one of the Clob constructors directly.

tryRead(String, CommonMimeType, File, Charset)

Shortcut for tryRead(name, mimeType, DataSource.ofFile(file), charset)

tryReadUtf8(String, CommonMimeType, File)

Shortcut for #tryRead(String, org.apache.causeway.applib.value.NamedWithMimeType.CommonMimeType, File, Charset) using StandardCharsets#UTF_8 .

flatMap(UnaryOperator)

Allows fluent chaining of Clob operators.

toBlob(Charset)

Converts to a Blob , using given Charset for the underlying String to byte[] conversion.

toBlobUtf8()

Shortcut for #toBlob(Charset) using StandardCharsets#UTF_8 .

writeTo(File, Charset)

Writes this Clob to the file represented by the specified File object.

If the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason then a FileNotFoundException is thrown.

writeToUtf8(File)

Shortcut for #writeTo(File, Charset) using StandardCharsets#UTF_8 .

Usage Notes

If using JPA/Eclipselink, Blob properties can be mapped using the ClobJpaEmbeddable:

@AttributeOverrides({
    @AttributeOverride(name="name",    column=@Column(name="doc_name")),
    @AttributeOverride(name="mimeType",column=@Column(name="doc_mimeType")),
    @AttributeOverride(name="bytes",   column=@Column(name="doc_bytes"))
})
@Getter @Setter
private ClobJpaEmbeddable doc;

@Property()
@PropertyLayout()
public Clob getDoc() {
  return ClobJpaEmbeddable.toClob(doc);
}
public void setDoc(final Clob doc) {
  this.doc = ClobJpaEmbeddable.fromClob(doc);
}