Package org.apache.xmpbox.schema

Examples of org.apache.xmpbox.schema.XMPSchema


     * @return The Class Schema representation
     */
    public XMPSchema getSchema(String nsURI)
    {
        Iterator<XMPSchema> it = schemas.iterator();
        XMPSchema tmp;
        while (it.hasNext())
        {
            tmp = it.next();
            if (tmp.getNamespace().equals(nsURI))
            {
                return tmp;
            }
        }
        return null;
View Full Code Here


     * @return The Class Schema representation
     */
    public XMPSchema getSchema(String prefix, String nsURI)
    {
        Iterator<XMPSchema> it = getAllSchemas().iterator();
        XMPSchema tmp;
        while (it.hasNext())
        {
            tmp = it.next();
            if (tmp.getNamespace().equals(nsURI) && tmp.getPrefix().equals(prefix))
            {
                return tmp;
            }
        }
        return null;
View Full Code Here

     *            The namespace URI wanted for the schema
     * @return The schema added in order to work on it
     */
    public XMPSchema createAndAddDefaultSchema(String nsPrefix, String nsURI)
    {
        XMPSchema schem = new XMPSchema(this, nsURI, nsPrefix);
        schem.setAboutAsSimple("");
        addSchema(schem);
        return schem;
    }
View Full Code Here

                    // do nothing
                }
                else
                {
                    String namespace = attr.getNamespaceURI();
                    XMPSchema schema = xmp.getSchema(namespace);
                    if (schema == null && tm.getSchemaFactory(namespace) != null)
                    {
                        schema = tm.getSchemaFactory(namespace).createXMPSchema(xmp, attr.getPrefix());
                        loadAttributes(schema, description);
                    }
                    // Only process when a schema was successfully found
                    if( schema != null )
                    {
                        ComplexPropertyContainer container = schema.getContainer();
                        PropertyType type = checkPropertyDefinition(xmp,
                                new QName(attr.getNamespaceURI(), attr.getLocalName()));
                       
                        //Default to text if no type is found
                        if( type == null)
                        {
                            type = TypeMapping.createPropertyType(Types.Text, Cardinality.Simple);
                        }
                                          
                        try
                        {
                            AbstractSimpleProperty sp = tm.instanciateSimpleProperty(namespace, schema.getPrefix(),
                                    attr.getLocalName(), attr.getValue(), type.type());
                            container.addProperty(sp);
                        }
                        catch( IllegalArgumentException exception)
                        {
                            //Swallow, and continue adding additional properties
                            LOG.warn("Unable to add property: "+ attr.getLocalName() + " value: "+attr.getValue(),exception);
                        }
                    }
                }
            }
            // parse children elements as properties
            for (Element property : properties)
            {
                String namespace = property.getNamespaceURI();
                PropertyType type = checkPropertyDefinition(xmp, DomHelper.getQName(property));
                // create the container
                if (!tm.isDefinedSchema(namespace))
                {
                    throw new XmpParsingException(ErrorType.NoSchema,
                            "This namespace is not a schema or a structured type : " + namespace);
                }
                XMPSchema schema = xmp.getSchema(namespace);
                if (schema == null)
                {
                    schema = tm.getSchemaFactory(namespace).createXMPSchema(xmp, property.getPrefix());
                    loadAttributes(schema, description);
                }
                ComplexPropertyContainer container = schema.getContainer();
                // create property
                createProperty(xmp, property, type, container);
            }
        }
        catch (XmpSchemaException e)
