Produced by Araxis Merge on 6/9/2017 3:49:59 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Jun 9 19:49:59 2017 UTC | ||
| 2 | eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-common\src\main\java\gov\va\nvap\common\xpath | XPathUtil.java | Fri Apr 21 20:03:26 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 124 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | package go v.va.nvap. common.xpa th; | |||||
| 2 | ||||||
| 3 | import jav ax.xml.tra nsform.Tra nsformerEx ception; | |||||
| 4 | import jav ax.xml.xpa th.XPathCo nstants; | |||||
| 5 | import jav ax.xml.xpa th.XPathEx pression; | |||||
| 6 | import jav ax.xml.xpa th.XPathEx pressionEx ception; | |||||
| 7 | import jav ax.xml.xpa th.XPathFa ctory; | |||||
| 8 | ||||||
| 9 | import org .apache.xp ath.XPathA PI; | |||||
| 10 | import org .w3c.dom.D OMExceptio n; | |||||
| 11 | import org .w3c.dom.D ocument; | |||||
| 12 | import org .w3c.dom.N ode; | |||||
| 13 | import org .w3c.dom.N odeList; | |||||
| 14 | ||||||
| 15 | /** | |||||
| 16 | * @author Asha Amri traj | |||||
| 17 | */ | |||||
| 18 | public cla ss XPathUt il { | |||||
| 19 | ||||||
| 20 | pu blic stati c XPathExp ression co mpileExpre ssion(fina l String x Query) { | |||||
| 21 | if ( (xQuery != null) && (xQuery.le ngth() > 0 )) { | |||||
| 22 | try { | |||||
| 23 | return X PathFactor y.newInsta nce().newX Path().com pile(xQuer y); | |||||
| 24 | } catc h (final X PathExpres sionExcept ion e) { | |||||
| 25 | throw ne w RuntimeE xception(e ); | |||||
| 26 | } | |||||
| 27 | } | |||||
| 28 | thro w new Runt imeExcepti on("Query is null!") ; | |||||
| 29 | } | |||||
| 30 | ||||||
| 31 | pu blic stati c boolean evaluateBo olean(fina l Document doc, | |||||
| 32 | final String exp ression) t hrows XPat hExpressio nException { | |||||
| 33 | fina l XPathExp ression cE xpression = XPathUti l | |||||
| 34 | .compile Expression (expressio n); | |||||
| 35 | retu rn (Boolea n) cExpres sion.evalu ate(doc, X PathConsta nts.BOOLEA N); | |||||
| 36 | } | |||||
| 37 | ||||||
| 38 | pu blic stati c String g etFieldByP ath(final Document d oc, final String pat h) | |||||
| 39 | throws XPathExce ption { | |||||
| 40 | ||||||
| 41 | Stri ng fieldVa lue = ""; | |||||
| 42 | try { | |||||
| 43 | final NodeList l ist = XPat hAPI.selec tNodeList( doc, path) ; | |||||
| 44 | if ((l ist != nul l) && (lis t.getLengt h() > 0)) { | |||||
| 45 | final No de n = lis t.item(0); | |||||
| 46 | if (n != null) { | |||||
| 47 | final Node text = n. getFirstCh ild(); | |||||
| 48 | if ((text != null) | |||||
| 49 | && ( text.getNo deType() = = Node.TEX T_NODE)) { | |||||
| 50 | fi eldValue = text.getN odeValue() ; | |||||
| 51 | } | |||||
| 52 | } | |||||
| 53 | } | |||||
| 54 | } ca tch (final Transform erExceptio n e2) { | |||||
| 55 | throw new XPathE xception( | |||||
| 56 | "getFieldB yPath: tra nsformer e xception, path: " + path, e2); | |||||
| 57 | } | |||||
| 58 | retu rn fieldVa lue; | |||||
| 59 | } | |||||
| 60 | ||||||
| 61 | pu blic stati c Node get NodeByPath (final Doc ument doc, final Str ing path) | |||||
| 62 | throws XPathExce ption { | |||||
| 63 | ||||||
| 64 | Node List list = null; | |||||
| 65 | try { | |||||
| 66 | list = XPathAPI. selectNode List(doc, path); | |||||
| 67 | } ca tch (final Transform erExceptio n e2) { | |||||
| 68 | throw new XPathE xception( | |||||
| 69 | "getNodeBy Path: Coul d not get the node f or XPATH: " + path, | |||||
| 70 | e2); | |||||
| 71 | } | |||||
| 72 | if ( list.getLe ngth() > 0 ) { | |||||
| 73 | return list.item (0); | |||||
| 74 | } | |||||
| 75 | retu rn null; | |||||
| 76 | } | |||||
| 77 | ||||||
| 78 | /* * | |||||
| 79 | * Returns a matching Node based on the XP ath & Node | |||||
| 80 | * | |||||
| 81 | * @param no de | |||||
| 82 | * @param pa th | |||||
| 83 | * @return N ode - the Node that matched | |||||
| 84 | * @throws D OMExceptio n | |||||
| 85 | * / | |||||
| 86 | pu blic stati c Node get NodeByPath (final Nod e node, fi nal String path) | |||||
| 87 | throws XPathExce ption { | |||||
| 88 | try { | |||||
| 89 | return XPathAPI. selectSing leNode(nod e, path); | |||||
| 90 | } ca tch (final Transform erExceptio n e2) { | |||||
| 91 | throw new XPathE xception( | |||||
| 92 | "getNodeBy Path:Could not get t he node fo r XPATH: " + path, | |||||
| 93 | e2); | |||||
| 94 | } | |||||
| 95 | } | |||||
| 96 | ||||||
| 97 | pu blic stati c NodeList getNodesB yPath(fina l Document doc, fina l String p ath) | |||||
| 98 | throws XPathExce ption { | |||||
| 99 | ||||||
| 100 | Node List list = null; | |||||
| 101 | try { | |||||
| 102 | list = XPathAPI. selectNode List(doc, path); | |||||
| 103 | } ca tch (final Transform erExceptio n e2) { | |||||
| 104 | throw new XPathE xception( | |||||
| 105 | "getNodesB yPath: Cou ld not get the node for XPATH: " + path, | |||||
| 106 | e2); | |||||
| 107 | } | |||||
| 108 | retu rn list; | |||||
| 109 | } | |||||
| 110 | ||||||
| 111 | pu blic stati c NodeList getNodesB yPath(fina l Node nod e, final S tring path ) | |||||
| 112 | throws XPathExce ption { | |||||
| 113 | ||||||
| 114 | Node List list = null; | |||||
| 115 | try { | |||||
| 116 | list = XPathAPI. selectNode List(node, path); | |||||
| 117 | } ca tch (final Transform erExceptio n e2) { | |||||
| 118 | throw new XPathE xception( | |||||
| 119 | "getNodesB yPath:Coul d not get the node f or XPATH: " + path, | |||||
| 120 | e2); | |||||
| 121 | } | |||||
| 122 | retu rn list; | |||||
| 123 | } | |||||
| 124 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.