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


Java JXPathContext.getValue方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: getTimeStamp

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
/**
 * Gets the time stamp.
 * 
 * @param context the JXPath context
 * @param group the group
 * @return the time stamp
 */
protected Date getTimeStamp(JXPathContext context, XmlGroup group) {
    if (group.getTimestampXpath() == null) {
        return null;
    }
    String pattern = group.getTimestampFormat() == null ? "yyyy-MM-dd HH:mm:ss" : group.getTimestampFormat();
    log().debug("getTimeStamp: retrieving custom timestamp to be used when updating RRDs using XPATH " + group.getTimestampXpath() + " and pattern " + pattern);
    Date date = null;
    String value = (String)context.getValue(group.getTimestampXpath());
    try {
        DateTimeFormatter dtf = DateTimeFormat.forPattern(pattern);
        DateTime dateTime = dtf.parseDateTime(value);
        date = dateTime.toDate();
    } catch (Exception e) {
        log().warn("getTimeStamp: can't convert custom timetime " + value + " using pattern " + pattern);
    }
    return date;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:25,代码来源:AbstractJsonCollectionHandler.java

示例8: 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

示例9: main2

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public static void main2(String[] args) {
    Phone p1 = new Phone(1);
    Phone p2 = new Phone(2);
    List<Phone> phones = new ArrayList<>();
    phones.add(p1);
    phones.add(p2);

    JXPathContext ctx = JXPathContext.newContext(phones);
    System.out.println(phones);
    long phone1 = (long) ctx.getValue("/*[type='br.eti.kinoshita.commons.jxpath.Phone']");
    System.out.println(phone1);
}
 
开发者ID:kinow,项目名称:commons-sandbox,代码行数:13,代码来源:TestsJxpath.java

示例10: transfer

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Override
public void transfer(OutputStream out) {
	this.context.put("create", true);
	
	JXPathContext xPathContext = getXPathContext();
	xPathContext.setLenient(true);
	Object o = xPathContext.getValue(getPath());
	if (o != null) {
		throw new IllegalArgumentException("Path '" + getPath() + "' exists.");
	}
	setupTX();
	
	Pointer p = xPathContext.createPath(getPath());
	
	JXPathContext relContext = getRelativeContext(p);
	
	for (String outputAttribute : getInputAttributeNameAsArray()) {
		
		/*
		Iterator<Pointer> outputAttrPointersIter = context.iteratePointers(outputAttribute);
		while(outputAttrPointersIter.hasNext()) {
			Pointer vPointer = outputAttrPointersIter.next();
			Object values = getValues(outputAttribute);
			//NodePointer nP = (NodePointer)vPointer;
			//nP.getImmediateValuePointer().setValue(values);
			vPointer.setValue(values);
		}
		*/	
		Object values = getValues(outputAttribute);
		relContext.setValue(outputAttribute, values);
	}
	
	processTX();
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:35,代码来源:CreateCommand.java

示例11: testGetPIXAddReqObject_Throws_IOException

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGetPIXAddReqObject_Throws_IOException()
		throws JAXBException, IOException {
	// Arrange
	// PRPAIN201301UV02 pRPAIN201301UV02Mock = mock(PRPAIN201301UV02.class);
	String expectedItVersion = "XML_1.0";
	String expectedFirstName = "WILMA";
	when(
			marshaller.unmarshallFromXml(
					PRPAIN201301UV02.class,
					IOUtils.toString(getClass()
							.getClassLoader()
							.getResourceAsStream(
									"xml/PRPA_IN201301UV02_PIXADD_VD1_Req.xml"))))
			.thenThrow(IOException.class);
	thrown.expect(IOException.class);

	// 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,代码行数:31,代码来源:PixManagerRequestXMLToJavaTest.java

示例12: testGetPIXAddReqObject_Throws_JAXBException2

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGetPIXAddReqObject_Throws_JAXBException2()
		throws JAXBException, IOException {
	// Arrange
	// PRPAIN201301UV02 pRPAIN201301UV02Mock = mock(PRPAIN201301UV02.class);
	String expectedItVersion = "XML_1.0";
	String expectedFirstName = "WILMA";
	when(
			marshaller.unmarshallFromXml(
					PRPAIN201301UV02.class,
					IOUtils.toString(getClass()
							.getClassLoader()
							.getResourceAsStream(
									"xml/PRPA_IN201301UV02_PIXADD_VD1_Req.xml"))))
			.thenThrow(JAXBException.class);
	thrown.expect(JAXBException.class);

	// 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,代码行数:31,代码来源:PixManagerRequestXMLToJavaTest.java

示例13: getProtoValue

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Override
public Object getProtoValue(final JXPathContext context, final Context vars, final Config.Entry entry) {
    final Object object = context.getValue(entry.getPath());
    if (null == object) {
        return null;
    }

    return parseDate(object.toString());
}
 
开发者ID:yahoo,项目名称:xpath_proto_builder,代码行数:10,代码来源:RfcTimestampHandler.java

示例14: setMetaDataXML

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public boolean setMetaDataXML(String MetaDataResponse) throws Exception{
    JDOMParser domParser = new JDOMParser();
    InputStream metadataInputStream = MetadataUtils.InputStreamFromString(MetaDataResponse);        
    metaDataDocument = (Document)domParser.parseXML(metadataInputStream);
    boolean isXmlLoaded = false;
    
    if (metaDataDocument != null ) {
        JXPathContext docContext = JXPathContext.newContext(metaDataDocument);
        String thisClassSysName = null;
        
        try {
            isXmlLoaded = true;
            thisClassSysName = (String)docContext.getValue(msf_xPathQueryStandardResourceNames);
            if (log.isDebugEnabled()) {
                log.debug("SUCCESS - FOUND a class with System Name: " + thisClassSysName);
            }
        } catch (JXPathException je) {                
            log.error("JXPath ERROR: " + je.getMessage());
            log.error(je);
            throw je;
        } catch (Exception e) {
            log.error("JXPath ERROR: " + e.getMessage());
            log.error(e);
            throw e;
        }
        
    }
    
    return isXmlLoaded;        
}
 
开发者ID:RESOStandards,项目名称:RESO-Server-Compliance-Tester,代码行数:31,代码来源:MetadataFacade.java

示例15: queryStrings

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


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