⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 localmodel.java

📁 SUN公司发布的SmartTicket 2.0蓝图
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            throws ApplicationException {        this.preferences.copy(preferences);        IndexEntry indexEntry = rmsAdapter.getIndexEntry("*",                 IndexEntry.TYPE_PREFERENCES, IndexEntry.MODE_ANY);        int recordId = rmsAdapter.storePreferences(preferences,                                                    indexEntry != null                                                    ? indexEntry.getRecordId()                                                    : -1);        if (indexEntry == null) {            indexEntry = new IndexEntry(recordId,                                         IndexEntry.TYPE_PREFERENCES, "*",                                         IndexEntry.MODE_PERSISTING);            rmsAdapter.addIndexEntry(indexEntry);        }         return;    }     public IndexedResourceBundle getResourceBundle(String baseName)             throws ApplicationException {        try {            IndexEntry indexEntry = rmsAdapter.getIndexEntry(baseName,                     IndexEntry.TYPE_RESOURCE_BUNDLE, IndexEntry.MODE_ANY);            if (indexEntry != null) {                return rmsAdapter.loadResourceBundle(indexEntry.getRecordId());            }         } catch (ApplicationException ae) {}        return null;    }     public void setResourceBundle(String baseName, IndexedResourceBundle bundle)             throws ApplicationException {        IndexEntry indexEntry = rmsAdapter.getIndexEntry(baseName,                 IndexEntry.TYPE_RESOURCE_BUNDLE, IndexEntry.MODE_ANY);        int recordId = rmsAdapter.storeResourceBundle(bundle,                 indexEntry != null ? indexEntry.getRecordId() : -1);        if (indexEntry == null) {            indexEntry = new IndexEntry(recordId,                                         IndexEntry.TYPE_RESOURCE_BUNDLE,                                         baseName, IndexEntry.MODE_PERSISTING);            rmsAdapter.addIndexEntry(indexEntry);        }         return;    }     public void setMovieRating(MovieRating movieRating)             throws ApplicationException {        IndexEntry indexEntry =             rmsAdapter.getIndexEntry(movieRating.getPrimaryKey(),                                      IndexEntry.TYPE_MOVIE_RATING,                                      IndexEntry.MODE_ANY);        int recordId = rmsAdapter.storeMovieRating(movieRating,                                                    indexEntry != null                                                    ? indexEntry.getRecordId()                                                    : -1);        if (indexEntry == null) {            indexEntry = new IndexEntry(recordId,                                         IndexEntry.TYPE_MOVIE_RATING,                                         movieRating.getPrimaryKey(),                                         IndexEntry.MODE_PERSISTING);            rmsAdapter.addIndexEntry(indexEntry);            persistRatedMovie(movieRating.getMovie());        }         return;    }     public void addMovieRating(MovieRating movieRating)             throws ApplicationException {        IndexEntry indexEntry =             rmsAdapter.getIndexEntry(movieRating.getPrimaryKey(),                                      IndexEntry.TYPE_MOVIE_RATING,                                      IndexEntry.MODE_ANY);        int recordId = -1;        if (indexEntry != null) {            recordId = indexEntry.getRecordId();            MovieRating rating = rmsAdapter.loadMovieRating(recordId);            rating.setLastViewingDate(movieRating.getLastViewingDate());            if (!rating.getAuthor().equals(movieRating.getAuthor())) {    // Override recommendation rating                rating.setStarNumber(MovieRating.RATING_UNRATED);                rating.setComment(movieRating.getComment() + "["                                   + rating.getAuthor() + ": ("                                   + rating.getStarNumber() + ") "                                   + rating.getComment() + "]");                rating.setAuthor(movieRating.getAuthor());            }             movieRating = rating;        }         recordId = rmsAdapter.storeMovieRating(movieRating, recordId);        if (indexEntry == null) {            indexEntry = new IndexEntry(recordId,                                         IndexEntry.TYPE_MOVIE_RATING,                                         movieRating.getPrimaryKey(),                                         IndexEntry.MODE_PERSISTING);            rmsAdapter.addIndexEntry(indexEntry);            persistRatedMovie(movieRating.getMovie());        }         return;    }     public void deleteMovieRating(String movieRatingKey)             throws ApplicationException {        IndexEntry indexEntry = rmsAdapter.getIndexEntry(movieRatingKey,                 IndexEntry.TYPE_MOVIE_RATING, IndexEntry.MODE_ANY);        if (indexEntry != null) {            MovieRating movieRating =                 rmsAdapter.loadMovieRating(indexEntry.getRecordId());            movieRating.setModificationStatus(Synchronizable.STATUS_DELETED);            rmsAdapter.storeMovieRating(movieRating,                                         indexEntry.getRecordId());        }         return;    }     public void purgeMovieRating(String movieRatingKey)             throws ApplicationException {        IndexEntry indexEntry = rmsAdapter.getIndexEntry(movieRatingKey,                 IndexEntry.TYPE_MOVIE_RATING, IndexEntry.MODE_ANY);        if (indexEntry != null) {            rmsAdapter.deleteMovieRating(indexEntry.getRecordId());            rmsAdapter.deleteIndexEntry(indexEntry.getKey(),                                         indexEntry.getType());        }         return;    }     public MovieRating[] getMovieRatings() throws ApplicationException {        IndexEntry[] indexEntries =             rmsAdapter.getIndexEntries(IndexEntry.TYPE_MOVIE_RATING,                                        IndexEntry.MODE_ANY);        MovieRating[] movieRatings = new MovieRating[indexEntries.length];        for (int i = 0; i < indexEntries.length; i++) {            movieRatings[i] =                 rmsAdapter.loadMovieRating(indexEntries[i].getRecordId());        }         return movieRatings;    }     private void persistRatedMovie(Movie movie) throws ApplicationException {        IndexEntry indexEntry =             rmsAdapter.getIndexEntry(movie.getPrimaryKey(),                                      IndexEntry.TYPE_MOVIE,                                      IndexEntry.MODE_ANY);        if (indexEntry == null) {            int recordId = rmsAdapter.storeMovie(movie, -1);            indexEntry = new IndexEntry(recordId, IndexEntry.TYPE_MOVIE,                                         movie.getPrimaryKey(),                                         IndexEntry.MODE_PERSISTING);            rmsAdapter.addIndexEntry(indexEntry);        } else if (indexEntry.getMode() != IndexEntry.MODE_PERSISTING) {            // since persisting: overwrite caching entries            indexEntry = new IndexEntry(indexEntry.getRecordId(),                                         indexEntry.getType(),                                         indexEntry.getKey(),                                         IndexEntry.MODE_PERSISTING);            rmsAdapter.addIndexEntry(indexEntry);        }         return;    }     public void setMovieRatingSyncAnchor(SyncAnchor syncAnchor)             throws ApplicationException {        IndexEntry indexEntry = rmsAdapter.getIndexEntry("MOVIE_RATINGS",                 IndexEntry.TYPE_SYNC_ANCHOR, IndexEntry.MODE_ANY);        int recordId = rmsAdapter.storeSyncAnchor(syncAnchor,                                                   indexEntry != null                                                   ? indexEntry.getRecordId()                                                   : -1);        if (indexEntry == null) {            indexEntry = new IndexEntry(recordId,                                         IndexEntry.TYPE_SYNC_ANCHOR,                                         "MOVIE_RATINGS",                                         IndexEntry.MODE_PERSISTING);            rmsAdapter.addIndexEntry(indexEntry);        }         return;    }     public SyncAnchor getMovieRatingSyncAnchor() throws ApplicationException {        IndexEntry indexEntry = rmsAdapter.getIndexEntry("MOVIE_RATINGS",                 IndexEntry.TYPE_SYNC_ANCHOR, IndexEntry.MODE_ANY);        return indexEntry != null                ? rmsAdapter.loadSyncAnchor(indexEntry.getRecordId()) : null;    }     public void setRecommendationRecipient(RecommendationRecipient recipient)             throws ApplicationException {        IndexEntry indexEntry =             rmsAdapter.getIndexEntry(recipient.getPrimaryKey(),                                      IndexEntry.TYPE_RECOMMENDATION_RECIPIENT,                                      IndexEntry.MODE_ANY);        int recordId = rmsAdapter.storeRecommendationRecipient(recipient,                 indexEntry != null ? indexEntry.getRecordId() : -1);        if (indexEntry == null) {            indexEntry =                 new IndexEntry(recordId,                                IndexEntry.TYPE_RECOMMENDATION_RECIPIENT,                                recipient.getPrimaryKey(),                                IndexEntry.MODE_PERSISTING);            rmsAdapter.addIndexEntry(indexEntry);        }         return;    }     public RecommendationRecipient[] getRecommendationRecipients()             throws ApplicationException {        IndexEntry[] indexEntries =             rmsAdapter.getIndexEntries(IndexEntry.TYPE_RECOMMENDATION_RECIPIENT,                                        IndexEntry.MODE_ANY);        RecommendationRecipient[] recipients =             new RecommendationRecipient[indexEntries.length];        for (int i = 0; i < indexEntries.length; i++) {            recipients[i] =                 rmsAdapter.loadRecommendationRecipient(indexEntries[i].getRecordId());        }         return recipients;    }     public void deleteRecommendationRecipient(String recipientKey)             throws ApplicationException {        IndexEntry indexEntry = rmsAdapter.getIndexEntry(recipientKey,                 IndexEntry.TYPE_RECOMMENDATION_RECIPIENT,                 IndexEntry.MODE_ANY);        if (indexEntry != null) {            rmsAdapter.deleteRecommendationRecipient(indexEntry.getRecordId());            rmsAdapter.deleteIndexEntry(indexEntry.getKey(),                                         indexEntry.getType());        }         return;    } }

⌨️ 快捷键说明

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