public class IFSTextFileDocument
extends java.lang.Object
implements javax.swing.text.StyledDocument, java.io.Serializable
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 system. 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 system. document.load ();
Constructor and Description |
---|
IFSTextFileDocument()
Deprecated.
Constructs a IFSTextFileDocument object.
|
IFSTextFileDocument(AS400 system,
java.lang.String path)
Deprecated.
Constructs a IFSTextFileDocument object.
|
IFSTextFileDocument(IFSFile file)
Deprecated.
Constructs a IFSTextFileDocument object.
|
Modifier and Type | Method and Description |
---|---|
void |
addDocumentListener(javax.swing.event.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(java.beans.PropertyChangeListener listener)
Deprecated.
Adds a listener to be notified when the value of any
bound property changes.
|
javax.swing.text.Style |
addStyle(java.lang.String name,
javax.swing.text.Style parent)
Deprecated.
Adds a style into the logical style hierarchy.
|
void |
addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Deprecated.
Adds an undoable edit listener to be notified when undoable
edits are made to the document.
|
void |
addVetoableChangeListener(java.beans.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.
|
javax.swing.text.Position |
createPosition(int offset)
Deprecated.
Returns a position that will track change as the document is altered.
|
java.awt.Color |
getBackground(javax.swing.text.AttributeSet attributes)
Deprecated.
Returns the background color based on a set of attributes.
|
javax.swing.text.Element |
getCharacterElement(int offset)
Deprecated.
Returns the element that represents the character that is at
a given offset within the document.
|
javax.swing.text.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.
|
javax.swing.text.Position |
getEndPosition()
Deprecated.
Returns a position that represents the end of the document.
|
java.awt.Font |
getFont(javax.swing.text.AttributeSet attributes)
Deprecated.
Returns the font based on a set of attributes.
|
java.awt.Color |
getForeground(javax.swing.text.AttributeSet attributes)
Deprecated.
Returns the foreground color based on a set of attributes.
|
int |
getLength()
Deprecated.
Returns the length of the document.
|
javax.swing.text.Style |
getLogicalStyle(int offset)
Deprecated.
Returns the logical style for a given offset within the document.
|
javax.swing.text.Element |
getParagraphElement(int offset)
Deprecated.
Returns the element that represents the paragraph that encloses
a given offset within the document.
|
java.lang.String |
getPath()
Deprecated.
The path name of the file.
|
java.lang.Object |
getProperty(java.lang.Object key)
Deprecated.
Returns a property value associated with the document.
|
javax.swing.text.Element[] |
getRootElements()
Deprecated.
Returns the root elements.
|
javax.swing.text.Position |
getStartPosition()
Deprecated.
Returns a position that represents the start of the document.
|
javax.swing.text.Style |
getStyle(java.lang.String name)
Deprecated.
Returns a named style.
|
AS400 |
getSystem()
Deprecated.
Returns the system on which the file resides.
|
java.lang.String |
getText(int offset,
int length)
Deprecated.
Returns the text contained within the specified portion of
the document.
|
void |
getText(int offset,
int length,
javax.swing.text.Segment text)
Deprecated.
Stores the text contained within the specified portion of
the document in a segment.
|
void |
insertString(int offset,
java.lang.String text,
javax.swing.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
system.
|
void |
putProperty(java.lang.Object key,
java.lang.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(javax.swing.event.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(java.beans.PropertyChangeListener listener)
Deprecated.
Removes a property change listener.
|
void |
removeStyle(java.lang.String name)
Deprecated.
Removes a style from the logical style hierarchy.
|
void |
removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Deprecated.
Removes an undoable edit listener.
|
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Deprecated.
Removes a vetoable change listener.
|
void |
removeWorkingListener(WorkingListener listener)
Deprecated.
Removes a working listener.
|
void |
render(java.lang.Runnable runnable)
Deprecated.
Renders the document.
|
void |
save()
Deprecated.
Saves the contents of the document to the file on the system.
|
void |
setCharacterAttributes(int offset,
int length,
javax.swing.text.AttributeSet attributes,
boolean replace)
Deprecated.
Sets the element attributes used for the given range of
existing content in the document.
|
void |
setLogicalStyle(int offset,
javax.swing.text.Style style)
Deprecated.
Sets the logical style for a given offset within the document.
|
void |
setParagraphAttributes(int offset,
int length,
javax.swing.text.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(java.lang.String path)
Deprecated.
Sets the path name of the file.
|
void |
setSystem(AS400 system)
Deprecated.
Sets the system on which the file resides.
|
java.lang.String |
toString()
Deprecated.
Returns the string representation.
|
public IFSTextFileDocument()
public IFSTextFileDocument(IFSFile file)
file
- The file.public IFSTextFileDocument(AS400 system, java.lang.String path)
system
- The system on which the file resides.path
- The fully qualified path name of the file that this object represents.public void addDocumentListener(javax.swing.event.DocumentListener listener)
addDocumentListener
in interface javax.swing.text.Document
listener
- The listener.public void addErrorListener(ErrorListener listener)
listener
- The listener.public void addFileListener(FileListener listener)
listener
- The listener.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener.public javax.swing.text.Style addStyle(java.lang.String name, javax.swing.text.Style parent)
addStyle
in interface javax.swing.text.StyledDocument
name
- The name of the style.parent
- The parent style.public void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
addUndoableEditListener
in interface javax.swing.text.Document
listener
- The listener.public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The listener.public void addWorkingListener(WorkingListener listener)
listener
- The listener.public javax.swing.text.Position createPosition(int offset) throws javax.swing.text.BadLocationException
createPosition
in interface javax.swing.text.Document
offset
- The offset from the start of the document.javax.swing.text.BadLocationException
- If the given offset does not
represent a valid location in the
document.public java.awt.Color getBackground(javax.swing.text.AttributeSet attributes)
getBackground
in interface javax.swing.text.StyledDocument
attributes
- The attributes.public javax.swing.text.Element getCharacterElement(int offset)
getCharacterElement
in interface javax.swing.text.StyledDocument
offset
- The offset to the character.public javax.swing.text.Element getDefaultRootElement()
getDefaultRootElement
in interface javax.swing.text.Document
public javax.swing.text.Position getEndPosition()
getEndPosition
in interface javax.swing.text.Document
public java.awt.Font getFont(javax.swing.text.AttributeSet attributes)
getFont
in interface javax.swing.text.StyledDocument
attributes
- The attributes.public java.awt.Color getForeground(javax.swing.text.AttributeSet attributes)
getForeground
in interface javax.swing.text.StyledDocument
attributes
- The attributes.public int getLength()
getLength
in interface javax.swing.text.Document
public javax.swing.text.Style getLogicalStyle(int offset)
getLogicalStyle
in interface javax.swing.text.StyledDocument
offset
- The offset within the document.public javax.swing.text.Element getParagraphElement(int offset)
getParagraphElement
in interface javax.swing.text.StyledDocument
offset
- The offset within the document.public java.lang.String getPath()
public java.lang.Object getProperty(java.lang.Object key)
getProperty
in interface javax.swing.text.Document
key
- The property key.public javax.swing.text.Element[] getRootElements()
getRootElements
in interface javax.swing.text.Document
public javax.swing.text.Position getStartPosition()
getStartPosition
in interface javax.swing.text.Document
public javax.swing.text.Style getStyle(java.lang.String name)
getStyle
in interface javax.swing.text.StyledDocument
name
- The name of the style.public AS400 getSystem()
public java.lang.String getText(int offset, int length) throws javax.swing.text.BadLocationException
getText
in interface javax.swing.text.Document
offset
- The offset into the document representing
the desired start of the text.length
- The length of the text.javax.swing.text.BadLocationException
- If the given offset and length does
not represent a valid range in the
document.public void getText(int offset, int length, javax.swing.text.Segment text) throws javax.swing.text.BadLocationException
getText
in interface javax.swing.text.Document
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.javax.swing.text.BadLocationException
- If the given offset and length does
not represent a valid range in the
document.public void insertString(int offset, java.lang.String text, javax.swing.text.AttributeSet attributes) throws javax.swing.text.BadLocationException
insertString
in interface javax.swing.text.Document
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.javax.swing.text.BadLocationException
- If the given offset does not
represent a valid position in the
document.public boolean isModified()
public void load()
public void putProperty(java.lang.Object key, java.lang.Object value)
putProperty
in interface javax.swing.text.Document
key
- The property key.value
- The property value.public void remove(int offset, int length) throws javax.swing.text.BadLocationException
remove
in interface javax.swing.text.Document
offset
- The offset into the document representing
the desired start of the text.length
- The length of the text.javax.swing.text.BadLocationException
- If the given offset and length does
not represent a valid range in the
document.public void removeDocumentListener(javax.swing.event.DocumentListener listener)
removeDocumentListener
in interface javax.swing.text.Document
listener
- The listener.public void removeErrorListener(ErrorListener listener)
listener
- The listener.public void removeFileListener(FileListener listener)
listener
- The listener.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener.public void removeStyle(java.lang.String name)
removeStyle
in interface javax.swing.text.StyledDocument
name
- The name of the style.public void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
removeUndoableEditListener
in interface javax.swing.text.Document
listener
- The listener.public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The listener.public void removeWorkingListener(WorkingListener listener)
listener
- The listener.public void render(java.lang.Runnable runnable)
render
in interface javax.swing.text.Document
runnable
- The runnable.public void save()
public void setCharacterAttributes(int offset, int length, javax.swing.text.AttributeSet attributes, boolean replace)
setCharacterAttributes
in interface javax.swing.text.StyledDocument
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.public void setLogicalStyle(int offset, javax.swing.text.Style style)
setLogicalStyle
in interface javax.swing.text.StyledDocument
offset
- The offset within the document.style
- The logical style.public void setParagraphAttributes(int offset, int length, javax.swing.text.AttributeSet attributes, boolean replace)
setParagraphAttributes
in interface javax.swing.text.StyledDocument
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.public void setPath(java.lang.String path) throws java.beans.PropertyVetoException
path
- The path name of the file.java.beans.PropertyVetoException
- If the change is vetoed.public void setSystem(AS400 system) throws java.beans.PropertyVetoException
system
- The system on which the file resides.java.beans.PropertyVetoException
- If the change is vetoed.public java.lang.String toString()
toString
in class java.lang.Object