| Method from org.displaytag.portlet.PortletHref Detail: |
public Href addParameter(String name,
int value) {
return this.addParameter(name, Integer.toString(value));
}
|
public Href addParameter(String name,
Object objValue) {
String value = ObjectUtils.toString(objValue, null);
if (name != null && name.startsWith(PARAM_PREFIX))
{
if (PARAM_TYPE.equals(name))
{
if (TYPE_RENDER.equals(value))
{
this.setAction(false);
}
else if (TYPE_ACTION.equals(value))
{
this.setAction(true);
}
else
{
throw new IllegalArgumentException("Value of parameter '"
+ name
+ "' must be equal to '"
+ TYPE_RENDER
+ "' or '"
+ TYPE_ACTION
+ "'. '"
+ value
+ "' is not allowed.");
}
}
else if (PARAM_SECURE.equals(name))
{
if (new Boolean(value).booleanValue())
{
this.setRequestedSecure(true);
}
else
{
this.setRequestedSecure(false);
}
}
else if (PARAM_MODE.equals(name))
{
if (value == null)
{
this.setRequestedMode(null);
}
else
{
final PortletMode mode = new PortletMode(value);
if (!this.portletRequest.isPortletModeAllowed(mode))
{
throw new IllegalArgumentException("PortletMode '"
+ mode
+ "' is not allowed for this request.");
}
this.setRequestedMode(mode);
}
}
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;
}
|
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());
}
}
}
|
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;
}
|
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();
}
|
public String getAnchor() {
return this.anchor;
}
|
public String getBaseUrl() {
if (this.isAction())
{
return this.renderResponse.createActionURL().toString();
}
else
{
return this.renderResponse.createRenderURL().toString();
}
}
Generates a render or action URL depending on the use of the PortletUrl specific features of this class. |
public Map getParameterMap() {
return this.parameters;
}
Warning, parameters added to the Map directly will not be parsed by the PortletUrl feature support portions of
this class. |
public PortletMode getRequestedMode() {
return this.requestedMode;
}
|
public WindowState getRequestedState() {
return this.requestedState;
}
|
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();
}
|
public boolean isAction() {
return this.isAction;
}
|
public boolean isRequestedSecure() {
return this.requestedSecure;
}
|
public void removeParameter(String name) {
this.parameters.remove(name);
}
|
public void setAction(boolean isAction) {
this.isAction = isAction;
}
|
public void setAnchor(String name) {
this.anchor = name;
}
|
public void setFullUrl(String baseUrl) {
// do nothing
}
|
public void setParameterMap(Map parametersMap) {
this.parameters.clear();
this.addParameterMap(parametersMap);
}
|
public void setRequestedMode(PortletMode requestedMode) {
this.requestedMode = requestedMode;
}
|
public void setRequestedSecure(boolean requestedSecure) {
this.requestedSecure = requestedSecure;
}
|
public void setRequestedState(WindowState requestedState) {
this.requestedState = requestedState;
}
|
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();
}
}
|