All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.vaccess.IFSTextFileDocument

java.lang.Object
   |
   +----com.ibm.as400.vaccess.IFSTextFileDocument

public class IFSTextFileDocument
extends Object
implements StyledDocument, Serializable
The IFSTextFileDocument class implements an underlying model for text components, where the text is the contents of a text file located in the integrated file system of an AS/400. You must explicitly call load() to load the information from the AS/400.

Use this class in conjuction with any JTextComponent or any other component that works with the Document interface.

Most errors are reported as ErrorEvents rather than throwing exceptions. Users should listen for ErrorEvents in order to diagnose and recover from error conditions.

IFSTextFileDocument objects generate the following events:

The following example creates a document which contains the contents of a text file in the integrated file system of an AS/400. It then presents the document in a JTextArea object.

// Set up the document and the JTextArea.
AS400 system = new AS400 ("MySystem", "Userid", "Password");
IFSTextFileDocument document = new IFSTextFileDocument (system, "/myFile");
JTextArea textArea = new JTextArea (document);

// Add the JTextArea to a frame. JFrame frame = new JFrame ("My Window"); frame.getContentPane().add(JTable.createScrollPaneForTable(textArea));
// Load the information from the AS/400. document.load ();


Constructor Index

 o IFSTextFileDocument()
Constructs a IFSTextFileDocument object.
 o IFSTextFileDocument(AS400, String)
Constructs a IFSTextFileDocument object.
 o IFSTextFileDocument(IFSFile)
Constructs a IFSTextFileDocument object.

Method Index

 o addDocumentListener(DocumentListener)
Adds a listener to be notified when a document event occurs.
 o addErrorListener(ErrorListener)
Adds a listener to be notified when an error occurs.
 o addFileListener(FileListener)
Adds a listener to be notified when a file event occurs.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified when the value of any bound property changes.
 o addStyle(String, Style)
Adds a style into the logical style hierarchy.
 o addUndoableEditListener(UndoableEditListener)
Adds an undoable edit listener to be notified when undoable edits are made to the document.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a listener to be notified when the value of any constrained property changes.
 o addWorkingListener(WorkingListener)
Adds a listener to be notified when work starts and stops on potentially long-running operations.
 o createPosition(int)
Returns a position that will track change as the document is altered.
 o getBackground(AttributeSet)
Returns the background color based on a set of attributes.
 o getCharacterElement(int)
Returns the element that represents the character that is at a given offset within the document.
 o getDefaultRootElement()
Returns the root element that views should be based upon unless some other mechanism for assigning views to element structures is provided.
 o getEndPosition()
Returns a position that represents the end of the document.
 o getFont(AttributeSet)
Returns the font based on a set of attributes.
 o getForeground(AttributeSet)
Returns the foreground color based on a set of attributes.
 o getLength()
Returns the length of the document.
 o getLogicalStyle(int)
Returns the logical style for a given offset within the document.
 o getParagraphElement(int)
Returns the element that represents the paragraph that encloses a given offset within the document.
 o getPath()
The path name of the file.
 o getProperty(Object)
Returns a property value associated with the document.
 o getRootElements()
Returns the root elements.
 o getStartPosition()
Returns a position that represents the start of the document.
 o getStyle(String)
Returns a named style.
 o getSystem()
Returns the AS/400 system on which the file resides.
 o getText(int, int)
Returns the text contained within the specified portion of the document.
 o getText(int, int, Segment)
Stores the text contained within the specified portion of the document in a segment.
 o insertString(int, String, AttributeSet)
Inserts text into the document.
 o isModified()
Indicates if the document has been modified since it was last read or written.
 o load()
Loads the contents of the document from the file on the AS/400.
 o putProperty(Object, Object)
Sets a property value associated with the document.
 o remove(int, int)
Removes text from the document.
 o removeDocumentListener(DocumentListener)
Removes a document listener.
 o removeErrorListener(ErrorListener)
Removes an error listener.
 o removeFileListener(FileListener)
Removes a file listener.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a property change listener.
 o removeStyle(String)
Removes a style from the logical style hierarchy.
 o removeUndoableEditListener(UndoableEditListener)
Removes an undoable edit listener.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a vetoable change listener.
 o removeWorkingListener(WorkingListener)
Removes a working listener.
 o render(Runnable)
Renders the document.
 o save()
Saves the contents of the document to the file on the AS/400.
 o setCharacterAttributes(int, int, AttributeSet, boolean)
Sets the element attributes used for the given range of existing content in the document.
 o setLogicalStyle(int, Style)
Sets the logical style for a given offset within the document.
 o setParagraphAttributes(int, int, AttributeSet, boolean)
