use of org.apache.xmpbox.type.DateType in project pdfbox by apache.
the class XMPBasicSchema method setMetadataDate.
/**
* Set the date and time that any metadata for this resource was last changed. (should be equals or more recent than
* the createDate)
*
* @param date
* the Metadata Date value to set
*/
public void setMetadataDate(Calendar date) {
DateType tt = (DateType) instanciateSimple(METADATADATE, date);
setMetadataDateProperty(tt);
}
use of org.apache.xmpbox.type.DateType in project pdfbox by apache.
the class XMPBasicSchema method setModifyDate.
/**
* Set the date and time the resource was last modified
*
* @param date
* the Modify Date value to set
*/
public void setModifyDate(Calendar date) {
DateType tt = (DateType) instanciateSimple(MODIFYDATE, date);
setModifyDateProperty(tt);
}
use of org.apache.xmpbox.type.DateType in project pdfbox by apache.
the class XMPBasicSchema method setModifierDate.
public void setModifierDate(Calendar date) {
DateType tt = (DateType) instanciateSimple(MODIFIER_DATE, date);
setModifierDateProperty(tt);
}
use of org.apache.xmpbox.type.DateType in project pdfbox by apache.
the class XMPSchemaTest method testProperties.
/**
* Test All common simple properties management in XMPSchema
*
* @throws IllegalArgumentException
* @throws BadFieldValueException
*/
@Test
public void testProperties() throws Exception {
Assert.assertEquals("nsURI", schem.getNamespace());
// In real cases, rdf ns will be declared before !
schem.addNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdf");
String aboutVal = "aboutTest";
schem.setAboutAsSimple(aboutVal);
Assert.assertEquals(aboutVal, schem.getAboutValue());
Attribute about = new Attribute(XmpConstants.RDF_NAMESPACE, "about", "YEP");
schem.setAbout(about);
Assert.assertEquals(about, schem.getAboutAttribute());
String textProp = "textProp";
String textPropVal = "TextPropTest";
schem.setTextPropertyValue(textProp, textPropVal);
Assert.assertEquals(textPropVal, schem.getUnqualifiedTextPropertyValue(textProp));
TextType text = parent.getTypeMapping().createText(null, "nsSchem", "textType", "GRINGO");
schem.setTextProperty(text);
Assert.assertEquals(text, schem.getUnqualifiedTextProperty("textType"));
Calendar dateVal = Calendar.getInstance();
String date = "nsSchem:dateProp";
schem.setDatePropertyValue(date, dateVal);
Assert.assertEquals(dateVal, schem.getDatePropertyValue(date));
DateType dateType = parent.getTypeMapping().createDate(null, "nsSchem", "dateType", Calendar.getInstance());
schem.setDateProperty(dateType);
Assert.assertEquals(dateType, schem.getDateProperty("dateType"));
String bool = "nsSchem:booleanTestProp";
Boolean boolVal = false;
schem.setBooleanPropertyValue(bool, boolVal);
Assert.assertEquals(boolVal, schem.getBooleanPropertyValue(bool));
BooleanType boolType = parent.getTypeMapping().createBoolean(null, "nsSchem", "boolType", false);
schem.setBooleanProperty(boolType);
Assert.assertEquals(boolType, schem.getBooleanProperty("boolType"));
String intProp = "nsSchem:IntegerTestProp";
Integer intPropVal = 5;
schem.setIntegerPropertyValue(intProp, intPropVal);
Assert.assertEquals(intPropVal, schem.getIntegerPropertyValue(intProp));
IntegerType intType = parent.getTypeMapping().createInteger(null, "nsSchem", "intType", 5);
schem.setIntegerProperty(intType);
Assert.assertEquals(intType, schem.getIntegerProperty("intType"));
// Check bad type verification
boolean ok = false;
try {
schem.getIntegerProperty("boolType");
} catch (IllegalArgumentException e) {
ok = true;
}
Assert.assertTrue(ok);
ok = false;
try {
schem.getUnqualifiedTextProperty("intType");
} catch (IllegalArgumentException e) {
ok = true;
}
Assert.assertTrue(ok);
ok = false;
try {
schem.getDateProperty("textType");
} catch (IllegalArgumentException e) {
ok = true;
}
Assert.assertTrue(ok);
ok = false;
try {
schem.getBooleanProperty("dateType");
} catch (IllegalArgumentException e) {
ok = true;
}
}
use of org.apache.xmpbox.type.DateType in project pdfbox by apache.
the class AbstractXMPSchemaTest method testGetSetDateProperty.
protected void testGetSetDateProperty() throws Exception {
String setName = setMethod(property);
String getName = getMethod(property);
DateType dt = new DateType(metadata, null, schema.getPrefix(), property, value);
Method setMethod = schemaClass.getMethod(setName, DateType.class);
Method getMethod = schemaClass.getMethod(getName);
setMethod.invoke(schema, dt);
Calendar found = ((DateType) getMethod.invoke(schema)).getValue();
Assert.assertEquals(value, found);
}
Aggregations