📄 smartticketservlet.java
字号:
return; } private void getTheaters(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String zipCode = call.readUTF(); Theater[] theaters = smartTicketBD.getTheaters(zipCode); result.writeInt(theaters.length); for (int i = 0; i < theaters.length; i++) { theaters[i].serialize(result); } return; } private void getTheaterSchedule(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String theaterKey = call.readUTF(); TheaterSchedule theaterSchedule = smartTicketBD.getTheaterSchedule(theaterKey); theaterSchedule.serialize(result, true); return; } private void getMovie(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String movieKey = call.readUTF(); Movie movie = smartTicketBD.getMovie(movieKey); movie.serialize(result); return; } private void getMoviePoster(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String movieKey = call.readUTF(); byte[] poster = smartTicketBD.getMoviePoster(movieKey); result.writeInt(poster.length); result.write(poster, 0, poster.length); return; } private void getMovieShowtimes(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String theaterKey = call.readUTF(); String movieKey = call.readUTF(); int[][] showtimes = smartTicketBD.getMovieShowTimes(theaterKey, movieKey); TheaterSchedule.serializeShowTimes(showtimes, result); return; } private void getSeatingPlan(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String theaterKey = call.readUTF(); String movieKey = call.readUTF(); int[] showtime = new int[3]; showtime[0] = call.readInt(); showtime[1] = call.readInt(); showtime[2] = call.readInt(); SeatingPlan seatingPlan = smartTicketBD.getSeatingPlan(theaterKey, movieKey, showtime); seatingPlan.serialize(result); return; } private void reserveSeats(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String theaterKey = call.readUTF(); String movieKey = call.readUTF(); int[] showtime = new int[3]; showtime[0] = call.readInt(); showtime[1] = call.readInt(); showtime[2] = call.readInt(); SeatingPlan.Seat[] seats = new SeatingPlan.Seat[call.readInt()]; for (int i = 0; i < seats.length; i++) { seats[i] = SeatingPlan.Seat.deserialize(call); } Reservation reservation = smartTicketBD.reserveSeats(theaterKey, movieKey, showtime, seats); reservation.serialize(result); return; } private void purchaseTickets(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String reservationId = call.readUTF(); smartTicketBD.purchaseTickets(reservationId); return; } private void cancelSeatReservation(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String reservationId = call.readUTF(); smartTicketBD.cancelSeatReservation(reservationId); return; } private void getLocales(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String[] locales = smartTicketBD.getLocales(); result.writeInt(locales.length); for (int i = 0; i < locales.length; i++) { result.writeUTF(locales[i]); } return; } private void getResourceBundle(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { String baseName = call.readUTF(); String locale = call.readUTF(); IndexedResourceBundle bundle = smartTicketBD.getResourceBundle(baseName, locale); bundle.serialize(result); return; } public void initiateSynchronization(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { SyncAnchor syncAnchor = SyncAnchor.deserialize(call); long clientTime = call.readLong(); syncAnchor = smartTicketBD.initiateSynchronization(syncAnchor, clientTime); syncAnchor.serialize(result); return; } public void synchronizeMovieRatings(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { int conflictResolutionStrategyId = call.readInt(); MovieRating[] changedMovieRatings = new MovieRating[call.readInt()]; for (int i = 0; i < changedMovieRatings.length; i++) { changedMovieRatings[i] = MovieRating.deserialize(call); } MovieRating[] updatedMovieRatings = smartTicketBD.synchronizeMovieRatings(changedMovieRatings, conflictResolutionStrategyId); if (updatedMovieRatings != null) { result.writeInt(updatedMovieRatings.length); for (int i = 0; i < updatedMovieRatings.length; i++) { updatedMovieRatings[i].serialize(result); } } else { result.writeInt(0); } return; } public void commitMovieRatings(SmartTicketBD smartTicketBD, DataInputStream call, DataOutputStream result) throws IOException, ModelException, ApplicationException { MovieRating[] resolvedMovieRatings = new MovieRating[call.readInt()]; for (int i = 0; i < resolvedMovieRatings.length; i++) { resolvedMovieRatings[i] = MovieRating.deserialize(call); } MovieRating[] updatedMovieRatings = smartTicketBD.commitMovieRatings(resolvedMovieRatings); if (updatedMovieRatings != null) { result.writeInt(updatedMovieRatings.length); for (int i = 0; i < updatedMovieRatings.length; i++) { updatedMovieRatings[i].serialize(result); } } else { result.writeInt(0); } return; } /** * @link dependency */ /* # SmartTicketBD lnkSmartTicketBD; */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -