노드를 통해 반복하고 모든 속성을 가져 오는 작은 코드 조각이 있습니다. 속성 값을 잡기 위해 하나의 변수를 설정하면 (이 함수를 둘러싼 이상한 []을 제외하고)이 함수를 사용할 수 있습니다. 하지만 중복 코드가 필요 없어 루프 내에서 여러 속성을 설정하려고합니다. 모든 반환 값이 단일 값이며 모든 노드 주위를 반복하지 않습니다.Groovy - 컬렉션은 하나의 값만 반환합니다.
어떤 도움을
String selectNodeLabel = null
selectNodeLabel = JcrUtils.getChildNodes("links").collect{
it.getProperty("label").getString()
}
SINGLE VALUE에게
String selectNodeLabel = null
String selectNodeMeta = null
String selectNodeFooter= null
String topicNode = null
topicNode = JcrUtils.getChildNodes("links").collect{
selectNodeLabel = it.getProperty("label").getString()
selectNodeMeta = it.getProperty("meta").getString()
selectNodeFooter = it.getProperty("footer").getString()
}
감사 WORKING!
[컬렉션 API]에서 보는 좋은 생각이 결코 마지막 줄은이 경우를 들어
이topicNode
은 (it.getProperty("footer").getString()
의 목록이 포함됩니다 (HTTP : //groovy.codehaus .org/groovy-jdk/java/util/Collection.html) 및 [유용한 정보] (http://groovy.codehaus.org/Collections) – dmahapatro아래쪽 투표에 대한 설명을 제공 할 수 있습니까? 기꺼이 고칠 수 있습니다. –