Sets the element attributes used for the paragraphs enclosing the given range of existing content in the document.
 o setPath(String)
Sets the path name of the file.
 o setSystem(AS400)
Sets the AS/400 system on which the file resides.
 o toString()
Returns the string representation.

Constructors

 o IFSTextFileDocument
 public IFSTextFileDocument()
Constructs a IFSTextFileDocument object.

 o IFSTextFileDocument
 public IFSTextFileDocument(IFSFile file)
Constructs a IFSTextFileDocument object.

Parameters:
file - The file.
 o IFSTextFileDocument
 public IFSTextFileDocument(AS400 system,
                            String path)
Constructs a IFSTextFileDocument object.

Parameters:
system - The AS/400 system on which the file resides.
path - The fully qualified path name of the file that this object represents.

Methods

 o addDocumentListener
 public void addDocumentListener(DocumentListener listener)
Adds a listener to be notified when a document event occurs.

Parameters:
listener - The listener.
 o addErrorListener
 public void addErrorListener(ErrorListener listener)
Adds a listener to be notified when an error occurs.

Parameters:
listener - The listener.
 o addFileListener
 public void addFileListener(FileListener listener)
Adds a listener to be notified when a file event occurs.

Parameters:
listener - The listener.
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound property changes.

Parameters:
listener - The listener.
 o addStyle
 public synchronized Style addStyle(String name,
                                    Style parent)
Adds a style into the logical style hierarchy.

Parameters:
name - The name of the style.
parent - The parent style.
Returns:
The style.
 o addUndoableEditListener
 public void addUndoableEditListener(UndoableEditListener listener)
Adds an undoable edit listener to be notified when undoable edits are made to the document.

Parameters:
listener - The listener.
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property changes.

Parameters:
listener - The listener.
 o addWorkingListener
 public void addWorkingListener(WorkingListener listener)
Adds a listener to be notified when work starts and stops on potentially long-running operations.

Parameters:
listener - The listener.
 o createPosition
 public synchronized Position createPosition(int offset) throws BadLocationException
Returns a position that will track change as the document is altered. If the relative position is null, then the start of the document will be used.

Parameters:
offset - The offset from the start of the document.
Returns:
The position.
Throws: BadLocationException
If the given offset does not represent a valid location in the document.
 o getBackground
 public synchronized Color getBackground(AttributeSet attributes)
Returns the background color based on a set of attributes.

Parameters:
attributes - The attributes.
Returns:
The background color.
 o getCharacterElement
 public synchronized Element getCharacterElement(int offset)
Returns the element that represents the character that is at a given offset within the document.

Parameters:
offset - The offset to the character.
Returns:
The element.
 o getDefaultRootElement
 public synchronized 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.
 o getEndPosition
 public synchronized 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 end position of the document.
 o getFont
 public synchronized Font getFont(AttributeSet attributes)
Returns the font based on a set of attributes.

Parameters:
attributes - The attributes.
Returns:
The font.
 o getForeground
 public synchronized Color getForeground(AttributeSet attributes)
Returns the foreground color based on a set of attributes.

Parameters:
attributes - The attributes.
Returns:
The foreground color.
 o getLength
 public synchronized int getLength()
Returns the length of the document.

Returns:
The length of the document in characters.
 o getLogicalStyle
 public synchronized Style getLogicalStyle(int offset)
Returns the logical style for a given offset within the document.

Parameters:
offset - The offset within the document.
Returns:
The logical style at the specified offset.
 o getParagraphElement
 public synchronized Element getParagraphElement(int offset)
Returns the element that represents the paragraph that encloses a given offset within the document.

Parameters:
offset - The offset within the document.
Returns:
The element that represents the paragraph.
 o getPath
 public String getPath()
The path name of the file.

Returns:
The path name of the file, or "" if the path has not been set.
 o getProperty
 public synchronized Object getProperty(Object key)
Returns a property value associated with the document.

Parameters:
key - The property key.
Returns:
The property value.
 o getRootElements
 public synchronized Element[] getRootElements()
Returns the root elements.

Returns:
The root elements.
 o getStartPosition
 public synchronized 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 start position of the document.
 o getStyle
 public synchronized Style getStyle(String name)
Returns a named style.

Parameters:
name - The name of the style.
Returns:
The style.
 o getSystem
 public AS400 getSystem()
Returns the AS/400 system on which the file resides.

Returns:
The system, or null if the system has not been set.
 o getText
 public synchronized String getText(int offset,
                                    int length) throws BadLocationException
Returns the text contained within the specified portion of the document.

