bea Systems, Inc.

theory.smart.ebusiness.shoppingadvisor
Class SuggestionsImpl

java.lang.Object
  |
  +--theory.smart.foundation.BelongingImpl
        |
        +--theory.smart.ebusiness.shoppingadvisor.SuggestionsImpl

public class SuggestionsImpl
extends BelongingImpl
implements Suggestions

This is the list of matching items scored by how well they match.

See Also:
Suggestions, SuggestionsHome, Serialized Form

Field Summary
 com.sun.java.util.collections.ArrayList suggestions
           suggestion (Array) [Suggestions] <*>------> [theory.smart.ebusiness.shoppingadvisor.Suggestion] 0..*
 
Fields inherited from class theory.smart.foundation.BelongingImpl
isDirty
 
Constructor Summary
SuggestionsImpl()
           
 
Method Summary
 void addSuggestion(int index, Suggestion suggestion)
          Inserts the specified suggestion at the specified position in the suggestion list.
 boolean addSuggestion(Suggestion suggestion)
          Appends the specified suggestion to the end of the suggestion list.
 boolean addSuggestions(com.sun.java.util.collections.ArrayList suggestions)
          Appends all of the suggestions in the specified collection to the end of the suggestion list, in the order that they are returned by the specified collection's iterator.
 boolean addSuggestions(int index, com.sun.java.util.collections.ArrayList suggestions)
          Inserts all of the suggestions in the specified collection into this list, starting at the specified position.
 void applyItemByDegree(ItemByDegree ibd)
          Apply an Item by degree to the list.
 void applyItemByDegree(ItemByDegree ibd, boolean addNewItems)
          Apply an Item by degree to the list.
 int compareTo(java.lang.Object o)
           
 boolean containsSuggestion(Suggestion suggestion)
          Returns true if the suggestion list contains the specified element.
 int getNumberOfSuggestions()
          Returns the number of suggestions in the suggestion list.
 Suggestion getSuggestion(int index)
          Returns the suggestion at the specified position in the suggestion list.
 com.sun.java.util.collections.ArrayList getSuggestions()
          Returns all of the suggestions in the suggestion list.
 com.sun.java.util.collections.ArrayList getSuggestions(int fromIndex, int toIndex)
          Returns a view of the portion of the suggestion list between fromIndex, inclusive, and toIndex, exclusive.
 int indexOfSuggestion(Suggestion suggestion)
          Returns the index in the suggestion list of the first occurrence of the specified element, or -1 if the suggestion list does not contain this element.
 boolean isSuggestionsEmtpy()
          Returns true if the suggestion list contains no suggestions.
 int lastIndexOfSuggestion(Suggestion suggestion)
          Returns the index in the suggestion list of the last occurrence of the specified element, or -1 if the suggestion list does not contain this element.
 void orderByItem()
          Order the list by the item key so that it can be more quickly searched.
 void orderByScore()
          Order the suggestions by the degree to which they match the request.
 void removeAllSuggestions()
          Removes all of the suggestions from the suggestion list.
 Suggestion removeSuggestion(int index)
          Removes the suggestion at the specified position in the suggestion list.
 boolean removeSuggestion(Suggestion suggestion)
          Removes the first occurrence of the specified suggestion in the suggestion list.
 Suggestion setSuggestion(int index, Suggestion suggestion)
          Replaces the suggestion at the specified position in the suggestion list with the specified element.
 void trim(int count)
          Trim the count of suggestions to the specified length.
 Belonging value()
           
 
Methods inherited from class theory.smart.foundation.BelongingImpl
equals
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

suggestions

public com.sun.java.util.collections.ArrayList suggestions
                  suggestion (Array)
 [Suggestions] <*>------> [theory.smart.ebusiness.shoppingadvisor.Suggestion] 
                     0..*
 
Constructor Detail

SuggestionsImpl

public SuggestionsImpl()
Method Detail

addSuggestion

public void addSuggestion(int index,
                          Suggestion suggestion)
Inserts the specified suggestion at the specified position in the suggestion list. Shifts the suggestion currently at that position (if any) and any subsequent suggestions to the right (adds one to their indices).
Specified by:
addSuggestion in interface Suggestions
Parameters:
index - index at which the specified suggestion is to be inserted.
suggestion - suggestion to be inserted.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addSuggestion

public boolean addSuggestion(Suggestion suggestion)
Appends the specified suggestion to the end of the suggestion list.
Specified by:
addSuggestion in interface Suggestions
Parameters:
suggestion - suggestion to be appended to the suggestion list.
Returns:
true (as per the general contract of Collection.add).

addSuggestions

public boolean addSuggestions(int index,
                              com.sun.java.util.collections.ArrayList suggestions)
Inserts all of the suggestions in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent suggestions to the right (increases their indices). The new suggestions will appear in the suggestion list in the order that they are returned by the specified collection's iterator.
Specified by:
addSuggestions in interface Suggestions
Parameters:
index - index at which to insert first element from the specified collection.
suggestions - suggestions to be inserted into the suggestion list.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addSuggestions

public boolean addSuggestions(com.sun.java.util.collections.ArrayList suggestions)
Appends all of the suggestions in the specified collection to the end of the suggestion list, in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is the suggestion list, and the suggestion list is nonempty.)
Specified by:
addSuggestions in interface Suggestions
Parameters:
suggestions - suggestions to be inserted into the suggestion list.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

containsSuggestion

