Groovy
Retrieve the first object (index [0]) among all objects attached to this page and of a certain class
obj = doc.getObject('XWiki.XWikiComments')
com.xpn.xwiki.api.Object@75dabeda
Retrieve all objects attached to this page and of a certain class and one of their properties
objs = doc.getObjects('XWiki.XWikiComments')
[com.xpn.xwiki.api.Object@7543eef2, com.xpn.xwiki.api.Object@3efc8e03, com.xpn.xwiki.api.Object@36cf8743, com.xpn.xwiki.api.Object@72b95bd1, com.xpn.xwiki.api.Object@673b312e, com.xpn.xwiki.api.Object@5f19f7f4, com.xpn.xwiki.api.Object@21e5e4f3, com.xpn.xwiki.api.Object@7c1a1ee7, com.xpn.xwiki.api.Object@16e30f58]
objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor