List of usage examples for org.apache.commons.jxpath JXPathContext newContext
public static JXPathContext newContext(Object contextBean)
From source file:org.xchain.namespaces.sax.BaseTestSaxEvents.java
@Before public void setUp() throws Exception { context = JXPathContext.newContext(new Object()); recorder = new SaxEventRecorder(); result = new SAXResult(recorder); context.getVariables().declareVariable("result", result); context.getVariables().declareVariable("executed", Boolean.FALSE); catalog = CatalogFactory.getInstance().getCatalog(catalogUri); }
From source file:org.xchain.namespaces.test.TestPathNotFound.java
@Before public void setUp() throws Exception { context = JXPathContext.newContext(new Object()); context.getVariables().declareVariable("variable", new Object()); catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI); }
From source file:org.xchain.namespaces.test.TestThrowingException.java
@Before public void setUp() throws Exception { context = JXPathContext.newContext(new Object()); context.registerNamespace("test", NAMESPACE_URI); catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI); }
From source file:org.xchain.StandAloneExecutor.java
/** * Create the JXPathContext that is going to be used */// ww w . j a va 2 s . co m public JXPathContext getContext() { return JXPathContext.newContext(new HashMap<Object, Object>()); }
From source file:org.xchain.test.component.TestComponent.java
@Before public void setUp() throws Exception { catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI); context = JXPathContext.newContext(new Object()); }
From source file:org.xiforge.pentaho.di.trans.step.parsejsonstring.ParseJsonString.java
private Object[] addRowData(Object[] r) throws KettleException { // Parsing field final JSON json = JSONSerializer.toJSON(r[data.fieldPos].toString()); final JXPathContext context = JXPathContext.newContext(json); final String[] fieldNames = meta.getFieldName(); final RowMetaInterface rowMeta = data.outputRowMeta; // Parsing each path into otuput rows for (int i = 0; i < fieldNames.length; i++) { final String fieldPath = meta.getXPath()[i]; final String fieldName = meta.getFieldName()[i]; final Object fieldValue = context.getValue(fieldPath); final Integer fieldIndex = rowMeta.indexOfValue(fieldNames[i]); final ValueMetaInterface valueMeta = rowMeta.getValueMeta(fieldIndex); final DateFormat df = (valueMeta.getType() == ValueMetaInterface.TYPE_DATE) ? new SimpleDateFormat(meta.getFieldFormat()[i]) : null;/* ww w . j av a 2s . co m*/ // safely add the unique field at the end of the output row r = RowDataUtil.addValueData(r, fieldIndex, getRowDataValue(fieldName, valueMeta, valueMeta, fieldValue, df)); } return r; }
From source file:org.xsystem.bpm2machineservice.impl.ScriptingService.java
public JXPathContext makeJXPathContext(Map<String, Object> data) { JXPathContext context = JXPathContext.newContext(data); FunctionLibrary lib = new FunctionLibrary(); lib.addFunctions(new ClassFunctions(CalendarHelper.class, "calendarhelper")); lib.addFunctions(new ClassFunctions(Calendar.class, "calendar")); context.setFunctions(lib);/*from ww w .j av a2s . co m*/ return context; }
From source file:org.xsystem.sql2.http.impl.HttpHelper.java
public static int getThumb(FileFormat fileFormat, Map<String, Object> reqContext) { if (fileFormat == null) { return -1; }/*from ww w.j ava2 s .com*/ String eval = fileFormat.getPreview(); if (eval.isEmpty()) { return 200; } JXPathContext context = JXPathContext.newContext(reqContext); context.setLenient(true); Object obj = context.getValue(eval); if (obj == null) { return 200; } Integer ret = Integer.valueOf(obj.toString().trim()); return ret; }
From source file:org.xsystem.sql2.http.impl.HttpHelper.java
public static FileTransfer getFileTransfer(FileFormat fileFormat, Object value, BiFunction<String, Object, byte[]> bi) { Map row = null;//from w w w .j a v a2 s . c om if (value instanceof List) { List lst = (List) value; if (!lst.isEmpty()) { Object test = lst.get(0); if (test instanceof Map) { row = (Map) test; } } } else if (value instanceof Map) { row = (Map) value; } if (row == null) { return null; } String evalContenttype = fileFormat.getContenttype(); String evalFilename = fileFormat.getFilename(); String evalContent = fileFormat.getContent(); String evalFormat = fileFormat.getFormat(); JXPathContext context = JXPathContext.newContext(row); context.setLenient(true); String contenttype = (String) context.getValue(evalContenttype); String filename = (String) context.getValue(evalFilename); //byte[] content = (byte[]) context.getValue(evalContent); String format = (String) context.getValue(evalFormat); Object data = context.getValue(evalContent); byte[] content = bi.apply(fileFormat.getStorage(), data); if (content == null) { return null; } FileTransfer ret = new FileTransfer(); ret.setContentType(contenttype); ret.setData(content); ret.setFileName(filename); ret.setFileType(format); return ret; }
From source file:org.xsystem.sql2.http.PageServlet2.java
static Map<String, Object> getContext(Map<String, String> evals, Map<String, Object> reqContext) { JXPathContext context = JXPathContext.newContext(reqContext); context.setFunctions(new ClassFunctions(Base64Decode.class, "BASE64")); context.setLenient(true);//from w ww . ja v a 2 s.c o m Map ret = new HashMap(); evals.entrySet().forEach(entry -> { String key = entry.getKey(); String eval = entry.getValue(); Object value = context.getValue(eval); ret.put(key, value); }); return ret; }