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@5cee919e
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@35e149b1, com.xpn.xwiki.api.Object@59ad1f19, com.xpn.xwiki.api.Object@74d4d04d, com.xpn.xwiki.api.Object@3fb7ab27, com.xpn.xwiki.api.Object@3345ae1f, com.xpn.xwiki.api.Object@23aa8f85, com.xpn.xwiki.api.Object@12b4770e, com.xpn.xwiki.api.Object@5f441ba, com.xpn.xwiki.api.Object@67071d63]
objsAuthors = doc.getObjects('XWiki.XWikiComments').author
objsAuthor = doc.getObjects('XWiki.XWikiComments')[2].author
println objs[0].author
println objsAuthors
println objsAuthor