javax.microedition.location.services
Class NavigationInstruction

java.lang.Object
  extended by javax.microedition.location.services.NavigationInstruction

public class NavigationInstruction
extends java.lang.Object

This class collects the instructions for navigating a route segment. Each NavigationInstruction object has the instructions in different MIME types and a geographical area within which the instruction should be given. The instruction may be any content that has a registered MIME type. An application using the instructions determines the proper object to be used based on the MIME type of the instruction. For example, an instruction with MIME type "image/png" could be casted into javax.microedition.lcdui.Image object. The mapping between MIME types and objects used to represent that content will be done in outside this specification.

An application may add content in several MIME types to an instruction. Content of one type is added in the constructor, and additional content with method addInstruction method. If there is a need to update the content, a new NavigationInstruction object must be created.

Since:
2.0

Constructor Summary
NavigationInstruction(java.lang.Object instruction, java.lang.String mimeType, GeographicArea coverageArea)
          Constructs a NavigationInstruction object with the given parameters.
 
Method Summary
 void addInstruction(java.lang.Object instruction, java.lang.String mimeType)
          Adds the instruction for navigation.
 boolean equals(java.lang.Object obj)
          Overriding the equals method in Object class to compare the equality of values in two NavigatoinInstruction objects.
 GeographicArea getCoverageArea()
          Returns the coverage area of the instruction.
 java.lang.Object getInstruction(java.lang.String mimeType)
          Returns the navigation instruction for the requested MIME type.
 java.lang.String[] getMimeTypes()
          Returns the MIME types of the instructions that have been set in this object.
 int hashCode()
          Overriding the hashCode method in Object class.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NavigationInstruction

public NavigationInstruction(java.lang.Object instruction,
                             java.lang.String mimeType,
                             GeographicArea coverageArea)

Constructs a NavigationInstruction object with the given parameters. The actual instruction is given as an Object, since it varies based on the MIME type of the instruction. The mimeType parameter ties the instruction into certain MIME type. The coverageArea parameter defines the geographical area within what the instruction should be given. The input values are validated only for non-null values.

Parameters:
instruction - the instruction for navigating a route segment
mimeType - the MIME type of the instruction
coverageArea - the area within what the instruction should be given
Throws:
java.lang.NullPointerException - if instruction, mimeType or coverageArea is null
Method Detail

getInstruction

public java.lang.Object getInstruction(java.lang.String mimeType)

Returns the navigation instruction for the requested MIME type. The method returns the values set in the constructor or with method addInstruction. An application casts the returned Object into right type object based on the mimeType parameter. If the instruction for the requested MIME type does not exist in this object, this method returns null. The assigned MIME types can be retrieved with method getMimeTypes.

Parameters:
mimeType - the MIME type of the requested instruction
Returns:
the instruction for navigation or null if the instruction for requested MIME type has not been set
Throws:
java.lang.NullPointerException - if mimeType is null

addInstruction

public void addInstruction(java.lang.Object instruction,
                           java.lang.String mimeType)

Adds the instruction for navigation. The instruction is passed in as an Object. The MIME type of the instruction is defined with mimeType parameter. If this object already has an instruction with the given MIME type set, an IllegalArgumentException is thrown.

Parameters:
instruction - the instruction for navigation
mimeType - the MIME type of the instruction
Throws:
java.lang.IllegalArgumentException - if this object already has an instruction with the given mimeType set
java.lang.NullPointerException - if instruction or mimeType is null

getCoverageArea

public GeographicArea getCoverageArea()

Returns the coverage area of the instruction. The instruction should be given when the coverage area is entered.

Returns:
the geographical area within what the instruction should be given

getMimeTypes

public java.lang.String[] getMimeTypes()

Returns the MIME types of the instructions that have been set in this object. The MIME types are given in the constructor and in the addInstruction method. The MIME type can be used to request appropriate instruction with the getInstruction method.

Returns:
the MIME types that has been set for the instructions in this object

equals

public boolean equals(java.lang.Object obj)

Overriding the equals method in Object class to compare the equality of values in two NavigatoinInstruction objects. Two NavigationInstruction objects are equal, if the fields are equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj - object to which the comparison is done
Returns:
true if all fields in the objects are equal, else false

hashCode

public int hashCode()

Overriding the hashCode method in Object class. The method returns a hash code value for the route object. Two NavigationInstruction objects that are equal must have the same hash code. For more information see java.lang.Object.hashCode() method.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of the coordinates


Copyright © 2003-2008 Nokia Corporation. All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.