com.aspose.words
Class PropertyType

java.lang.Object
    extended by com.aspose.words.PropertyType

public class PropertyType 
extends java.lang.Object

Utility class containing constants. Specifies data type of a document property.

Example:

Shows how to add custom properties to a document.
Document doc = new Document();
CustomDocumentProperties properties = doc.getCustomDocumentProperties();

// The custom property collection will be empty by default
Assert.assertEquals(0, properties.getCount());

// We can populate it with key/value pairs with a variety of value types
properties.add("Authorized", true);
properties.add("Authorized By", "John Doe");
properties.add("Authorized Date", new Date());
properties.add("Authorized Revision", doc.getBuiltInDocumentProperties().getRevisionNumber());
properties.add("Authorized Amount", 123.45);

// Custom properties are automatically sorted in alphabetic order
Assert.assertEquals(properties.indexOf("Authorized Amount"), 1);
Assert.assertEquals(properties.getCount(), 5);

// Enumerate and print all custom properties
Iterator<DocumentProperty> enumerator = properties.iterator();
try {
    while (enumerator.hasNext()) {
        DocumentProperty property = enumerator.next();
        System.out.println(MessageFormat.format("Name: \"{0}\", Type: \"{1}\", Value: \"{2}\"", property.getName(), property.getType(), property.getValue()));
    }
} finally {
    if (enumerator != null) enumerator.remove();
}

// We can view/edit custom properties by opening the document and looking in File > Properties > Advanced Properties > Custom
doc.save(getArtifactsDir() + "Properties.DocumentPropertyCollection.docx");

// We can remove elements from the property collection by index or by name
properties.removeAt(1);
Assert.assertFalse(properties.contains("Authorized Amount"));
Assert.assertEquals(properties.getCount(), 4);

properties.remove("Authorized Revision");
Assert.assertFalse(properties.contains("Authorized Revision"));
Assert.assertEquals(properties.getCount(), 3);

// We can also empty the entire custom property collection at once
properties.clear();
Assert.assertEquals(properties.getCount(), 0);
See Also:
DocumentProperty, DocumentProperty.Type

Field Summary
static final intBOOLEAN = 0
           The property is a boolean value.
static final intDATE_TIME = 1
           The property is a date time value.
static final intDOUBLE = 2
           The property is a floating number.
static final intNUMBER = 3
           The property is an integer number.
static final intSTRING = 4
           The property is a string value.
static final intSTRING_ARRAY = 5
           The property is an array of strings.
static final intOBJECT_ARRAY = 6
           The property is an array of objects.
static final intBYTE_ARRAY = 7
           The property is an array of bytes.
static final intOTHER = 8
           The property is some other type.
 

Field Detail

BOOLEAN = 0

public static final int BOOLEAN
The property is a boolean value.

DATE_TIME = 1

public static final int DATE_TIME
The property is a date time value.

DOUBLE = 2

public static final int DOUBLE
The property is a floating number.

NUMBER = 3

public static final int NUMBER
The property is an integer number.

STRING = 4

public static final int STRING
The property is a string value.

STRING_ARRAY = 5

public static final int STRING_ARRAY
The property is an array of strings.

OBJECT_ARRAY = 6

public static final int OBJECT_ARRAY
The property is an array of objects.

BYTE_ARRAY = 7

public static final int BYTE_ARRAY
The property is an array of bytes.

OTHER = 8

public static final int OTHER
The property is some other type.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.