// Copyright (c) 2001, Oracle Corporation. All rights reserved.
package oracle.portal.provider.v2;

import java.util.Calendar;

public class UserLocation
{

    private LocationType mType;
    private float mPositionX;
    private float mPositionY;
    private Address mAddress;

    public UserLocation(
        LocationType type,
        float positionX,
        float positionY,
        Address address)
    {
        mType = type;
        mPositionX = positionX;
        mPositionY = positionY;

        mAddress = address;
    }

    public LocationType getType()
    {
        return mType;
    }

    public void setType(LocationType type)
    {
        mType = type;
    }

    public float getXPosition()
    {
        return mPositionX;
    }

    public void setXPosition(float x)
    {
        mPositionX = x;
    }

    public float getYPosition()
    {
        return mPositionY;
    }

    public void setYPosition(float y)
    {
        mPositionY = y;
    }

    public Address getAddress()
    {
        return mAddress;
    }

    public void setAddress(Address address)
    {
        mAddress = address;
    }

    // Nested Top level classes for types used/defined by User Location
    public static class Address extends Object
    {
        private String mCompanyName;
        private String mAddressLine1;
        private String mAddressLine2;
        private String mAddressLastLine;
        private String mBlock;
        private String mCity;
        private String mCounty;
        private String mState;
        private String mPostalCode;
        private String mPostalCodeExt;
        private String mCountry;

        public Address(
            String companyName,
            String addressLine1,
            String addressLine2,
            String addressLastLine,
            String block,
            String city,
            String county,
            String state,
            String country,
            String postalCode,
            String postalCodeExt)
        {
            mCompanyName = companyName;
            mAddressLine1 = addressLine1;
            mAddressLine2 = addressLine2;
            mAddressLastLine = addressLastLine;
            mBlock = block;
            mCity = city;
            mCounty = county;
            mState = state;
            mCountry = country;
            mPostalCode = postalCode;
            mPostalCodeExt = postalCodeExt;
        }

        public String getCompanyName()
        {
            return mCompanyName;
        }

        public void setCompanyName(String companyName)
        {
            mCompanyName = companyName;
        }

        public String getAddressLine1()
        {
            return mAddressLine1;
        }

        public void setAddressLine1(String addressLine1)

        {
            mAddressLine1 = addressLine1;
        }

        public String getAddressLine2()
        {
            return mAddressLine2;
        }

        public void setAddressLine2(String addressLine2)

        {
            mAddressLine2 = addressLine2;
        }

        public String getAddressLastLine()
        {
            return mAddressLastLine;
        }

        public void setAddressLastLine(String addressLastLine)

        {
            mAddressLastLine = addressLastLine;
        }

        public String getBlock()
        {
            return mBlock;
        }

        public void setBlock(String block)

        {
            mBlock = block;
        }

        public String getCity()
        {
            return mCity;
        }

        public void setCity(String city)

        {
            mCity = city;
        }

        public String getCounty()
        {
            return mCounty;
        }

        public void setCounty(String county)

        {
            mCounty = county;
        }

        public String getState()
        {
            return mState;
        }

        public void setState(String state)

        {
            mState = state;
        }

        public String getCountry()
        {
            return mCountry;
        }

        public void setCountry(String country)

        {
            mCountry = country;
        }

        public String getPostalCode()
        {
            return mPostalCode;
        }

        public void setPostalCode(String postalCode)

        {
            mPostalCode = postalCode;
        }

        public String getPostalCodeExt()
        {
            return mPostalCodeExt;
        }

        public void setPostalCodeExt(String postalCodeExt)

        {
            mPostalCodeExt = postalCodeExt;
        }

    }

    // Nested Top level classes for types used/defined by User Location

    public static class LocationType extends Object
    {
        public static final int UNKNOWN = 0;
        public static final int REAL = 1;
        public static final int PROFILE = 2;
        private static final int LAST = PROFILE;

        public static final LocationType LOCATION_UNKNOWN = new LocationType(LocationType.UNKNOWN);
        public static final LocationType LOCATION_REAL = new LocationType(LocationType.REAL);
        public static final LocationType LOCATION_PROFILE = new LocationType(LocationType.PROFILE);

        protected static final String LOCATION_TYPE_REAL = "auto";
        protected static final String LOCATION_TYPE_PROFILE = "profile";
        protected static final String LOCATION_TYPE_UNKNOWN = "unknown";


        static public boolean isLocationReal(LocationType type)
        {
            if (type.getValue() == LocationType.REAL)
                return true;
            else
                return false;
        }

        static public boolean isLocationProfile(LocationType type)
        {
            if (type.getValue() == LocationType.PROFILE)
                return true;
            else
                return false;
        }

        static public boolean isLocationKnown(LocationType type)
        {
            if (type.getValue() != LocationType.UNKNOWN)
                return true;
            else
                return false;
        }

        static public LocationType getLocationType(String location)
        {
            if (location == null)
                return LocationType.LOCATION_UNKNOWN;
            else if (location.equalsIgnoreCase(LocationType.LOCATION_TYPE_REAL))
                return LocationType.LOCATION_REAL;
            else if (location.equalsIgnoreCase(LocationType.LOCATION_TYPE_PROFILE))
                return LocationType.LOCATION_PROFILE;
            else
                return LocationType.LOCATION_UNKNOWN;
        }

        private int mValue;

        public LocationType(String location)
        {
            if (location == null)
                mValue = LocationType.UNKNOWN;
            else if (location.equalsIgnoreCase(LocationType.LOCATION_TYPE_REAL))
                mValue = LocationType.REAL;
            else if (location.equalsIgnoreCase(LocationType.LOCATION_TYPE_PROFILE))
                mValue = LocationType.PROFILE;
            else
                mValue = LocationType.UNKNOWN;
        }

        public LocationType(int location)
        {
            if (location > LocationType.UNKNOWN && location <= LocationType.LAST)
                mValue = location;
            else
                mValue = LocationType.UNKNOWN;
        }

        public int getValue()
        {
            return mValue;
        }

        public String toString()
        {
            switch (mValue)
            {
            case LocationType.REAL:
                return LocationType.LOCATION_TYPE_REAL;
            case LocationType.PROFILE:
                return LocationType.LOCATION_TYPE_PROFILE;
            default:
                return LocationType.LOCATION_TYPE_UNKNOWN;
            }
        }
    }

}

