Search in sources :

Example 1 with DateType

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);
}
Also used : DateType(org.apache.xmpbox.type.DateType)

Example 2 with DateType

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);
}
Also used : DateType(org.apache.xmpbox.type.DateType)

Example 3 with DateType

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);
}
Also used : DateType(org.apache.xmpbox.type.DateType)

Example 4 with DateType

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;
    }
}
Also used : IntegerType(org.apache.xmpbox.type.IntegerType) Attribute(org.apache.xmpbox.type.Attribute) Calendar(java.util.Calendar) BooleanType(org.apache.xmpbox.type.BooleanType) DateType(org.apache.xmpbox.type.DateType) TextType(org.apache.xmpbox.type.TextType) Test(org.junit.Test)

Example 5 with DateType

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);
}
Also used : Calendar(java.util.Calendar) Method(java.lang.reflect.Method) DateType(org.apache.xmpbox.type.DateType)

Aggregations

DateType (org.apache.xmpbox.type.DateType)8 Calendar (java.util.Calendar)3 Method (java.lang.reflect.Method)1 AbstractField (org.apache.xmpbox.type.AbstractField)1 ArrayProperty (org.apache.xmpbox.type.ArrayProperty)1 Attribute (org.apache.xmpbox.type.Attribute)1 BooleanType (org.apache.xmpbox.type.BooleanType)1 IntegerType (org.apache.xmpbox.type.IntegerType)1 TextType (org.apache.xmpbox.type.TextType)1 Test (org.junit.Test)1