To retrieve an object, simply use Core.retrieveXPathQuery(). Check the javadoc for its variations. This can be found in your Mendix installation folder (for example: C:\Program Files (x86)\Mendix\2.5.5.1\runtime\javadoc)
If you want to batch delete items, have a look at Core.removeBatch() too.
You can download the communitycommons package and take a look at the java source of the communitycommons.Batches.deleteAll method.