public class EntityView extends Object implements Cloneable, Serializable
VIEW_LIST) | Modifier and Type | Class and Description |
|---|---|
static class |
EntityView.Method
Represents HTTP methods (GET, POST, etc.)
|
| Modifier and Type | Field and Description |
|---|---|
static String |
DIRECT |
static String |
DIRECT_PREFIX |
static String |
ID |
static char |
PERIOD |
static String |
PREFIX |
static char |
SEPARATOR |
static long |
serialVersionUID |
static String |
VIEW_DELETE
Defines the view for the "delete" (destroy) operation,
remove an entity or access a form for removing an entity,
represents a
EntityView.Method.DELETE to a specific entity |
static String |
VIEW_EDIT
Defines the view for the "edit" (update) operation,
update an entity or access a form for updating an entity,
represents a
EntityView.Method.PUT (or POST) to a specific entity,
also indicates an action related to writing a specific entity |
static String |
VIEW_LIST
Defines the view for the "list" (index) or collection operation,
access a list/collection of all entities of a type (possibly filtered by search params),
represents a
EntityView.Method.GET to the entity space/collection,
also indicates an action related to reading a collection of entities |
static String |
VIEW_NEW
Defines the view for the "new" (create) operation,
create a new record or access a form for creating a new record,
represents a
EntityView.Method.POST (or PUT) to the entity space/collection,
also indicates an action related to writing a collection of entities |
static String |
VIEW_SHOW
Defines the view for the "show" (read) operation,
access data or a view of an entity,
represents a
EntityView.Method.GET to a specific entity,
also indicates an action related to reading a specific entity |
| Constructor and Description |
|---|
EntityView() |
EntityView(EntityReference ref,
String viewKey,
String extension)
Construct an entity view based on a reference, view, and format extension
|
EntityView(String entityURL)
Constructor which takes an entity URL path,
(should not include anything but the path, for example:
http://server/webapp/myprefix/edit/3/stuff.xml?
|
EntityView(String viewKey,
Map<String,String> segments,
String extension)
Turn this viewKey and map of segments (key -> value pairs) into an entity view object
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
checkEntityURL(String entityURL)
Check if an entityUrl is basically valid
|
Object |
clone() |
EntityView |
copy() |
static EntityView |
copy(EntityView ev)
Makes a copy of an EntityView which can be changed independently
|
List<TemplateParseUtil.PreProcessedTemplate> |
getAnazlyzedTemplates() |
EntityReference |
getEntityReference() |
String |
getEntityURL() |
String |
getEntityURL(String viewKey,
String extension)
Get an entityUrl by merging a specific template with the data in this EB object
|
String |
getExtension()
The extension for this view which defines the type of data that will be returned for this view,
examples: html, xml, json
NOTE: you should assume html return format when this is null
|
String |
getFormat() |
String |
getMethod() |
String |
getOriginalEntityUrl()
Special use only,
normally you should use
toString() or getEntityURL(String, String) |
String |
getParseTemplate(String templateKey) |
List<TemplateParseUtil.Template> |
getParseTemplates() |
String |
getPathSegment(int position)
Get a segment value by position from the encoded URL for this view
Position 0 is always the prefix Example: /user/aaronz/promote/stuff.xml position 0: 'user' position 1: 'aaronz' position 2: 'promote' position 3: 'stuff' position 4: null |
String |
getPathSegment(String parseVariable)
Gets the parsed values of path segment variables
|
String[] |
getPathSegments()
Get all the path segments for the encoded URL for this view
Example: /user/aaronz/promote/stuff.xml segments = {"user","aaronz","promote","stuff"} |
String |
getViewKey() |
void |
loadParseTemplates(List<TemplateParseUtil.Template> templates)
Override this method if creating a custom
EntityView object |
void |
parseEntityURL(String entityURL)
Used to build this object after it has already been created (typically so custom templates can be inserted)
|
protected void |
populateInternals(String viewKey,
Map<String,String> segments,
String extension)
Populates the internal values based on the view key, map of segments, and extension
|
void |
preloadParseTemplates(List<TemplateParseUtil.PreProcessedTemplate> preprocessedTemplates)
Special efficiency method to reduce reloading of custom templates,
do not use this unless you wrote it or REALLY know what you are doing
|
EntityView |
setEntityReference(EntityReference ref)
Allows for easy chained construction of EntityViews by setting an EntityReference,
does not set the viewkey or extension unless they are unset, maintains current extension
|
void |
setExtension(String extension) |
void |
setMethod(EntityView.Method method) |
protected void |
setOriginalEntityURL(String entityUrl) |
void |
setViewKey(String viewKey) |
String |
toString() |
static EntityView.Method |
translateViewKeyToMethod(String viewKey)
Translate a viewkey into an http method
|
public static final long serialVersionUID
public static final char SEPARATOR
public static final char PERIOD
public static final String PREFIX
public static final String ID
public static final String DIRECT
public static final String DIRECT_PREFIX
public static final String VIEW_LIST
EntityView.Method.GET to the entity space/collection,
also indicates an action related to reading a collection of entitiespublic static final String VIEW_SHOW
EntityView.Method.GET to a specific entity,
also indicates an action related to reading a specific entitypublic static final String VIEW_NEW
EntityView.Method.POST (or PUT) to the entity space/collection,
also indicates an action related to writing a collection of entitiespublic static final String VIEW_EDIT
EntityView.Method.PUT (or POST) to a specific entity,
also indicates an action related to writing a specific entitypublic static final String VIEW_DELETE
EntityView.Method.DELETE to a specific entitypublic EntityView()
public EntityView(String entityURL)
entityURL - a URL path which goes to a specific entity view,
consists of path segments defined by path templates and includes an option extensionpublic EntityView(String viewKey, Map<String,String> segments, String extension)
viewKey - a key which uniquely identifies a view,
from the set of template keys #PARSE_TEMPLATE_KEYSsegments - a map of replaceable keys (e.g. PREFIX) to values,
the replaceable variable names -> values (e.g. "prefix" -> "myPrefix"),
must contain at LEAST a key for the prefix (use constant PREFIX) which is not set to nullextension - (optional) format extension related to this view (e.g. xml), do not include the period,
leave this null for no extensionpublic EntityView(EntityReference ref, String viewKey, String extension)
ref - an EntityReference object which represents a unique entity referenceviewKey - (optional) a key which uniquely identifies a view,
from the set of template keys #PARSE_TEMPLATE_KEYSextension - (optional) format extension related to this view (e.g. xml), do not include the period,
leave this null for no extensionpublic String getOriginalEntityUrl()
toString() or getEntityURL(String, String)protected void setOriginalEntityURL(String entityUrl)
public String getExtension()
public void setExtension(String extension)
public String getFormat()
Formats) that is being used for this view,
will return Formats.HTML if none setpublic String getMethod()
EntityView.Method) being used for this view,
defaults to GET if none was set explicitlypublic void setMethod(EntityView.Method method)
public String getViewKey()
public void setViewKey(String viewKey)
public EntityReference getEntityReference()
public EntityView setEntityReference(EntityReference ref)
public List<TemplateParseUtil.Template> getParseTemplates()
public List<TemplateParseUtil.PreProcessedTemplate> getAnazlyzedTemplates()
protected void populateInternals(String viewKey, Map<String,String> segments, String extension)
public void parseEntityURL(String entityURL)
entityURL - a URL path which goes to a specific entity view,
consists of path segments defined by path templates and includes an option extensionpublic void loadParseTemplates(List<TemplateParseUtil.Template> templates)
EntityView objecttemplates - a list of template constants -> parse templates,
the array which defines the set of template keys is #PARSE_TEMPLATE_KEYSSEPARATOR are special characters and must be used as indicated only
2) Must begin with a SEPARATOR, must not end with a SEPARATOR
3) must begin with "/{prefix}" (use the SEPARATOR and PREFIX constants)
3) each {var} can only be used once in a template
4) {var} can never touch each other (i.e /{var1}{var2}/{id} is invalid)
5) each {var} can only have the chars from TemplateParseUtil.VALID_VAR_CHARS
6) parse templates can only have the chars from TemplateParseUtil.VALID_TEMPLATE_CHARS
7) Empty braces ({}) cannot appear in the templatepublic void preloadParseTemplates(List<TemplateParseUtil.PreProcessedTemplate> preprocessedTemplates)
public String toString()
toString in class ObjectTemplateParseUtil.TEMPLATE_SHOW or
the TemplateParseUtil.TEMPLATE_LIST one if there is no id,
example: /prefix if there is no id or /prefix/id if there is an idIllegalArgumentException - if there is not enough information to generate a URLpublic String getEntityURL()
TemplateParseUtil.TEMPLATE_SHOW or
the TemplateParseUtil.TEMPLATE_LIST one if there is no id,
example: /prefix if there is no id or /prefix/id if there is an idIllegalArgumentException - if there is not enough information to generate a URLpublic String getEntityURL(String viewKey, String extension)
viewKey - a key which uniquely identifies a view,
from the set of template keys #PARSE_TEMPLATE_KEYSextension - an optional extension related to this view (e.g. xml),
do not include the period, leave this null for no extensionIllegalArgumentException - if the viewKey is invalid OR there is not enough information
in the path segments to generate the requested URLpublic String getPathSegment(String parseVariable)
parseVariable - a path segment variable (the thing that gets replaced in the parse template)public String getPathSegment(int position)
position - the position number in the path segments, 0 is always the prefixpublic String[] getPathSegments()
public String getParseTemplate(String templateKey)
templateKey - a key from the set of template keys #PARSE_TEMPLATE_KEYS,
should match with the viewKeypublic Object clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic EntityView copy()
copy(EntityView)protected static void checkEntityURL(String entityURL)
entityURL - IllegalArgumentException - if the entityUrl is not even basically validpublic static EntityView copy(EntityView ev)
ev - any EntityViewIllegalArgumentException - if the input is null OR not completely constructedpublic static EntityView.Method translateViewKeyToMethod(String viewKey)
viewKey - Copyright © 2003–2022 Sakai Project. All rights reserved.