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@3cf22df5
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@1a5bc31d, com.xpn.xwiki.api.Object@7e66b26f, com.xpn.xwiki.api.Object@84cd63e, com.xpn.xwiki.api.Object@6c8584b3, com.xpn.xwiki.api.Object@31cb3b6e, com.xpn.xwiki.api.Object@15aacc4c, com.xpn.xwiki.api.Object@4a9cb1, com.xpn.xwiki.api.Object@2275289d, com.xpn.xwiki.api.Object@39bd6d17]
objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor