/** * Does this step require access to the element text content. * <p/> * Does this step include a 'text()' predicate at any level. * * @return True if the step requires access to the element's text content, otherwise false. */ public boolean accessesText() { XPathExpressionEvaluator evaluator = getPredicatesEvaluator(); if(evaluator == null) { return false; } return accessesText(evaluator); }
/** * Does this step require access to the element text content. * <p/> * Does this step include a 'text()' predicate at any level. * * @return True if the step requires access to the element's text content, otherwise false. */ public boolean accessesText() { XPathExpressionEvaluator evaluator = getPredicatesEvaluator(); if(evaluator == null) { return false; } return accessesText(evaluator); }
/** * Does this step require access to the element text content. * <p/> * Does this step include a 'text()' predicate at any level. * * @return True if the step requires access to the element's text content, otherwise false. */ public boolean accessesText() { XPathExpressionEvaluator evaluator = getPredicatesEvaluator(); if(evaluator == null) { return false; } return accessesText(evaluator); }
/** * Does this step require access to the element text content. * * Does this step include a 'text()' predicate at any level. * * @return True if the step requires access to the element's text content, otherwise false. */ public boolean accessesText() { XPathExpressionEvaluator evaluator = getPredicatesEvaluator(); if(evaluator == null) { return false; } if(accessesText(evaluator)) { return true; } return false; }
/** * Does the supplied {@link XPathExpressionEvaluator} access the element text content. * @return True if the supplied {@link XPathExpressionEvaluator} accesses the element text content, * otherwise false. */ @SuppressWarnings("RedundantIfStatement") private boolean accessesText(XPathExpressionEvaluator evaluator) { if(evaluator instanceof AbstractEqualityEvaluator) { if(((AbstractEqualityEvaluator)evaluator).getLhs() instanceof TextValue) { return true; } else if(((AbstractEqualityEvaluator)evaluator).getRhs() instanceof TextValue) { return true; } } else if(evaluator instanceof AbstractLogicalEvaluator) { if(accessesText(((AbstractLogicalEvaluator)evaluator).getLhs())) { return true; } else if(accessesText(((AbstractLogicalEvaluator)evaluator).getRhs())) { return true; } } else if(evaluator instanceof PredicatesEvaluator) { List<XPathExpressionEvaluator> evaluators = ((PredicatesEvaluator) evaluator).getEvaluators(); for(XPathExpressionEvaluator pEvaluator : evaluators) { if(accessesText(pEvaluator)) { return true; } } } return false; }
/** * Does the supplied {@link XPathExpressionEvaluator} access the element text content. * @return True if the supplied {@link XPathExpressionEvaluator} accesses the element text content, * otherwise false. */ @SuppressWarnings("RedundantIfStatement") private boolean accessesText(XPathExpressionEvaluator evaluator) { if(evaluator instanceof AbstractEqualityEvaluator) { if(((AbstractEqualityEvaluator)evaluator).getLhs() instanceof TextValue) { return true; } else if(((AbstractEqualityEvaluator)evaluator).getRhs() instanceof TextValue) { return true; } } else if(evaluator instanceof AbstractLogicalEvaluator) { if(accessesText(((AbstractLogicalEvaluator)evaluator).getLhs())) { return true; } else if(accessesText(((AbstractLogicalEvaluator)evaluator).getRhs())) { return true; } } else if(evaluator instanceof PredicatesEvaluator) { List<XPathExpressionEvaluator> evaluators = ((PredicatesEvaluator) evaluator).getEvaluators(); for(XPathExpressionEvaluator pEvaluator : evaluators) { if(accessesText(pEvaluator)) { return true; } } } return false; }
/** * Does the supplied {@link XPathExpressionEvaluator} access the element text content. * @return True if the supplied {@link XPathExpressionEvaluator} accesses the element text content, * otherwise false. */ private boolean accessesText(XPathExpressionEvaluator evaluator) { if(evaluator instanceof AbstractEqualityEvaluator) { if(((AbstractEqualityEvaluator)evaluator).getLhs() instanceof TextValue) { return true; } else if(((AbstractEqualityEvaluator)evaluator).getRhs() instanceof TextValue) { return true; } } else if(evaluator instanceof AbstractLogicalEvaluator) { if(accessesText(((AbstractLogicalEvaluator)evaluator).getLhs())) { return true; } else if(accessesText(((AbstractLogicalEvaluator)evaluator).getRhs())) { return true; } } else if(evaluator instanceof PredicatesEvaluator) { List<XPathExpressionEvaluator> evaluators = ((PredicatesEvaluator) evaluator).getEvaluators(); for(XPathExpressionEvaluator pEvaluator : evaluators) { if(accessesText(pEvaluator)) { return true; } } } return false; }
/** * Does the supplied {@link XPathExpressionEvaluator} access the element text content. * @return True if the supplied {@link XPathExpressionEvaluator} accesses the element text content, * otherwise false. */ @SuppressWarnings("RedundantIfStatement") private boolean accessesText(XPathExpressionEvaluator evaluator) { if(evaluator instanceof AbstractEqualityEvaluator) { if(((AbstractEqualityEvaluator)evaluator).getLhs() instanceof TextValue) { return true; } else if(((AbstractEqualityEvaluator)evaluator).getRhs() instanceof TextValue) { return true; } } else if(evaluator instanceof AbstractLogicalEvaluator) { if(accessesText(((AbstractLogicalEvaluator)evaluator).getLhs())) { return true; } else if(accessesText(((AbstractLogicalEvaluator)evaluator).getRhs())) { return true; } } else if(evaluator instanceof PredicatesEvaluator) { List<XPathExpressionEvaluator> evaluators = ((PredicatesEvaluator) evaluator).getEvaluators(); for(XPathExpressionEvaluator pEvaluator : evaluators) { if(accessesText(pEvaluator)) { return true; } } } return false; }
private void assertSelectorsNotAccessingText(ContentHandlerConfigMapTable saxVisitorMap) { Map<String, List<ContentHandlerConfigMap<? extends SAXVisitor>>> table = saxVisitorMap.getTable(); Collection<List<ContentHandlerConfigMap<? extends SAXVisitor>>> contentHandlerMaps = table.values(); for(List<ContentHandlerConfigMap<? extends SAXVisitor>> contentHandlerMapList : contentHandlerMaps) { for(ContentHandlerConfigMap<? extends SAXVisitor> contentHandlerMap : contentHandlerMapList) { SmooksResourceConfiguration resourceConfig = contentHandlerMap.getResourceConfig(); SelectorStep selectorStep = resourceConfig.getSelectorStep(); if(selectorStep.accessesText()) { throw new SmooksConfigurationException("Unsupported selector '" + selectorStep.getXPathExpression() + "' on resource '" + resourceConfig + "'. The 'text()' XPath token is only supported on SAX Visitor implementations that implement the " + SAXVisitAfter.class.getName() + " interface only. Class '" + resourceConfig.getResource() + "' implements other SAX Visitor interfaces."); } } } }
private void assertSelectorsNotAccessingText(ContentHandlerConfigMapTable saxVisitorMap) { Map<String, List<ContentHandlerConfigMap<? extends SAXVisitor>>> table = saxVisitorMap.getTable(); Collection<List<ContentHandlerConfigMap<? extends SAXVisitor>>> contentHandlerMaps = table.values(); for(List<ContentHandlerConfigMap<? extends SAXVisitor>> contentHandlerMapList : contentHandlerMaps) { for(ContentHandlerConfigMap<? extends SAXVisitor> contentHandlerMap : contentHandlerMapList) { SmooksResourceConfiguration resourceConfig = contentHandlerMap.getResourceConfig(); SelectorStep selectorStep = resourceConfig.getSelectorStep(); if(selectorStep.accessesText()) { throw new SmooksConfigurationException("Unsupported selector '" + selectorStep.getXPathExpression() + "' on resource '" + resourceConfig + "'. The 'text()' XPath token is only supported on SAX Visitor implementations that implement the " + SAXVisitAfter.class.getName() + " interface only. Class '" + resourceConfig.getResource() + "' implements other SAX Visitor interfaces."); } } } }
private void assertSelectorsNotAccessingText(ContentHandlerConfigMapTable saxVisitorMap) { Map<String, List<ContentHandlerConfigMap<? extends SAXVisitor>>> table = saxVisitorMap.getTable(); Collection<List<ContentHandlerConfigMap<? extends SAXVisitor>>> contentHandlerMaps = table.values(); for(List<ContentHandlerConfigMap<? extends SAXVisitor>> contentHandlerMapList : contentHandlerMaps) { for(ContentHandlerConfigMap<? extends SAXVisitor> contentHandlerMap : contentHandlerMapList) { SmooksResourceConfiguration resourceConfig = contentHandlerMap.getResourceConfig(); SelectorStep selectorStep = resourceConfig.getSelectorStep(); if(selectorStep.accessesText()) { throw new SmooksConfigurationException("Unsupported selector '" + selectorStep.getXPathExpression() + "' on resource '" + resourceConfig + "'. The 'text()' XPath token is only supported on SAX Visitor implementations that implement the " + SAXVisitAfter.class.getName() + " interface only. Class '" + resourceConfig.getResource() + "' implements other SAX Visitor interfaces."); } } } }
private void assertSelectorsNotAccessingText(ContentHandlerConfigMapTable saxVisitorMap) { Map<String, List<ContentHandlerConfigMap<? extends SAXVisitor>>> table = saxVisitorMap.getTable(); Collection<List<ContentHandlerConfigMap<? extends SAXVisitor>>> contentHandlerMaps = table.values(); for(List<ContentHandlerConfigMap<? extends SAXVisitor>> contentHandlerMapList : contentHandlerMaps) { for(ContentHandlerConfigMap<? extends SAXVisitor> contentHandlerMap : contentHandlerMapList) { SmooksResourceConfiguration resourceConfig = contentHandlerMap.getResourceConfig(); SelectorStep selectorStep = resourceConfig.getSelectorStep(); if(selectorStep.accessesText()) { throw new SmooksConfigurationException("Unsupported selector '" + selectorStep.getXPathExpression() + "' on resource '" + resourceConfig + "'. The 'text()' XPath token is only supported on SAX Visitor implementations that implement the " + SAXVisitAfter.class.getName() + " interface only. Class '" + resourceConfig.getResource() + "' implements other SAX Visitor interfaces."); } } } }
public void initAccumulateText() { // If any of the before/after handlers are marked as text consumers... if(getAnnotatedHandler(visitBefores, TextConsumer.class, false) != null) { accumulateText = true; return; } if(getAnnotatedHandler(visitAfters, TextConsumer.class, false) != null) { accumulateText = true; return; } // If any of the selector steps need access to the fragment text... if(visitAfters == null) { return; } for(ContentHandlerConfigMap<? extends SAXVisitor> contentHandlerMap : visitAfters) { SmooksResourceConfiguration resourceConfig = contentHandlerMap.getResourceConfig(); SelectorStep selectorStep = resourceConfig.getSelectorStep(); if(selectorStep.accessesText()) { accumulateText = true; break; } } }
public void initAccumulateText() { // If any of the before/after handlers are marked as text consumers... if(getAnnotatedHandler(visitBefores, TextConsumer.class, false) != null) { accumulateText = true; return; } if(getAnnotatedHandler(visitAfters, TextConsumer.class, false) != null) { accumulateText = true; return; } // If any of the selector steps need access to the fragment text... if(visitAfters == null) { return; } for(ContentHandlerConfigMap<? extends SAXVisitor> contentHandlerMap : visitAfters) { SmooksResourceConfiguration resourceConfig = contentHandlerMap.getResourceConfig(); SelectorStep selectorStep = resourceConfig.getSelectorStep(); if(selectorStep.accessesText()) { accumulateText = true; break; } } }
public void initAccumulateText() { // If any of the before/after handlers are marked as text consumers... if(getAnnotatedHandler(visitBefores, TextConsumer.class, false) != null) { accumulateText = true; return; } if(getAnnotatedHandler(visitAfters, TextConsumer.class, false) != null) { accumulateText = true; return; } // If any of the selector steps need access to the fragment text... if(visitAfters == null) { return; } for(ContentHandlerConfigMap<? extends SAXVisitor> contentHandlerMap : visitAfters) { SmooksResourceConfiguration resourceConfig = contentHandlerMap.getResourceConfig(); SelectorStep selectorStep = resourceConfig.getSelectorStep(); if(selectorStep.accessesText()) { accumulateText = true; break; } } }
public void initAccumulateText() { // If any of the before/after handlers are marked as text consumers... if(getAnnotatedHandler(visitBefores, TextConsumer.class, false) != null) { accumulateText = true; return; } if(getAnnotatedHandler(visitAfters, TextConsumer.class, false) != null) { accumulateText = true; return; } // If any of the selector steps need access to the fragment text... if(visitAfters == null) { return; } for(ContentHandlerConfigMap<? extends SAXVisitor> contentHandlerMap : visitAfters) { SmooksResourceConfiguration resourceConfig = contentHandlerMap.getResourceConfig(); SelectorStep selectorStep = resourceConfig.getSelectorStep(); if(selectorStep.accessesText()) { accumulateText = true; break; } } }
/** * Set the namespaces on the specified set of selector steps. * @param steps The selector steps. * @param namespaces The set of selector steps to be updated. * @return The set of selector steps (as passed in the 'steps' argument). * @throws org.jaxen.saxpath.SAXPathException Error setting namespaces */ public static SelectorStep[] setNamespaces(SelectorStep[] steps, Properties namespaces) throws SAXPathException { AssertArgument.isNotNull(steps, "steps"); AssertArgument.isNotNull(namespaces, "namespaces"); for(int i = 0; i < steps.length; i++) { SelectorStep step = steps[i]; try { step.buildPredicatesEvaluator(namespaces); } catch (SAXPathException e) { throw e; } catch (Exception e) { throw new SAXPathException("Error compiling PredicatesEvaluator.", e); } // if(i < steps.length - 1 && step.accessesText()) { throw new SAXPathException("Unsupported XPath selector expression '" + step.getXPathExpression() + "'. XPath 'text()' tokens are only supported in the last step."); } } return steps; }
/** * Set the namespaces on the specified set of selector steps. * @param steps The selector steps. * @param namespaces The set of selector steps to be updated. * @return The set of selector steps (as passed in the 'steps' argument). * @throws org.jaxen.saxpath.SAXPathException Error setting namespaces */ public static SelectorStep[] setNamespaces(SelectorStep[] steps, Properties namespaces) throws SAXPathException { AssertArgument.isNotNull(steps, "steps"); AssertArgument.isNotNull(namespaces, "namespaces"); for(int i = 0; i < steps.length; i++) { SelectorStep step = steps[i]; try { step.buildPredicatesEvaluator(namespaces); } catch (SAXPathException e) { throw e; } catch (Exception e) { throw new SAXPathException("Error compiling PredicatesEvaluator.", e); } // if(i < steps.length - 1 && step.accessesText()) { throw new SAXPathException("Unsupported XPath selector expression '" + step.getXPathExpression() + "'. XPath 'text()' tokens are only supported in the last step."); } } return steps; }
/** * Set the namespaces on the specified set of selector steps. * @param steps The selector steps. * @param namespaces The set of selector steps to be updated. * @return The set of selector steps (as passed in the 'steps' argument). * @throws org.jaxen.saxpath.SAXPathException Error setting namespaces */ public static SelectorStep[] setNamespaces(SelectorStep[] steps, Properties namespaces) throws SAXPathException { AssertArgument.isNotNull(steps, "steps"); AssertArgument.isNotNull(namespaces, "namespaces"); for(int i = 0; i < steps.length; i++) { SelectorStep step = steps[i]; try { step.buildPredicatesEvaluator(namespaces); } catch (SAXPathException e) { throw e; } catch (Exception e) { throw new SAXPathException("Error compiling PredicatesEvaluator.", e); } // if(i < steps.length - 1 && step.accessesText()) { throw new SAXPathException("Unsupported XPath selector expression '" + step.getXPathExpression() + "'. XPath 'text()' tokens are only supported in the last step."); } } return steps; }
/** * Set the namespaces on the specified set of selector steps. * @param steps The selector steps. * @param namespaces The set of selector steps to be updated. * @return The set of selector steps (as passed in the 'steps' argument). * @throws org.jaxen.saxpath.SAXPathException Error setting namespaces */ public static SelectorStep[] setNamespaces(SelectorStep[] steps, Properties namespaces) throws SAXPathException { AssertArgument.isNotNull(steps, "steps"); AssertArgument.isNotNull(namespaces, "namespaces"); for(int i = 0; i < steps.length; i++) { SelectorStep step = steps[i]; try { step.buildPredicatesEvaluator(namespaces); } catch (SAXPathException e) { throw e; } catch (Exception e) { throw new SAXPathException("Error compiling PredicatesEvaluator.", e); } // if(i < steps.length - 1 && step.accessesText()) { throw new SAXPathException("Unsupported XPath selector expression '" + step.getXPathExpression() + "'. XPath 'text()' tokens are only supported in the last step."); } } return steps; }