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


Java JXPathContext.setLenient方法代码示例

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


在下文中一共展示了JXPathContext.setLenient方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: determineFlag

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
/**
 * Determine the product model flag value (decompress GZIP data and check for productModel entries)
 * 
 * @param data
 *            GZIP compressed data of XML
 * @return <code>true</code> if product models are available, <code>false</code> otherwise
 */
private boolean determineFlag( byte[] data ) {
	try {
		JDOMParser parser = new JDOMParser();
		parser.setValidating( false );
		Object doc = parser.parseXML( new GZIPInputStream( new ByteArrayInputStream( data ) ) );
		JXPathContext context = JXPathContext.newContext( doc );
		context.setLenient( true );
		context.registerNamespace( "common", "http://lca.jrc.it/ILCD/Common" );
		context.registerNamespace( "ilcd", "http://lca.jrc.it/ILCD/Process" );
		context.registerNamespace( "pm", "http://iai.kit.edu/ILCD/ProductModel" );

		DataSetParsingHelper helper = new DataSetParsingHelper( context );
		return helper.getElements( "/ilcd:processDataSet/ilcd:processInformation/common:other/pm:productModel" ).size() > 0;
	}
	catch ( Exception e ) {
		return false;
	}

}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:27,代码来源:V2_8__ProductModelFlag.java

示例3: findJaxbElementUsingJXPath

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public static List<Object> findJaxbElementUsingJXPath(Object object, String xPath) {

        List<Object> listObjectFound = new ArrayList<Object>();

        JXPathContext context = JXPathContext.newContext(object);
        context.setLenient(true);
        Iterator<?> it = context.iterate(xPath);
        while (it.hasNext()) {
            listObjectFound.add(it.next());
        }
        return listObjectFound;
    }
 
开发者ID:clstoulouse,项目名称:motu,代码行数:13,代码来源:JAXBTDSModel.java

