Search code examples
jcraem

how to get array values of a node property in jcr


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


Solution

  • 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();     
    }