Package org.jaxen

Examples of org.jaxen.SimpleVariableContext


    }

    protected ContextSupport getContextSupport() {
        return new ContextSupport(new SimpleNamespaceContext(),
                XPathFunctionContext.getInstance(),
                new SimpleVariableContext(), DocumentNavigator.getInstance());
    }
View Full Code Here


        DOMXPath xpath = new DOMXPath("/root/child");
        assertNotNull(xpath.getVariableContext());
    }
    public void testSetNamespacelessVariable() throws JaxenException {
        SimpleVariableContext context = new SimpleVariableContext();
        context.setVariableValue("foo", "bar");
        assertEquals("bar", context.getVariableValue("", "", "foo"));
    }
View Full Code Here

    public void testRoundTripSerialization()
      throws IOException, ClassNotFoundException, UnresolvableException {
       
        // construct test object
        SimpleVariableContext original = new SimpleVariableContext();
        original.setVariableValue("s", "String Value");
        original.setVariableValue("x", new Double(3.1415292));
        original.setVariableValue("b", Boolean.TRUE);
       
        // serialize
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(out);
        oos.writeObject(original);
        oos.close();
       
        //deserialize
        byte[] pickled = out.toByteArray();
        InputStream in = new ByteArrayInputStream(pickled);
        ObjectInputStream ois = new ObjectInputStream(in);
        Object o = ois.readObject();
        SimpleVariableContext copy = (SimpleVariableContext) o;
       
        // test the result
        assertEquals("String Value", copy.getVariableValue("", "", "s"));
        assertEquals(new Double(3.1415292), copy.getVariableValue("", "", "x"));
        assertEquals(Boolean.TRUE, copy.getVariableValue("", "", "b"));
        assertEquals("", "");
       
    }
View Full Code Here

       
        //deserialize
        InputStream in = new FileInputStream("xml/simplevariablecontext.ser");
        ObjectInputStream ois = new ObjectInputStream(in);
        Object o = ois.readObject();
        SimpleVariableContext context = (SimpleVariableContext) o;
       
        // test the result
        assertEquals("String Value", context.getVariableValue("", "", "s"));
        assertEquals(new Double(3.1415292), context.getVariableValue("", "", "x"));
        assertEquals(Boolean.TRUE, context.getVariableValue("", "", "b"));
        assertEquals("", "");
       
    }
View Full Code Here

    }

    protected ContextSupport getContextSupport() {
        return new ContextSupport(new SimpleNamespaceContext(),
                XPathFunctionContext.getInstance(),
                new SimpleVariableContext(), DocumentNavigator.getInstance());
    }
View Full Code Here

/*     */   public String toString() {
/* 115 */     return "[XPathPattern: text: " + this.text + " Pattern: " + this.pattern + "]";
/*     */   }
/*     */
/*     */   protected ContextSupport getContextSupport() {
/* 119 */     return new ContextSupport(new SimpleNamespaceContext(), XPathFunctionContext.getInstance(), new SimpleVariableContext(), DocumentNavigator.getInstance());
/*     */   }
View Full Code Here

        assertEquals(6, new SynapseXPath("string-length(//test)").numberValueOf(ctx).intValue());
    }
   
    public void testCustomVariables() throws Exception {
        SynapseXPath xpath = new SynapseXPath("$myvar");
        SimpleVariableContext variableContext = new SimpleVariableContext();
        variableContext.setVariableValue("myvar", "myvalue");
        xpath.setVariableContext(variableContext);
        assertEquals("myvalue", xpath.evaluate(TestUtils.getTestContext("<test/>")));
    }
View Full Code Here

TOP

Related Classes of org.jaxen.SimpleVariableContext

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.