示例4: evaluate

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public <T> T evaluate(Exchange exchange, Class<T> tClass) {
    try {
        JXPathContext context = JXPathContext.newContext(exchange);
        context.setLenient(lenient);
        Object result = getJXPathExpression().getValue(context, type);
        assertResultType(exchange, result);
        return exchange.getContext().getTypeConverter().convertTo(tClass, result);
    } catch (JXPathException e) {
        throw new ExpressionEvaluationException(this, exchange, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:JXPathExpression.java

示例5: navigateTo

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
public ObjectGraphNavigationResult navigateTo(final Object root, final String xpath) throws InvalidConfigurationException {
    Assert.argumentNotNull("root", root);
    Assert.argumentNotNull("xpath", xpath);

    try {
        final JXPathContext ctx = JXPathContext.newContext(root);
        ctx.setLenient(true); // do not throw an exception if object graph is incomplete, e.g. contains null-values

        Pointer pointer = ctx.getPointer(xpath);

        // no match found or invalid xpath
        if (pointer instanceof NullPropertyPointer || pointer instanceof NullPointer)
            return null;

        if (pointer instanceof BeanPointer) {
            final Pointer parent = ((BeanPointer) pointer).getImmediateParentPointer();
            if (parent instanceof PropertyPointer) {
                pointer = parent;
            }
        }

        if (pointer instanceof PropertyPointer) {
            final PropertyPointer pp = (PropertyPointer) pointer;
            final Class<?> beanClass = pp.getBean().getClass();
            AccessibleObject accessor = ReflectionUtils.getField(beanClass, pp.getPropertyName());
            if (accessor == null) {
                accessor = ReflectionUtils.getGetter(beanClass, pp.getPropertyName());
            }
            return new ObjectGraphNavigationResult(root, xpath, pp.getBean(), accessor, pointer.getValue());
        }

        throw new InvalidConfigurationException("Don't know how to handle pointer [" + pointer + "] of type [" + pointer.getClass().getName()
                + "] for xpath [" + xpath + "]");
    } catch (final JXPathNotFoundException ex) {
        // thrown if the xpath is invalid
        throw new InvalidConfigurationException(ex);
    }
}
 
开发者ID:sebthom,项目名称:oval,代码行数:39,代码来源:ObjectGraphNavigatorJXPathImpl.java

示例6: transformToObjectAndRemoveKey

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
/**
 * transformToObject - This method converts incoming JsonString to HashMap. Need/use of this method is, in EPL we need
 * to use pass Objects through window. But EPL allows primitives type alone. For that we 'll convert Obejct to
 * JsonString and pass it to the stream. After that we need to convert back the Json String to original Object type.
 * 
 */
@SuppressWarnings("unchecked")
public static HashMap<String, Object> transformToObjectAndRemoveKey(String jsonStr, String key) throws Exception {
  if (jsonStr != null) {
    ObjectMapper mapper = new ObjectMapper();
    HashMap<String, Object> event = mapper.readValue(jsonStr, HashMap.class);
    if (key != null && !key.equals("")) {
      JXPathContext context = JXPathContext.newContext(event);
      context.setLenient(true);
      context.removePath(key);
    }
    return event;
  }
  return null;
}
 
开发者ID:pulsarIO,项目名称:jetstream-esper,代码行数:21,代码来源:EPLUtilities.java

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

示例8: builder

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
/**
 * Gives a message builder from the content provided.
 *
 * @param content - The content object that is converted to JXPathContext to build the message.
 * @return The corresponding message builder object for the input.
 */
public Message.Builder builder(final Object content) {
    JXPathContext jXPathContext = JXPathContext.newContext(content);
    jXPathContext.setLenient(true);
    JXPathCopier jxPathCopier = new JXPathCopier(jXPathContext, null);

    return transformUsing(new Context(context), builderConfig, jxPathCopier, transform);
}
 
开发者ID:yahoo,项目名称:xpath_proto_builder,代码行数:14,代码来源:ProtoBuilder.java

示例9: parseStream

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
private DataSet parseStream( InputStream inputStream ) {

		JDOMParser parser = new JDOMParser();
		parser.setValidating( false );
		Object doc = parser.parseXML( inputStream );
		JXPathContext context = JXPathContext.newContext( doc );
		context.setLenient( true );
		context.registerNamespace( "common", "http://lca.jrc.it/ILCD/Common" );

		parserHelper = new DataSetParsingHelper( context );
		commonReader = new CommonConstructsReader( parserHelper );

		return parse( context, out );
	}
 
开发者ID:PE-INTERNATIONAL,项目名称:soda4lca,代码行数:15,代码来源:DataSetReader.java

示例10: apply

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean apply(Object input) {
    JXPathContext jxpath = JXPathContext.newContext(input);
    // We should allow non-existing path, and let predicate handle it. 
    jxpath.setLenient(true);
    
    Object value = jxpath.getValue(xpath);
   
    return predicate.apply(value);
}
 
开发者ID:Netflix,项目名称:suro,代码行数:12,代码来源:PathValueMessageFilter.java

示例11: apply

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Override
public boolean apply(Object input) {
    JXPathContext jxpath = JXPathContext.newContext(input);
    // We should allow non-existing path, and let predicate handle it.
    jxpath.setLenient(true);

    Pointer pointer = jxpath.getPointer(xpath);
   
    return pointer != null && !(pointer instanceof NullPointer) && pointer.getValue() != null;
}
 
开发者ID:Netflix,项目名称:suro,代码行数:11,代码来源:PathExistsMessageFilter.java

示例12: apply

import org.apache.commons.jxpath.JXPathContext; //导入方法依赖的package包/类
@Override
  public boolean apply(@Nullable String input) {
JXPathContext context = JXPathContext.newContext(input);
context.setLenient(true);
   return Objects.equal(context.getValue(valueXpath), context.getValue(inputXpath));
  }
 
开发者ID:Netflix,项目名称:suro,代码行数:7,代码来源:PathValuePredicate.java


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