Examples of DublinCoreAdapter


Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

    public void testParseBasics() throws Exception {
        URL url = getClass().getResource("test-basics.xmp");
        Metadata meta = XMPParser.parseXMP(url);

        DublinCoreAdapter dcAdapter = DublinCoreSchema.getAdapter(meta);
        XMPBasicAdapter basicAdapter = XMPBasicSchema.getAdapter(meta);
        AdobePDFAdapter pdfAdapter = AdobePDFSchema.getAdapter(meta);

        XMPProperty prop;
        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "creator");
        XMPArray array;
        array = prop.getArrayValue();
        assertEquals(1, array.getSize());
        assertEquals("John Doe", array.getValue(0).toString());
        assertEquals("John Doe", dcAdapter.getCreators()[0]);

        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "title");
        assertEquals("Example document", prop.getValue().toString());
        assertEquals("Example document", dcAdapter.getTitle());
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreateDate");
        //System.out.println("Creation Date: " + prop.getValue() + " " + prop.getClass().getName());
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreatorTool");
        assertEquals("An XML editor", prop.getValue().toString());
        assertEquals("An XML editor", basicAdapter.getCreatorTool());
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

    public void testParse1() throws Exception {
        URL url = getClass().getResource("unknown-schema.xmp");
        Metadata meta = XMPParser.parseXMP(url);

        DublinCoreAdapter dcAdapter = DublinCoreSchema.getAdapter(meta);

        XMPProperty prop;
        //Access through the known schema as reference
        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "title");
        assertEquals("Unknown Schema", prop.getValue().toString());
        assertEquals("Unknown Schema", dcAdapter.getTitle());

        //Access through a schema unknown to the XMP framework
        prop = meta.getProperty("http://unknown.org/something", "dummy");
        assertEquals("Dummy!", prop.getValue().toString());
    }
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

    public void testAttributeValues() throws Exception {
        URL url = getClass().getResource("test-attribute-values.xmp");
        Metadata meta = XMPParser.parseXMP(url);

        DublinCoreAdapter dcAdapter = DublinCoreSchema.getAdapter(meta);
        assertEquals("Ender's Game", dcAdapter.getTitle());
        assertEquals("Orson Scott Card", dcAdapter.getCreators()[0]);
    }
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

    public void testParseDates() throws Exception {
        URL url = getClass().getResource("test-dates.xmp");
        Metadata meta = XMPParser.parseXMP(url);
        XMPProperty prop;

        DublinCoreAdapter dcAdapter = DublinCoreSchema.getAdapter(meta);

        //Simple adapter access
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+2:00"));
        cal.set(2006, Calendar.JUNE, 2, 10, 36, 40);
        cal.set(Calendar.MILLISECOND, 0);
        assertEquals(cal.getTime(), dcAdapter.getDate());
        Date[] dates = dcAdapter.getDates();
        assertEquals(2, dates.length);

        //The second is the most recent and should match the simple value
        assertEquals(dates[1], dcAdapter.getDate());

        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "date");
        assertNotNull(prop.getArrayValue());
        assertEquals(2, prop.getArrayValue().getSize());

        //Now add a new date and check if the adapter's getDate() method returns the new date.
        cal.set(2008, Calendar.NOVEMBER, 1, 10, 10, 0);
        dcAdapter.addDate(cal.getTime());
        assertEquals(3, dcAdapter.getDates().length);
        prop = meta.getProperty(XMPConstants.DUBLIN_CORE_NAMESPACE, "date");
        assertNotNull(prop.getArrayValue());
        assertEquals(3, prop.getArrayValue().getSize());
        assertEquals(cal.getTime(), dcAdapter.getDate());
    }
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

    public void testParseEmptyValues() throws Exception {
        URL url = getClass().getResource("empty-values.xmp");
        Metadata meta = XMPParser.parseXMP(url);

        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
        String title = dc.getTitle();
        assertEquals("empty", title);

        title = dc.getTitle("fr"); //Does not exist
        assertNull(title);

        title = dc.getTitle("de");
        assertNull(title); //Empty value treated same as not existant
    }
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "Producer");
        System.out.println("Producer: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "PDFVersion");
        System.out.println("PDF version: " + prop.getValue());

        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(meta);
        System.out.println("Default title: " + dc.getTitle());
        System.out.println("German title: " + dc.getTitle("de"));

        StreamResult res = new StreamResult(System.out);
        XMPSerializer.writeXML(meta, res);
    }
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

