how to get array values of a node property in jcr

て烟熏妆下的殇ゞ 提交于 2019-12-06 07:20:15

问题


Need help in getting the string[] values of node property??

for example I have a node image which has property "references" of type String[] . I need to get the first value of array.

Thanks


回答1:


From the Node, you can get the references property. And then call getValues to the reference values. From there, just take the first. Something like

public String getFirstReference(Node node) throws RepositoryException {
  Property references = node.getProperty("references");     
  Value[] values = references.getValues();
  return values[0].getString();     
}



回答2:


Property nProp = node.getProperty("references");
Value[] values = propertyNode.getValues();
for (Value v : values) {
    System.out.println("Property Name = "+nProp.getName()+" ; Property Value= "+v.getString());
}


来源:https://stackoverflow.com/questions/14460843/how-to-get-array-values-of-a-node-property-in-jcr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!