com.ibm.as400.vaccess
Class IFSTextFileDocument

java.lang.Object
  extended bycom.ibm.as400.vaccess.IFSTextFileDocument
All Implemented Interfaces:
Document, Serializable, StyledDocument

Deprecated. Use Java Swing instead, along with the classes in package com.ibm.as400.access

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 a server. You must explicitly call load() to load the information from the server.

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 a server. 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(new JScrollPane(textArea));
// Load the information from the server. document.load ();

See Also:
Serialized Form

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

Constructor Detail

IFSTextFileDocument

public IFSTextFileDocument()
Deprecated. 
Constructs a IFSTextFileDocument object.


IFSTextFileDocument

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

Parameters:
file - The file.

IFSTextFileDocument

public IFSTextFileDocument(AS400 system,
                           String path)
Deprecated. 
Constructs a IFSTextFileDocument object.

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

addDocumentListener

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

Specified by:
addDocumentListener in interface Document
Parameters:
listener - The listener.

addErrorListener

public void addErrorListener(ErrorListener listener)
Deprecated. 
Adds a listener to be notified when an error occurs.

Parameters:
listener - The listener.

addFileListener

public void addFileListener(FileListener listener)
Deprecated. 
Adds a listener to be notified when a file event occurs.

Parameters:
listener - The listener.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Deprecated. 
Adds a listener to be notified when the value of any bound property changes.

Parameters:
listener - The listener.

addStyle

public Style addStyle(String name,
                      Style parent)
Deprecated. 
Adds a style into the logical style hierarchy.

Specified by:
addStyle in interface StyledDocument
Parameters:
name - The name of the style.
parent - The parent style.
Returns:
The style.

addUndoableEditListener

public void addUndoableEditListener(UndoableEditListener listener)
Deprecated. 
Adds an undoable edit listener to be notified when undoable edits are made to the document.

Specified by:
addUndoableEditListener in interface Document
Parameters:
listener - The listener.

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener listener)
Deprecated. 
Adds a listener to be notified when the value of any constrained property changes.

Parameters:
listener - The listener.

addWorkingListener

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

Parameters:
listener - The listener.

createPosition

public Position createPosition(int offset)
                        throws BadLocationException
Deprecated. 
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.

Specified by:
createPosition in interface Document
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.

getBackground

public Color getBackground(AttributeSet attributes)
Deprecated. 
Returns the background color based on a set of attributes.

Specified by:
getBackground in interface StyledDocument
Parameters:
attributes - The attributes.
Returns:
The background color.

getCharacterElement

public Element getCharacterElement(int offset)
Deprecated. 
Returns the element that represents the character that is at a given offset within the document.

Specified by:
getCharacterElement in interface StyledDocument
Parameters:
offset - The offset to the character.
Returns:
The element.

getDefaultRootElement

public Element getDefaultRootElement()
Deprecated. 
Returns the root element that views should be based upon unless some other mechanism for assigning views to element structures is provided.

Specified by:
getDefaultRootElement in interface Document
Returns:
The root element.

getEndPosition

public Position getEndPosition()
Deprecated. 
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.

Specified by:
getEndPosition in interface Document
Returns:
The end position of the document.

getFont

public Font getFont(AttributeSet attributes)
Deprecated. 
Returns the font based on a set of attributes.

Specified by:
getFont in interface StyledDocument
Parameters:
attributes - The attributes.
Returns:
The font.

getForeground

public Color getForeground(AttributeSet attributes)
Deprecated. 
Returns the foreground color based on a set of attributes.

Specified by:
getForeground in interface StyledDocument
Parameters:
attributes - The attributes.
Returns:
The foreground color.

getLength

public int getLength()
Deprecated. 
Returns the length of the document.

Specified by:
getLength in interface Document
Returns:
The length of the document in characters.

getLogicalStyle

public Style getLogicalStyle(int offset)
Deprecated. 
Returns the logical style for a given offset within the document.

Specified by:
getLogicalStyle in interface StyledDocument
Parameters:
offset - The offset within the document.
Returns:
The logical style at the specified offset.

getParagraphElement

public Element getParagraphElement(int offset)
Deprecated. 
Returns the element that represents the paragraph that encloses a given offset within the document.

Specified by:
getParagraphElement in interface StyledDocument
Parameters:
offset - The offset within the document.
Returns:
The element that represents the paragraph.

getPath

public String getPath()
Deprecated. 
The path name of the file.

Returns:
The path name of the file, or "" if the path has not been set.

getProperty

public Object getProperty(Object key)
Deprecated. 
Returns a property value associated with the document.

Specified by:
getProperty in interface Document
Parameters:
key - The property key.
Returns:
The property value.

getRootElements

public Element[] getRootElements()
Deprecated. 
Returns the root elements.

Specified by:
getRootElements in interface Document
Returns:
The root elements.

getStartPosition

public Position getStartPosition()
Deprecated. 
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.

Specified by:
getStartPosition in interface Document
Returns:
The start position of the document.

getStyle

public Style getStyle(String name)
Deprecated. 
Returns a named style.

Specified by:
getStyle in interface StyledDocument
Parameters:
name - The name of the style.
Returns:
The style.

getSystem

public AS400 getSystem()
Deprecated. 
Returns the system on which the file resides.

Returns:
The system, or null if the system has not been set.

getText

public String getText(int offset,
                      int length)
               throws BadLocationException
Deprecated. 
Returns the text contained within the specified portion of the document.

Specified by:
getText in interface 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.

getText

public void getText(int offset,
                    int length,
                    Segment text)
             throws BadLocationException
Deprecated. 
Stores the text contained within the specified portion of the document in a segment.

Specified by:
getText in interface Document
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.

insertString

public void insertString(int offset,
                         String text,
                         AttributeSet attributes)
                  throws BadLocationException
Deprecated. 
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.

Specified by:
insertString in interface Document
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.

isModified

public boolean isModified()
Deprecated. 
Indicates if the document has been modified since it was last read or written.

Returns:
true if the document has been modified; false otherwise.

load

public void load()
Deprecated. 
Loads the contents of the document from the file on the server.


putProperty

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

Specified by:
putProperty in interface Document
Parameters:
key - The property key.
value - The property value.

remove

public void remove(int offset,
                   int length)
            throws BadLocationException
Deprecated. 
Removes text from the document.

Specified by:
remove in interface 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.

removeDocumentListener

public void removeDocumentListener(DocumentListener listener)
Deprecated. 
Removes a document listener.

Specified by:
removeDocumentListener in interface Document
Parameters:
listener - The listener.

removeErrorListener

public void removeErrorListener(ErrorListener listener)
Deprecated. 
Removes an error listener.

Parameters:
listener - The listener.

removeFileListener

public void removeFileListener(FileListener listener)
Deprecated. 
Removes a file listener.

Parameters:
listener - The listener.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Deprecated. 
Removes a property change listener.

Parameters:
listener - The listener.

removeStyle

public void removeStyle(String name)
Deprecated. 
Removes a style from the logical style hierarchy.

Specified by:
removeStyle in interface StyledDocument
Parameters:
name - The name of the style.

removeUndoableEditListener

public void removeUndoableEditListener(UndoableEditListener listener)
Deprecated. 
Removes an undoable edit listener.

Specified by:
removeUndoableEditListener in interface Document
Parameters:
listener - The listener.

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener listener)
Deprecated. 
Removes a vetoable change listener.

Parameters:
listener - The listener.

removeWorkingListener

public void removeWorkingListener(WorkingListener listener)
Deprecated. 
Removes a working listener.

Parameters:
listener - The listener.

render

public void render(Runnable runnable)
Deprecated. 
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.

Specified by:
render in interface Document
Parameters:
runnable - The runnable.

save

public void save()
Deprecated. 
Saves the contents of the document to the file on the server. This will creates the file if it does not already exist.


setCharacterAttributes

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

Specified by:
setCharacterAttributes in interface StyledDocument
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.

setLogicalStyle

public void setLogicalStyle(int offset,
                            Style style)
Deprecated. 
Sets the logical style for a given offset within the document.

Specified by:
setLogicalStyle in interface StyledDocument
Parameters:
offset - The offset within the document.
style - The logical style.

setParagraphAttributes

public void setParagraphAttributes(int offset,
                                   int length,
                                   AttributeSet attributes,
                                   boolean replace)
Deprecated. 
Sets the element attributes used for the paragraphs enclosing the given range of existing content in the document.

Specified by:
setParagraphAttributes in interface StyledDocument
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.

setPath

public void setPath(String path)
             throws PropertyVetoException
Deprecated. 
Sets the path name of the file.

Parameters:
path - The path name of the file.
Throws:
PropertyVetoException - If the change is vetoed.

setSystem

public void setSystem(AS400 system)
               throws PropertyVetoException
Deprecated. 
Sets the system on which the file resides.

Parameters:
system - The system on which the file resides.
Throws:
PropertyVetoException - If the change is vetoed.

toString

public String toString()
Deprecated. 
Returns the string representation. This is the name of the file.

Returns:
The string representation of the file name.