Fix minor bug in FRM proactive flow code path
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-data-impl / src / test / java / org / opendaylight / controller / yang / data / impl / IgnoreWhiteCharsDiffListener.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.yang.data.impl;
9
10 import org.custommonkey.xmlunit.Difference;
11 import org.custommonkey.xmlunit.DifferenceConstants;
12 import org.custommonkey.xmlunit.DifferenceListener;
13
14 /**
15  * Implementatin of {@link DifferenceListener} ignoring white characters around text elements
16  * @author mirehak
17  *
18  */
19 public class IgnoreWhiteCharsDiffListener implements DifferenceListener {
20     
21     @Override
22     public void skippedComparison(org.w3c.dom.Node control,
23             org.w3c.dom.Node test) {
24         // do nothing                
25     }
26
27     @Override
28     public int differenceFound(Difference diff) {
29         
30         if (diff.getId() == DifferenceConstants.TEXT_VALUE.getId()) {
31             
32             String control = diff.getControlNodeDetail().getValue();
33             if (control != null) {
34                 control = control.trim();
35                 if (diff.getTestNodeDetail().getValue() != null
36                     && control.equals(diff.getTestNodeDetail().getValue().trim())) {
37                     return
38                         DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_SIMILAR;
39                 }
40             }
41         }
42         return RETURN_ACCEPT_DIFFERENCE;
43     }
44 }