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@27f81895
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@45e29ccd, com.xpn.xwiki.api.Object@20a47a93, com.xpn.xwiki.api.Object@e6b59a3, com.xpn.xwiki.api.Object@29c9e3ba, com.xpn.xwiki.api.Object@585ddc5, com.xpn.xwiki.api.Object@17a2b358, com.xpn.xwiki.api.Object@3aac6287, com.xpn.xwiki.api.Object@b78ab29, com.xpn.xwiki.api.Object@1f2d16a1]
objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor