Examples of ODOMAttribute


Examples of com.volantis.mcs.eclipse.common.odom.ODOMAttribute

                    : ProxyElementDetails.ATTRIBUTES);
            }
           
        } else {
            // Target attribute DOES exist in the target: get it
            final ODOMAttribute existingAttribute =
                (ODOMAttribute) targetElement.getAttribute(attribName);
               
            // If there is an attribute value passed in...
            if (attribValue != null && attribValue.length() != 0) {   
               
                // Just update the existing attribute with the new value
                // and set the change return accordingly
                existingAttribute.setValue(attribValue);
                change = ProxyElementDetails.ATTRIB_VALUES;
               
            } else {   
                    
                // Delete the attrib and note whether its element was deleted
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.ODOMAttribute

        // targets.
        if (targetElement instanceof ProxyElement) {
            targetElement.setAttribute(attribName, attribValue);
        } else {
            // Create the attribute to insert
            final ODOMAttribute newAttribute =
                        (ODOMAttribute) odomFactory.
                        attribute(attribName, attribValue);

            // Use a create xpath instead of just setAttribute on the
            // target as only the former method creates (or ensures is
            // created) the "whole path" from source to target (e.g. if
            // latter is grandchild)
            // NOTE that this is ok even where sourceToTargetPath==null
            final ODOMXPath createPath =
                        new ODOMXPath(sourceToTargetPath, newAttribute);

            // This just creates an EMPTY attribute.......
            final ODOMAttribute createdAttribute =
                        (ODOMAttribute) createPath.
                        create(sourceElement, odomFactory);

            // ....but in doing so it might have created us a new target:
            // first check whether it was originally null
            if (targetElement == null) {

                // Navigate to the target that the create should have made
                targetElement = navigateToTarget(sourceElement);
                if (targetElement == null) {
                    throw new IllegalStateException
                                ("xpath create did not create target");
                }

                // OK, add in the new target
                sourceTargetPairs.setTarget(pairIndex, targetElement);

                // We did create an element
                wasTargetCreated = true;
            }

            // Finally we can insert the actual target value!
            createdAttribute.setValue(attribValue);
        }
        return wasTargetCreated;
    }
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.ODOMAttribute

     * @param event The original event from the changed callback
     */
    private void processAttribHierarchyEvent(ODOMChangeEvent event) {

        // Get the event source, which we know to be an attribute
        final ODOMAttribute eventSrcAttrib = (ODOMAttribute) event.getSource();

        // Is it an addition?
        if (event.getNewValue() != null && event.getOldValue() == null) {

            // TODO Should we do this test:
            // To be consistent with element hierarchy events, make sure
            // we do NOT already have this attribute

            // If the attribute has just been added to an element that is
            // a target in the source/target pairs, and the attribute is
            // currently supported, then this counts as a notifiable
            // change to the proxied elements
            if (sourceTargetPairs.isTargetElement(
                    (Element)event.getNewValue()) &&
                proxyElementDetails.isAttributeName(
                    eventSrcAttrib.getName())) {
                proxiedElementsUpdated(ProxyElementDetails.ATTRIBUTES);
            }

        // Is it a deletion?
        } else if (event.getNewValue() == null &&
                   event.getOldValue() != null) {

            // TODO Should we do this test:
            // To be consistent with element hierarchy events, make sure
            // we DO already have this attribute

            // If the attribute has just been removed from an element that
            // is a target in the source/target pairs, and the attribute is
            // currently supported, then this counts as a notifiable
            // change to the proxied elements
            if (sourceTargetPairs.isTargetElement(
                    (Element)event.getOldValue()) &&
                proxyElementDetails.isAttributeName(
                    eventSrcAttrib.getName())) {
                proxiedElementsUpdated(ProxyElementDetails.ATTRIBUTES);
            }

        } else {
            // Event content is nonsense
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.ODOMAttribute

        Map expectedAttributesAfterAdd = new HashMap();
        expectedAttributesAfterAdd.put("attr01", "value01");
        expectedAttributesAfterAdd.put("attr01_1", "value01_1");

        rootElement.getChild("elem01").getAttributes().add(
                new ODOMAttribute("attr01_1", "value01_1"));

        assertAttributesEquals(expectedAttributesAfterAdd,
                               rootElement.getChild("elem01").getAttributes());

        {
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.ODOMAttribute

     */
    public void testRemoveGrandparentNodes() throws Exception {
        ODOMElement one = (ODOMElement) factory.element("one");
        ODOMElement two = (ODOMElement) factory.element("two");
        ODOMElement three = (ODOMElement) factory.element("three");
        ODOMAttribute threeAttrib =
                (ODOMAttribute) factory.attribute("threeAttrib", "");

        one.addContent(two);
        two.addContent(three);
        three.setAttribute(threeAttrib);

        ODOMXPath oneToThree = new ODOMXPath("two/three");
        ODOMXPath oneToThreeAttrib = new ODOMXPath(oneToThree,
                                           "@" + threeAttrib.getName());

        // Do the removal.
        ODOMObservable observable = oneToThreeAttrib.remove(one);

        assertNotNull("Node shouldn't be null", observable);
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.ODOMAttribute

     * Test removal of a grandchild that is the only child of an only child.
     */
    public void testRemoveMultiStepGrandchildAttribute() throws Exception {
        ODOMElement root = (ODOMElement) factory.element("root");
        ODOMElement child = (ODOMElement) factory.element("child");
        ODOMAttribute grandchild = (ODOMAttribute) factory.attribute(
                "grandchild", "value");
        ODOMXPath path = new ODOMXPath("child/@grandchild");

        root.addContent(child);
        child.setAttribute(grandchild);
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.ODOMAttribute


    public void testSelectAttribute() throws Exception {
        final ODOMElement fourthCdElement = ((ODOMElement) (root.getChildren()
                .get(3)));
        ODOMAttribute attribute = (ODOMAttribute) fourthCdElement.getChild(
                "title")
                .getAttribute("testAttribute");
        assertEquals("sanity check", "remove", attribute.getValue());

        assertSelectFromODOMObservable(attribute);
    }
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.ODOMAttribute


    public void testSelectAttributeWithinElemWithNS() throws Exception {
        final ODOMElement newElement = ((ODOMElement) (root.getChildren()
                .get(4)));
        ODOMAttribute attribute = (ODOMAttribute) newElement.getAttribute(
                "country");
        assertEquals("sanity check", "Nowhere", attribute.getValue());

        assertSelectFromODOMObservable(attribute);
    }
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.ODOMAttribute


    public void testSelectAttributeWithNSinPath() throws Exception {
        final ODOMElement newElement2 = ((ODOMElement) (root.getChildren()
                .get(5)));
        ODOMAttribute attribute = (ODOMAttribute) newElement2.getChild(
                "newElement2_2").getAttribute("attr2_2");
        assertEquals("sanity check", "attr2_2Value", attribute.getValue());

        assertSelectFromODOMObservable(attribute);
    }
View Full Code Here

Examples of com.volantis.mcs.eclipse.common.odom.ODOMAttribute

    // javadoc inherited
    public List getAttributes() {
        Iterator attribsIter = super.getAttributes().iterator();
        List result = new ArrayList();
        while (attribsIter.hasNext()) {
            ODOMAttribute attribute = (ODOMAttribute) attribsIter.next();
            // TODO This should not return a new one every time (ideally)
            result.add(new ProxyAttribute(attribute, this));
        }
        return result;
    }
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.