public boolean containsSuggestion(Suggestion suggestion)
Returns true if the suggestion list contains the specified element. More formally, returns true if and only if the suggestion list contains at least one suggestion e such that (o==null ? e==null : o.equals(e)).
Specified by:
containsSuggestion in interface Suggestions
Parameters:
suggestion - suggestion whose presence in the suggestion list is to be tested.
Returns:
true if the suggestion list contains the specified element.

getSuggestion

public Suggestion getSuggestion(int index)
Returns the suggestion at the specified position in the suggestion list.
Specified by:
getSuggestion in interface Suggestions
Parameters:
index - index of suggestion to return.
Returns:
the suggestion at the specified position in the suggestion list.
Throws:
IndexOutOfBoundsException - if the specified index is is out of range (index < 0 || index >= size()).

getSuggestions

public com.sun.java.util.collections.ArrayList getSuggestions(int fromIndex,
                                                              int toIndex)
Returns a view of the portion of the suggestion list between fromIndex, inclusive, and toIndex, exclusive.
Specified by:
getSuggestions in interface Suggestions
Parameters:
fromIndex - low endpoint (inclusive) of the subList.
toKey - high endpoint (exclusive) of the subList.
Returns:
a view of the specified range within the suggestion list.
Throws:
IndexOutOfBoundsException - endpoint index value out of range (fromIndex < 0 || toIndex > size)
java.lang.IllegalArgumentException - endpoint indices out of order (fromIndex > toIndex)

getSuggestions

public com.sun.java.util.collections.ArrayList getSuggestions()
Returns all of the suggestions in the suggestion list.
Specified by:
getSuggestions in interface Suggestions
Returns:
all of the suggestions in the suggestion list.

getNumberOfSuggestions

public int getNumberOfSuggestions()
Returns the number of suggestions in the suggestion list.
Specified by:
getNumberOfSuggestions in interface Suggestions
Returns:
the number of suggestions in the suggestion list.

indexOfSuggestion

public int indexOfSuggestion(Suggestion suggestion)
Returns the index in the suggestion list of the first occurrence of the specified element, or -1 if the suggestion list does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Specified by:
indexOfSuggestion in interface Suggestions
Parameters:
suggestion - suggestion to search for.
Returns:
the index in the suggestion list of the first occurrence of the specified element, or -1 if the suggestion list does not contain this element.

isSuggestionsEmtpy

public boolean isSuggestionsEmtpy()
Returns true if the suggestion list contains no suggestions.

Specified by:
isSuggestionsEmtpy in interface Suggestions
Returns:
true if the suggestion list contains no suggestions.

lastIndexOfSuggestion

public int lastIndexOfSuggestion(Suggestion suggestion)
Returns the index in the suggestion list of the last occurrence of the specified element, or -1 if the suggestion list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Specified by:
lastIndexOfSuggestion in interface Suggestions
Parameters:
suggestion - suggestion to search for.
Returns:
the index in the suggestion list of the last occurrence of the specified element, or -1 if the suggestion list does not contain this element.

removeAllSuggestions

public void removeAllSuggestions()
Removes all of the suggestions from the suggestion list.
Specified by:
removeAllSuggestions in interface Suggestions

removeSuggestion

public Suggestion removeSuggestion(int index)
Removes the suggestion at the specified position in the suggestion list. Shifts any subsequent suggestions to the left (subtracts one from their indices). Returns the suggestion that was removed from the suggestion list.
Specified by:
removeSuggestion in interface Suggestions
Parameters:
index - the index of the suggestion to removed.
Returns:
the suggestion previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

removeSuggestion

public boolean removeSuggestion(Suggestion suggestion)
Removes the first occurrence of the specified suggestion in the suggestion list. If the suggestion list does not contain the element, it is unchanged. More formally, removes the suggestion with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an suggestion exists).
Specified by:
removeSuggestion in interface Suggestions
Parameters:
suggestion - suggestion to be removed from the suggestion list, if present.
Returns:
true if the suggestion list contained the specified element.

setSuggestion

public Suggestion setSuggestion(int index,
                                Suggestion suggestion)
Replaces the suggestion at the specified position in the suggestion list with the specified element.
Specified by:
setSuggestion in interface Suggestions
Parameters:
index - index of suggestion to replace.
suggestion - suggestion to be stored at the specified position.
Returns:
the suggestion previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

value

public Belonging value()

compareTo

public int compareTo(java.lang.Object o)
Overrides:
compareTo in class BelongingImpl

applyItemByDegree

public void applyItemByDegree(ItemByDegree ibd)
                       throws java.rmi.RemoteException
Apply an Item by degree to the list. First check if the item is there. If not it will be added.
Specified by:
applyItemByDegree in interface Suggestions

applyItemByDegree

public void applyItemByDegree(ItemByDegree ibd,
                              boolean addNewItems)
                       throws java.rmi.RemoteException
Apply an Item by degree to the list. The addNewItems flag will determine if items that are not on the list are to be added.
Specified by:
applyItemByDegree in interface Suggestions

orderByScore

public void orderByScore()
Order the suggestions by the degree to which they match the request.
Specified by:
orderByScore in interface Suggestions

orderByItem

public void orderByItem()
Order the list by the item key so that it can be more quickly searched.
Specified by:
orderByItem in interface Suggestions

trim

public void trim(int count)
Trim the count of suggestions to the specified length.
Specified by:
trim in interface Suggestions

bea Systems, Inc.

© Copyright 2000 bea Systems, Inc. All rights reserved.