@Override public PreferenceArray getPreferencesFromUser(long userID) throws TasteException { if (userID == TEMP_USER_ID) { if (tempPrefs == null) { throw new NoSuchUserException(TEMP_USER_ID); } return tempPrefs; } return delegate.getPreferencesFromUser(userID); }
@Override public FastIDSet getItemIDsFromUser(long userID) throws TasteException { if (userID == TEMP_USER_ID) { if (tempPrefs == null) { throw new NoSuchUserException(TEMP_USER_ID); } return prefItemIDs; } return delegate.getItemIDsFromUser(userID); }
@Override public void removePreference(long userID, long itemID) throws TasteException { if (userID == TEMP_USER_ID) { if (tempPrefs == null) { throw new NoSuchUserException(TEMP_USER_ID); } throw new UnsupportedOperationException(); } delegate.removePreference(userID, itemID); }
/** * @throws NoSuchUserException * if there is no such user */ @Override public PreferenceArray getPreferencesFromUser(long userID) throws NoSuchUserException { PreferenceArray prefs = preferenceFromUsers.get(userID); if (prefs == null) { throw new NoSuchUserException(userID); } return prefs; }
/** * @throws NoSuchUserException * if there is no such user */ @Override public PreferenceArray getPreferencesFromUser(long userID) throws NoSuchUserException { PreferenceArray prefs = preferenceFromUsers.get(userID); if (prefs == null) { throw new NoSuchUserException(userID); } return prefs; }
@Override public void setPreference(long userID, long itemID, float value) throws TasteException { if (userID == TEMP_USER_ID) { if (tempPrefs == null) { throw new NoSuchUserException(TEMP_USER_ID); } throw new UnsupportedOperationException(); } delegate.setPreference(userID, itemID, value); }
public double[] getUserFeatures(long userID) throws NoSuchUserException { Integer index = userIDMapping.get(userID); if (index == null) { throw new NoSuchUserException(userID); } return userFeatures[index]; }
public int userIndex(long userID) throws NoSuchUserException { Integer index = userIDMapping.get(userID); if (index == null) { throw new NoSuchUserException(userID); } return index; }
@Override public void removePreference(long userID, long itemID) throws TasteException { if (userID == TEMP_USER_ID) { if (tempPrefs == null) { throw new NoSuchUserException(TEMP_USER_ID); } throw new UnsupportedOperationException(); } delegate.removePreference(userID, itemID); }
@Override public void setPreference(long userID, long itemID, float value) throws TasteException { if (userID == TEMP_USER_ID) { if (tempPrefs == null) { throw new NoSuchUserException(TEMP_USER_ID); } throw new UnsupportedOperationException(); } delegate.setPreference(userID, itemID, value); }
@Override public FastIDSet getItemIDsFromUser(long userID) throws TasteException { FastIDSet itemIDs = preferenceFromUsers.get(userID); if (itemIDs == null) { throw new NoSuchUserException(userID); } return itemIDs; }
public double[] getUserFeatures(long userID) throws NoSuchUserException { Integer index = userIDMapping.get(userID); if (index == null) { throw new NoSuchUserException(userID); } return userFeatures[index]; }
@Override public Long getPreferenceTime(long userID, long itemID) throws TasteException { if (userID == TEMP_USER_ID) { if (tempPrefs == null) { throw new NoSuchUserException(TEMP_USER_ID); } return null; } return delegate.getPreferenceTime(userID, itemID); }
public int userIndex(long userID) throws NoSuchUserException { Integer index = userIDMapping.get(userID); if (index == null) { throw new NoSuchUserException(userID); } return index; }
@Override public FastIDSet getItemIDsFromUser(long userID) throws TasteException { FastIDSet itemIDs = preferenceFromUsers.get(userID); if (itemIDs == null) { throw new NoSuchUserException(userID); } return itemIDs; }
@Override public Long getPreferenceTime(long userID, long itemID) throws TasteException { if (timestamps == null) { return null; } FastByIDMap<Long> itemTimestamps = timestamps.get(userID); if (itemTimestamps == null) { throw new NoSuchUserException(userID); } return itemTimestamps.get(itemID); }
@Override public Long getPreferenceTime(long userID, long itemID) throws TasteException { if (timestamps == null) { return null; } FastByIDMap<Long> itemTimestamps = timestamps.get(userID); if (itemTimestamps == null) { throw new NoSuchUserException(userID); } return itemTimestamps.get(itemID); }
@Override public Long getPreferenceTime(long userID, long itemID) throws TasteException { if (timestamps == null) { return null; } FastByIDMap<Long> itemTimestamps = timestamps.get(userID); if (itemTimestamps == null) { throw new NoSuchUserException(userID); } return itemTimestamps.get(itemID); }
@Override public Float getPreferenceValue(long userID, long itemID) throws NoSuchUserException { FastIDSet itemIDs = preferenceFromUsers.get(userID); if (itemIDs == null) { throw new NoSuchUserException(userID); } if (itemIDs.contains(itemID)) { return 1.0f; } return null; }
@Test public void testNSUException() { // Just make sure this all doesn't, ah, throw an exception TasteException te1 = new NoSuchUserException(); TasteException te4 = new NoSuchUserException(te1.toString()); te4.printStackTrace(new PrintStream(new ByteArrayOutputStream())); te4.printStackTrace(new PrintWriter(new OutputStreamWriter(new ByteArrayOutputStream()))); }