Package com.sun.speech.engine.synthesis

# Class BaseSynthesizerQueueItem

SynthesizerQueueItem
com.sun.speech.engine.synthesis.BaseSynthesizerQueueItem

All Implemented Interfaces:
  `SpeechEventDispatcher`

Direct Known Subclasses:
  `FreeTTSSynthesizerQueueItem`, `TextSynthesizerQueueItem`

public class BaseSynthesizerQueueItem extends SynthesizerQueueItem implements SpeechEventDispatcher
Extends the JSAPI 1.0 `SynthesizerQueueItem` with handling for JSML, generation of engine-specific text, and other features.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static int`
`itemNumber`
Global count of queue items used for debug.
`protected BaseSynthesizer`
`synth`
`Synthesizer` that has queued this item.
`protected int`
`thisItemNumber`
Count for this item used for debug.

## Constructor Summary

Constructors
Constructor
Description
`BaseSynthesizerQueueItem()`
Class constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`cancelled()`
indicate that this item has been canceled
`void`
`completed()`
indicate that this item has been completed
`void`
`dispatchSpeechEvent(SpeechEvent event)`
Dispatches a `SpeechEvent`.
`void`
`fireMarkerReached(SpeakableEvent event)`
Utility function that sends a `MARKER_REACHED` event to all speakable listeners.
`void`
`fireSpeakableCancelled(SpeakableEvent event)`
Utility function that sends a `SPEAKABLE_CANCELLED` event to all speakable listeners.
`void`
`fireSpeakableEnded(SpeakableEvent event)`
Utility function that sends a `SPEAKABLE_ENDED` event to all speakable listeners.
`void`
`fireSpeakablePaused(SpeakableEvent event)`
Utility function that sends a `SPEAKABLE_PAUSED` event to all speakable listeners.
`void`
`fireSpeakableResumed(SpeakableEvent event)`
Utility function that sends a `SPEAKABLE_RESUMED` event to all speakable listeners.
`void`
`fireSpeakableStarted(SpeakableEvent event)`
Utility function that sends a `SPEAKABLE_STARTED` event to all speakable listeners.
`void`
`fireTopOfQueue(SpeakableEvent event)`
Utility function that sends a `TOP_OF_QUEUE` event to all speakable listeners.
`void`
`fireWordStarted(SpeakableEvent event)`
Utility function that sends a `WORD_STARTED` event to all speakable listeners.
`protected Document`
`getDocument()`
Gets the DOM document for this object.
`int`
`getItemNumber()`
Gets the item number for debug purposes only.
`protected boolean`
`isCancelled()`
determines if this queue item has been canceled
`boolean`
`isCompleted()`
returns true if this queue item has been processed.
`void`
`postMarkerReached(String text, int markerType)`
Utility function that generates a `MARKER_REACHED` event and posts it to the event queue.
`void`
`postSpeakableCancelled()`
Utility function that generates a `SPEAKABLE_CANCELLED` event and posts it to the event queue.
`void`
`postSpeakableEnded()`
Utility function that generates a `SPEAKABLE_ENDED` event and posts it to the event queue.
`void`
`postSpeakablePaused()`
Utility function that generates a `SPEAKABLE_PAUSED` event and posts it to the event queue.
`void`
`postSpeakableResumed()`
Utility function that generates a `SPEAKABLE_RESUMED` event and posts it to the event queue.
`void`
`postSpeakableStarted()`
Utility function that generates a `SPEAKABLE_STARTED` event and posts it to the event queue.
`void`
`postTopOfQueue()`
Utility function that generates a `TOP_OF_QUEUE` event and posts it to the event queue.
`void`
`postWordStarted(String text, int wordStart, int wordEnd)`
Utility function that generates a `WORD_STARTED` event and posts it to the event queue.
`protected void`
`setData(BaseSynthesizer synth, String source, boolean plainText, SpeakableListener listener)`
Sets queue item data with a `String` source that is either plain text or JSML.
`protected void`
`setData(BaseSynthesizer synth, URL source, SpeakableListener listener)`
Sets queue item data with a `URL` source.
`protected void`
`setData(BaseSynthesizer synth, Speakable source, SpeakableListener listener)`
Sets queue item data with a `Speakable` source.
`void`
`started()`
indicate that this item has been started
`boolean`
`waitCompleted()`
wait for this queue item to be completed

## Field Details

### itemNumber

protected static int itemNumber
Global count of queue items used for debug.

### thisItemNumber

protected int thisItemNumber
Count for this item used for debug.

### synth

protected BaseSynthesizer synth
`Synthesizer` that has queued this item.

## Constructor Details

### BaseSynthesizerQueueItem

public BaseSynthesizerQueueItem()
Class constructor.

## Method Details

### setData

protected void setData(BaseSynthesizer synth, Speakable source, SpeakableListener listener) throws JSMLException
Sets queue item data with a `Speakable` source.

Parameters:
  `synth` - the synthesizer
  `source` - the `Speakable`
  `listener` - the `SpeakableListener` to be notified as this object is processed

### setData

protected void setData(BaseSynthesizer synth, String source, boolean plainText, SpeakableListener listener) throws JSMLException
Sets queue item data with a `String` source that is either plain text or JSML.

Parameters:
  `synth` - the synthesizer
  `source` - the text
  `plainText` - `true` only if the `source` is plain text
  `listener` - the `SpeakableListener` to be notified as this object is processed

### setData

protected void setData(BaseSynthesizer synth, URL source, SpeakableListener listener) throws JSMLException, IOException
Sets queue item data with a `URL` source.

Parameters:
  `synth` - the synthesizer
  `source` - the `URL` containing JSML text
  `listener` - the `SpeakableListener` to be notified as this object is processed

### getDocument

protected Document getDocument()
Gets the DOM document for this object.

Returns:
  the DOM document for this object.

### isCancelled

protected boolean isCancelled()
determines if this queue item has been canceled

Returns:
  `true` if this item has been canceled; otherwise `false`

### isCompleted

public boolean isCompleted()
returns true if this queue item has been processed.

Returns:
  true if it has been processed

### waitCompleted

public boolean waitCompleted()
wait for this queue item to be completed

Returns:
  true if the item was completed successfully, false if the item was canceled or an error occurred.

### cancelled

public void cancelled()
indicate that this item has been canceled

### completed

public void completed()
indicate that this item has been completed

### started

public void started()
indicate that this item has been started

### getItemNumber

public int getItemNumber()
Gets the item number for debug purposes only. Each queue item is given a unique ID.

Returns:
  the unique ID for this queue item

### postMarkerReached

public void postMarkerReached(String text, int markerType)
Utility function that generates a `MARKER_REACHED` event and posts it to the event queue. Eventually `fireMarkerReached` will be called by `dispatchSpeechEvent` as a result of this action.

Parameters:
  `text` - the text of the marker
  `markerType` - the type of marker
See Also:
  - invalid reference

        SpeakableEvent#getMarkerType

  - `fireMarkerReached(SpeakableEvent)`
  - `dispatchSpeechEvent(SpeechEvent)`

### fireMarkerReached

public void fireMarkerReached(SpeakableEvent event)
Utility function that sends a `MARKER_REACHED` event to all speakable listeners.

Parameters:
  `event` - the `MARKER_REACHED` event
See Also:
  - `postMarkerReached(java.lang.String, int)`

### postSpeakableCancelled

public void postSpeakableCancelled()
Utility function that generates a `SPEAKABLE_CANCELLED` event and posts it to the event queue. Eventually `fireSpeakableCancelled` will be called by `dispatchSpeechEvent` as a result of this action.

See Also:
  - `fireSpeakableCancelled(SpeakableEvent)`
  - `dispatchSpeechEvent(SpeechEvent)`

### fireSpeakableCancelled

public void fireSpeakableCancelled(SpeakableEvent event)
Utility function that sends a `SPEAKABLE_CANCELLED` event to all speakable listeners.

Parameters:
  `event` - the `SPEAKABLE_CANCELLED` event
See Also:
  - `postSpeakableCancelled()`

### postSpeakableEnded

public void postSpeakableEnded()
Utility function that generates a `SPEAKABLE_ENDED` event and posts it to the event queue. Eventually `fireSpeakableEnded` will be called by `dispatchSpeechEvent` as a result of this action.

See Also:
  - `fireSpeakableEnded(SpeakableEvent)`
  - `dispatchSpeechEvent(SpeechEvent)`

### fireSpeakableEnded

public void fireSpeakableEnded(SpeakableEvent event)
Utility function that sends a `SPEAKABLE_ENDED` event to all speakable listeners.

Parameters:
  `event` - the `SPEAKABLE_ENDED` event
See Also:
  - `postSpeakableEnded()`

### postSpeakablePaused

public void postSpeakablePaused()
Utility function that generates a `SPEAKABLE_PAUSED` event and posts it to the event queue. Eventually `fireSpeakablePaused` will be called by `dispatchSpeechEvent` as a result of this action.

See Also:
  - `fireSpeakablePaused(SpeakableEvent)`
  - `dispatchSpeechEvent(SpeechEvent)`

### fireSpeakablePaused

public void fireSpeakablePaused(SpeakableEvent event)
Utility function that sends a `SPEAKABLE_PAUSED` event to all speakable listeners.

Parameters:
  `event` - the `SPEAKABLE_PAUSED` event
See Also:
  - `postSpeakablePaused()`

### postSpeakableResumed

public void postSpeakableResumed()
Utility function that generates a `SPEAKABLE_RESUMED` event and posts it to the event queue. Eventually `fireSpeakableResumed` will be called by `dispatchSpeechEvent` as a result of this action.

See Also:
  - `fireSpeakableResumed(SpeakableEvent)`
  - `dispatchSpeechEvent(SpeechEvent)`

### fireSpeakableResumed

public void fireSpeakableResumed(SpeakableEvent event)
Utility function that sends a `SPEAKABLE_RESUMED` event to all speakable listeners.

Parameters:
  `event` - the `SPEAKABLE_RESUMED` event
See Also:
  - `postSpeakableResumed()`

### postSpeakableStarted

public void postSpeakableStarted()
Utility function that generates a `SPEAKABLE_STARTED` event and posts it to the event queue. Eventually `fireSpeakableStarted` will be called by `dispatchSpeechEvent` as a result of this action.

See Also:
  - `fireSpeakableStarted(SpeakableEvent)`
  - `dispatchSpeechEvent(SpeechEvent)`

### fireSpeakableStarted

public void fireSpeakableStarted(SpeakableEvent event)
Utility function that sends a `SPEAKABLE_STARTED` event to all speakable listeners.

Parameters:
  `event` - the `SPEAKABLE_STARTED` event
See Also:
  - `postSpeakableStarted()`

### postTopOfQueue

public void postTopOfQueue()
Utility function that generates a `TOP_OF_QUEUE` event and posts it to the event queue. Eventually `fireTopOfQueue` will be called by `dispatchSpeechEvent` as a result of this action.

See Also:
  - `fireTopOfQueue(SpeakableEvent)`
  - `dispatchSpeechEvent(SpeechEvent)`

### fireTopOfQueue

public void fireTopOfQueue(SpeakableEvent event)
Utility function that sends a `TOP_OF_QUEUE` event to all speakable listeners.

Parameters:
  `event` - the `TOP_OF_QUEUE` event
See Also:
  - `postTopOfQueue()`

### postWordStarted

public void postWordStarted(String text, int wordStart, int wordEnd)
Utility function that generates a `WORD_STARTED` event and posts it to the event queue. Eventually `fireWordStarted` will be called by `dispatchSpeechEvent` as a result of this action.

See Also:
  - `fireWordStarted(SpeakableEvent)`
  - `dispatchSpeechEvent(SpeechEvent)`

### fireWordStarted

public void fireWordStarted(SpeakableEvent event)
Utility function that sends a `WORD_STARTED` event to all speakable listeners.

Parameters:
  `event` - the `WORD_STARTED` event
See Also:
  - `postWordStarted(java.lang.String, int, int)`

### dispatchSpeechEvent

public void dispatchSpeechEvent(SpeechEvent event)
Dispatches a `SpeechEvent`. The dispatcher should notify all `EngineListeners` from this method. The `SpeechEvent` was added via the various post methods of this class.

Specified by:
  `dispatchSpeechEvent` in interface `SpeechEventDispatcher`
Parameters:
  `event` - the `SpeechEvent` to dispatch
See Also:
  - `postMarkerReached(java.lang.String, int)`
  - `postSpeakableCancelled()`
  - `postSpeakableEnded()`
  - `postSpeakablePaused()`
  - `postSpeakableResumed()`
  - `postSpeakableStarted()`
  - `postTopOfQueue()`
  - `postWordStarted(java.lang.String, int, int)`