Skip to main content

DocumentCustomProperty Class

A custom document property.

Declaration

public final class DocumentCustomProperty extends Struct<DocumentCustomProperty> implements IEquatable<DocumentCustomProperty>

Remarks

The DocumentProperties.getCustomProperties() method returns a map of custom property names and DocumentCustomProperty objects. To create a custom property, pass a value to a DocumentCustomProperty constructor.

Call the getType() method to get the value type. Call the method that matches the value type to get the typed value:

Value Type Constructor Method
STRING DocumentCustomProperty(String value) toStringValue()
DATE_TIME DocumentCustomProperty(Instant value) toDateTimeValue()
INTEGER DocumentCustomProperty(int value) toIntValue()
BOOLEAN DocumentCustomProperty(boolean value) toBooleanValue()
DOUBLE DocumentCustomProperty(double value) toDoubleValue()
DECIMAL DocumentCustomProperty(BigDecimal value) toDecimalValue()

Refer to the following help topic for additional information: Read and Modify Presentation Document Properties.

Example: Read Custom Document Property Values by Type

The following code snippet adds custom properties to a presentation and displays the name and value of each custom property in the console:

import java.math.BigDecimal;
import java.time.Instant;
import java.util.Map;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Presentation presentation = new Presentation()) {
            IDocumentCustomPropertyDictionary customProperties =
                    presentation.getDocumentProperties().getCustomProperties();
            customProperties.put("Project", new DocumentCustomProperty("Apollo"));
            customProperties.put("Approved", new DocumentCustomProperty(true));
            customProperties.put("Review Date", new DocumentCustomProperty(Instant.parse("2026-10-19T09:00:00Z")));
            customProperties.put("Budget", new DocumentCustomProperty(new BigDecimal("12500.50")));

            for (Map.Entry<String, DocumentCustomProperty> entry : customProperties.entrySet()) {
                DocumentCustomProperty property = entry.getValue();
                String value = switch (property.getType().getValue()) {
                    case DocumentCustomPropertyValueType._DATE_TIME -> property.toDateTimeValue().toString();
                    case DocumentCustomPropertyValueType._BOOLEAN -> property.toBooleanValue() ? "Yes" : "No";
                    default -> String.valueOf(property.getValue());
                };
                System.out.println(entry.getKey() + ": " + value);
            }
        }
    }
}

Implements

com.devexpress.system.IEquatable<com.devexpress.docs.office.DocumentCustomProperty>

Inherited Members

com.devexpress.system.Struct.clone()
com.devexpress.system.Struct.equals(java.lang.Object)
com.devexpress.system.Struct.getHashCode()
com.devexpress.system.Struct.hashCode()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.toString()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
com.devexpress.system.ValueType
com.devexpress.system.Struct
DocumentCustomProperty
See Also

Constructors

DocumentCustomProperty() Constructor

Initializes a new instance of the DocumentCustomProperty class.

Declaration

public DocumentCustomProperty()

DocumentCustomProperty(BigDecimal value) Constructor

Initializes a new instance of the DocumentCustomProperty class with the specified BigDecimal value.

Declaration

public DocumentCustomProperty(BigDecimal value)

Parameters

Name Type Description
value BigDecimal

The property value.

DocumentCustomProperty(boolean value) Constructor

Initializes a new instance of the DocumentCustomProperty class with the specified boolean value.

Declaration

public DocumentCustomProperty(boolean value)

Parameters

Name Type Description
value boolean

The property value.

DocumentCustomProperty(double value) Constructor

Initializes a new instance of the DocumentCustomProperty class with the specified double value.

Declaration

public DocumentCustomProperty(double value)

Parameters

Name Type Description
value double

The property value.

DocumentCustomProperty(Instant value) Constructor

Initializes a new instance of the DocumentCustomProperty class with the specified Instant value.

Declaration

public DocumentCustomProperty(Instant value)

Parameters

Name Type Description
value Instant

The property value.