View Full Code Here

    @Before
    public void init() throws Exception
    {
        metadata = XMPMetadata.createXMPMetadata();
        String tmpNsURI = "http://www.test.org/schem/";
        tmp = new XMPSchema(metadata, tmpNsURI, "test");
        tmp.addQualifiedBagValue("BagContainer", "Value1");
        tmp.addQualifiedBagValue("BagContainer", "Value2");
        tmp.addQualifiedBagValue("BagContainer", "Value3");

        tmp.addUnqualifiedSequenceValue("SeqContainer", "Value1");
        tmp.addUnqualifiedSequenceValue("SeqContainer", "Value2");
        tmp.addUnqualifiedSequenceValue("SeqContainer", "Value3");

        tmp.addProperty(metadata.getTypeMapping().createText(null, "test", "simpleProperty", "YEP"));

        tmp2 = new XMPSchema(metadata, "http://www.space.org/schem/", "space", "space");
        tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace1");
        tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace2");
        tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace3");

        metadata.addSchema(tmp);
View Full Code Here

        XMPMetadata xmpmd = new XMPMetadata();
        TypeMapping mapping = new TypeMapping(xmpmd);
        XMPSchemaFactory factory = mapping.getSchemaFactory(namespace);
        assertNotNull("Schema not existing: " + namespace, factory);
        // ensure preferred is as expected
        XMPSchema schema = factory.createXMPSchema(xmpmd,"aa");
        assertEquals(preferred,schema.getPreferedPrefix());
        // ensure field is defined
        boolean found = false;
        Class<?> clz  = schema.getClass();
        for (Field dfield : clz.getDeclaredFields()) {
            PropertyType ptype = dfield.getAnnotation(PropertyType.class);
            if (ptype!=null) {
                // is a field definition
                if (String.class.equals(dfield.getType())) {
View Full Code Here

    @Before
    public void init() throws Exception
    {
        metadata = XMPMetadata.createXMPMetadata();
        String tmpNsURI = "http://www.test.org/schem/";
        tmp = new XMPSchema(metadata, tmpNsURI, "test");
        tmp.addQualifiedBagValue("BagContainer", "Value1");
        tmp.addQualifiedBagValue("BagContainer", "Value2");
        tmp.addQualifiedBagValue("BagContainer", "Value3");

        tmp.addUnqualifiedSequenceValue("SeqContainer", "Value1");
        tmp.addUnqualifiedSequenceValue("SeqContainer", "Value2");
        tmp.addUnqualifiedSequenceValue("SeqContainer", "Value3");

        tmp.addProperty(metadata.getTypeMapping().createText(null, "test", "simpleProperty", "YEP"));

        tmp2 = new XMPSchema(metadata, "http://www.space.org/schem/", "space", "space");
        tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace1");
        tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace2");
        tmp2.addUnqualifiedSequenceValue("SeqSpContainer", "ValueSpace3");

        metadata.addSchema(tmp);
View Full Code Here

     * @return The Class Schema representation
     */
    public XMPSchema getSchema(String nsURI)
    {
        Iterator<XMPSchema> it = schemas.iterator();
        XMPSchema tmp;
        while (it.hasNext())
        {
            tmp = it.next();
            if (tmp.getNamespace().equals(nsURI))
            {
                return tmp;
            }
        }
        return null;
View Full Code Here

     * @return The Class Schema representation
     */
    public XMPSchema getSchema(String prefix, String nsURI)
    {
        Iterator<XMPSchema> it = getAllSchemas().iterator();
        XMPSchema tmp;
        while (it.hasNext())
        {
            tmp = it.next();
            if (tmp.getNamespace().equals(nsURI) && tmp.getPrefix().equals(prefix))
            {
                return tmp;
            }
        }
        return null;
View Full Code Here

     *            The namespace URI wanted for the schema
     * @return The schema added in order to work on it
     */
    public XMPSchema createAndAddDefaultSchema(String nsPrefix, String nsURI)
    {
        XMPSchema schem = new XMPSchema(this, nsURI, nsPrefix);
        schem.setAboutAsSimple("");
        addSchema(schem);
        return schem;
    }
View Full Code Here

TOP

Related Classes of org.apache.xmpbox.schema.XMPSchema

Copyright © 2018 www.massapicom. 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.