Skip navigation links


com.essbase.eas.framework.defs.command
Class BinaryMessage

java.lang.Object
  extended by com.essbase.eas.framework.defs.command.BinaryMessage

Direct Known Subclasses:
EssbaseBinaryMessage

public class BinaryMessage
extends java.lang.Object

This is a utility class used by the DefaultCommandManager to decode some of the results returned for some commands.

Since:
7.0.0
Version:
7.0.0
Author:
Hank Cox

Field Summary
protected  boolean deleteFiles
          indicates whether or not to delete the file set
protected  java.io.File[] files
          contains the set of message containing files.
static java.lang.String MESSAGE_FILE_NAME
           

 

Constructor Summary
BinaryMessage()
          constructs a BinaryMessage object with no files and the delete files flag set to true.

 

Method Summary
static BinaryMessage createInstance(java.lang.Class c)
          Creates an instance of a BinaryMessage object.
 void deleteMessageFiles()
          removes the embedded messsage files from the local file system
 void deleteXmlMessageFiles()
           
 java.io.ByteArrayOutputStream exportMessage(CommandStatus cmdStatus, java.util.List errorList, java.io.File[] messageFiles)
          This method is used to pack the CommandStatus object, the List of errors and the Message Files into a ByteArrayOutputStream
 java.io.ByteArrayOutputStream exportMessage(java.util.List errorList, java.io.File[] messageFiles)
          This method can be used to pack a list of errors and messageFiles as a set of files.
 java.io.ByteArrayOutputStream exportMessage(java.lang.String xmlMessage, java.io.File[] messageFiles)
          This method can be used to pack a message String and messageFiles as a set of files.
 void finalize()
           
 java.io.File getFile(java.lang.String fileName)
          retrieves one of the embedded File objects.
 java.io.File getFile(java.lang.String prefix, java.lang.String suffix)
           
 byte[] getFileAsBytes(java.lang.String fileName)
          retrieves the contents of one of the embedded files as a String.
 java.lang.String getFileAsString(java.lang.String fileName, java.lang.String charset)
          retrieves the contents of one of the embedded files as a String.
 java.io.File[] getFiles(java.lang.String fileName)
           
 java.io.File[] getMessageFiles()
           
 java.lang.String getXmlMessages()
          Returns the contents of the message file in this BinaryMessage as a String object
 java.io.File[] importMessage(java.io.InputStream receivedInput)
          Imports the message from the receivedInput to a File array
 java.io.ByteArrayOutputStream packMessage(java.io.File[] messageFiles)
          This method zips the files passed as messageFiles to a byte stream.
 void removeFileFromList(java.io.File file)
          Removes the specified file from the list of files in this BinaryMessage
 void removeFilesFromList(java.io.File[] f)
           
 void setDeleteMessageFiles(boolean delete)
          Set the flag to deleteMessage files automatically when this object is no longer used.
 java.io.File[] unpackMessage(java.io.InputStream in)
          converts an InputStream object to an array of File objects.

 

Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

MESSAGE_FILE_NAME

public static final java.lang.String MESSAGE_FILE_NAME
See Also:
Constant Field Values

files

protected java.io.File[] files
contains the set of message containing files.

deleteFiles

protected boolean deleteFiles
indicates whether or not to delete the file set

Constructor Detail

BinaryMessage

public BinaryMessage()
constructs a BinaryMessage object with no files and the delete files flag set to true.

Method Detail

createInstance

public static BinaryMessage createInstance(java.lang.Class c)
Creates an instance of a BinaryMessage object. If the Class c is subclassed from BinaryMessage, then creates an instance of that class.
Parameters:
c - the class which is subclassed from BinaryMessage
Returns:
a new instance of type Class c.

getMessageFiles

public java.io.File[] getMessageFiles()

unpackMessage

public java.io.File[] unpackMessage(java.io.InputStream in)
                             throws java.io.IOException,
                                    java.lang.IllegalArgumentException
converts an InputStream object to an array of File objects. The input stream must be a file that can be used to create a zip input file.
Parameters:
in - the input stream
Returns:
an array of file objects containing messages embedded inside XMLTransferObject instances.
Throws:
java.lang.IllegalArgumentException - if the input stream parameter is null
java.io.IOException

getFileAsString

public java.lang.String getFileAsString(java.lang.String fileName,
                                        java.lang.String charset)
                                 throws java.io.IOException,
                                        java.lang.IllegalArgumentException
