rmsadapter.java

来自「SUN公司发布的SmartTicket 2.0蓝图」· Java 代码 · 共 652 行 · 第 1/2 页

JAVA
652
字号
            return recordId;        } catch (IOException ioe) {            throw new ApplicationException(ioe);        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public void deleteTheaterSchedule(int recordId)             throws ApplicationException {        delete(remoteDataRecordStore, recordId);        return;    }     public Movie loadMovie(int recordId) throws ApplicationException {        try {            byte[] data = remoteDataRecordStore.getRecord(recordId);            return Movie.deserialize(new DataInputStream(new ByteArrayInputStream(data)));        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public int storeMovie(Movie movie,                           int recordId) throws ApplicationException {        try {            ByteArrayOutputStream stream = new ByteArrayOutputStream();            DataOutputStream dataStream = new DataOutputStream(stream);            movie.serialize(dataStream);            dataStream.flush();            if (recordId > 0) {                remoteDataRecordStore.setRecord(recordId,                                                 stream.toByteArray(), 0,                                                 stream.size());            } else {                recordId =                     remoteDataRecordStore.addRecord(stream.toByteArray(), 0,                                                     stream.size());            }             return recordId;        } catch (IOException ioe) {            throw new ApplicationException(ioe);        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public void deleteMovie(int recordId) throws ApplicationException {        delete(remoteDataRecordStore, recordId);        return;    }     public MovieRating loadMovieRating(int recordId)             throws ApplicationException {        try {            byte[] data = remoteDataRecordStore.getRecord(recordId);            return MovieRating.deserialize(new DataInputStream(new ByteArrayInputStream(data)));        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public int storeMovieRating(MovieRating movieRating,                                 int recordId) throws ApplicationException {        try {            ByteArrayOutputStream stream = new ByteArrayOutputStream();            DataOutputStream dataStream = new DataOutputStream(stream);            movieRating.serialize(dataStream);            dataStream.flush();            if (recordId > 0) {                remoteDataRecordStore.setRecord(recordId,                                                 stream.toByteArray(), 0,                                                 stream.size());            } else {                recordId =                     remoteDataRecordStore.addRecord(stream.toByteArray(), 0,                                                     stream.size());            }             return recordId;        } catch (IOException ioe) {            throw new ApplicationException(ioe);        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public void deleteMovieRating(int recordId) throws ApplicationException {        delete(remoteDataRecordStore, recordId);        return;    }     public Preferences loadPreferences(int recordId)             throws ApplicationException {        try {            byte[] data = localDataRecordStore.getRecord(recordId);            return Preferences.deserialize(new DataInputStream(new ByteArrayInputStream(data)));        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public int storePreferences(Preferences preferences,                                 int recordId) throws ApplicationException {        try {            ByteArrayOutputStream stream = new ByteArrayOutputStream();            DataOutputStream dataStream = new DataOutputStream(stream);            preferences.serialize(dataStream);            dataStream.flush();            if (recordId > 0) {                localDataRecordStore.setRecord(recordId,                                                stream.toByteArray(), 0,                                                stream.size());            } else {                recordId =                     localDataRecordStore.addRecord(stream.toByteArray(), 0,                                                    stream.size());            }             return recordId;        } catch (IOException ioe) {            throw new ApplicationException(ioe);        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public SyncAnchor loadSyncAnchor(int recordId)             throws ApplicationException {        try {            byte[] data = localDataRecordStore.getRecord(recordId);            return SyncAnchor.deserialize(new DataInputStream(new ByteArrayInputStream(data)));        } catch (RecordStoreException rse) {            throw new ApplicationException(rse);        }     }     public int storeSyncAnchor(SyncAnchor syncAnchor,                                int recordId) throws ApplicationException {        try {            ByteArrayOutputStream stream = new ByteArrayOutputStream();            DataOutputStream dataStream = new DataOutputStream(stream);            syncAnchor.serialize(dataStream);            dataStream.flush();            if (recordId > 0) {                localDataRecordStore.setRecord(recordId,                                                stream.toByteArray(), 0,                                                stream.size());            } else {                recordId =                     localDataRecordStore.addRecord(stream.toByteArray(), 0,                                                    stream.size());            }             return recordId;        } catch (IOException ioe) {            throw new ApplicationException(ioe);        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public AccountInfo loadAccountInfo(int recordId)             throws ApplicationException {        try {            byte[] data = localDataRecordStore.getRecord(recordId);            return AccountInfo.deserialize(new DataInputStream(new ByteArrayInputStream(data)));        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public int storeAccountInfo(AccountInfo accountInfo,                                 int recordId) throws ApplicationException {        try {            ByteArrayOutputStream stream = new ByteArrayOutputStream();            DataOutputStream dataStream = new DataOutputStream(stream);            accountInfo.serialize(dataStream);            dataStream.flush();            if (recordId > 0) {                localDataRecordStore.setRecord(recordId,                                                stream.toByteArray(), 0,                                                stream.size());            } else {                recordId =                     localDataRecordStore.addRecord(stream.toByteArray(), 0,                                                    stream.size());            }             return recordId;        } catch (IOException ioe) {            throw new ApplicationException(ioe);        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public IndexedResourceBundle loadResourceBundle(int recordId)             throws ApplicationException {        try {            byte[] data = localDataRecordStore.getRecord(recordId);            return IndexedResourceBundle.deserialize(new DataInputStream(new ByteArrayInputStream(data)));        } catch (RecordStoreException rse) {            throw new ApplicationException(rse);        }     }     public int storeResourceBundle(IndexedResourceBundle bundle,                                    int recordId) throws ApplicationException {        try {            ByteArrayOutputStream stream = new ByteArrayOutputStream();            DataOutputStream dataStream = new DataOutputStream(stream);            bundle.serialize(dataStream);            dataStream.flush();            if (recordId > 0) {                localDataRecordStore.setRecord(recordId,                                                stream.toByteArray(), 0,                                                stream.size());            } else {                recordId =                     localDataRecordStore.addRecord(stream.toByteArray(), 0,                                                    stream.size());            }             return recordId;        } catch (IOException ioe) {            throw new ApplicationException(ioe);        } catch (RecordStoreException rse) {            throw new ApplicationException(rse);        }     }     public RecommendationRecipient loadRecommendationRecipient(int recordId)             throws ApplicationException {        try {            byte[] data = remoteDataRecordStore.getRecord(recordId);            return RecommendationRecipient.deserialize(new DataInputStream(new ByteArrayInputStream(data)));        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public int storeRecommendationRecipient(RecommendationRecipient recommendationRecipient,                                             int recordId) throws ApplicationException {        try {            ByteArrayOutputStream stream = new ByteArrayOutputStream();            DataOutputStream dataStream = new DataOutputStream(stream);            recommendationRecipient.serialize(dataStream);            dataStream.flush();            if (recordId > 0) {                remoteDataRecordStore.setRecord(recordId,                                                 stream.toByteArray(), 0,                                                 stream.size());            } else {                recordId =                     remoteDataRecordStore.addRecord(stream.toByteArray(), 0,                                                     stream.size());            }             return recordId;        } catch (IOException ioe) {            throw new ApplicationException(ioe);        } catch (RecordStoreException rse) {            rse.printStackTrace();            throw new ApplicationException(rse);        }     }     public void deleteRecommendationRecipient(int recordId)             throws ApplicationException {        delete(remoteDataRecordStore, recordId);        return;    } }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?