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.
-
beginHighSeason
- The date the hotel's high season begins.
-
endHighSeason
- The date the hotel's high season ends.
-
highSeasonRate
- The hotel's rate during its busy season.
-
hotelId
- Stored in the hotel_id column.
-
level
- A short that represents whether the hotel is economy, standard, or first class.
-
name
- Name of the hotel.
-
NOHIGHSEASON
- A short used if the hotel has no high season.
-
normalRate
- The hotel's rate normally.
-
Hotel()
- public no-arg constructor for a hotel.
-
Hotel(int, String, int, short, BigDecimal, BigDecimal, int)
- Constructs a hotel object for a hotel with no special high-season rate.
-
Hotel(int, String, int, short, BigDecimal, BigDecimal, int, short, short)
- Constructs a hotel object for a hotel with a special high-season rate.
-
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.
-
Hotel(ResultSet)
- Constructs a Hotel given a row (ResultSet) in the Hotels table.
-
getCityId()
- Get the cityId for this hotel.
-
getHighRate()
- Get the rate for the high season
-
getInfo()
- Return a message describing this hotel.
-
getLevel()
- Get the level of this hotel.
-
getName()
- Get the name of this hotel.
-
getNormalRate()
- Get the rate for the normal season
-
getNumberRoomsInTourBlock()
- Get the number of rooms in a tour block for
this hotel.
-
getTodayRate()
- Get today's rate.
-
insertInDatabase(Connection)
- Inserts the hotel into the database, "translating" it into flat relational
data.
-
isAHighSeason()
- Returns a "true" if this hotel has a high season in which it raises its rates.
-
isAvailable(Connection, Date, Date, int)
- Return true if the hotel has a given number of rooms
available for a stay.
-
isHigh(Date, Date)
- Returns a "true" any of part of the stay occurs during high season.
-
setHighSeason(short, short)
- Define the months in the 'high season' for the hotel.
-
setRates(BigDecimal, BigDecimal)
- Sets rates for normal and high season, in dollars.
-
toString()
- Create a string that describes this hotel.
-
updateInDatabase(Connection, Hotel)
- Updates a this hotel's record in the database with the data contained a new Hotel object;
updates only changed fields.
-
updateRatesInDatabase(Connection)
- Updates the rates in the database.
hotelId
public int hotelId
- Stored in the hotel_id column.
name
public String name
- Name of the hotel. Stored in the hotel_name column.
level
public short level
- A short that represents whether the hotel is economy, standard, or first class.
Stored in the tour_level column.
normalRate
public BigDecimal normalRate
- The hotel's rate normally. Stored in the normal_rate column.
highSeasonRate
public BigDecimal highSeasonRate
- The hotel's rate during its busy season. Stored in the high_season_rate column
beginHighSeason
public short beginHighSeason
- The date the hotel's high season begins. Stored in the high_season_begin column
endHighSeason
public short endHighSeason
- The date the hotel's high season ends. Stored in the high_season_end column
NOHIGHSEASON
public static final short NOHIGHSEASON
- A short used if the hotel has no high season.
Hotel
public Hotel()
- public no-arg constructor for a hotel.
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
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
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
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
toString
public String toString()
- Create a string that describes this hotel.
- Overrides:
- toString in class Object
getName
public String getName()
- Get the name of this hotel.
getCityId
public int getCityId()
- Get the cityId for this hotel.
getLevel
public short getLevel()
- Get the level of this hotel.
getNumberRoomsInTourBlock
public int getNumberRoomsInTourBlock()
- Get the number of rooms in a tour block for
this hotel.
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)
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
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
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.
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
getNormalRate
public BigDecimal getNormalRate()
- Get the rate for the normal season
getHighRate
public BigDecimal getHighRate()
- Get the rate for the high season
getTodayRate
public BigDecimal getTodayRate()
- Get today's rate.
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.
getInfo
public String getInfo()
- Return a message describing this hotel.
- Returns:
- String object information about the Hotel
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
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