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