DocumentCustomProperty(int value) Constructor

Initializes a new instance of the DocumentCustomProperty class with the specified int value.

Declaration

public DocumentCustomProperty(int value)

Parameters

Name Type Description
value int

The property value.

DocumentCustomProperty(String value) Constructor

Initializes a new instance of the DocumentCustomProperty class with the specified String value.

Declaration

public DocumentCustomProperty(String value)

Parameters

Name Type Description
value String

The property value.

Methods

equals(DocumentCustomProperty value) Method

Returns whether the specified custom property equals this custom property.

Declaration

public boolean equals(DocumentCustomProperty value)

Parameters

Name Type Description
value DocumentCustomProperty

The custom property to compare with this custom property.

Returns

Type Description
boolean

true if the specified custom property equals this custom property; otherwise, false.

equals(Object obj) Method

Returns whether the specified object equals this custom property.

Declaration

public boolean equals(Object obj)

Parameters

Name Type Description
obj Object

The object to compare with this custom property.

Returns

Type Description
boolean

true if the specified object equals this custom property; otherwise, false.

getType() Method

Returns the value type of the custom property.

Declaration

public DocumentCustomPropertyValueType getType()

Returns

Type Description
DocumentCustomPropertyValueType

The value type.

Remarks

Value Description
STRING The custom property contains a String value.
DATE_TIME The custom property contains an Instant value (a date and time).
INTEGER The custom property contains an int value.
BOOLEAN The custom property contains a boolean value.
DOUBLE The custom property contains a double value.
DECIMAL The custom property contains a BigDecimal value.

getValue() Method

Returns the property value.

Declaration

public Object getValue()

Returns

Type Description
Object

The property value, or null if the object contains no value.

Remarks

The getValue() method returns the property value as an Object. To get a typed value, call the getType() method and the method that matches the value type (for example, toStringValue() for a String value).

hashCode() Method

Returns the hash code for this custom property.

Declaration

public int hashCode()

Returns

Type Description
int

The hash code for this custom property.

toBooleanValue() Method

Returns the property value as a boolean value.

Declaration

public boolean toBooleanValue()

Returns

Type Description
boolean

The property value.

Exceptions

Type Description
InvalidOperationException

Thrown if the getType() method does not return DocumentCustomPropertyValueType.BOOLEAN. The exception message is “Invalid property type.”

toDateTimeValue() Method

Returns the property value as an Instant value.

Declaration

public Instant toDateTimeValue()

Returns

Type Description
Instant

The property value.

Exceptions

Type Description
InvalidOperationException

Thrown if the getType() method does not return DocumentCustomPropertyValueType.DATE_TIME. The exception message is “Invalid property type.”

toDecimalValue() Method

Returns the property value as a BigDecimal value.

Declaration

public BigDecimal toDecimalValue()

Returns

Type Description
BigDecimal

The property value.

Exceptions

Type Description
InvalidOperationException

Thrown if the getType() method does not return DocumentCustomPropertyValueType.DECIMAL. The exception message is “Invalid property type.”

toDoubleValue() Method

Returns the property value as a double value.

Declaration

public double toDoubleValue()

Returns

Type Description
double

The property value.

Exceptions

Type Description
InvalidOperationException

Thrown if the getType() method does not return DocumentCustomPropertyValueType.DOUBLE. The exception message is “Invalid property type.”

toIntValue() Method

Returns the property value as an int value.

Declaration

public int toIntValue()

Returns

Type Description
int

The property value.

Exceptions

Type Description
InvalidOperationException

Thrown if the getType() method does not return DocumentCustomPropertyValueType.INTEGER. The exception message is “Invalid property type.”

toStringValue() Method

Returns the property value as a String value.

Declaration

public String toStringValue()

Returns

Type Description
String

The property value.

Exceptions

Type Description
InvalidOperationException

Thrown if the getType() method does not return DocumentCustomPropertyValueType.STRING. The exception message is “Invalid property type.”