Examples of ArrayProperty


Examples of org.apache.xmpbox.type.ArrayProperty

     * @throws BadFieldValueException
     *             Property not contains property (not complex property)
     */
    public List<AbstractField> getUnqualifiedArrayList(String name) throws BadFieldValueException
    {
        ArrayProperty array = null;
        Iterator<AbstractField> itProp = getAllProperties().iterator();
        AbstractField tmp;
        while (itProp.hasNext())
        {
            tmp = itProp.next();
            if (tmp.getPropertyName().equals(name))
            {
                if (tmp instanceof ArrayProperty)
                {
                    array = (ArrayProperty) tmp;
                    break;
                }
                else
                {
                    throw new BadFieldValueException("Property asked not seems to be an array");
                }

            }
        }
        if (array != null)
        {
            Iterator<AbstractField> it = array.getContainer().getAllProperties().iterator();
            List<AbstractField> list = new ArrayList<AbstractField>();
            while (it.hasNext())
            {
                list.add(it.next());
            }
View Full Code Here

Examples of org.apache.xmpbox.type.ArrayProperty

    @Test
    public void testArrayList() throws Exception
    {
        XMPMetadata meta = XMPMetadata.createXMPMetadata();
        ArrayProperty newSeq = meta.getTypeMapping().createArrayProperty(null, "nsSchem", "seqType", Cardinality.Seq);
        TypeMapping tm = meta.getTypeMapping();
        TextType li1 = tm.createText(null, "rdf", "li", "valeur1");
        TextType li2 = tm.createText(null, "rdf", "li", "valeur2");
        newSeq.getContainer().addProperty(li1);
        newSeq.getContainer().addProperty(li2);
        schem.addProperty(newSeq);
        List<AbstractField> list = schem.getUnqualifiedArrayList("seqType");
        Assert.assertTrue(list.contains(li1));
        Assert.assertTrue(list.contains(li2));
View Full Code Here

Examples of org.apache.xmpbox.type.ArrayProperty

        // retrieve complex property
        String getter = TypeTestingHelper.calculateArrayGetter(fieldName) + "Property";
        Method getcp = getSchemaClass().getMethod(getter, new Class[0]);
        Object ocp = getcp.invoke(getSchema(), new Object[0]);
        Assert.assertTrue(ocp instanceof ArrayProperty);
        ArrayProperty cp = (ArrayProperty) ocp;
        // check size is ok (1)
        Assert.assertEquals(1, cp.getContainer().getAllProperties().size());
        // add a new one
        Object value2 = TypeTestingHelper.getJavaValue(type);
        set.invoke(getSchema(), new Object[] { value2 });
        Assert.assertEquals(2, cp.getContainer().getAllProperties().size());
        // remove the first
        String remover = "remove" + TypeTestingHelper.calculateFieldNameForMethod(fieldName);
        Method remove = getSchemaClass().getMethod(remover, new Class<?>[] { TypeTestingHelper.getJavaType(type) });
        remove.invoke(getSchema(), value1);
        Assert.assertEquals(1, cp.getContainer().getAllProperties().size());

    }
View Full Code Here

Examples of org.apache.xmpbox.type.ArrayProperty

                esimple.setTextContent(simple.getStringValue());
                parent.appendChild(esimple);
            }
            else if (field instanceof ArrayProperty)
            {
                ArrayProperty array = (ArrayProperty) field;
                // property
                Element asimple = doc.createElement(array.getPrefix() + ":" + array.getPropertyName());
                parent.appendChild(asimple);
                // attributes
                fillElementWithAttributes(asimple, array);
                // the array definition
                Element econtainer = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX + ":" + array.getArrayType());
                asimple.appendChild(econtainer);
                // for each element of the array
                List<AbstractField> innerFields = array.getAllProperties();
                serializeFields(doc, econtainer, innerFields, false);
            }
            else if (field instanceof AbstractStructuredType)
            {
                AbstractStructuredType structured = (AbstractStructuredType) field;
View Full Code Here

Examples of org.apache.xmpbox.type.ArrayProperty

        {
            // not the good array type
            throw new XmpParsingException(ErrorType.Format, "Invalid array type, expecting " + type.card()
                    + " and found " + bagOrSeq.getLocalName());
        }
        ArrayProperty array = tm.createArrayProperty(namespace, prefix, name, type.card());
        container.addProperty(array);
        List<Element> lis = DomHelper.getElementChildren(bagOrSeq);

        for (Element element : lis)
        {
            QName propertyQName = DomHelper.getQName(property);
            AbstractField ast = parseLiElement(xmp, propertyQName, element);
            if (ast != null)
            {
                array.addProperty(ast);
            }
        }
    }
View Full Code Here

Examples of org.apache.xmpbox.type.ArrayProperty

                throw new XmpParsingException(ErrorType.NoType, "Type '" + name + "' not defined in "
                        + element.getNamespaceURI());
            }
            else if (type.card().isArray())
            {
                ArrayProperty array = tm.createArrayProperty(namespace, prefix, name, type.card());
                ast.getContainer().addProperty(array);
                Element bagOrSeq = DomHelper.getUniqueElementChild(element);
                List<Element> lis = DomHelper.getElementChildren(bagOrSeq);
                for (Element element2 : lis)
                {
                    AbstractField ast2 = parseLiElement(xmp, descriptor, element2);
                    if (ast2 != null)
                    {
                        array.addProperty(ast2);
                    }
                }
            }
            else if (type.type().isSimple())
            {
View Full Code Here

Examples of org.apache.xmpbox.type.ArrayProperty

    {

        DublinCoreSchema dc = metadata.getDublinCoreSchema();
        if (dc != null)
        {
            ArrayProperty copyrights = dc.getRightsProperty();
            if (copyrights == null || copyrights.getContainer() == null
                    || copyrights.getContainer().getAllProperties().isEmpty())
            {
                ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_PROPERTY_MISSING,
                        "CopyRights is missing from the XMP information (dc:rights) of the Font File Stream."));
                return false;
            }
View Full Code Here

Examples of org.apache.xmpbox.type.ArrayProperty

     * @param fieldValue
     *            the field value
     */
    private void removeUnqualifiedArrayValue(String arrayName, String fieldValue)
    {
        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();
            while (eraseProperties.hasNext())
            {
                array.getContainer().removeProperty(eraseProperties.next());
            }
        }

    }
View Full Code Here

Examples of org.apache.xmpbox.type.ArrayProperty

        this.internalAddBagValue(simpleName, bagValue);
    }

    private void internalAddBagValue(String qualifiedBagName, String bagValue)
    {
        ArrayProperty bag = (ArrayProperty) getAbstractProperty(qualifiedBagName);
        TextType li = createTextType(XmpConstants.LIST_NAME, bagValue);
        if (bag != null)
        {
            bag.getContainer().addProperty(li);
        }
        else
        {
            ArrayProperty newBag = createArrayProperty(qualifiedBagName, Cardinality.Bag);
            newBag.getContainer().addProperty(li);
            addProperty(newBag);
        }
    }
View Full Code Here

Examples of org.apache.xmpbox.type.ArrayProperty

     *
     * @return All values of the bag property in a list.
     */
    public List<String> getUnqualifiedBagValueList(String bagName)
    {
        ArrayProperty array = (ArrayProperty) getAbstractProperty(bagName);
        if (array != null)
        {
            return array.getElementsAsString();
        }
        else
        {
            return null;
        }
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.