Provides a utility class helpful for determining which type of resource the client is requesting. Each resource type (e.g. service doc, collection, entry, edit uri, media resource, etc) is assigned a regex pattern. Given the request URI (path and querystring), this will determine which resource was selected and return an appropriate TargetMatcher. TargetMatcher is essentially just a simplified version of the java.util.regex.Matcher that also specifies the Resource Type.
RequestContext request = ... RegexTargetResolver tr = new RegexTargetResolver(); tr.setPattern("/atom",ResourceType.INTROSPECTION) .setPattern("/atom/([^/#?]+)",ResourceType.COLLECTION) .setPattern("/atom/([^/#?]+)/([^/#?]+)",ResourceType.ENTRY) .setPattern("/atom/([^/#?]+)/([^/#?]+)\\?edit",ResourceType.ENTRY_EDIT) .setPattern("/atom/([^/#?]+)/([^/#?]+)\\?media",ResourceType.MEDIA) .setPattern("/atom/([^/#?]+)/([^/#?]+)\\?edit-media",ResourceType.MEDIA_EDIT); Target target = tr.resolve(request); System.out.println(target.getType()); System.out.println(targer.getParameter("foo"));
|
|