Parameters:
offset - The offset into the document representing the desired start of the text.
length - The length of the text.
Returns:
The text.
Throws: BadLocationException
If the given offset and length does not represent a valid range in the document.
 o getText
 public synchronized void getText(int offset,
                                  int length,
                                  Segment text) throws BadLocationException
Stores the text contained within the specified portion of the document in a segment.

Parameters:
offset - The offset into the document representing the desired start of the text.
length - The length of the text.
text - The segment in which to store the text.
Throws: BadLocationException
If the given offset and length does not represent a valid range in the document.
 o insertString
 public synchronized void insertString(int offset,
                                       String text,
                                       AttributeSet attributes) throws BadLocationException
Inserts text into the document. A position marks a location in the document between items. If the attributes that have been defined exactly match the current attributes defined at the position, the element representing the content at that position will simply be expanded. If the attributes defined are different, a new content element will be created that matches the attributes.

Parameters:
offset - The offset into the document representing the insertion position.
text - The text.
attributes - The attributes to associate with the inserted content, or null if there are no attributes.
Throws: BadLocationException
If the given offset does not represent a valid position in the document.
 o isModified
 public boolean isModified()
Indicates if the document has been modified since it was last read or written.

Returns:
true if the document has been modified; false otherwise.
 o load
 public void load()
Loads the contents of the document from the file on the AS/400.

 o putProperty
 public synchronized void putProperty(Object key,
                                      Object value)
Sets a property value associated with the document.

Parameters:
key - The property key.
value - The property value.
 o remove
 public synchronized void remove(int offset,
                                 int length) throws BadLocationException
Removes text from the document.

Parameters:
offset - The offset into the document representing the desired start of the text.
length - The length of the text.
Throws: BadLocationException
If the given offset and length does not represent a valid range in the document.
 o removeDocumentListener
 public void removeDocumentListener(DocumentListener listener)
Removes a document listener.

Parameters:
listener - The listener.
 o removeErrorListener
 public void removeErrorListener(ErrorListener listener)
Removes an error listener.

Parameters:
listener - The listener.
 o removeFileListener
 public void removeFileListener(FileListener listener)
Removes a file listener.

Parameters:
listener - The listener.
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change listener.

Parameters:
listener - The listener.
 o removeStyle
 public synchronized void removeStyle(String name)
Removes a style from the logical style hierarchy.

Parameters:
name - The name of the style.
 o removeUndoableEditListener
 public void removeUndoableEditListener(UndoableEditListener listener)
Removes an undoable edit listener.

Parameters:
listener - The listener.
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a vetoable change listener.

Parameters:
listener - The listener.
 o removeWorkingListener
 public void removeWorkingListener(WorkingListener listener)
Removes a working listener.

Parameters:
listener - The listener.
 o render
 public void render(Runnable runnable)
Renders the document. 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.

Parameters:
runnable - The runnable.
 o save
 public void save()
Saves the contents of the document to the file on the AS/400. This will creates the file if it does not already exist.

 o setCharacterAttributes
 public synchronized void setCharacterAttributes(int offset,
                                                 int length,
                                                 AttributeSet attributes,
                                                 boolean replace)
Sets the element attributes used for the given range of existing content in the document.

Parameters:
offset - The offset to the start of the change.
length - The length of the change.
attributes - The attributes.
replace - Indicates whether or not the previous attributes should be cleared before the new attributes are set. If true, true to replace the previous attributes with these attributes; false to merge them.
 o setLogicalStyle
 public synchronized void setLogicalStyle(int offset,
                                          Style style)
Sets the logical style for a given offset within the document.

Parameters:
offset - The offset within the document.
style - The logical style.
 o setParagraphAttributes
 public synchronized void setParagraphAttributes(int offset,
                                                 int length,
                                                 AttributeSet attributes,
                                                 boolean replace)
Sets the element attributes used for the paragraphs enclosing the given range of existing content in the document.

Parameters:
offset - The offset to the start of the change.
length - The length of the change.
attributes - The attributes.
replace - Indicates whether or not the previous attributes should be cleared before the new attributes are set. If true, this will replace the previous attributes entirely. If false, the new attributes will be merged with the previous attributes.
 o setPath
 public void setPath(String path) throws PropertyVetoException
Sets the path name of the file.

Parameters:
path - The path name of the file.
Throws: PropertyVetoException
If the change is vetoed.
 o setSystem
 public void setSystem(AS400 system) throws PropertyVetoException
Sets the AS/400 system on which the file resides.

Parameters:
system - The AS/400 system on which the file resides.
Throws: PropertyVetoException
If the change is vetoed.
 o toString
 public String toString()
Returns the string representation. This is the name of the file.

Returns:
The string representation of the file name.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index