package BradsJavaPackages;
import java.io.Serializable;

public class GuestBook extends Object implements Serializable
	{
		private String Name;
		private String State;
		private String Occupation;
		private String City;
		private String Email;
		private String WebPage;
		private String Comments;
		private String DisplayName;

		public GuestBook()
		{
			this.Name = null;
			this.State = null;
			this.Occupation = null;
			this.City = null;
			this.Email = null;
			this.WebPage = null;
			this.Comments = null;
			this.DisplayName = null;
		}

		public GuestBook(String Name, String State)
		{
			setName(Name.trim());
			setState(State.trim());
			this.Occupation = null;
			this.City = null;
			this.Email = null;
			this.WebPage = null;
			this.Comments = null;
		}

        public GuestBook(String Name, String Occupation, String City,
                                          String State, String E_Mail, String WebPage)
		{
			setName(Name.trim());
			setState(State.trim());
			setOccupation(Occupation.trim());
			setCity(City.trim());
			setEmail(E_Mail.trim());
			setWebPage(WebPage.trim());
			this.Comments = null;
		}

		public void setName(String Name)
		{
			Name = Name.trim();
			Name = Name.replace('\'','`');
			Name = Name.replace(',',' ');
			Name = Name.replace('.',' ');
			Name = Name.toUpperCase();
			this.DisplayName = Name;
			if (Name.equals(""))
				Name = null;
			else Name = "'" + Name + "'";
			this.Name = Name;
		}

		public void setState(String State)
		{
			State = State.trim();
			State = State.replace('\'','`');
			State = State.replace(',',' ');
			State = State.replace('.',' ');
			if (State.equals(""))
				State = null;
			else State = "'" + State + "'";
			this.State = State;
		}

		public void setOccupation(String Occupation)
		{

			Occupation = Occupation.trim();
			Occupation = Occupation.replace('\'','`');
			Occupation = Occupation.replace(',',' ');
			Occupation = Occupation.replace('.',' ');
			Occupation = Occupation.toUpperCase();
			if (Occupation.equals(""))
				Occupation = null;
			else Occupation = "'" + Occupation + "'";
			this.Occupation = Occupation;
		}

		public void setCity(String City)
		{
			City = City.trim();
			City = City.replace('\'','`');
			City = City.replace(',',' ');
			City = City.replace('.',' ');
			City = City.toUpperCase();
			if (City.equals(""))
				City = null;
			else City = "'" + City + "'";
			this.City = City;
		}

		public void setEmail(String Email)
		{
			Email = Email.trim();
			Email = Email.replace('\'','`');
			if (Email.equals(""))
				Email = null;
			else Email = "'" + Email + "'";
			this.Email = Email;
		}

		public void setWebPage(String WebPage)
		{
			WebPage = WebPage.trim();
			WebPage = WebPage.replace('\'','`');
			if (WebPage.equals(""))
				WebPage = null;
			else
			{
				if (WebPage.indexOf("http://") == -1)
					WebPage = "http://" + WebPage;
				WebPage = "'" + WebPage + "'";
			}
			this.WebPage = WebPage;
		}

		public void setComments(String Comments)
		{
			Comments = Comments.trim();
			Comments = Comments.replace('\'','`');
			if (Comments.equals(""))
				Comments = null;
			else Comments = "'" + Comments + "'";
			this.Comments = Comments;

		}

		public String getName()
		{
			return Name;
		}

		public String getDisplayName()
		{
			return DisplayName;
		}

		public String getState()
		{
			return State;
		}

		public String getOccupation()
		{
			return Occupation;
		}

		public String getCity()
		{
			return City;
		}

		public String getEmail()
		{
			return Email;
		}

		public String getWebPage()
		{
			return WebPage;
		}

		public String getComments()
		{
			return Comments;
		}

        public String toString()
        {
            return  "\n\n Name: " + getName() + "\n Occupation: " + getOccupation() +
                    "\n City: " + getCity() + "\n State: " + getState() +
                    "\n Email: " + getEmail() + "\n Website: " + getWebPage();
        }

        public static GuestBook loadData(Object Name, Object Occupation, Object City,
                                         Object State, Object E_Mail, Object WebPage)
        {
            if (Name == null)
               Name = "";
            String strName = (String) Name;

            if (Occupation == null)
            Occupation = "";
            String strOccupation = (String) Occupation;

            if (City == null)
                City = "";
            String strCity = (String) City;

            if (State == null)
                State = "";
            String strState = (String) State;

            if (E_Mail == null)
                E_Mail = "";
            String strE_Mail = (String) E_Mail;

            if (WebPage == null)
                WebPage = "";
            String strWebPage = (String) WebPage;

            return new GuestBook(strName, strOccupation, strCity, strState, strE_Mail, strWebPage);
        }

	} //end GuestBook class