All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JBMSTours.Hotel

java.lang.Object
   |
   +----JBMSTours.Hotel

public class Hotel
extends Object
Look at the Source.

A class to represent hotels. Demonstrates: how to translate an object into flat relational data.


Variable Index

 o beginHighSeason
The date the hotel's high season begins.
 o endHighSeason
The date the hotel's high season ends.
 o highSeasonRate
The hotel's rate during its busy season.
 o hotelId
Stored in the hotel_id column.
 o level
A short that represents whether the hotel is economy, standard, or first class.
 o name
Name of the hotel.
 o NOHIGHSEASON
A short used if the hotel has no high season.
 o normalRate
The hotel's rate normally.

Constructor Index

 o Hotel()
public no-arg constructor for a hotel.
 o Hotel(int, String, int, short, BigDecimal, BigDecimal, int)
Constructs a hotel object for a hotel with no special high-season rate.
 o Hotel(int, String, int, short, BigDecimal, BigDecimal, int, short, short)
Constructs a hotel object for a hotel with a special high-season rate.
 o Hotel(Integer, String, Integer, Short, BigDecimal, BigDecimal, Integer, Short, Short)
Constructs a hotel object for a hotel that has a high-season rate using objects for parameters to make it easier for Cloudscape to recognize the signature.
 o Hotel(ResultSet)
Constructs a Hotel given a row (ResultSet) in the Hotels table.

Method Index

 o getCityId()
Get the cityId for this hotel.
 o getHighRate()
Get the rate for the high season
 o getInfo()
Return a message describing this hotel.
 o getLevel()
Get the level of this hotel.
 o getName()
Get the name of this hotel.
 o getNormalRate()
Get the rate for the normal season
 o getNumberRoomsInTourBlock()
Get the number of rooms in a tour block for this hotel.
 o getTodayRate()
Get today's rate.
 o insertInDatabase(Connection)
Inserts the hotel into the database, "translating" it into flat relational data.
 o isAHighSeason()
Returns a "true" if this hotel has a high season in which it raises its rates.
 o isAvailable(Connection, Date, Date, int)
Return true if the hotel has a given number of rooms available for a stay.
 o isHigh(Date, Date)
Returns a "true" any of part of the stay occurs during high season.
 o setHighSeason(short, short)
Define the months in the 'high season' for the hotel.
 o setRates(BigDecimal, BigDecimal)
Sets rates for normal and high season, in dollars.
 o toString()
Create a string that describes this hotel.
 o updateInDatabase(Connection, Hotel)
Updates a this hotel's record in the database with the data contained a new Hotel object; updates only changed fields.
 o updateRatesInDatabase(Connection)
Updates the rates in the database.

Variables

 o hotelId
 public int hotelId
Stored in the hotel_id column.

 o name
 public String name
Name of the hotel. Stored in the hotel_name column.

 o level
 public short level
A short that represents whether the hotel is economy, standard, or first class. Stored in the tour_level column.

 o normalRate
 public BigDecimal normalRate
The hotel's rate normally. Stored in the normal_rate column.

 o highSeasonRate
 public BigDecimal highSeasonRate
The hotel's rate during its busy season. Stored in the high_season_rate column

 o beginHighSeason
 public short beginHighSeason
The date the hotel's high season begins. Stored in the high_season_begin column

 o endHighSeason
 public short endHighSeason
The date the hotel's high season ends. Stored in the high_season_end column

 o NOHIGHSEASON
 public static final short NOHIGHSEASON
A short used if the hotel has no high season.

Constructors

 o Hotel
 public Hotel()
public no-arg constructor for a hotel.

 o Hotel
 public Hotel(int ID,
              String hotelName,
              int theCity,
              short level,
              BigDecimal normal,
              BigDecimal high,
              int rooms)
Constructs a hotel object for a hotel with no special high-season rate. Hotels are not stored in the database as objects. They are stored as standard SQL-92 data.

Parameters:
ID - hotel_id
hotelName - name of hotel
theCity - name of city
The - level of the tour. See the static variables in Tour.java.
normal - the rate for staying at the hotel in the normal season
high - the rate for staying in the hotel in the high season
rooms - the number of rooms in the hotel reserved for our tour company
 o Hotel
 public Hotel(int ID,
              String hotelName,
              int theCity,
              short level,
              BigDecimal normal,
              BigDecimal high,
              int rooms,
              short begin_high_season,
              short end_high_season)
Constructs a hotel object for a hotel with a special high-season rate. Hotels are not stored in the database as objects. They are stored as standard SQL-92 data.

