📄 portlethref.java
字号:
}
}
else if (PARAM_STATE.equals(name))
{
if (value == null)
{
this.setRequestedState(null);
}
else
{
final WindowState state = new WindowState(value);
if (!this.portletRequest.isWindowStateAllowed(state))
{
throw new IllegalArgumentException("WindowState '"
+ state
+ "' is not allowed for this request.");
}
this.setRequestedState(state);
}
}
else
{
throw new IllegalArgumentException("'"
+ name
+ "' is not a valid '"
+ PARAM_PREFIX
+ "' prefixed parameter.");
}
}
else
{
this.parameters.put(name, value);
}
return this;
}
/**
* @see org.displaytag.util.Href#addParameterMap(java.util.Map)
*/
public void addParameterMap(Map parametersMap)
{
for (final Iterator paramItr = parametersMap.entrySet().iterator(); paramItr.hasNext();)
{
final Map.Entry entry = (Map.Entry) paramItr.next();
final String name = (String) entry.getKey();
final Object value = entry.getValue();
// Allow multivalued parameters since code elsewhere calls this method to copy
// parameters from the request to the response. Ensures that developer specified
// multivalued parameters are retained correctly.
if (value instanceof String[])
{
this.parameters.put(name, value);
}
else if (value == null || value instanceof String)
{
this.addParameter(name, value);
}
else
{
this.addParameter(name, value.toString());
}
}
}
/**
* @see org.displaytag.util.Href#setParameterMap(java.util.Map)
*/
public void setParameterMap(Map parametersMap)
{
this.parameters.clear();
this.addParameterMap(parametersMap);
}
/**
* Warning, parameters added to the Map directly will not be parsed by the PortletUrl feature support portions of
* this class.
* @see org.displaytag.util.Href#getParameterMap()
*/
public Map getParameterMap()
{
return this.parameters;
}
/**
* @see org.displaytag.util.Href#removeParameter(java.lang.String)
*/
public void removeParameter(String name)
{
this.parameters.remove(name);
}
/**
* @see org.displaytag.util.Href#setAnchor(java.lang.String)
*/
public void setAnchor(String name)
{
this.anchor = name;
}
/**
* @see org.displaytag.util.Href#getAnchor()
*/
public String getAnchor()
{
return this.anchor;
}
/**
* Generates a render or action URL depending on the use of the PortletUrl specific features of this class.
* @see org.displaytag.util.Href#getBaseUrl()
*/
public String getBaseUrl()
{
if (this.isAction())
{
return this.renderResponse.createActionURL().toString();
}
else
{
return this.renderResponse.createRenderURL().toString();
}
}
/**
* @see org.displaytag.util.Href#clone()
*/
public Object clone()
{
PortletHref href;
try
{
href = (PortletHref) super.clone();
}
catch (CloneNotSupportedException cnse)
{
throw new RuntimeException("Parent through a CloneNotSupportedException, this should never happen", cnse);
}
href.isAction = this.isAction;
href.parameters = this.createParameterMap();
href.parameters.putAll(this.parameters);
href.requestedMode = this.requestedMode;
href.requestedState = this.requestedState;
href.requestedSecure = this.requestedSecure;
href.anchor = this.anchor;
return href;
}
/**
* @see org.displaytag.util.Href#equals(java.lang.Object)
*/
public boolean equals(Object object)
{
if (this == object)
{
return true;
}
if (!(object instanceof PortletHref))
{
return false;
}
PortletHref rhs = (PortletHref) object;
return new EqualsBuilder().append(this.isAction, rhs.isAction).append(this.parameters, rhs.parameters).append(
this.requestedMode,
rhs.requestedMode).append(this.requestedState, rhs.requestedState).append(
this.requestedSecure,
rhs.requestedSecure).append(this.anchor, rhs.anchor).isEquals();
}
/**
* @see org.displaytag.util.Href#hashCode()
*/
public int hashCode()
{
return new HashCodeBuilder(1313733113, -431360889)
.append(this.isAction)
.append(this.parameters)
.append(this.requestedMode)
.append(this.requestedState)
.append(this.requestedSecure)
.append(this.anchor)
.toHashCode();
}
/**
* @see org.displaytag.util.Href#toString()
*/
public String toString()
{
final PortletURL url;
if (this.isAction())
{
url = this.renderResponse.createActionURL();
}
else
{
url = this.renderResponse.createRenderURL();
}
if (this.isRequestedSecure())
{
try
{
url.setSecure(true);
}
catch (PortletSecurityException pse)
{
throw new RuntimeException("Creating secure PortletURL Failed.", pse);
}
}
if (this.getRequestedMode() != null)
{
try
{
url.setPortletMode(this.getRequestedMode());
}
catch (PortletModeException pme)
{
final IllegalStateException ise = new IllegalStateException("Requested PortletMode='"
+ this.getRequestedMode()
+ "' could not be set.");
ise.initCause(pme);
throw ise;
}
}
if (this.getRequestedState() != null)
{
try
{
url.setWindowState(this.getRequestedState());
}
catch (WindowStateException wse)
{
final IllegalStateException ise = new IllegalStateException("Requested WindowState='"
+ this.getRequestedState()
+ "' could not be set.");
ise.initCause(wse);
throw ise;
}
}
for (final Iterator paramItr = this.parameters.entrySet().iterator(); paramItr.hasNext();)
{
final Map.Entry entry = (Map.Entry) paramItr.next();
final String name = (String) entry.getKey();
final Object value = entry.getValue();
if (value instanceof String)
{
url.setParameter(name, (String) value);
}
else if (value instanceof String[])
{
url.setParameter(name, (String[]) value);
}
}
if (this.getAnchor() == null)
{
return url.toString();
}
else
{
return url.toString() + "#" + this.getAnchor();
}
}
private Map createParameterMap()
{
return PredicatedMap.decorate(new HashMap(), PRED_TYPE_OF_STRING, PRED_OR_STR_STRARR);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -