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


Java XPathFunctionException类代码示例

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


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

示例1: createPropertiesFunction

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
private XPathFunction createPropertiesFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            if (!list.isEmpty()) {
                Object value = list.get(0);
                if (value != null) {
                    String text = exchange.get().getContext().getTypeConverter().convertTo(String.class, value);
                    try {
                        // use the property placeholder resolver to lookup the property for us
                        Object answer = exchange.get().getContext().resolvePropertyPlaceholders("{{" + text + "}}");
                        return answer;
                    } catch (Exception e) {
                        throw new XPathFunctionException(e);
                    }
                }
            }
            return null;
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:XPathBuilder.java

示例2: createSimpleFunction

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
private XPathFunction createSimpleFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            if (!list.isEmpty()) {
                Object value = list.get(0);
                if (value != null) {
                    String text = exchange.get().getContext().getTypeConverter().convertTo(String.class, value);
                    Language simple = exchange.get().getContext().resolveLanguage("simple");
                    Expression exp = simple.createExpression(text);
                    Object answer = exp.evaluate(exchange.get(), Object.class);
                    return answer;
                }
            }
            return null;
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:XPathBuilder.java

示例3: getStringParam

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
/**
 * Gets the string param.
 *
 * @param o
 *            the o
 * @return the string param
 * @throws XPathFunctionException
 *             the x path function exception
 */
