Note that there are some explanatory texts on larger screens.

plurals
  1. PODesign API for taking xpath input from user
    primarykey
    data
    text
    <p>I want to design API which could handle XPATH input from user. Currently i have model the XPATH input in following way,</p> <pre><code>public interface ICondition { String getConditionString(); } public class XPathCondition implements ICondition { private Class&lt;? extends XPATHFunction&gt; clazz = null; private Operator operator = null; private String compValue = null; private String param = null; public void setXPathFunction(Class&lt;? extends XPATHFunction&gt; clazz) { this.clazz = clazz; } public void setComparisionType(Operator operator) { this.operator = operator; } public void setComparisionValue(String value) { this.compValue = value; } public void setParam(String param) { this.param = param; } public String getConditionString() { XPATHFunction function = null; try { function = (XPATHFunction) clazz.newInstance(); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } return function.call(param) + operator.getOprValue() + compValue; } public static void main(String[] args) { XPathCondition xpathCond = new XPathCondition(); xpathCond.setXPathFunction(CountFunction.class); xpathCond.setParam("/CPRRegistrationInfo/*"); xpathCond.setComparisionType(Operator.GT); xpathCond.setComparisionValue("0"); System.out.println(xpathCond.getConditionString()); } } public interface XPATHFunction { public String call(String param); } public class CountFunction implements XPATHFunction { public String call(String param) { return "count(" + param + ") "; } } </code></pre> <p>There could be other XPATH function which have to implement and interface XPATHFunction and implement it in its way.</p> <p>API just have create XPATHCondition and set appropriate function and call getConditionString() method to get the final xpath.</p> <p>Is there any better way, we can model XPATH input?</p> <p>Please help me to re factor the above design.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload