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


Java JXPathContext.newContext方法代码示例

本文整理汇总了Java中org.apache.commons.jxpath.JXPathContext.newContext方法的典型用法代码示例。如果您正苦于以下问题:Java JXPathContext.newContext方法的具体用法?Java JXPathContext.newContext怎么用?Java JXPathContext.newContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.jxpath.JXPathContext的用法示例。


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

示例1: testToCsv

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Test
public void testToCsv() {
  final SimplePatientCsvFormat fmt = new SimplePatientCsvFormat();

  Patient patient = newPatient();

  
  JXPathContext patientCtx = JXPathContext.newContext(patient);
  Pointer ptr = patientCtx.getPointer("identifier[system='SSN']");
  assertNotNull(ptr);
  Identifier id = (Identifier) ptr.getValue();
  if (id != null) {
    assertNotNull("ssn", id.getValue());
  }
  Object obj1 = ptr.getNode();

  ptr = patientCtx.getPointer("name[use='official']");
  assertNotNull(ptr);
  Object obj2 = ptr.getValue();
  ptr = patientCtx.getPointer("name[not(use)]");
  assertNotNull(ptr);
  obj2 = ptr.getValue();
  
  String str = fmt.toCsv(patient);
  LOG.info("CSV: {}", str);
  assertTrue(str.length() > 0);
  // Ensure the literal, null doesn't appear
  assertTrue(!str.contains("null"));
  // Ensure there is no sign of array delimiters
  assertTrue(!str.contains("["));
  // Ensure line doesn't end with a comma
  assertTrue(!str.endsWith(","));
  assertTrue(str.contains("Smith"));
  
  List<ContactPoint> matches = ContactPointUtil.find(
      patient.getTelecom(), ContactPointSystem.PHONE, ContactPointUse.WORK);
  assertNotNull(matches);
  assertNotNull(matches.get(0));
}
 
开发者ID:mitre,项目名称:ptmatchadapter,代码行数:40,代码来源:SimplePatientCsvFormatTest.java

示例2: handle

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Override
public Object handle(Object[] args) throws Exception {
    String xPathQuery = (String) args[0];
    Boolean visibleOnly = (Boolean) args[1];
    AccessibilityElement localRootElement = (AccessibilityElement) args[2];

    AccessibilityHelper accessibilityHelper = AccessibilityFactory.getAccessibilityHelper();
    AccessibilityNodeInfo accessibilityRootNode = accessibilityHelper.getRootInActiveWindow();

    UiRoot uiRoot = AccessibilityFactory.getUiRoot(accessibilityRootNode);

    JXPathContext context = JXPathContext.newContext(uiRoot);
    QueryExecutor executor = new QueryExecutor(context);

    return executor.executeOnLocalRoot(localRootElement, xPathQuery, visibleOnly);
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:17,代码来源:UiElementXPathSuccessorRetriever.java

示例3: getValue

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Override
public String getValue(String key) {

    try {
        if (NumberUtils.isDigits(key)) {
            Integer.parseInt(key);
            JSONObject jsonResponse = new JSONObject(this.response);
            return (String) jsonResponse.get(key);
        }
    } catch (Exception e) {
    }
    try {
        if (this.jsonMap == null) {
            initialize();
        }
        String keyTrans = key.replace("@", "");
        // note that indexing is 1 based not zero based
        JXPathContext context = JXPathContext.newContext(this.jsonMap);
        String output = URLDecoder.decode(String.valueOf(context.getValue(keyTrans)), "UTF-8");
        if (output.equalsIgnoreCase("null"))
            return "";
        return output;
    } catch (Exception ex) {
        return "";
    }
}
 
开发者ID:intuit,项目名称:Tank,代码行数:27,代码来源:JsonResponse.java

示例4: getAttribute

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public static Object getAttribute(Object object, String key) {
  try {
    Object event = object;
    if (object instanceof String) {
      ObjectMapper mapper = new ObjectMapper();
      event = mapper.readValue(object.toString(), HashMap.class);
    }
    if (event != null) {
      JXPathContext context = JXPathContext.newContext(event);
      context.setLenient(true);
      return context.getValue(key);
    }
  }
  catch (Exception e) { // NOPMD
    return null;
  }
  return null;
}
 
开发者ID:pulsarIO,项目名称:jetstream-esper,代码行数:19,代码来源:EPLUtilities.java

示例5: getXPathContext

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public JXPathContext getXPathContext() {
	
	if (this.xPathContext == null) {
		log.debug("Create new OneCMDbContext");
		ISession session = this.oneCmdbContext.getSession(getAuth());
		if (session == null) {
			throw new SecurityException("No Session found! Try to do auth() first!");
		}
		/*
		IModelService mSvc = (IModelService)session.getService(IModelService.class);
		this.xPathContext = JXPathContext.newContext(new OneCMDBContext(new OneCMDBContextBeanProvider(mSvc)));
		*/
		this.context.put("session", session);
		this.xPathContext = JXPathContext.newContext(new OneCMDBContext(this.context, session));
		this.xPathContext.setFactory(new OneCMDBFactory());
	}
	return(this.xPathContext);
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:19,代码来源:AbstractPathCommand.java

示例6: format

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public String format(final Object obj) {
	final JXPathContext context = JXPathContext.newContext(obj);
	context.setFunctions(new ClassFunctions(JXPathFormatExtension.class, "format"));
	for(final Map.Entry<String,String> entry : this.namespaces.entrySet()) {
		context.registerNamespace(entry.getKey(), entry.getValue());
	}
	if(this.locale != null) {
		context.setLocale(this.locale);
		context.setDecimalFormatSymbols(null, new DecimalFormatSymbols(this.locale));
	}
	if(this.expression == null) {
		this.expression = context.compilePath(this.expressionString);
	}
	final Object val = this.expression.getValue(context);
	return val == null ? null : val.toString();
}
 
开发者ID:mklemm,项目名称:jxpath-object-formatter,代码行数:17,代码来源:ObjectFormatter.java

示例7: testGetPIXAddReqObject_by_ValidDomainXMLFile

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Test
public void testGetPIXAddReqObject_by_ValidDomainXMLFile()
		throws JAXBException, IOException {
	// Arrange
	// PRPAIN201301UV02 pRPAIN201301UV02Mock = mock(PRPAIN201301UV02.class);
	String expectedItVersion = "XML_1.0";
	String expectedFirstName = "WILMA";

	// Act
	PRPAIN201301UV02 pRPAIN201301UV02 = cstl.getPIXAddReqObject(
			"xml/PRPA_IN201301UV02_PIXADD_VD1_Req.xml", encodeString);
	String actualItversion = pRPAIN201301UV02.getITSVersion();
	JXPathContext context = JXPathContext.newContext(pRPAIN201301UV02);
	String actualFirstName = (String) context
			.getValue("controlActProcess/subject[1]/registrationEvent/subject1/patient/patientPerson/value/name[1]/content[2]/value/content");

	// Assert
	assertEquals(expectedItVersion, actualItversion);
	assertEquals(expectedFirstName, actualFirstName);
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:21,代码来源:PixManagerRequestXMLToJavaTest.java

示例8: testGetPIXUpdateReqObject_by_ValidDomainXMLFile

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Test
public void testGetPIXUpdateReqObject_by_ValidDomainXMLFile()
		throws JAXBException, IOException {
	// Arrange
	// PRPAIN201301UV02 pRPAIN201301UV02Mock = mock(PRPAIN201301UV02.class);
	String expectedItVersion = "XML_1.0";
	String expectedFirstName = "WILMA";

	// Act
	PRPAIN201302UV02 pRPAIN201302UV02 = cstl.getPIXUpdateReqObject(
			"xml/PRPA_IN201302UV02_PIXUpdate_Addr_Req.xml", encodeString);
	String actualItversion = pRPAIN201302UV02.getITSVersion();
	JXPathContext context = JXPathContext.newContext(pRPAIN201302UV02);
	String actualFirstName = (String) context
			.getValue("controlActProcess/subject[1]/registrationEvent/subject1/patient/patientPerson/value/name[1]/content[2]/value/content");

	// Assert
	assertEquals(expectedItVersion, actualItversion);
	assertEquals(expectedFirstName, actualFirstName);
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:21,代码来源:PixManagerRequestXMLToJavaTest.java

示例9: testGetPIXQueryReqObject_by_ValidDomainXMLFile

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Test
public void testGetPIXQueryReqObject_by_ValidDomainXMLFile()
		throws JAXBException, IOException {
	// Arrange
	// PRPAIN201301UV02 pRPAIN201301UV02Mock = mock(PRPAIN201301UV02.class);
	String expectedItVersion = "XML_1.0";
	String expectedId = "JW-824-v3";

	// Act
	PRPAIN201309UV02 pRPAIN201309UV02 = cstl
			.getPIXQueryReqObject(
					"xml/PRPA_IN201309UV02_PIXQuery_VD1INALL_Req.xml",
					encodeString);
	String actualItversion = pRPAIN201309UV02.getITSVersion();
	JXPathContext context = JXPathContext.newContext(pRPAIN201309UV02);
	String actualId = (String) context
			.getValue("controlActProcess/queryByParameter/value/parameterList/patientIdentifier[1]/value[1]/extension");

	// Assert
	assertEquals(expectedItVersion, actualItversion);
	assertEquals(expectedId, actualId);
}
 
开发者ID:tlin-fei,项目名称:ds4p,代码行数:23,代码来源:PixManagerRequestXMLToJavaTest.java

示例10: testPerformanceFromJxPathModified

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Test
public void testPerformanceFromJxPathModified() {
    WorkInstanceOlemlDocBuilder docBuilder = new WorkInstanceOlemlDocBuilder();
    List<SolrInputDocument> jxSolrDocs = new ArrayList<SolrInputDocument>();
    List<SolrInputDocument> custSolrDocs = new ArrayList<SolrInputDocument>();
    RequestDocument rd = new RequestDocument();
    rd.setCategory(DocCategory.WORK.getCode());
    rd.setType(DocType.INSTANCE.getCode());
    rd.getContent().setContentObject(instance);
    Long timeJxPath = System.currentTimeMillis();
    JXPathContext instance1 = JXPathContext.newContext(instance);
    for (int i = 0; i < 1; i++) {
        docBuilder.buildSolrInputDocumentsForInstanceByJXPathTest(instance1, instance, jxSolrDocs);
        docBuilder.buildSolrInputDocumentsForHoldingByJXPathTest(instance1, instance, jxSolrDocs);
        docBuilder.buildSolrInputDocumentsForItemsByJXPathTest(instance1, instance, jxSolrDocs);
        //                        if (i == 0)
        //                            System.out.println("Modified JS SOLR DOCS: \n" + jxSolrDocs);
    }
    timeJxPath = System.currentTimeMillis() - timeJxPath;
    System.out.println("testPerformanceFromJxPathModified " + timeJxPath);
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:22,代码来源:WorkInstanceOlemlDocBuilder_UT.java

示例11: addRowData

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
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;

        // 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;
}
 
开发者ID:instaclick,项目名称:pdi-plugin-parsejsonstring,代码行数:26,代码来源:ParseJsonString.java

示例12: fillCollectionSet

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
/**
 * Fill collection set.
 *
 * @param agent the agent
 * @param collectionSet the collection set
 * @param source the source
 * @param json the JSON Object
 * @throws ParseException the parse exception
 */
@SuppressWarnings("unchecked")
protected void fillCollectionSet(CollectionAgent agent, XmlCollectionSet collectionSet, XmlSource source, JSONObject json) throws ParseException {
    JXPathContext context = JXPathContext.newContext(json);
    for (XmlGroup group : source.getXmlGroups()) {
        log().debug("fillCollectionSet: getting resources for XML group " + group.getName() + " using XPATH " + group.getResourceXpath());
        Date timestamp = getTimeStamp(context, group);
        Iterator<Pointer> itr = context.iteratePointers(group.getResourceXpath());
        while (itr.hasNext()) {
            JXPathContext relativeContext = context.getRelativeContext(itr.next());
            String resourceName = getResourceName(relativeContext, group);
            log().debug("fillCollectionSet: processing XML resource " + resourceName);
            XmlCollectionResource collectionResource = getCollectionResource(agent, resourceName, group.getResourceType(), timestamp);
            AttributeGroupType attribGroupType = new AttributeGroupType(group.getName(), group.getIfType());
            for (XmlObject object : group.getXmlObjects()) {
                String value = (String) relativeContext.getValue(object.getXpath());
                XmlCollectionAttributeType attribType = new XmlCollectionAttributeType(object, attribGroupType);
                collectionResource.setAttributeValue(attribType, value);
            }
            processXmlResource(collectionResource, attribGroupType);
            collectionSet.getCollectionResources().add(collectionResource);
        }
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:33,代码来源:AbstractJsonCollectionHandler.java

示例13: testXpath

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
/**
 * Test to verify XPath content.
 *
 * @throws Exception the exception
 */
@Test
@SuppressWarnings("unchecked")
public void testXpath() throws Exception {
    JSONObject json = MockDocumentBuilder.getJSONDocument();
    JXPathContext context = JXPathContext.newContext(json);
    Iterator<Pointer> itr = context.iteratePointers("/zones/zone");
    while (itr.hasNext()) {
        Pointer resPtr = itr.next();
        JXPathContext relativeContext = context.getRelativeContext(resPtr);
        String resourceName = (String) relativeContext.getValue("@name");
        Assert.assertNotNull(resourceName);
        String value = (String) relativeContext.getValue("parameter[@key='nproc']/@value");
        Assert.assertNotNull(Integer.valueOf(value));
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:21,代码来源:JsonCollectorSolarisZonesTest.java

示例14: query

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public static Collection<Value> query(Queriable context,String jxpath) {
	JXPathContext ctx = JXPathContext.newContext(context);
	Object o;
	try {
		o = ctx.selectNodes(jxpath);
		//o = ctx.getValue(jxpath);
	} catch(JXPathException e){
		log.debug(e.getMessage(), e);
		o = null;
	}
	if(o instanceof Value) {
		return Collections.singleton((Value)o);
	} else if (o instanceof Collection<?>) {
		List<Value> v = new ArrayList<Value>();
		for(Object o1 : ((Collection<?>) o)) {
			if(o1 instanceof Value) {
				v.add((Value) o1);
			}
		}
		return v;
	} else {
		return new ArrayList<Value>();
	}
}
 
开发者ID:lexml,项目名称:madoc,代码行数:25,代码来源:DataSetUtil.java

示例15: getClassesNameSystemName

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public Hashtable getClassesNameSystemName(String resourceName) {
    Hashtable classNamesByStrdName  = new Hashtable();
    Iterator classNodesIterator     = null;
    List mdClassNodes               = null;
    Element mdClassNode             = null;
    String thisClassName            = null;
    String thisStrdName             = null;
    String xPathQuery         = msf_xPathQuerySystemClass + "'" + resourceName + "']/METADATA-CLASS/Class";
    
    JXPathContext mdDocContext = JXPathContext.newContext(metaDataDocument);
    mdClassNodes = mdDocContext.selectNodes(xPathQuery);

    classNodesIterator = mdClassNodes.iterator();
    while(classNodesIterator.hasNext()) {
        mdClassNode = (Element)classNodesIterator.next();
        thisClassName = mdClassNode.getChildText(MetadataField.classNameClass);
        thisStrdName = mdClassNode.getChildText(MetadataField.standardNameClass);

        classNamesByStrdName.put(thisStrdName, thisClassName);            
    }

    return classNamesByStrdName;
}
 
开发者ID:RESOStandards,项目名称:RESO-Server-Compliance-Tester,代码行数:24,代码来源:MetadataFacade.java


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