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@1c3f36b4
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@1995c9, com.xpn.xwiki.api.Object@fb8bf2c, com.xpn.xwiki.api.Object@2a0ee9c4, com.xpn.xwiki.api.Object@3915586e, com.xpn.xwiki.api.Object@2860bb09, com.xpn.xwiki.api.Object@66976094, com.xpn.xwiki.api.Object@5c45c92a, com.xpn.xwiki.api.Object@699a13b9, com.xpn.xwiki.api.Object@2850cd9]
objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor