当前位置: 首页>>代码示例>>Java>>正文


Java SimpleVariableContext类代码示例

本文整理汇总了Java中org.jaxen.SimpleVariableContext的典型用法代码示例。如果您正苦于以下问题:Java SimpleVariableContext类的具体用法?Java SimpleVariableContext怎么用?Java SimpleVariableContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SimpleVariableContext类属于org.jaxen包,在下文中一共展示了SimpleVariableContext类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSerializationFormatHasNotChanged

import org.jaxen.SimpleVariableContext; //导入依赖的package包/类
public void testSerializationFormatHasNotChanged() 
  throws IOException, ClassNotFoundException, UnresolvableException {
    
    //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("", "");
    
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:17,代码来源:SimpleVariableContextTest.java

示例2: testRoundTripSerialization

import org.jaxen.SimpleVariableContext; //导入依赖的package包/类
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("", "");
    
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:30,代码来源:SimpleVariableContextTest.java

示例3: testVariableWithNamespace

import org.jaxen.SimpleVariableContext; //导入依赖的package包/类
public void testVariableWithNamespace() throws IOException, JaxenException {
    Element root = doc.createElementNS("http://www.example.org/", "root");
    doc.appendChild(root);
    XPath xpath = new DOMXPath("//*[not($foo)]");
    SimpleVariableContext variables = new SimpleVariableContext();
    variables.setVariableValue("foo", "bar");
    xpath.setVariableContext(variables);
    xpath.addNamespace("", "http://www.example.org/");
    List result = xpath.selectNodes(doc);
    assertEquals(0, result.size());
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:12,代码来源:DOMXPathTest.java

示例4: NodeServiceXPath

import org.jaxen.SimpleVariableContext; //导入依赖的package包/类
/**
 * 
 * @param xpath
 *            the xpath statement
 * @param documentNavigator
 *            the navigator that will allow the xpath to be resolved
 * @param paramDefs
 *            parameters to resolve variables required by xpath
 * @throws JaxenException
 */
public NodeServiceXPath(String xpath, DocumentNavigator documentNavigator, QueryParameterDefinition[] paramDefs)
        throws JaxenException
{
    super(xpath, documentNavigator);

    if (logger.isDebugEnabled())
    {
        StringBuilder sb = new StringBuilder();
        sb.append("Created XPath: \n")
          .append("   XPath: ").append(xpath).append("\n")
          .append("   Parameters: \n");
        for (int i = 0; paramDefs != null && i < paramDefs.length; i++)
        {
            sb.append("      Parameter: \n")
              .append("         name: ").append(paramDefs[i].getQName()).append("\n")
              .append("         value: ").append(paramDefs[i].getDefault()).append("\n");
        }
        logger.debug(sb.toString());
    }
    
    // Add support for parameters
    if (paramDefs != null)
    {
        SimpleVariableContext svc = (SimpleVariableContext) this.getVariableContext();
        for (int i = 0; i < paramDefs.length; i++)
        {
            if (!paramDefs[i].hasDefaultValue())
            {
                throw new AlfrescoRuntimeException("Parameter must have default value");
            }
            Object value = null;
            if (paramDefs[i].getDataTypeDefinition().getName().equals(DataTypeDefinition.BOOLEAN))
            {
                value = Boolean.valueOf(paramDefs[i].getDefault());
            }
            else if (paramDefs[i].getDataTypeDefinition().getName().equals(DataTypeDefinition.DOUBLE))
            {
                value = Double.valueOf(paramDefs[i].getDefault());
            }
            else if (paramDefs[i].getDataTypeDefinition().getName().equals(DataTypeDefinition.FLOAT))
            {
                value = Float.valueOf(paramDefs[i].getDefault());
            }
            else if (paramDefs[i].getDataTypeDefinition().getName().equals(DataTypeDefinition.INT))
            {
                value = Integer.valueOf(paramDefs[i].getDefault());
            }
            else if (paramDefs[i].getDataTypeDefinition().getName().equals(DataTypeDefinition.LONG))
            {
                value = Long.valueOf(paramDefs[i].getDefault());
            }
            else
            {
                value = paramDefs[i].getDefault();
            }
            svc.setVariableValue(paramDefs[i].getQName().getNamespaceURI(), paramDefs[i].getQName().getLocalName(),
                    value);
        }
    }

    for (String prefix : documentNavigator.getNamespacePrefixResolver().getPrefixes())
    {
        addNamespace(prefix, documentNavigator.getNamespacePrefixResolver().getNamespaceURI(prefix));
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:76,代码来源:NodeServiceXPath.java

示例5: testSetNamespacelessVariable

import org.jaxen.SimpleVariableContext; //导入依赖的package包/类
public void testSetNamespacelessVariable() throws JaxenException { 
    SimpleVariableContext context = new SimpleVariableContext();
    context.setVariableValue("foo", "bar");
    assertEquals("bar", context.getVariableValue("", "", "foo"));
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:6,代码来源:VariableContextTest.java

示例6: NormalizedNodeContextSupport

import org.jaxen.SimpleVariableContext; //导入依赖的package包/类
private NormalizedNodeContextSupport(final ConverterNamespaceContext context,
        final NormalizedNodeNavigator navigator) {
    super(context, YangFunctionContext.getInstance(), new SimpleVariableContext(), navigator);
    this.root = new NormalizedNodeContext(this, navigator.getRootNode(), null);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:6,代码来源:NormalizedNodeContextSupport.java


注:本文中的org.jaxen.SimpleVariableContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。