List of usage examples for org.apache.commons.jxpath ExpressionContext getContextNodePointer
Pointer getContextNodePointer();
From source file:org.chiba.xml.xforms.xpath.ChibaExtensionFunctions.java
/** * Returns the calculation result of an external calculator. * * @param expressionContext the expression context. * @param uri the calculator uri.//w w w. j av a2s . c o m * @return the calculation result of an external calculator. * @throws XFormsException if any error occurred during the calculation. * @deprecated use custom extension functions instead */ public static String calculate(ExpressionContext expressionContext, String uri) throws XFormsException { JXPathContext context = expressionContext.getJXPathContext(); while (context != null) { Object contextBean = context.getContextBean(); if (contextBean instanceof XFormsElement) { // get hook from jxpath to chiba XFormsElement xFormsElement = (XFormsElement) contextBean; Container container = xFormsElement.getModel().getContainer(); Element contextElement = xFormsElement.getElement(); Node instanceNode = (Node) expressionContext.getContextNodePointer().getNode(); ModelItemCalculator calculator = container.getConnectorFactory().createModelItemCalculator(uri, contextElement); return calculator.calculate(instanceNode); } context = context.getParentContext(); } throw new XFormsException("invalid expression context when evaluating calculate('" + uri + "')"); }
From source file:org.chiba.xml.xforms.xpath.ChibaExtensionFunctions.java
/** * Returns the validation result of an external validator. * * @param expressionContext the expression context. * @param uri the calculator uri.// w w w. ja va 2s . com * @return the validation result of an external validator. * @throws XFormsException if any error occurred during the validation. * @deprecated use custom extension functions instead */ public static boolean validate(ExpressionContext expressionContext, String uri) throws XFormsException { JXPathContext context = expressionContext.getJXPathContext(); while (context != null) { Object contextBean = context.getContextBean(); if (contextBean instanceof XFormsElement) { // get hook from jxpath to chiba XFormsElement xFormsElement = (XFormsElement) contextBean; Container container = xFormsElement.getModel().getContainer(); Element contextElement = xFormsElement.getElement(); Node instanceNode = (Node) expressionContext.getContextNodePointer().getNode(); ModelItemValidator validator = container.getConnectorFactory().createModelItemValidator(uri, contextElement); return validator.validate(instanceNode); } context = context.getParentContext(); } throw new XFormsException("invalid expression context when evaluating validate('" + uri + "')"); }
From source file:org.nasdanika.cdo.xpath.EMFFunctions.java
/** * Expression context method.// w w w .j ava2s . com * @param expressionContext * @return */ public static String eClassName(ExpressionContext expressionContext) { Pointer cnp = expressionContext.getContextNodePointer(); if (cnp != null) { Object node = cnp.getNode(); if (node instanceof EObject) { return ((EObject) node).eClass().getName(); } } return null; }
From source file:org.nasdanika.cdo.xpath.EMFFunctions.java
/** * Expression context method.//from w w w . j a va 2 s .com * @param expressionContext * @return */ public static String ePackageNsURI(ExpressionContext expressionContext) { Pointer cnp = expressionContext.getContextNodePointer(); if (cnp != null) { Object node = cnp.getNode(); if (node instanceof EObject) { return ((EObject) node).eClass().getEPackage().getNsURI(); } } return null; }
From source file:org.openvpms.archetype.function.list.ListFunctions.java
/** * Convenience function to sort and concatenate the object names of the specified node, separated by commas. * * @param context the expression context. Must refer to an {@link IMObject}. * @param node the collection node name * @return the concatenated names, or {@code null} if the context doesn't refer to an {@link IMObject} *///www .j a v a 2 s . c o m public String sortNamesOf(ExpressionContext context, String node) { Pointer pointer = context.getContextNodePointer(); Object value = pointer.getValue(); if (value instanceof IMObject) { IMObjectBean bean = new IMObjectBean((IMObject) value, service); return sortNames(bean.getValues(node, IMObject.class)); } return null; }
From source file:org.openvpms.archetype.function.party.PartyFunctions.java
/** * Returns the full name for the passed party. * * @param context the expression context. Expected to reference a patient * party or an act.//w w w .j av a2 s. c o m * @return the parties full name. */ public String getPartyFullName(ExpressionContext context) { Pointer pointer = context.getContextNodePointer(); Object value = pointer.getValue(); if (value instanceof Party) { return getPartyFullName((Party) value); } else if (value instanceof Act) { return getPartyFullName((Act) value); } return null; }
From source file:org.openvpms.archetype.function.party.PartyFunctions.java
/** * Returns the current owner party for the passed party. * * @param context the expression context. Expected to reference a patient party or act containing an * <em>participation.patient</em> * @return the patients current owner Party. May be {@code null} *///www. j a va 2 s . c o m public Party getPatientOwner(ExpressionContext context) { Pointer pointer = context.getContextNodePointer(); Object value = pointer.getValue(); if (value instanceof Party) { return getPatientOwner((Party) value); } else if (value instanceof Act) { return getPatientOwner((Act) value); } return null; }
From source file:org.openvpms.archetype.function.party.PartyFunctions.java
/** * Returns a formatted list of preferred contacts for a party. * * @param context the expression context. Expected to reference a party. * @return a formatted list of contacts. May be {@code null} *//* ww w. j a v a2 s .c om*/ public String getPreferredContacts(ExpressionContext context) { Pointer pointer = context.getContextNodePointer(); if (pointer == null || !(pointer.getValue() instanceof Party)) { return null; } return getPreferredContacts((Party) pointer.getValue()); }
From source file:org.openvpms.archetype.function.party.PartyFunctions.java
/** * Returns a formatted billing address for a party. * * @param context the expression context. Expected to reference a party or * act/* ww w. ja va 2 s .com*/ * @return a formatted billing address, or {@code null} */ public String getBillingAddress(ExpressionContext context) { Pointer pointer = context.getContextNodePointer(); Object value = pointer.getValue(); if (value instanceof Party) { return getBillingAddress((Party) value); } else if (value instanceof Act) { return getBillingAddress((Act) value); } return null; }
From source file:org.openvpms.archetype.function.party.PartyFunctions.java
/** * Returns a formatted billing address for a party. * * @param context the expression context. Expected to reference a party or act * @return a formatted billing address, or {@code null} *//* w ww. j ava 2s .com*/ public String getCorrespondenceAddress(ExpressionContext context) { Pointer pointer = context.getContextNodePointer(); Object value = pointer.getValue(); if (value instanceof Party) { return getCorrespondenceAddress((Party) value); } else if (value instanceof Act) { return getCorrespondenceAddress((Act) value); } return null; }