Produced by Araxis Merge on 8/1/2019 1:42:43 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 | JLV_2_8_0_0_0_July_2019.zip\JLV_2_8_0_0_0_July_2019\jMeadows\src\main\java\gov\va\med\jmeadows\dao\util | DataQuery.java | Mon Jul 8 19:18:52 2019 UTC |
2 | JLV_2_8_0_0_0_July_2019.zip\JLV_2_8_0_0_0_July_2019\jMeadows\src\main\java\gov\va\med\jmeadows\dao\util | DataQuery.java | Wed Jul 31 18:41:36 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 278 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
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 | /** | |
2 | * Janus 4 .0 (c) | |
3 | * Copyrig ht (c) 201 1 Hawaii R esource Gr oup LLC. A ll Rights Reserved. | |
4 | * Develop ed for the Pacific T elehealth & Technolo gy Hui and the Pacif ic Joint I nformation Technolog y Center | |
5 | * Contrib utors: | |
6 | * Hon orable Sen ator Danie l K. Inouy e | |
7 | * VA Pacific Is lands Heal th Care Sy stem | |
8 | * Tri pler Army Medical Ce nter | |
9 | */ | |
10 | ||
11 | ||
12 | package go v.va.med.j meadows.da o.util; | |
13 | ||
14 | import jav a.io.Seria lizable; | |
15 | import jav a.lang.ref lect.Invoc ationTarge tException ; | |
16 | import jav a.lang.ref lect.Metho d; | |
17 | ||
18 | /** | |
19 | * DataQue ry uses re flection t o execute a method o n a given class obje ct. | |
20 | * @author DNS | |
21 | */ | |
22 | public cla ss DataQue ry impleme nts Serial izable { | |
23 | /** | |
24 | * Cla ss UID. | |
25 | */ | |
26 | privat e static f inal long serialVers ionUID = - 4672649255 420220521L ; | |
27 | ||
28 | privat e Object c lassObj; | |
29 | privat e String m ethodName; | |
30 | privat e Object[] args; | |
31 | ||
32 | /** | |
33 | * Dat aQuery con structor | |
34 | * @pa ram classO bj Object to invoke | |
35 | * @pa ram method Name Metho d to invok e | |
36 | * @pa ram args A rguments t o pass met hod. | |
37 | */ | |
38 | public DataQuery (Object cl assObj, St ring metho dName, Obj ect[] args ) { | |
39 | th is.classOb j = classO bj; | |
40 | th is.methodN ame = meth odName; | |
41 | if (args == null) { | |
42 | this.arg s = null; | |
43 | } else { | |
44 | this.arg s = args.c lone(); | |
45 | } | |
46 | } | |
47 | ||
48 | public String to String() { | |
49 | St ringBuilde r sbuild = new Strin gBuilder() ; | |
50 | sb uild.appen d("{"); | |
51 | sb uild.appen d("clasObj : "); | |
52 | if (classObj != null) { | |
53 | sbuild.a ppend(clas sObj.getCl ass().getN ame()); | |
54 | } | |
55 | sb uild.appen d(", metho dName: "); | |
56 | sb uild.appen d(methodNa me); | |
57 | sb uild.appen d(", args length: ") ; | |
58 | if (args != null) { | |
59 | sbuild.a ppend(args .length); | |
60 | } | |
61 | sb uild.appen d("}"); | |
62 | ||
63 | re turn sbuil d.toString (); | |
64 | } | |
65 | ||
66 | /** | |
67 | * Use s reflecti on invoke a method o n the clas sObj membe r variable | |
68 | * wit h given ar guments. | |
69 | * @re turn Resul t of invok ed method. | |
70 | */ | |
71 | public Object ex ecute() { | |
72 | Ob ject rtc; | |
73 | if (classObj == null) { | |
74 | rtc = nu ll; | |
75 | } else { | |
76 | Object r esult; | |
77 | ||
78 | try { | |
79 | Clas s cls = cl assObj.get Class(); | |
80 | Clas s[] paramT ypes = new Class[arg s.length]; | |
81 | for (int i = 0 ; i < args .length; i ++) { | |
82 | paramTypes [i] = args [i].getCla ss(); | |
83 | } | |
84 | ||
85 | Meth od method = getMetho d(cls, met hodName, p aramTypes) ; | |
86 | resu lt = metho d.invoke(c lassObj, a rgs); | |
87 | } catch (NoSuchMet hodExcepti on e) { | |
88 | resu lt = e; | |
89 | } catch (Invocatio nTargetExc eption e) { | |
90 | resu lt = e; | |
91 | } catch (IllegalAc cessExcept ion e) { | |
92 | resu lt = e; | |
93 | } | |
94 | ||
95 | rtc = re sult; | |
96 | } | |
97 | re turn rtc; | |
98 | } | |
99 | ||
100 | /** | |
101 | * Sea rches for and return s method w ithin give n class th at matches | |
102 | * nam e and para meter type list. Thi s method i s used in lieu of | |
103 | * Cla ss.getMeth od() becau se it matc hes parame ter types based on | |
104 | * ass ignability instead o f type nam e. | |
105 | * (i. e. can pas s paramete rs that ar e a subcla ss of thos e | |
106 | * def ined in me thod signa ture). | |
107 | * | |
108 | * @pa ram theCla ss Class t o get meth od from. | |
109 | * @pa ram method Name Name of method to get. | |
110 | * @pa ram paramT ypes List of paramet er types. | |
111 | * @re turn Metho d if found . | |
112 | * @th rows NoSuc hMethodExc eption If no method is found. | |
113 | */ | |
114 | privat e Method g etMethod(C lass theCl ass, Strin g methodNa me, Class[ ] paramTyp es) throws NoSuchMet hodExcepti on { | |
115 | Me thod[] met hods = the Class.getM ethods(); | |
116 | ||
117 | fo r (Method method : m ethods) { | |
118 | if (meth od.getName ().equals( methodName )) { | |
119 | Clas s[] method ParamTypes = method. getParamet erTypes(); | |
120 | if ( methodPara mTypes.len gth != par amTypes.le ngth) { | |
121 | continue; | |
122 | } | |
123 | ||
124 | bool ean isPara mMatch = t rue; | |
125 | for (int i = 0 ; i < para mTypes.len gth; i++) { | |
126 | Class para m = method ParamTypes [i]; | |
127 | if (!param .isAssigna bleFrom(pa ramTypes[i ])) { | |
128 | isPara mMatch = f alse; | |
129 | } | |
130 | } | |
131 | ||
132 | if ( isParamMat ch) { | |
133 | return met hod; | |
134 | } | |
135 | } | |
136 | } | |
137 | ||
138 | th row new No SuchMethod Exception( ); | |
139 | } | |
140 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.