retrieves the contents of one of the embedded files as a String. This method probably only gives the correct, expected results when the original file was a text file. If there is binary data in the file, then the results probably will not be what the user is expecting.
Parameters:
fileName - the "base" file name whose contens are being extracted.
Returns:
the contents of this file after conversion to a string.
Throws:
java.lang.IllegalArgumentException - if the file name is null or empty.
java.io.IOException

getFileAsBytes

public byte[] getFileAsBytes(java.lang.String fileName)
                      throws java.lang.IllegalArgumentException
retrieves the contents of one of the embedded files as a String. This method probably only gives the correct, expected results when the original file was a text file. If there is binary data in the file, then the results probably will not be what the user is expecting.
Parameters:
fileName - the "base" file name whose contens are being extracted.
Returns:
the contents of this file as a byte array
Throws:
java.lang.IllegalArgumentException - if the file name is null or empty.

getFile

public java.io.File getFile(java.lang.String fileName)
                     throws java.lang.IllegalArgumentException
retrieves one of the embedded File objects.
Parameters:
fileName - the "base" file name being requested
Returns:
the expected File object, or null if it doesn't exist in the set of embedded files.
Throws:
java.lang.IllegalArgumentException - if the file name is null or empty.

getFile

public java.io.File getFile(java.lang.String prefix,
                            java.lang.String suffix)
                     throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getFiles

public java.io.File[] getFiles(java.lang.String fileName)
                        throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

packMessage

public java.io.ByteArrayOutputStream packMessage(java.io.File[] messageFiles)
                                          throws java.io.IOException,
                                                 java.lang.IllegalArgumentException
This method zips the files passed as messageFiles to a byte stream. The packed files can later be retrieved using the unpackMessage method
Parameters:
messageFiles - the files to pack
Returns:
a ByteArrayOutputStream of the packaged files
Throws:
java.io.IOException
java.lang.IllegalArgumentException - if there are no message files to pack

deleteMessageFiles

public void deleteMessageFiles()
removes the embedded messsage files from the local file system

setDeleteMessageFiles

public void setDeleteMessageFiles(boolean delete)
Set the flag to deleteMessage files automatically when this object is no longer used.
Parameters:
delete - a boolean stating whether the message files should be deleted

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

exportMessage

public java.io.ByteArrayOutputStream exportMessage(java.util.List errorList,
                                                   java.io.File[] messageFiles)
This method can be used to pack a list of errors and messageFiles as a set of files. The errorlist and message files can be retrieved using the importMessage method
Parameters:
errorList - list containing errors
message - the array of Files to pack
Returns:
a ByteArrayOutputStream containing the errors and messages

exportMessage

public java.io.ByteArrayOutputStream exportMessage(java.lang.String xmlMessage,
                                                   java.io.File[] messageFiles)
This method can be used to pack a message String and messageFiles as a set of files. The message and message files can be retrieved using the importMessage method
Parameters:
xmlMessage - is a string containing some message
messageFiles - the array of Files to pack
Returns:
a ByteArrayOutputStream containing the associated message and message files

importMessage

public java.io.File[] importMessage(java.io.InputStream receivedInput)
                             throws java.io.IOException
Imports the message from the receivedInput to a File array
Parameters:
receivedInput - the InputStream from which the messages have to be extracted
Returns:
an array of File containing the files imported from the InputStream
Throws:
java.io.IOException

exportMessage

public java.io.ByteArrayOutputStream exportMessage(CommandStatus cmdStatus,
                                                   java.util.List errorList,
                                                   java.io.File[] messageFiles)
This method is used to pack the CommandStatus object, the List of errors and the Message Files into a ByteArrayOutputStream
Parameters:
cmdStatus - The status to be attached to this BinaryMessage object
errorList - list containing errors
messageFiles - the array of Files to pack
Returns:
a ByteArrayOutputStream containing the command status, errors and messages

getXmlMessages

public java.lang.String getXmlMessages()
Returns the contents of the message file in this BinaryMessage as a String object
Returns:
String representing contents of the first message file contained.

removeFileFromList

public void removeFileFromList(java.io.File file)
Removes the specified file from the list of files in this BinaryMessage
Parameters:
file - the file to remove

removeFilesFromList

public void removeFilesFromList(java.io.File[] f)

deleteXmlMessageFiles

public void deleteXmlMessageFiles()

Skip navigation links


Copyright © 2001, 2012, Oracle. All rights reserved.