All Packages Class Hierarchy This Package Previous Next Index
Class com.ibm.as400.access.MessageFile
java.lang.Object
|
+----com.ibm.as400.access.MessageFile
- public class MessageFile
- extends Object
- implements Serializable
The MessageFile class
allows a user to get a message from an AS/400 message file.
It returns an AS400Message object which contains the message.
The calling program can optionally supply substitution text for the message.
MessageFile will optionally format the message's associated help text. Three
options are available for help text formatting:
- No formatting - the help text is returned as a string of characters.
This is the default.
- Include formatting characters - the help text contains AS/400
formatting characters. The formatting characters are:
&N -- Force a new line
&P -- Force a new line and indent the new line six characters
&B -- Force a new line and indent the new line four characters
- Substitute formatting characters - the MessageFile class replaces
AS/400 formatting characters with newline and space characters.
The difference between options 2 and 3 are with line wrapping.
If the formatting characters remain the application can handle line
wrapping and indentation. If the MessageFile class inserts newline and space
characters, Java components will handle line wrapping.
For example, to retrieve and print a message:
AS400 system = new AS400("mysystem.mycompany.com");
MessageFile messageFile = new MessageFile(system);
messageFile.setPath("/QSYS.LIB/QCPFMSG.MSGF");
AS400Message message = messageFile.getMessage("CPD0170");
System.out.println(message.getText());
Replacement text is provided to MessageFile as a byte array or a
String. For performance, some Toolbox components such as CommandCall
return only the error message and the replacement text. MessageFile
can be used to get the help text for the message. For example,
MessageFile file = new MessageFile(system, "/QSYS.LIB/QCPFMSG.MSGF");
CommandCall c = new CommandCall(system);
c.run("CRTDTAQ DTAQ(LIB/DQ) MAXLEN(1234567)");
AS400Message msg = c.getMessageList()[0];
AS400Message m2 = file.getMessage(msg.getID(), msg.getSubstitutionData());
System.out.println(m2.getHelp());
- See Also:
- AS400Message, CommandCall, ProgramCall, QSYSObjectPathName
-
NO_FORMATTING
- Constant indicating help text should not be formatted.
-
RETURN_FORMATTING_CHARACTERS
- Constant indicating formatting characters are left in the help text.
-
SUBSTITUTE_FORMATTING_CHARACTERS
- Constant indicating MessageFile should replace formatting
characters with newline and space characters.
-
MessageFile()
- Constructs a MessageFile object.
-
MessageFile(AS400)
- Constructs a MessageFile object.
-
MessageFile(AS400, String)
- Constructs a message file object.
-
addPropertyChangeListener(PropertyChangeListener)
- Adds a PropertyChangeListener.
-
addVetoableChangeListener(VetoableChangeListener)
- Adds a VetoableChangeListener.
-
getHelpTextFormatting()
- Returns the status of help text formatting.
-
getMessage(String)
- Returns an AS400Message object containing the object.
-
getMessage(String, byte[])
- Returns an AS400Message object containing the message.
-
getMessage(String, String)
- Returns an AS400Message object containing the message.
-
getPath()
- Returns the integrated file system pathname for the message file.
-
getSystem()
- Returns the AS/400 which contains the message file.
-
removePropertyChangeListener(PropertyChangeListener)
- Removes this PropertyChangeListener from the internal list.
-
removeVetoableChangeListener(VetoableChangeListener)
- Removes this VetoableChangeListener from the internal list.
-
setHelpTextFormatting(int)
- Sets the help text formatting value.
-
setPath(String)
- Sets the message file name.
-
setSystem(AS400)
- Sets the AS/400 which contains the message file.
NO_FORMATTING
public static final int NO_FORMATTING
- Constant indicating help text should not be formatted.
RETURN_FORMATTING_CHARACTERS
public static final int RETURN_FORMATTING_CHARACTERS
- Constant indicating formatting characters are left in the help text.
SUBSTITUTE_FORMATTING_CHARACTERS
public static final int SUBSTITUTE_FORMATTING_CHARACTERS
- Constant indicating MessageFile should replace formatting
characters with newline and space characters.
MessageFile
public MessageFile()
- Constructs a MessageFile object.
The system and message file name must be provided later.
MessageFile
public MessageFile(AS400 system)
- Constructs a MessageFile object. It uses the specified AS/400.
The message file name must be provided later.
- Parameters:
- system - The AS/400 which contains the message file.
MessageFile
public MessageFile(AS400 system,
String path)
- Constructs a message file object. It uses the specified AS/400 and
message file name.
- Parameters:
- system - The AS/400 which contains the message file
- path - The integrated file system pathname for the message file.
That is, the message file name as a fully qualified path name
in the library file system.
The library and message file name must each be
10 characters or less. The extension for message files is .msgf.
For example, /QSYS.LIB/MYLIB.LIB/MSGFILE.MSGF.
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
- Adds a PropertyChangeListener.
The specified PropertyChangeListener's propertyChange method will
be called each time the value of any bound property is changed.
The PropertyChangeListener object is added to a list of PropertyChangeListeners
managed by this MessageFile. It can be removed with removePropertyChangeListener.
- Parameters:
- listener - The PropertyChangeListener.
- See Also:
- removePropertyChangeListener
addVetoableChangeListener
public void addVetoableChangeListener(VetoableChangeListener listener)
- Adds a VetoableChangeListener.
The specified VetoableChangeListener's vetoableChange method will
be called each time the value of any constrained property is about to be changed.
The VetoableChangeListener object is added to a list of listeners
managed by this MessageFile, it can be removed with removeVetoableChangeListener.
- Parameters:
- listener - The VetoableChangeListener.
- See Also:
- removeVetoableChangeListener
getHelpTextFormatting
public int getHelpTextFormatting()
- Returns the status of help text formatting. Possible values are:
- NO_FORMATTING - The help text is returned as a string of characters.
This is the default.
- RETURN_FORMATTING_CHARACTERS - The help text contains AS/400
formatting characters. The formatting characters are:
&N -- Force a new line
&P -- Force a new line and indent the new line six characters
&B -- Force a new line and indent the new line four characters
- SUBSTITUTE_FORMATTING_CHARACTERS - The MessageFile class replaces
AS/400 formatting characters with newline and space characters.
- Returns:
- The status of help text formatting.
getPath
public String getPath()
- Returns the integrated file system pathname for the message file.
It will return null if not previously set.
- Returns:
- The integrated file system pathname for the program.
getMessage
public AS400Message getMessage(String ID) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, PropertyVetoException
- Returns an AS400Message object containing the object. The system and message file name must be
set before calling this method.
- Parameters:
- ID - The message identifier.
- Returns:
- An AS400Message object containing the message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ErrorCompletingRequestException
- If an error occurs before the request is completed.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
- Throws: PropertyVetoException
- If a change is vetoed.
- Throws: ObjectDoesNotExistException
- If the AS/400 object does not exist.
getMessage
public AS400Message getMessage(String ID,
String substitutionText) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, PropertyVetoException
- Returns an AS400Message object containing the message. The system and message file name must be
set before calling this method. Up to 1024 bytes of substitution
text can be supplied to this method. The calling program is
responsible for correctly formatting the string containing the
substitution text for the specified message.
For example, using
AS/400 command DSPMSGD, we see the format of the substitution text for
message CPD0170 is char 4, char 10, char 10. Passing string
"12 abcd xyz"
as the substitution text on this call means
"12" will be substituted for &1, "abcd" will be substituted for &2, and
"xyz" will be substituted for &3.
- Parameters:
- ID - The message identifier.
- substitutionText - The substitution text.
- Returns:
- An AS400Message object containing the message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ErrorCompletingRequestException
- If an error occurs before the request is completed.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
- Throws: PropertyVetoException
- If a change is vetoed.
- Throws: ObjectDoesNotExistException
- If the AS/400 object does not exist.
getMessage
public AS400Message getMessage(String ID,
byte substitutionText[]) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, PropertyVetoException
- Returns an AS400Message object containing the message. The system and
message file name must be
set before calling this method. Up to 1024 bytes of substitution
text can be supplied to this method. The byte array is not changed
or converted before being sent to the AS/400.
- Parameters:
- ID - The message identifier.
- substitutionText - The substitution text.
- Returns:
- An AS400Message object containing the message.
- Throws: AS400SecurityException
- If a security or authority error occurs.
- Throws: ErrorCompletingRequestException
- If an error occurs before the request is completed.
- Throws: InterruptedException
- If this thread is interrupted.
- Throws: IOException
- If an error occurs while communicating with the AS/400.
- Throws: PropertyVetoException
- If a change is vetoed.
- Throws: ObjectDoesNotExistException
- If the AS/400 object does not exist.
getSystem
public AS400 getSystem()
- Returns the AS/400 which contains the message file.
- Returns:
- The AS/400 which contains the message file.
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
- Removes this PropertyChangeListener from the internal list.
If the PropertyChangeListener is not on the list, nothing is done.
- Parameters:
- listener - The PropertyChangeListener.
- See Also:
- addPropertyChangeListener
removeVetoableChangeListener
public void removeVetoableChangeListener(VetoableChangeListener listener)
- Removes this VetoableChangeListener from the internal list.
If the VetoableChangeListener is not on the list, nothing is done.
- Parameters:
- listener - The VetoableChangeListener.
- See Also:
- addVetoableChangeListener
setHelpTextFormatting
public void setHelpTextFormatting(int value) throws PropertyVetoException
- Sets the help text formatting value. Possible values are:
- NO_FORMATTING - the help text is returned as a string of characters.
This is the default.
- RETURN_FORMATTING_CHARACTERS - the help text contains AS/400
formatting characters. The formatting characters are:
&N -- Force a new line
&P -- Force a new line and indent the new line six characters
&B -- Force a new line and indent the new line four characters
- SUBSTITUTE_FORMATTING_CHARACTERS - the MessageFile class replaces
AS/400 formatting characters with new line and space characters.
- Parameters:
- value - The help text formatting value.
- Throws: PropertyVetoException
- If a change is vetoed.
setPath
public void setPath(String path) throws PropertyVetoException
- Sets the message file name. The name cannot be changed after
retrieving a message from the AS/400.
- Parameters:
- path - The integrated file system pathname for the message file.
That is, the message file name as a fully qualified path name
in the library file system.
The library and file name must each be
10 characters or less. The extension for message files is .msgf.
For example, /QSYS.LIB/MyLib.LIB/MyFile.MSGF.
- Throws: PropertyVetoException
- If a change is vetoed.
setSystem
public void setSystem(AS400 system) throws ExtendedIllegalStateException, PropertyVetoException
- Sets the AS/400 which contains the message file. The system cannot be changed after
retrieving a message from the AS/400.
- Parameters:
- system - The AS/400 which contains the message file.
- Throws: PropertyVetoException
- If a change is vetoed.
All Packages Class Hierarchy This Package Previous Next Index