Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

Copyright © 2006 Sun Microsystems, Inc. All rights reserved.

JSR-927 (Maintenance Release)

javax.tv.service.navigation
Interface ServiceList


public interface ServiceList

ServiceList represents an ordered list of Service objects based on a specific grouping rule defined by a ServiceFilter. The objects in a ServiceList are numbered from 0 to size() -1. A ServiceList is immutable. In other words, once a ServiceList instance is created, the elements in the list and their order will never change. All classes that implement the ServiceList interface are required to maintain this property.

See Also:
Service, ServiceFilter, size()

Method Summary
 boolean contains(Service service)
          Tests if the indicated Service object is contained in the list.
 ServiceIterator createServiceIterator()
          Generates an iterator on the Service elements in this list.
 boolean equals(java.lang.Object o)
          Compares the specified object with this ServiceList for equality.
 ServiceList filterServices(ServiceFilter filter)
          Creates a new ServiceList object that is a subset of this list, based on the conditions specified by a ServiceFilter object.
 Service findService(Locator locator)
          Reports the Service corresponding to the specified locator if it is a member of this list.
 Service getService(int index)
          Reports the Service at the specified index position.
 int hashCode()
          Provides the hash code value for this ServiceList.
 int indexOf(Service service)
          Reports the position of the first occurrence of the indicated Service object in the list.
 int size()
          Reports the number of Service objects in the list.
 ServiceList sortByName()
          Generates a new ServiceList containing the same elements as the current list, sorted in ascending order by service name.
 ServiceList sortByNumber()
          Generates a new ServiceList containing the same elements as the current list, sorted in ascending order by service number.
 

Method Detail

sortByName

public ServiceList sortByName()
Generates a new ServiceList containing the same elements as the current list, sorted in ascending order by service name. The sort order is implementation dependent, but should be sensible when presented to a user.

Returns:
A ServiceList sorted by service name.
See Also:
Service.getName()

sortByNumber

public ServiceList sortByNumber()
                         throws SortNotAvailableException
Generates a new ServiceList containing the same elements as the current list, sorted in ascending order by service number.

Returns:
A ServiceList sorted by service number.
Throws:
SortNotAvailableException - If any of the Service objects in this ServiceList do not implement the ServiceNumber interface.
See Also:
ServiceNumber

findService

public Service findService(Locator locator)
                    throws InvalidLocatorException
Reports the Service corresponding to the specified locator if it is a member of this list.

Parameters:
locator - Specifies the Service to be searched for.
Returns:
The Service corresponding to locator, or null if the Service is not a member of this list.
Throws:
InvalidLocatorException - If locator does not reference a valid Service.

filterServices

public ServiceList filterServices(ServiceFilter filter)
Creates a new ServiceList object that is a subset of this list, based on the conditions specified by a ServiceFilter object. This method may be used to generate increasingly specialized lists of Service objects based on multiple filtering criteria. If the filter is null, the resulting ServiceList will be a duplicate of this list.

Note that the accept method of the given ServiceFilter will be invoked for each Service to be filtered using the same application thread that invokes this method.

Parameters:
filter - A filter constraining the requested service list, or null.
Returns:
A ServiceList object created based on the specified filtering rules.
See Also:
ServiceFilter.accept(javax.tv.service.Service)

createServiceIterator

public ServiceIterator createServiceIterator()
Generates an iterator on the Service elements in this list.

Returns:
A ServiceIterator on the Services in this list.

contains

public boolean contains(Service service)
Tests if the indicated Service object is contained in the list.

Parameters:
service - The Service object for which to search.
Returns:
true if the specified Service is member of the list; false otherwise.

indexOf

public int indexOf(Service service)
Reports the position of the first occurrence of the indicated Service object in the list.

Parameters:
service - The Service object for which to search.
Returns:
The index of the first occurrence of the service, or -1 if service is not contained in the list.

size

public int size()
Reports the number of Service objects in the list.

Returns:
The number of Service objects in the list.

getService

public Service getService(int index)
Reports the Service at the specified index position.

Parameters:
index - A position in the ServiceList.
Returns:
The Service at the specified index.
Throws:
java.lang.IndexOutOfBoundsException - If index < 0 or index > size()-1.

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this ServiceList for equality. Returns true if and only if the specified object is also a ServiceList, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order.

Parameters:
o - The object to be compared for equality with this list.
Returns:
true if the specified object is equal to this list; false otherwise.

hashCode

public int hashCode()
Provides the hash code value for this ServiceList. Two ServiceList objects that are equal will have the same hash code.

Returns:
The hash code value of this ServiceList.

JSR-927 (Maintenance Release)

Copyright © 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

For more information, please consult the JSR 927 specification.