public class MetadataFromScratch {

    private static void buildAndPrintMetadata()
                throws TransformerConfigurationException, SAXException {
        Metadata meta = new Metadata();
        DublinCoreAdapter dc = new DublinCoreAdapter(meta);
        dc.setTitle("de", "Der Herr der Ringe");
        dc.setTitle("en", "Lord of the Rings");
        dc.addDate(new Date());
        dc.setFormat("application/pdf");
        dc.addCreator("J.R.R. Tolkien");

        StreamResult res = new StreamResult(System.out);
        XMPSerializer.writeXML(meta, res);

    }
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

    private static void mergeMetadata() throws TransformerException, SAXException {
        URL url = MergeMetadata.class.getResource("pdf-example.xmp");
        Metadata meta1 = XMPParser.parseXMP(url);

        Metadata meta2 = new Metadata();
        DublinCoreAdapter dc = new DublinCoreAdapter(meta2);
        dc.setTitle("de", "Der Herr der Ringe");
        dc.setTitle("en", "Lord of the Rings");
        dc.addCreator("J.R.R. Tolkien"); //Will replace creator from pdf-example.xmp
        dc.addDate(new Date());

        meta2.mergeInto(meta1);

        Metadata meta = meta1;
        XMPProperty prop;
        dc = new DublinCoreAdapter(meta);
        String[] creators = dc.getCreators();
        for (int i = 0, c = creators.length; i < c; i++) {
            System.out.println("Creator: " + creators[i]);
        }
        System.out.println("Title: " + dc.getTitle());
        System.out.println("Title de: " + dc.getTitle("de"));
        System.out.println("Title en: " + dc.getTitle("en"));
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreateDate");
        System.out.println("Creation Date: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.XMP_BASIC_NAMESPACE, "CreatorTool");
        System.out.println("Creator Tool: " + prop.getValue());
        prop = meta.getProperty(XMPConstants.ADOBE_PDF_NAMESPACE, "Producer");
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

*/
public class XMPPropertyTest extends TestCase {

    public void testPropertyAccess() throws Exception {
        Metadata xmp = new Metadata();
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
        assertNull(dc.getContributors());

        dc.addContributor("Contributor1");
        assertEquals(1, dc.getContributors().length);
        assertEquals("Contributor1", dc.getContributors()[0]);
        dc.removeContributor("Contributor1");
        assertNull(dc.getContributors());

        dc.addContributor("Contributor1");
        assertEquals(1, dc.getContributors().length);
        dc.addContributor("Contributor2");
        assertEquals(2, dc.getContributors().length);
        assertFalse(dc.removeContributor("DoesNotExist"));
        assertTrue(dc.removeContributor("Contributor1"));
        assertEquals(1, dc.getContributors().length);
        assertTrue(dc.removeContributor("Contributor2"));
        assertFalse(dc.removeContributor("Contributor2"));
        assertNull(dc.getContributors());
    }
View Full Code Here

Examples of org.apache.xmlgraphics.xmp.schemas.DublinCoreAdapter

        return null;
    }

    private Metadata createDefaultDocumentMetadata() {
        Metadata xmp = new Metadata();
        DublinCoreAdapter dc = DublinCoreSchema.getAdapter(xmp);
        if (getUserAgent().getTitle() != null) {
            dc.setTitle(getUserAgent().getTitle());
        }
        if (getUserAgent().getAuthor() != null) {
            dc.addCreator(getUserAgent().getAuthor());
        }
        if (getUserAgent().getKeywords() != null) {
            dc.addSubject(getUserAgent().getKeywords());
        }
        XMPBasicAdapter xmpBasic = XMPBasicSchema.getAdapter(xmp);
        if (getUserAgent().getProducer() != null) {
            xmpBasic.setCreatorTool(getUserAgent().getProducer());
        } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.