|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.as400.access.MessageFile
public class MessageFile extends Object implements Serializable
Represents a message file object on the system. This class allows a user to get a message from a message file, returning 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:
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 String |
FIRST
Constant indicating we are going to retrieve the first message in the message file. |
static 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,
String path)
Constructs a MessageFile object. |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener. |
void |
addVetoableChangeListener(VetoableChangeListener listener)
Adds a VetoableChangeListener. |
int |
getHelpTextFormatting()
Returns the status of help text formatting. |
AS400Message |
getMessage(String ID)
Returns an AS400Message object containing the object. |
AS400Message |
getMessage(String ID,
byte[] substitutionText)
Returns an AS400Message object containing the message. |
AS400Message |
getMessage(String ID,
byte[] substitutionText,
int type)
Returns an AS400Message object containing the message. |
AS400Message |
getMessage(String ID,
byte[] substitutionText,
int type,
int ccsidOfSubstitutionText,
int ccsidToConvertTo)
Returns an AS400Message object containing the message. |
AS400Message |
getMessage(String ID,
int type)
Returns an AS400Message object containing the object. |
AS400Message |
getMessage(String ID,
String substitutionText)
Returns an AS400Message object containing the message. |
AS400Message |
getMessage(String ID,
String substitutionText,
int type)
Returns an AS400Message object containing the message. |
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(PropertyChangeListener listener)
Removes the PropertyChangeListener. |
void |
removeVetoableChangeListener(VetoableChangeListener listener)
Removes the VetoableChangeListener. |
void |
setHelpTextFormatting(int helpTextFormatting)
Sets the help text formatting value. |
void |
setPath(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 String |
substituteFormattingCharacters(String sourceText)
Substitutes formatting characters with appropriate new line and indent characters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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 String NEXT
public static final String FIRST
Constructor Detail |
---|
public MessageFile()
public MessageFile(AS400 system)
system
- The system object representing the system on which the message file exists.public MessageFile(AS400 system, 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.Method Detail |
---|
public void addPropertyChangeListener(PropertyChangeListener listener)
listener
- The listener.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void addVetoableChangeListener(VetoableChangeListener listener)
listener
- The listener.removeVetoableChangeListener(java.beans.VetoableChangeListener)
public static String substituteFormattingCharacters(String sourceText)
sourceText
- The source text.public int getHelpTextFormatting()
public String getPath()
public AS400Message getMessage(String ID) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, 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.InterruptedException
- If this thread is interrupted.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.PropertyVetoException
- If any of the registered listeners vetos the property change.public AS400Message getMessage(String ID, int type) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, PropertyVetoException
ID
- The message identifier, FIRST
, or NEXT
.type
- The bidi message string type, as defined by the CDRA (Character Data Representataion 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.InterruptedException
- If this thread is interrupted.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.PropertyVetoException
- If any of the registered listeners vetos the property change.public AS400Message getMessage(String ID, String substitutionText) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, 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.InterruptedException
- If this thread is interrupted.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.PropertyVetoException
- If any of the registered listeners vetos the property change.public AS400Message getMessage(String ID, String substitutionText, int type) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, 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 Representataion 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.InterruptedException
- If this thread is interrupted.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.PropertyVetoException
- If any of the registered listeners vetos the property change.public AS400Message getMessage(String ID, byte[] substitutionText) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, 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.InterruptedException
- If this thread is interrupted.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.PropertyVetoException
- If any of the registered listeners vetos the property change.public AS400Message getMessage(String ID, byte[] substitutionText, int type) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, 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 Representataion 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.InterruptedException
- If this thread is interrupted.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.PropertyVetoException
- If any of the registered listeners vetos the property change.public AS400Message getMessage(String ID, byte[] substitutionText, int type, int ccsidOfSubstitutionText, int ccsidToConvertTo) throws AS400SecurityException, ErrorCompletingRequestException, InterruptedException, IOException, ObjectDoesNotExistException, 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 Representataion Architecture). The default value is BidiStringType.DEFAULT
. 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.InterruptedException
- If this thread is interrupted.IOException
- If an error occurs while communicating with the system.ObjectDoesNotExistException
- If the object does not exist on the system.PropertyVetoException
- If any of the registered listeners vetos the property change.public AS400 getSystem()
public void removePropertyChangeListener(PropertyChangeListener listener)
listener
- The listener object.public void removeVetoableChangeListener(VetoableChangeListener listener)
listener
- The listener object.public void setHelpTextFormatting(int helpTextFormatting) throws PropertyVetoException
helpTextFormatting
- The help text formatting value.PropertyVetoException
- If any of the registered listeners vetos the property change.public void setPath(String path) throws 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.PropertyVetoException
- If any of the registered listeners vetos the property change.public void setSystem(AS400 system) throws PropertyVetoException
system
- The system object representing the system on which the message file exists.PropertyVetoException
- If any of the registered listeners vetos the property change.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |