public class MessageFile
extends java.lang.Object
implements java.io.Serializable
MessageFile will optionally format the message's associated help text. Three options are available for help text formatting:
Note: To return formatting characters, you must call setHelpTextFormatting
prior to calling any of the getMessage() methods.
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());
You can also sequentially retrieve messages from a message file by using the FIRST
and NEXT
message id values.
AS400Message msg = messageFile.getMessage(MessageFile.FIRST); while (msg != null) { System.out.println(msg.getID() + " = " + msg.getText()); msg = messageFile.getMessage(MessageFile.NEXT); }
AS400Message
,
CommandCall
,
ProgramCall
,
QSYSObjectPathName
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
CCSID_OF_JOB
Constant indicating "the CCSID of the job".
|
static java.lang.String |
FIRST
Constant indicating we are going to retrieve the first message
in the message file.
|
static java.lang.String |
NEXT
Constant indicating we are going to retrieve the next message
(using the previous message as a starting point).
|
static int |
NO_FORMATTING
Constant indicating help text should not be formatted.
|
static int |
RETURN_FORMATTING_CHARACTERS
Constant indicating formatting characters are left in the help text.
|
static int |
SUBSTITUTE_FORMATTING_CHARACTERS
Constant indicating MessageFile should replace formatting characters with newline and space characters.
|
Constructor and Description |
---|
MessageFile()
Constructs a MessageFile object.
|
MessageFile(AS400 system)
Constructs a MessageFile object.
|
MessageFile(AS400 system,
java.lang.String path)
Constructs a MessageFile object.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener.
|
void |
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a VetoableChangeListener.
|
int |
getHelpTextFormatting()
Returns the status of help text formatting.
|
AS400Message |
getMessage(java.lang.String ID)
Returns an AS400Message object containing the object.
|
AS400Message |
getMessage(java.lang.String ID,
byte[] substitutionText)
Returns an AS400Message object containing the message.
|
AS400Message |
getMessage(java.lang.String ID,
byte[] substitutionText,
int type)
Returns an AS400Message object containing the message.
|
AS400Message |
getMessage(java.lang.String ID,
byte[] substitutionText,
int type,
int ccsidOfSubstitutionText,
int ccsidToConvertTo)
Returns an AS400Message object containing the message.
|
AS400Message |
getMessage(java.lang.String ID,
int type)
Returns an AS400Message object containing the object.
|
AS400Message |
getMessage(java.lang.String ID,
java.lang.String substitutionText)
Returns an AS400Message object containing the message.
|
AS400Message |
getMessage(java.lang.String ID,
java.lang.String substitutionText,
int type)
Returns an AS400Message object containing the message.
|
java.lang.String |
getPath()
Returns the integrated file system path name of the message file.
|
AS400 |
getSystem()
Returns the system object representing the system on which the message file exists.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes the PropertyChangeListener.
|
void |
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes the VetoableChangeListener.
|
void |
setHelpTextFormatting(int helpTextFormatting)
Sets the help text formatting value.
|
void |
setPath(java.lang.String path)
Sets the message file name.
|
void |
setSystem(AS400 system)
Sets the system object representing the system on which the message file exists.
|
static java.lang.String |
substituteFormattingCharacters(java.lang.String sourceText)
Substitutes formatting characters with appropriate new line and indent characters.
|
public static final int NO_FORMATTING
public static final int RETURN_FORMATTING_CHARACTERS
public static final int SUBSTITUTE_FORMATTING_CHARACTERS
public static final int CCSID_OF_JOB
public static final java.lang.String NEXT
public static final java.lang.String FIRST
public MessageFile()
public MessageFile(AS400 system)
system
- The system object representing the system on which the message file exists.public MessageFile(AS400 system, java.lang.String path)
system
- The system object representing the system on which the message file exists.path
- The integrated file system path name 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/MYFILE.MSGF.public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The listener.removeVetoableChangeListener(java.beans.VetoableChangeListener)
public static java.lang.String substituteFormattingCharacters(java.lang.String sourceText)
sourceText
- The source text.public int getHelpTextFormatting()
public java.lang.String getPath()
public AS400Message getMessage(java.lang.String ID) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException, java.beans.PropertyVetoException
ID
- The message identifier, FIRST
, or NEXT
.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.java.beans.PropertyVetoException
- If any of the registered listeners vetos the property change.setHelpTextFormatting(int)
public AS400Message getMessage(java.lang.String ID, int type) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException, java.beans.PropertyVetoException
ID
- The message identifier, FIRST
, or NEXT
.type
- The bidi message string type, as defined by the CDRA (Character Data Representation Architecture). See BidiStringType for more information and valid values.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.java.beans.PropertyVetoException
- If any of the registered listeners vetos the property change.setHelpTextFormatting(int)
public AS400Message getMessage(java.lang.String ID, java.lang.String substitutionText) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException, java.beans.PropertyVetoException
For example, using CL 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.
ID
- The message identifier, FIRST
, or NEXT
.substitutionText
- The substitution text.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.java.beans.PropertyVetoException
- If any of the registered listeners vetos the property change.setHelpTextFormatting(int)
public AS400Message getMessage(java.lang.String ID, java.lang.String substitutionText, int type) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException, java.beans.PropertyVetoException
For example, using CL 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.
ID
- The message identifier, FIRST
, or NEXT
.substitutionText
- The substitution text.type
- The bidi message string type, as defined by the CDRA (Character Data Representation Architecture). See BidiStringType for more information and valid values.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.java.beans.PropertyVetoException
- If any of the registered listeners vetos the property change.setHelpTextFormatting(int)
public AS400Message getMessage(java.lang.String ID, byte[] substitutionText) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException, java.beans.PropertyVetoException
ID
- The message identifier, FIRST
, or NEXT
.substitutionText
- The substitution text. The bytes are assumed to be in the CCSID of the job.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.java.beans.PropertyVetoException
- If any of the registered listeners vetos the property change.setHelpTextFormatting(int)
public AS400Message getMessage(java.lang.String ID, byte[] substitutionText, int type) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException, java.beans.PropertyVetoException
ID
- The message identifier, FIRST
, or NEXT
.substitutionText
- The substitution text. The bytes are assumed to be in the CCSID of the job.type
- The bidi message string type, as defined by the CDRA (Character Data Representation Architecture). See BidiStringType for more information and valid values.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.java.beans.PropertyVetoException
- If any of the registered listeners vetos the property change.setHelpTextFormatting(int)
public AS400Message getMessage(java.lang.String ID, byte[] substitutionText, int type, int ccsidOfSubstitutionText, int ccsidToConvertTo) throws AS400SecurityException, ErrorCompletingRequestException, java.lang.InterruptedException, java.io.IOException, ObjectDoesNotExistException, java.beans.PropertyVetoException
ID
- The message identifier, FIRST
, or NEXT
.substitutionText
- The substitution text.type
- The bidi message string type, as defined by the CDRA (Character Data Representation Architecture). See BidiStringType for more information and valid values.ccsidOfSubstitutionText
- The CCSID of the substitution text. The default value is CCSID_OF_JOB
.ccsidToConvertTo
- The CCSID in which the system should return the message text. The Toolbox then converts from that CCSID to Unicode when constructing the AS400Message. The default value is CCSID_OF_JOB
.AS400SecurityException
- If a security or authority error occurs.ErrorCompletingRequestException
- If an error occurs before the request is completed.java.lang.InterruptedException
- If this thread is interrupted.java.io.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.java.beans.PropertyVetoException
- If any of the registered listeners vetos the property change.setHelpTextFormatting(int)
public AS400 getSystem()
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener object.public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
listener
- The listener object.public void setHelpTextFormatting(int helpTextFormatting) throws java.beans.PropertyVetoException
Note: To return formatting characters, call this method prior to calling any of the getMessage() methods.
helpTextFormatting
- The help text formatting value.
Possible values are:
java.beans.PropertyVetoException
- If any of the registered listeners vetos the property change.public void setPath(java.lang.String path) throws java.beans.PropertyVetoException
path
- The integrated file system path name 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/MYFILE.MSGF.java.beans.PropertyVetoException
- If any of the registered listeners vetos the property change.public void setSystem(AS400 system) throws java.beans.PropertyVetoException
system
- The system object representing the system on which the message file exists.java.beans.PropertyVetoException
- If any of the registered listeners vetos the property change.