package org.apache.struts.config;

import java.io.Serializable;

public class ForwardConfig implements Serializable {
  public ForwardConfig() {}
  
  public ForwardConfig(String name, String path, boolean redirect) {
    setName(name);
    setPath(path);
    setRedirect(redirect);
  }
  
  public ForwardConfig(String name, String path, boolean redirect, boolean contextRelative) {
    setName(name);
    setPath(path);
    setRedirect(redirect);
    setContextRelative(contextRelative);
  }
  
  protected boolean configured = false;
  
  protected boolean contextRelative = false;
  
  public boolean getContextRelative() {
    return this.contextRelative;
  }
  
  public void setContextRelative(boolean contextRelative) {
    if (this.configured)
      throw new IllegalStateException("Configuration is frozen"); 
    this.contextRelative = contextRelative;
  }
  
  protected String name = null;
  
  public String getName() {
    return this.name;
  }
  
  public void setName(String name) {
    if (this.configured)
      throw new IllegalStateException("Configuration is frozen"); 
    this.name = name;
  }
  
  protected String path = null;
  
  public String getPath() {
    return this.path;
  }
  
  public void setPath(String path) {
    if (this.configured)
      throw new IllegalStateException("Configuration is frozen"); 
    this.path = path;
  }
  
  protected boolean redirect = false;
  
  public boolean getRedirect() {
    return this.redirect;
  }
  
  public void setRedirect(boolean redirect) {
    if (this.configured)
      throw new IllegalStateException("Configuration is frozen"); 
    this.redirect = redirect;
  }
  
  public void freeze() {
    this.configured = true;
  }
  
  public String toString() {
    StringBuffer sb = new StringBuffer("ForwardConfig[");
    sb.append("name=");
    sb.append(this.name);
    sb.append(",path=");
    sb.append(this.path);
    sb.append(",redirect=");
    sb.append(this.redirect);
    sb.append(",contextRelative=");
    sb.append(this.contextRelative);
    sb.append("]");
    return sb.toString();
  }
}
