com.raritantechnologies.searchApp.swing
Class SwingResultSet

java.lang.Object
  extended bycom.raritantechnologies.searchApp.swing.SwingResultSet
All Implemented Interfaces:
javax.swing.text.Document, IResultSet, javax.swing.text.StyledDocument

public abstract class SwingResultSet
extends java.lang.Object
implements javax.swing.text.StyledDocument, IResultSet


Field Summary
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Fields inherited from interface com.raritantechnologies.searchApp.IResultSet
ELAPSEDTIME, PAGESIZE, QUERYSTRING, RESULTSETID, STARTDOC, TOTALDOCS
 
Constructor Summary
SwingResultSet(IResultSet resultSet)
           
SwingResultSet(IResultSet resultSet, IDisplayFormRenderer displayRenderer)
           
 
Method Summary
 void addDocumentListener(javax.swing.event.DocumentListener listener)
           
 javax.swing.text.Style addStyle(java.lang.String nm, javax.swing.text.Style parent)
          addUndoableEditListener public void addUndoableEditListener(UndoableEditListener listener) Registers the given observer to begin receiving notifications when undoable edits are made to the document.
 java.awt.Color getBackground(javax.swing.text.AttributeSet attr)
           
 Element getCharacterElement(int pos)
           
 java.awt.Font getFont(javax.swing.text.AttributeSet attr)
           
 java.awt.Color getForeground(javax.swing.text.AttributeSet attr)
           
 int getLength()
           
 javax.swing.text.Style getLogicalStyle(int p)
           
 Element getParagraphElement(int pos)
           
 javax.swing.text.Style getStyle(java.lang.String nm)
           
 void removeDocumentListener(javax.swing.event.DocumentListener listener)
           
 void removeStyle(java.lang.String nm)
           
 void setCharacterAttributes(int offset, int length, javax.swing.text.AttributeSet attrSet, boolean replace)
           
 void setLogicalStyle(int pos, javax.swing.text.Style s)
           
 void setParagraphAttributes(int offset, int length, javax.swing.text.AttributeSet attrSet, boolean replace)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.text.Document
addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeUndoableEditListener, render
 
Methods inherited from interface com.raritantechnologies.searchApp.IResultSet
addAttribute, addResult, getAttribute, getAttributes, getElapsedTime, getElapsedTimeMS, getEndDoc, getNavigator, getPageSize, getQueryString, getResult, getResults, getResults, getResultSetID, getStartDoc, getTotalDocs, getXML, getXML, getXML, setElapsedTimeMS, setNavigator, setPageSize, setQueryString, setResultSetID, setStartDoc, setTotalDocs, size, toString
 

Constructor Detail

SwingResultSet

public SwingResultSet(IResultSet resultSet)

SwingResultSet

public SwingResultSet(IResultSet resultSet,
                      IDisplayFormRenderer displayRenderer)
Method Detail

getLength

public int getLength()
Specified by:
getLength in interface javax.swing.text.Document

addDocumentListener

public void addDocumentListener(javax.swing.event.DocumentListener listener)
Specified by:
addDocumentListener in interface javax.swing.text.Document

removeDocumentListener

public void removeDocumentListener(javax.swing.event.DocumentListener listener)
Specified by:
removeDocumentListener in interface javax.swing.text.Document

addStyle

public javax.swing.text.Style addStyle(java.lang.String nm,
                                       javax.swing.text.Style parent)
addUndoableEditListener public void addUndoableEditListener(UndoableEditListener listener) Registers the given observer to begin receiving notifications when undoable edits are made to the document. Parameters: listener - the observer to register See Also: UndoableEditEvent -------------------------------------------------------------------------------- removeUndoableEditListener public void removeUndoableEditListener(UndoableEditListener listener) Unregisters the given observer from the notification list so it will no longer receive updates. Parameters: listener - the observer to register See Also: UndoableEditEvent -------------------------------------------------------------------------------- getProperty public Object getProperty(Object key) Gets the properties associated with the document. Parameters: key - a non-null property key Returns: the properties See Also: putProperty(Object, Object) -------------------------------------------------------------------------------- putProperty public void putProperty(Object key, Object value) Associates a property with the document. Two standard property keys provided are: StreamDescriptionProperty and TitleProperty. Other properties, such as author, may also be defined. Parameters: key - the non-null property key value - the property value See Also: getProperty(Object) -------------------------------------------------------------------------------- remove public void remove(int offs, int len) throws BadLocationException Removes a portion of the content of the document. This will cause a DocumentEvent of type DocumentEvent.EventType.REMOVE to be sent to the registered DocumentListeners, unless an exception is thrown. The notification will be sent to the listeners by calling the removeUpdate method on the DocumentListeners. To ensure reasonable behavior in the face of concurrency, the event is dispatched after the mutation has occurred. This means that by the time a notification of removal is dispatched, the document has already been updated and any marks created by createPosition have already changed. For a removal, the end of the removal range is collapsed down to the start of the range, and any marks in the removal range are collapsed down to the start of the range. If the Document structure changed as result of the removal, the details of what Elements were inserted and removed in response to the change will also be contained in the generated DocumentEvent. It is up to the implementation of a Document to decide how the structure should change in response to a remove. If the Document supports undo/redo, an UndoableEditEvent will also be generated. Parameters: offs - the offset from the beginning >= 0 len - the number of characters to remove >= 0 Throws: BadLocationException - some portion of the removal range was not a valid part of the document. The location in the exception is the first bad position encountered. See Also: DocumentEvent, DocumentListener, UndoableEditEvent, UndoableEditListener -------------------------------------------------------------------------------- insertString public void insertString(int offset, String str, AttributeSet a) throws BadLocationException Inserts a string of content. This will cause a DocumentEvent of type DocumentEvent.EventType.INSERT to be sent to the registered DocumentListers, unless an exception is thrown. The DocumentEvent will be delivered by calling the insertUpdate method on the DocumentListener. The offset and length of the generated DocumentEvent will indicate what change was actually made to the Document. If the Document structure changed as result of the insertion, the details of what Elements were inserted and removed in response to the change will also be contained in the generated DocumentEvent. It is up to the implementation of a Document to decide how the structure should change in response to an insertion. If the Document supports undo/redo, an UndoableEditEvent will also be generated. Parameters: offset - the offset into the document to insert the content >= 0. All positions that track change at or after the given location will move. str - the string to insert a - the attributes to associate with the inserted content. This may be null if there are no attributes. Throws: BadLocationException - the given insert position is not a valid position within the document See Also: DocumentEvent, DocumentListener, UndoableEditEvent, UndoableEditListener -------------------------------------------------------------------------------- getText public String getText(int offset, int length) throws BadLocationException Fetches the text contained within the given portion of the document. Parameters: offset - the offset into the document representing the desired start of the text >= 0 length - the length of the desired string >= 0 Returns: the text, in a String of length >= 0 Throws: BadLocationException - some portion of the given range was not a valid part of the document. The location in the exception is the first bad position encountered. -------------------------------------------------------------------------------- getText public void getText(int offset, int length, Segment txt) throws BadLocationException Fetches the text contained within the given portion of the document. If the partialReturn property on the txt parameter is false, the data returned in the Segment will be the entire length requested and may or may not be a copy depending upon how the data was stored. If the partialReturn property is true, only the amount of text that can be returned without creating a copy is returned. Using partial returns will give better performance for situations where large parts of the document are being scanned. The following is an example of using the partial return to access the entire document: int nleft = doc.getDocumentLength(); Segment text = new Segment(); int offs = 0; text.setPartialReturn(true); while (nleft > 0) { doc.getText(offs, nleft, text); // do someting with text nleft -= text.count; offs += text.count; } Parameters: offset - the offset into the document representing the desired start of the text >= 0 length - the length of the desired string >= 0 txt - the Segment object to return the text in Throws: BadLocationException - Some portion of the given range was not a valid part of the document. The location in the exception is the first bad position encountered. -------------------------------------------------------------------------------- getStartPosition public Position getStartPosition() Returns a position that represents the start of the document. The position returned can be counted on to track change and stay located at the beginning of the document. Returns: the position -------------------------------------------------------------------------------- getEndPosition public Position getEndPosition() Returns a position that represents the end of the document. The position returned can be counted on to track change and stay located at the end of the document. Returns: the position -------------------------------------------------------------------------------- createPosition public Position createPosition(int offs) throws BadLocationException This method allows an application to mark a place in a sequence of character content. This mark can then be used to tracks change as insertions and removals are made in the content. The policy is that insertions always occur prior to the current position (the most common case) unless the insertion location is zero, in which case the insertion is forced to a position that follows the original position. Parameters: offs - the offset from the start of the document >= 0 Returns: the position Throws: BadLocationException - if the given position does not represent a valid location in the associated document -------------------------------------------------------------------------------- getRootElements public Element[] getRootElements() Returns all of the root elements that are defined. Typically there will be only one document structure, but the interface supports building an arbitrary number of structural projections over the text data. The document can have multiple root elements to support multiple document structures. Some examples might be: Text direction. Lexical token streams. Parse trees. Conversions to formats other than the native format. Modification specifications. Annotations. Returns: the root element -------------------------------------------------------------------------------- getDefaultRootElement public Element getDefaultRootElement() Returns the root element that views should be based upon, unless some other mechanism for assigning views to element structures is provided. Returns: the root element -------------------------------------------------------------------------------- render public void render(Runnable r) This allows the model to be safely rendered in the presence of currency, if the model supports being updated asynchronously. The given runnable will be executed in a way that allows it to safely read the model with no changes while the runnable is being executed. The runnable itself may not make any mutations.

Specified by:
addStyle in interface javax.swing.text.StyledDocument

removeStyle

public void removeStyle(java.lang.String nm)
Specified by:
removeStyle in interface javax.swing.text.StyledDocument

getStyle

public javax.swing.text.Style getStyle(java.lang.String nm)
Specified by:
getStyle in interface javax.swing.text.StyledDocument

setCharacterAttributes

public void setCharacterAttributes(int offset,
                                   int length,
                                   javax.swing.text.AttributeSet attrSet,
                                   boolean replace)
Specified by:
setCharacterAttributes in interface javax.swing.text.StyledDocument

setParagraphAttributes

public void setParagraphAttributes(int offset,
                                   int length,
                                   javax.swing.text.AttributeSet attrSet,
                                   boolean replace)
Specified by:
setParagraphAttributes in interface javax.swing.text.StyledDocument

setLogicalStyle

public void setLogicalStyle(int pos,
                            javax.swing.text.Style s)
Specified by:
setLogicalStyle in interface javax.swing.text.StyledDocument

getLogicalStyle

public javax.swing.text.Style getLogicalStyle(int p)
Specified by:
getLogicalStyle in interface javax.swing.text.StyledDocument

getParagraphElement

public Element getParagraphElement(int pos)
Specified by:
getParagraphElement in interface javax.swing.text.StyledDocument

getCharacterElement

public Element getCharacterElement(int pos)
Specified by:
getCharacterElement in interface javax.swing.text.StyledDocument

getForeground

public java.awt.Color getForeground(javax.swing.text.AttributeSet attr)
Specified by:
getForeground in interface javax.swing.text.StyledDocument

getBackground

public java.awt.Color getBackground(javax.swing.text.AttributeSet attr)
Specified by:
getBackground in interface javax.swing.text.StyledDocument

getFont

public java.awt.Font getFont(javax.swing.text.AttributeSet attr)
Specified by:
getFont in interface javax.swing.text.StyledDocument