Package org.openquark.util.attributes

Examples of org.openquark.util.attributes.Attribute$AttributeComparator


        // Check to see if there are multiple values first
        Element lovElement = XMLPersistenceHelper.getChildElement(element, LIST_OF_VALUES);
        if (lovElement != null) {
            List<Attribute> values = new ArrayList<Attribute>();
            manager.loadFromChildElements(lovElement, values);
            return new Attribute(name, values);
        } else {
            List<Attribute> values = new ArrayList<Attribute>();
            manager.loadFromChildElements(lovElement, values);
            if (!values.isEmpty()) {
                return new Attribute(name, values.iterator().next());
            } else {
                // TODO Just return null for now.  Returning null will exclude
                // this attribute from the parent attribute set.  But eventually
                // this case should generate an exception
                return null;
View Full Code Here


   
    /* (non-Javadoc)
     * @see org.openquark.util.xml.XMLElementSerializer#storeToElement(org.openquark.util.xml.XMLSerializer, org.w3c.dom.Element, java.lang.Object)
     */
    public void storeToElement(XMLSerializationManager manager, Element element, Object value) {
        Attribute attribute = (Attribute) value;
        Document doc = element.getOwnerDocument();
        Element attrElement = doc.createElement(ROOT_TAG);
        element.appendChild(attrElement);
       
        // Name of the attribute is stored as an attribute of the XML element
        attrElement.setAttribute(NAME_ATTRIBUTE, attribute.getName());
       
        // The value(s) is/are stored as a child element(s).  If there is only
        // one value, just store it as is.  Otherwise, wrap the list of values
        // by a ListOfValues tag
        List<?> values = attribute.getValues();
        if (values.size() == 1) {
            manager.storeToElement(attrElement, values.iterator().next());
        } else {
            Element lovElement = doc.createElement(LIST_OF_VALUES);
            attrElement.appendChild(lovElement);
            manager.storeToElement(lovElement, attribute.getValues());
        }
    }
View Full Code Here

     * can be a shared instance.
     * @param name
     * @param value
     */
    public void setAttribute(String name, Object value) {
        attributes.setAttribute(new Attribute(name, value));
    }
View Full Code Here

        /**
         * @see org.openquark.util.xml.XMLElementSerializer#storeToElement(org.openquark.util.xml.XMLSerializationManager, org.w3c.dom.Element, java.lang.Object)
         */
        public void storeToElement(XMLSerializationManager manager, Element element, Object value) {
            // Don't store the attribute if it has no values.
            Attribute attribute = (Attribute) value;
            List<?> values = attribute.getValues();
            if (values.isEmpty()) {
                return;
            }
           
            Document document = element.getOwnerDocument ();
            Element attrElement = document.createElement(tagName);
            element.appendChild(attrElement);

            // Store the name member as an attribute.
            attrElement.setAttribute(NAME_ATTR_NAME, attribute.getName());

            // Store the value member.
            if (values.size() == 1) {
                // attempts to store the single value as an attribute, if it does not work, attempt
                // to store it as an element
                if (manager.storeAsAttribute(attrElement, attribute.getSingleValue())) {
                    return;
                }
            }

            // If the value cannot be stored as an attribute or there are multiple values,
View Full Code Here

         * @param name
         * @param value
         * @return Attribute
         */
        protected Attribute createAttribute(String name, Object value) {
            return new Attribute(name, value);
        }
View Full Code Here

         * @param name
         * @param values
         * @return Attribute
         */
        protected Attribute createAttribute(String name, Collection<?> values) {
            return new Attribute(name, values);
        }
View Full Code Here

TOP

Related Classes of org.openquark.util.attributes.Attribute$AttributeComparator

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.