Parameters:
ID - hotel_id
hotelName - name of hotel
theCity - name of city
The - level of the tour. See the static variables in Tour.java.
normal - the rate for staying at the hotel in the normal season
high - the rate for staying in the hotel in the high season
rooms - the number of rooms in the hotel reserved for our tour company
begin_high_season - the month the high season begins
end_high_season - the month the high season ends
 o Hotel
 public Hotel(Integer ID,
              String hotelName,
              Integer theCity,
              Short level,
              BigDecimal normal,
              BigDecimal high,
              Integer rooms,
              Short begin_high_season,
              Short end_high_season)
Constructs a hotel object for a hotel that has a high-season rate using objects for parameters to make it easier for Cloudscape to recognize the signature.

Hotels are not stored in the database as objects. They are stored as standard SQL-92 data.

However, using this signature, you can construct Hotel objects within SQL-J. For example:

SELECT NEW Hotel(hotel_id, hotel_name, city_id, tour_level, normal_rate, high_season_rate, number_rooms_in_block, high_season_begin, high_season_end) FROM Hotels

Parameters:
ID - hotel_id
hotelName - name of hotel
theCity - name of city
level - levelof the tour
normal - the rate for staying at the hotel in the normal season
high - the rate for staying in the hotel in the high season
rooms - the number of rooms in the hotel reserved for our tour company
begin_high_season - the month the high season begins
end_high_season - the month the high season ends
 o Hotel
 public Hotel(ResultSet rs) throws SQLException
Constructs a Hotel given a row (ResultSet) in the Hotels table.

Throws: SQLException
if a database error occurs

Methods

 o toString
 public String toString()
Create a string that describes this hotel.

Overrides:
toString in class Object
 o getName
 public String getName()
Get the name of this hotel.

 o getCityId
 public int getCityId()
Get the cityId for this hotel.

 o getLevel
 public short getLevel()
Get the level of this hotel.

 o getNumberRoomsInTourBlock
 public int getNumberRoomsInTourBlock()
Get the number of rooms in a tour block for this hotel.

 o setHighSeason
 public void setHighSeason(short start,
                           short stop)
Define the months in the 'high season' for the hotel.

To use this provide the start (first month) and stop (last month) for the high season. Months are zero-based so January is month 0. You can use the static variables of java.lang.Calendar.

To define a sequence of months that begins at the end of the year and wraps around into the beginning of the next year the provide a first month that is greater than the last month. For example to define a 'high season' from December to January inclusive use 'setHighSeason(java.lang.Calendar.DECEMBER, java.lang.Calendar.JANUARY)'.

Parameters:
start - the month the high season begins (0 based)
stop - the month the high season ends (0 based)
 o isHigh
 public boolean isHigh(Date start,
                       Date end)
Returns a "true" any of part of the stay occurs during high season.

Parameters:
start - the start date of the stay
end - the end date of the stay
 o isAHighSeason
 public boolean isAHighSeason()
Returns a "true" if this hotel has a high season in which it raises its rates.

Returns:
boolean if there is a high season
 o setRates
 public void setRates(BigDecimal normal,
                      BigDecimal high)
Sets rates for normal and high season, in dollars. Does not update rates in database, if data has already been stored.

Parameters:
normal - rate for normal season
high - rate for high season.
 o updateRatesInDatabase
 public int updateRatesInDatabase(Connection conn) throws SQLException
Updates the rates in the database.

Parameters:
conn - a connection to the database
Throws: SQLException
if a database error occurs
 o getNormalRate
 public BigDecimal getNormalRate()
Get the rate for the normal season

 o getHighRate
 public BigDecimal getHighRate()
Get the rate for the high season

 o getTodayRate
 public BigDecimal getTodayRate()
Get today's rate.

 o isAvailable
 public boolean isAvailable(Connection conn,
                            Date begin,
                            Date end,
                            int rooms) throws SQLException
Return true if the hotel has a given number of rooms available for a stay.

Parameters:
conn - a connection to the database
begin - beginning date for the proposed stay.
end - ending date for the proposed stay.
rooms - number of rooms needed
Returns:
true if hotel has the requested number of rooms available for the proposed stay.
Throws: SQLException
a error occurred.
 o getInfo
 public String getInfo()
Return a message describing this hotel.

Returns:
String object information about the Hotel
 o insertInDatabase
 public int insertInDatabase(Connection conn) throws SQLException
Inserts the hotel into the database, "translating" it into flat relational data.

Parameters:
conn - a connection to the database
Throws: SQLException
if there is an SQL error
 o updateInDatabase
 public int updateInDatabase(Connection conn,
                             Hotel newhotel) throws SQLException
Updates a this hotel's record in the database with the data contained a new Hotel object; updates only changed fields.

Parameters:
conn - a connection to the database
Hotel - the new Hotel object
Throws: SQLException
if there is an SQL error

All Packages  Class Hierarchy  This Package  Previous  Next  Index