The Document Object

Here we will discuss the document object for Prismic when using the Java development kit.

Before Reading

This article assumes that you have queried your API and saved the document object in a variable named document.

Accessing Document Fields

Here is how to access a document's information fields.

ID

Copy
document.getId()


UID

Copy
document.getUid()


Type

Copy
document.getType()


API Url

Copy
document.getHref()


Tags

Copy
document.getTags()
// returns a Set<String>


First Publication Date

Copy
document.getFirstPublicationDate()


Last Publication Date

Copy
document.getLastPublicationDate()


Language

Copy
document.getLang()


Alternate Language Versions

Copy
document.getAlternateLanguages()
// returns a list

You can read more about this in the Multi-language Templating page.


Document Content

To retrieve the content fields from the document you must specify the API ID of the field. Here is an example that retrieves a Date field's content from the document. Here the Date field has the API ID of date.

Copy
// Assuming the document is of the type "page"
document.getDate("page.date").getValue()

Refer to the specific templating documentation for each field to learn how to add content fields to your pages.