Package org.apache.xmpbox.type

Examples of org.apache.xmpbox.type.AbstractSimpleProperty


    {
        if (cardinality != Cardinality.Simple)
            return;
        // only test simple properties
        Object value = TypeTestingHelper.getJavaValue(type);
        AbstractSimpleProperty property = getSchema().instanciateSimple(fieldName, value);
        getSchema().addProperty(property);
        String qn = getPropertyQualifiedName(fieldName);
        Assert.assertNotNull(getSchema().getProperty(fieldName));
        // check other properties not modified
        List<Field> fields = TypeTestingHelper.getXmpFields(getSchemaClass());
View Full Code Here


    {
        if (cardinality == Cardinality.Simple)
            return;
        // only test array properties
        Object value = TypeTestingHelper.getJavaValue(type);
        AbstractSimpleProperty property = getSchema().instanciateSimple(fieldName, value);
        switch (cardinality)
        {
        case Seq:
            getSchema().addUnqualifiedSequenceValue(property.getPropertyName(), property);
            break;
        case Bag:
            getSchema().addBagValue(property.getPropertyName(), property);
            break;
        default:
            throw new Exception("Unexpected case in test : " + cardinality.name());
        }
        String qn = getPropertyQualifiedName(fieldName);
View Full Code Here

    {
        if (cardinality != Cardinality.Simple)
            return;
        String setter = TypeTestingHelper.calculateSimpleSetter(fieldName) + "Property";
        Object value = TypeTestingHelper.getJavaValue(type);
        AbstractSimpleProperty asp = typeMapping.instanciateSimpleProperty(getSchema().getNamespace(), getSchema()
                .getPrefix(), fieldName, value, type);
        Method set = getSchemaClass().getMethod(setter, new Class<?>[] { type.getImplementingClass() });
        set.invoke(getSchema(), new Object[] { asp });
        // check property set
        AbstractSimpleProperty stored = (AbstractSimpleProperty) getSchema().getProperty(fieldName);
        Assert.assertEquals(value, stored.getValue());
        // check getter
        String getter = TypeTestingHelper.calculateSimpleGetter(fieldName) + "Property";
        Method get = getSchemaClass().getMethod(getter, new Class[0]);
        Object result = get.invoke(getSchema(), new Object[0]);
        Assert.assertTrue(type.getImplementingClass().isAssignableFrom(result.getClass()));
View Full Code Here

                            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)
                        {
View Full Code Here

    {
        TypeMapping tm = xmp.getTypeMapping();
        String prefix = property.getPrefix();
        String name = property.getLocalName();
        String namespace = property.getNamespaceURI();
        AbstractSimpleProperty sp = tm.instanciateSimpleProperty(namespace, prefix, name, property.getTextContent(),
                type);
        loadAttributes(sp, property);
        container.addProperty(sp);
    }
View Full Code Here

        else
        {
            // no child, so consider as simple text
            String text = liElement.getTextContent();
            TypeMapping tm = xmp.getTypeMapping();
            AbstractSimpleProperty sp = tm.instanciateSimpleProperty(descriptor.getNamespaceURI(),
                    descriptor.getPrefix(), descriptor.getLocalPart(), text, Types.Text);
            loadAttributes(sp, liElement);
            return sp;
        }
    }
View Full Code Here

                    }
                }
            }
            else if (type.type().isSimple())
            {
                AbstractSimpleProperty sp = tm.instanciateSimpleProperty(namespace, prefix, name,
                        element.getTextContent(), type.type());
                loadAttributes(sp, element);
                ast.getContainer().addProperty(sp);
            }
            else if (type.type().isStructured())
View Full Code Here

        for (AbstractField field : fields)
        {

            if (field instanceof AbstractSimpleProperty)
            {
                AbstractSimpleProperty simple = (AbstractSimpleProperty) field;
                Element esimple = doc.createElement(simple.getPrefix() + ":" + simple.getPropertyName());
                esimple.setTextContent(simple.getStringValue());
                parent.appendChild(esimple);
            }
            else if (field instanceof ArrayProperty)
            {
                ArrayProperty array = (ArrayProperty) field;
View Full Code Here

                }
            }
        }
        else
        {
            AbstractSimpleProperty specifiedTypeProperty;
            try
            {
                TypeMapping tm = getMetadata().getTypeMapping();
                specifiedTypeProperty = tm.instanciateSimpleProperty(null, getPrefix(), qualifiedName, propertyValue,
                        type);
View Full Code Here

        ArrayProperty array = (ArrayProperty) getAbstractProperty(arrayName);
        if (array != null)
        {
            ArrayList<AbstractField> toDelete = new ArrayList<AbstractField>();
            Iterator<AbstractField> it = array.getContainer().getAllProperties().iterator();
            AbstractSimpleProperty tmp;
            while (it.hasNext())
            {
                tmp = (AbstractSimpleProperty) it.next();
                if (tmp.getStringValue().equals(fieldValue))
                {
                    toDelete.add(tmp);
                }
            }
            Iterator<AbstractField> eraseProperties = toDelete.iterator();
View Full Code Here

TOP

Related Classes of org.apache.xmpbox.type.AbstractSimpleProperty

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.