這是depthFirst()
的快捷方式。請參閱API文檔GPathResult#getProperty(String):
返回此GPathResult的指定屬性。
。實現如下快捷鍵:
'..' for parent()
'*' for children()
'**' for depthFirst()
'@' for attribute access
有關的getProperty是怎麼做的,這裏是從GPathResult代碼:
public Object getProperty(final String property) {
if ("..".equals(property)) {
return parent();
} else if ("*".equals(property)) {
return children();
} else if ("**".equals(property)) {
return depthFirst();
} else if (property.startsWith("@")) {
if (property.indexOf(":") != -1) {
final int i = property.indexOf(":");
return new Attributes(this, "@" + property.substring(i + 1), property.substring(1, i), this.namespaceTagHints);
} else {
return new Attributes(this, property, this.namespaceTagHints);
}
} else {
if (property.indexOf(":") != -1) {
final int i = property.indexOf(":");
return new NodeChildren(this, property.substring(i + 1), property.substring(0, i), this.namespaceTagHints);
} else {
return new NodeChildren(this, property, this.namespaceTagHints);
}
}
}
我一直期待使用的是看某種元編程兩輪牛車的missingProperty或某物,但這不是必需的。對response.'**'
的調用被視爲訪問一個屬性,並以「**」作爲參數調用getProperty。
有沒有兩輪牛車,這只是一個財產是不是? –
@tim_yates:是的,它只是一個屬性,不得不審查屬性如何工作。 –