Package org.apache.xmpbox.type

Examples of org.apache.xmpbox.type.AbstractStructuredType


            }
            else if (type.type().isStructured())
            {
                if (DomHelper.isParseTypeResource(property))
                {
                    AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property);
                    if (ast != null)
                    {
                        ast.setPrefix(prefix);
                        container.addProperty(ast);
                    }
                }
                else
                {
                    Element inner = DomHelper.getFirstChildElement(property);
                    if (inner != null)
                    {
                        nsFinder.push(inner);
                        AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner);
                        ast.setPrefix(prefix);
                        container.addProperty(ast);
                    }
                }
            }
            else if (type.type() == Types.DefinedType)
            {
                if (DomHelper.isParseTypeResource(property))
                {
                    AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property);
                    ast.setPrefix(prefix);
                    container.addProperty(ast);
                }
                else
                {
                    Element inner = DomHelper.getFirstChildElement(property);
                    if (inner == null)
                    {
                        throw new XmpParsingException(ErrorType.Format, "property should contain child element : "
                                + property);
                    }
                    AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner);
                    ast.setPrefix(prefix);
                    container.addProperty(ast);
                }
            }
        }
        finally
View Full Code Here


        }
        // Instantiate abstract structured type with hint from first element
        Element first = elements.get(0);
        PropertyType ctype = checkPropertyDefinition(xmp, DomHelper.getQName(first));
        Types tt = ctype.type();
        AbstractStructuredType ast = instanciateStructured(tm, tt, descriptor.getLocalPart(), first.getNamespaceURI());

        ast.setNamespace(descriptor.getNamespaceURI());
        ast.setPrefix(descriptor.getPrefix());

        PropertiesDescription pm;
        if (tt.isStructured())
        {
            pm = tm.getStructuredPropMapping(tt);
        }
        else
        {
            pm = tm.getDefinedDescriptionByNamespace(first.getNamespaceURI());
        }
        for (Element element : elements)
        {
            String prefix = element.getPrefix();
            String name = element.getLocalName();
            String namespace = element.getNamespaceURI();
            PropertyType type = pm.getPropertyType(name);
            if (type == null)
            {
                // not defined
                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())
            {
                AbstractSimpleProperty sp = tm.instanciateSimpleProperty(namespace, prefix, name,
                        element.getTextContent(), type.type());
                loadAttributes(sp, element);
                ast.getContainer().addProperty(sp);
            }
            else if (type.type().isStructured())
            {
                // create a new structured type
                AbstractStructuredType inner = instanciateStructured(tm, type.type(), name, null);
                inner.setNamespace(namespace);
                inner.setPrefix(prefix);
                ast.getContainer().addProperty(inner);
                ComplexPropertyContainer cpc = inner.getContainer();
                if (DomHelper.isParseTypeResource(element))
                {
                    parseDescriptionInner(xmp, element, cpc);
                }
                else
View Full Code Here

                List<AbstractField> innerFields = array.getAllProperties();
                serializeFields(doc, econtainer, innerFields,resourceNS, false);
            }
            else if (field instanceof AbstractStructuredType)
            {
                AbstractStructuredType structured = (AbstractStructuredType) field;
                List<AbstractField> innerFields = structured.getAllProperties();
                // property name attribute
                Element listParent = parent;
                if (wrapWithProperty)
                {
                    Element nstructured = doc
                            .createElement(resourceNS + ":" + structured.getPropertyName());
                    parent.appendChild(nstructured);
                    listParent = nstructured;
                }

                // element li
View Full Code Here

                List<AbstractField> innerFields = array.getAllProperties();
                serializeFields(doc, econtainer, innerFields, false);
            }
            else if (field instanceof AbstractStructuredType)
            {
                AbstractStructuredType structured = (AbstractStructuredType) field;
                List<AbstractField> innerFields = structured.getAllProperties();
                // property name attribute
                Element listParent = parent;
                if (wrapWithProperty)
                {
                    Element nstructured = doc
                            .createElement(structured.getPrefix() + ":" + structured.getPropertyName());
                    parent.appendChild(nstructured);
                    listParent = nstructured;
                }

                // element li
View Full Code Here

            }
            else if (type.type().isStructured())
            {
                if (DomHelper.isParseTypeResource(property))
                {
                    AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property);
                    ast.setPrefix(prefix);
                    container.addProperty(ast);
                }
                else
                {
                    Element inner = DomHelper.getFirstChildElement(property);
                    if (inner != null)
                    {
                        AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner);
                        ast.setPrefix(prefix);
                        container.addProperty(ast);
                    }
                }
            }
            else if (type.type() == Types.DefinedType)
            {
                if (DomHelper.isParseTypeResource(property))
                {
                    AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), property);
                    ast.setPrefix(prefix);
                    container.addProperty(ast);
                }
                else
                {
                    Element inner = DomHelper.getFirstChildElement(property);
                    if (inner == null)
                    {
                        throw new XmpParsingException(ErrorType.Format, "property should contain child element : "
                                + property);
                    }
                    AbstractStructuredType ast = parseLiDescription(xmp, DomHelper.getQName(property), inner);
                    ast.setPrefix(prefix);
                    container.addProperty(ast);
                }
            }
        }
        finally
View Full Code Here

        }
        // Instantiate abstract structured type with hint from first element
        Element first = elements.get(0);
        PropertyType ctype = checkPropertyDefinition(xmp, DomHelper.getQName(first));
        Types tt = ctype.type();
        AbstractStructuredType ast = instanciateStructured(tm, tt, descriptor.getLocalPart(), first.getNamespaceURI());

        ast.setNamespace(descriptor.getNamespaceURI());
        ast.setPrefix(descriptor.getPrefix());

        PropertiesDescription pm;
        if (tt.isStructured())
        {
            pm = tm.getStructuredPropMapping(tt);
        }
        else
        {
            pm = tm.getDefinedDescriptionByNamespace(first.getNamespaceURI());
        }
        for (Element element : elements)
        {
            String prefix = element.getPrefix();
            String name = element.getLocalName();
            String namespace = element.getNamespaceURI();
            PropertyType type = pm.getPropertyType(name);
            if (type == null)
            {
                // not defined
                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())
            {
                AbstractSimpleProperty sp = tm.instanciateSimpleProperty(namespace, prefix, name,
                        element.getTextContent(), type.type());
                loadAttributes(sp, element);
                ast.getContainer().addProperty(sp);
            }
            else if (type.type().isStructured())
            {
                // create a new structured type
                AbstractStructuredType inner = instanciateStructured(tm, type.type(), name, null);
                inner.setNamespace(namespace);
                inner.setPrefix(prefix);
                ast.getContainer().addProperty(inner);
                ComplexPropertyContainer cpc = inner.getContainer();
                if (DomHelper.isParseTypeResource(element))
                {
                    parseDescriptionInner(xmp, element, cpc);
                }
                else
View Full Code Here

TOP

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

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.