3434import org .w3c .dom .Document ;
3535import org .w3c .dom .Element ;
3636import org .w3c .dom .Node ;
37+
3738/*
3839 * Base class for UA model elements.
3940 */
@@ -59,6 +60,7 @@ public Filter(String name, String value, boolean isNegated) {
5960 this .value = value ;
6061 this .isNegated = isNegated ;
6162 }
63+
6264 String name ;
6365 String value ;
6466 boolean isNegated ;
@@ -82,7 +84,7 @@ public UAElement(String name, IUAElement src) {
8284 }
8385
8486 private void copyFilters (IUAElement src ) {
85- UAElement sourceElement = (UAElement )src ;
87+ UAElement sourceElement = (UAElement ) src ;
8688 String filter = sourceElement .getAttribute (ATTRIBUTE_FILTER );
8789 if (filter != null && filter .length () > 0 ) {
8890 this .setAttribute (ATTRIBUTE_FILTER , filter );
@@ -101,15 +103,14 @@ private Filter[] getFilterElements() {
101103 if (node .getNodeType () == Node .ELEMENT_NODE ) {
102104 String elementKind = node .getNodeName ();
103105 if (ExpressionTagNames .ENABLEMENT .equals (elementKind )) {
104- Element enablement = (Element )node ;
106+ Element enablement = (Element ) node ;
105107 try {
106108 enablementExpression = ExpressionConverter .getDefault ().perform (enablement );
107- }
108- catch (CoreException e ) {
109+ } catch (CoreException e ) {
109110
110111 }
111112 } else if (ELEMENT_FILTER .equals (elementKind )) {
112- Element filter = (Element )node ;
113+ Element filter = (Element ) node ;
113114 String filterName = filter .getAttribute (ATTRIBUTE_NAME );
114115 String value = filter .getAttribute (ATTRIBUTE_VALUE );
115116 if (filterName .length () > 0 && value .length () > 0 ) {
@@ -146,14 +147,15 @@ public void appendChildren(IUAElement[] children) {
146147 if (this .children == null && children .length > 0 ) {
147148 this .children = new ArrayList <>(4 );
148149 }
149- for (int i = 0 ; i < children . length ; i ++ ) {
150- appendChild (children [ i ] instanceof UAElement ? (UAElement )children [ i ] : UAElementFactory .newElement (children [ i ] ));
150+ for (IUAElement child : children ) {
151+ appendChild (child instanceof UAElement ? (UAElement ) child : UAElementFactory .newElement (child ));
151152 }
152153 }
153154
154155 /*
155- * This method is synchronized to fix Bug 232169. When modifying this source be careful not
156- * to introduce any logic which could possibly cause this thread to block.
156+ * This method is synchronized to fix Bug 232169. When modifying this source
157+ * be careful not to introduce any logic which could possibly cause this
158+ * thread to block.
157159 */
158160 synchronized public String getAttribute (String name ) {
159161 String value = element .getAttribute (name );
@@ -164,9 +166,10 @@ synchronized public String getAttribute(String name) {
164166 }
165167
166168 /*
167- * This method is synchronized to fix Bug 230037. A review of the code indicated that there was no
168- * path which could get blocked and cause deadlock. When modifying this source be careful not
169- * to introduce any logic which could possibly cause this thread to block.
169+ * This method is synchronized to fix Bug 230037. A review of the code
170+ * indicated that there was no path which could get blocked and cause
171+ * deadlock. When modifying this source be careful not to introduce any
172+ * logic which could possibly cause this thread to block.
170173 */
171174 @ Override
172175 public synchronized IUAElement [] getChildren () {
@@ -176,7 +179,7 @@ public synchronized IUAElement[] getChildren() {
176179 Node node = element .getFirstChild ();
177180 while (node != null ) {
178181 if (node .getNodeType () == Node .ELEMENT_NODE ) {
179- UAElement uaElement = UAElementFactory .newElement ((Element )node );
182+ UAElement uaElement = UAElementFactory .newElement ((Element ) node );
180183 if (uaElement != null ) {
181184 uaElement .parent = this ;
182185 children .add (uaElement );
@@ -196,8 +199,7 @@ public <T> T[] getChildren(Class<T> clazz) {
196199 IUAElement [] children = getChildren ();
197200 if (children .length > 0 ) {
198201 List <Object > list = new ArrayList <>();
199- for (int i =0 ;i <children .length ;++i ) {
200- IUAElement child = children [i ];
202+ for (IUAElement child : children ) {
201203 if (clazz .isAssignableFrom (child .getClass ())) {
202204 list .add (child );
203205 }
@@ -256,8 +258,8 @@ public boolean isEnabled(IEvaluationContext context) {
256258 return isEnabledByFilterAttribute (filter );
257259 }
258260 Filter [] filterElements = getFilterElements ();
259- for (int i = 0 ; i < filterElements . length ; i ++ ) {
260- if (!isFilterEnabled (filterElements [ i ] )) {
261+ for (Filter filterElement : filterElements ) {
262+ if (!isFilterEnabled (filterElement )) {
261263 return false ;
262264 }
263265 }
@@ -291,12 +293,12 @@ public void setAttribute(String name, String value) {
291293 private void importElement (UAElement uaElementToImport ) {
292294 Element elementToImport = uaElementToImport .element ;
293295 Document ownerDocument = element .getOwnerDocument ();
294- if (!ownerDocument .equals (elementToImport .getOwnerDocument ()) ) {
295- elementToImport = (Element )ownerDocument .importNode (elementToImport , true );
296+ if (!ownerDocument .equals (elementToImport .getOwnerDocument ())) {
297+ elementToImport = (Element ) ownerDocument .importNode (elementToImport , true );
296298 uaElementToImport .children = null ;
297- } else {
299+ } else {
298300 if (elementToImport .getParentNode () != null ) {
299- elementToImport = (Element )ownerDocument .importNode (elementToImport , true );
301+ elementToImport = (Element ) ownerDocument .importNode (elementToImport , true );
300302 uaElementToImport .children = null ;
301303 } else {
302304 }
0 commit comments