protected String getStringParam(Object o) throws XPathFunctionException {
	// perform conversions
	String output = null;
	if (o instanceof String) {
		output = (String) o;
	} else if (o instanceof Boolean) {
		output = o.toString();
	} else if (o instanceof Double) {
		output = o.toString();
	} else if (o instanceof NodeList) {
		NodeList list = (NodeList) o;
		Node node = list.item(0);
		output = node.getTextContent();
	} else {
		throw new XPathFunctionException("Could not convert argument type");
	}
	return output;
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:28,代码来源:AbstractFunction.java

示例4: getNumberParam

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
/**
 * Gets the number param.
 *
 * @param o
 *            the o
 * @return the number param
 * @throws XPathFunctionException
 *             the x path function exception
 */
protected Number getNumberParam(Object o) throws XPathFunctionException {
	// perform conversions
	Number output = null;
	try {
		if (o instanceof String) {
			output = Double.parseDouble((String) o);
		} else if (o instanceof Double) {
			output = (Double) o;
		} else if (o instanceof NodeList) {
			NodeList list = (NodeList) o;
			Node node = list.item(0);
			output = Double.parseDouble(node.getTextContent());
		} else {
			throw new XPathFunctionException("Could not convert argument type");
		}
	} catch (NumberFormatException ex) {
		throw new XPathFunctionException(ex);
	}
	return output;
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:30,代码来源:AbstractFunction.java

示例5: evaluate

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
public Object evaluate(List args) throws XPathFunctionException {
    MessageDAO inputMsg = evalCtx.getInput();
    String partName = (String) args.get(0);
    Node matchingElement = null;
    if (StringUtils.isNullOrEmpty(partName)) {
        throw new HumanTaskRuntimeException("The getInput function should be provided with the part name");
    }

    if (inputMsg.getBodyData().hasChildNodes()) {
        NodeList nodeList = inputMsg.getBodyData().getChildNodes();

        for (int i = 0; i < nodeList.getLength(); i++) {
            if (partName.trim().equals(nodeList.item(i).getNodeName())) {
                matchingElement = nodeList.item(i);
            }
        }
    }

    if (matchingElement == null || matchingElement.getFirstChild() == null) {
        throw new HumanTaskRuntimeException(
                "Cannot find a matching Element for expression evaluation: getInput");
    }

    return matchingElement.getFirstChild();
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:26,代码来源:JaxpFunctionResolver.java

示例6: eval

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
public Object eval(List<?> args) throws XPathFunctionException {
  String source = args.get(0).toString();
  int start = ((Number)args.get(1)).intValue();
  int end = ((Number)args.get(2)).intValue();
  // perform boundary checking
  if (start < 0) start = 0;
  int len = source.length();
  if (start > len) {
    start = len;
    end = len;
  }
  if (end > len) end = len;
  if (end < start) end = start;
  
  return source.substring(start, end);
}
 
开发者ID:quoll,项目名称:mulgara,代码行数:17,代码来源:AfnFunctionGroup.java

示例7: eval

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
public Object eval(List<?> args) throws XPathFunctionException {
  String source = args.get(0).toString();
  int start = ((Number)args.get(1)).intValue() - 1;
  int end = ((Number)args.get(2)).intValue() + start;
  // perform boundary checking
  int len = source.length();
  if (start < 0) start = 0;
  if (start > len) {
    start = len;
    end = len;
  }
  if (end > len) end = len;
  if (end < start) end = start;
  
  return source.substring(start, end);
}
 
开发者ID:quoll,项目名称:mulgara,代码行数:17,代码来源:FnFunctionGroup.java

示例8: eval

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
public Object eval(List<?> args) throws XPathFunctionException {
  String str = (String)args.get(0);
  StringBuilder outputString = new StringBuilder();
  try {
    Process proc = Runtime.getRuntime().exec(str);
    proc.getOutputStream().close();
    BufferedReader procStdOut = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    char[] buffer = new char[BUFFER_SIZE];
    int len;
    while ((len = procStdOut.read(buffer)) >= 0) outputString.append(buffer, 0, len);
    procStdOut.close();
    proc.getErrorStream().close();
  } catch (IOException e) {
    throw new XPathFunctionException("I/O error communicating with external process.");
  }
  return outputString.toString();
}
 
开发者ID:quoll,项目名称:mulgara,代码行数:18,代码来源:MulgaraXFunctionGroup.java

示例9: evaluate

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
/**
 * Random XPath wrapper. Return depends on the params, as follows:
 * <ul>
 * <li>random(): returns a floating-point number between 0.0 and 1.0.</li>
 * <li>random(num): integer between 0 (inclusive) and num (exclusive).</li>
 * <li>random(nodeset): picks a random node from the set.</li>
 * </ul>
 */
@SuppressWarnings("rawtypes")
@Override
public Object evaluate(List params) throws XPathFunctionException {
	if (params==null || params.size() ==0){
		return random.nextDouble();
	}
	Object oParam = params.get(0);
	if (oParam instanceof Double){
		double d= (double) random.nextInt((int)Math.round(((Double)oParam)));
		return d;
	}
	if (oParam instanceof NodeList){
		NodeList nl = (NodeList)oParam;
		return nl.item(random.nextInt(nl.getLength()));
	}
	return null;
}
 
开发者ID:brtl-fhc,项目名称:lolxml-common,代码行数:26,代码来源:XPathFunctionRandom.java

示例10: getNumberParam

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
protected Number getNumberParam(Object o) throws XPathFunctionException {
    // perform conversions
    Number output = null;
    try {
        if (o instanceof String) output = Double.parseDouble((String) o);
        else if (o instanceof Double) output = (Double)o;
        else if (o instanceof NodeList) {
            NodeList list = (NodeList) o;
            Node node = list.item(0);
            output = Double.parseDouble(node.getTextContent());
        } else {
            throw new XPathFunctionException("Could not convert argument type");
        }
    } catch (NumberFormatException ex) {
        throw new XPathFunctionException(ex);
    }
    return output;
}
 
开发者ID:3dcitydb,项目名称:swingx-ws,代码行数:19,代码来源:AbstractFunction.java

示例11: resolveFunction

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
@Override
public XPathFunction resolveFunction(final QName functionName, final int arity)
{
    if (functionMap.containsKey(functionName))
    {
        return new XPathFunction()
        {
            @Override
            public Object evaluate(List args) throws XPathFunctionException
            {
                return functionMap.get(functionName).evaluate(args);
            }
        };
    }
    return originalResolver.resolveFunction(functionName, arity);
}
 
开发者ID:windup,项目名称:windup,代码行数:17,代码来源:XmlFileFunctionResolver.java

示例12: evaluate

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
public Object evaluate(List args)
  throws XPathFunctionException
{
  // We can't do anything useful here.
  // So much for the JAXP API...
  return Collections.EMPTY_SET;
}
 
开发者ID:vilie,项目名称:javify,代码行数:8,代码来源:CurrentFunction.java

示例13: createBodyFunction

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
private XPathFunction createBodyFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            return exchange.get().getIn().getBody();
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:XPathBuilder.java

示例14: createHeaderFunction

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
private XPathFunction createHeaderFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            if (!list.isEmpty()) {
                Object value = list.get(0);
                if (value != null) {
                    String text = exchange.get().getContext().getTypeConverter().convertTo(String.class, value);
                    return exchange.get().getIn().getHeader(text);
                }
            }
            return null;
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:XPathBuilder.java

示例15: createOutBodyFunction

import javax.xml.xpath.XPathFunctionException; //导入依赖的package包/类
private XPathFunction createOutBodyFunction() {
    return new XPathFunction() {
        @SuppressWarnings("rawtypes")
        public Object evaluate(List list) throws XPathFunctionException {
            if (exchange.get() != null && exchange.get().hasOut()) {
                return exchange.get().getOut().getBody();
            }
            return null;
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:XPathBuilder.java


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