PMD Xpath,如何比较2 @Image?

时间:2016-06-29 13:40:25

标签: xpath pmd

将一个路径的@Image与静态字符串进行比较是非常容易的,但如何比较2个路径的@ Image?

应触发规则的代码:

public class Foo implements {
      public String checkDBConnexion() {
        try {
            int result = jdbcTemplate.queryForObject("SELECT 1 FROM dual ", Integer.class);

        } catch (DataAccessException e) {
            // This is Ok : throw new MyException(test, e);
            // this is not : hrow new MyException(test);
            // This is also not ok if there are no thrown;
            return "KO : " + e.getMessage();
        }
    }
}

Catch块的param名称的Xpath:

//CatchStatement[//FormalParameter//VariableDeclaratorId]

抛出方法的变量名称的Xpath:

//ThrowStatement//Arguments//Expression//Name

很容易将两者都与'e'进行比较:

//CatchStatement[//FormalParameter//VariableDeclaratorId[@Image = 'e']]

//CatchStatement[//ThrowStatement//Arguments//Expression//Name[@Image = 'e']]

如何将它们与彼此进行比较?

此外,如果您有详细说明PMD XPath synthax示例的链接。 基本的PMD页面有......基本的;)

1 个答案:

答案 0 :(得分:0)

回答自己:

{
    "airportList": [
        {
            "originalAirportId": "123",
            "airportName": "asdf",
            "cityName": "qwer",
            "cityId": "qwer",
            "provinceName": "qwer",
            "provinceId": "qwer",
            "countryId": "qwer",
            "countryName": "qwer"
        },
        {
            "originalAirportId": "123",
            "airportName": "asdf",
            "cityName": "qwer",
            "cityId": "qwer",
            "provinceName": "qwer",
            "provinceId": "qwer",
            "countryId": "qwer",
            "countryName": "qwer"
        }
    ]
}