Top Description Inners Fields Constructors Methods
org.apache.poi.poifs.filesystem

public Class Ole10Native

extends Object
Class Inheritance
Annotations
@SuppressWarnings:unused
Imports
java.io.IOException, .OutputStream, java.nio.charset.Charset, .StandardCharsets, org.apache.commons.io.input.UnsynchronizedByteArrayInputStream, org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream, org.apache.poi.util.IOUtils, .LittleEndianByteArrayInputStream, .LittleEndianConsts, .LittleEndianInput, .LittleEndianOutputStream, .StringUtil

Represents an Ole10Native record which is wrapped around certain binary files being embedded in OLE2 documents.

Ole10Native objects come in different shapes:

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
Ole10Native.EncodingMode

the field encoding mode - merely a try-and-error guess ...

Field Summary

Modifier and TypeField and Description
private String
private String
private byte[]
private static final int
private static final int
private String
private String
private short
private short
private String
private String
private static int
private static int
private Ole10Native.EncodingMode
public static final String
private static final byte[]
OLE_MARKER_BYTES

Default content of the Ole entry

private static final String
private int
private short
private static final Charset

Constructor Summary

AccessConstructor and Description
public
Ole10Native(String label, String filename, String command, byte[] data)

Creates an instance and fills the fields based on ...

public
Ole10Native(final byte[]
The buffer containing the Ole10Native record
data
,
final int
The start offset of the record in the buffer
offset
)

Creates an instance and fills the fields based on the data in the given buffer.

Method Summary

Modifier and TypeMethod and Description
public static Ole10Native

Returns:

Returns an instance of this class
createFromEmbeddedOleObject
(POIFSFileSystem
POI Filesystem object
poifs
)

Creates an instance of this class from an embedded OLE Object.

public static Ole10Native

Returns:

Returns an instance of this class
createFromEmbeddedOleObject
(DirectoryNode
POI Filesystem object
directory
)

Creates an instance of this class from an embedded OLE Object.

public static void
createOleMarkerEntry(final DirectoryEntry parent)

Add the \1OLE marker entry, which is not the Ole10Native entry.

public static void
createOleMarkerEntry(final POIFSFileSystem poifs)

Add the \1OLE marker entry, which is not the Ole10Native entry.

public String

Returns:

the command
getCommand
()

Returns the command field - usually the name of the file being embedded including the full path, may be a command specified during embedding the file.

public String
getCommand2()

Get Command string of UTF16 extended OLE packages or null if not set or not UTF16 extended

public byte[]

Returns:

the dataBuffer
getDataBuffer
()

Returns the buffer containing the embedded file's data, or null if no data was embedded.

public int

Returns:

the dataSize
getDataSize
()

Returns the size of the embedded file.

public String

Returns:

the fileName
getFileName
()

Returns the fileName field - usually the name of the file being embedded including the full path.

public String
getFileName2()

Get filename string for UTF16 extended OLE packages or null if not set or not UTF16 extended

public short

Returns:

the flags1
getFlags1
()

Returns flags1 - currently unknown - usually 0x0002.

public short

Returns:

the flags2
getFlags2
()

Returns flags2 - currently unknown - mostly 0x0000.

public String

Returns:

the label
getLabel
()

Returns the label field - usually the name of the file (without directory) but probably may be any name specified during packaging/embedding the data.

public String
getLabel2()

Get Label string for UTF16 extended OLE packages or null if not set or not UTF16 extended

public static int

Returns:

the max record length allowed for Ole10Native
getMaxRecordLength
()

public static int

Returns:

the max string length allowed for Ole10Native
getMaxStringLength
()

public int

Returns:

the totalSize
getTotalSize
()

Returns the value of the totalSize field - the total length of the structure is totalSize + 4 (value of this field + size of this field).

public short

Returns:

the unknown1
getUnknown1
()

Returns unknown1 field - currently unknown.

private static String
private static String
readAsciiZ(LittleEndianInput is)

Read zero terminated string (ASCIIZ).

private void
private void
private void
private static String
public void
setCommand(String command)

public void
setCommand2(String command2)

Set Command string for UTF16 extended OLE packages or null if not set or not UTF16 extended

public void
setDataBuffer(byte[] dataBuffer)

public void
setFileName(String fileName)

public void
setFileName2(String fileName2)

Set filename string for UTF16 extended OLE packages or null if not set or not UTF16 extended

public void
setFlags1(short flags1)

public void
setFlags2(short flags2)

public void
public void
setLabel2(String label2)

Set Label string for UTF16 extended OLE packages or null if not set or not UTF16 extended

public static void
setMaxRecordLength(int
the max record length allowed for Ole10Native
length
)

public static void
setMaxStringLength(int
the max string length allowed for Ole10Native
length
)

public void
setUnknown1(short unknown1)

public void
writeOut(OutputStream out)

Have the contents printer out into an OutputStream, used when writing a file back out to disk (Normally, atom classes will keep their bytes around, but non atom classes will just request the bytes from their children, then chuck on their header and return)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

commandback to summary
private String command
command2back to summary
private String command2
dataBufferback to summary
private byte[] dataBuffer
DEFAULT_MAX_RECORD_LENGTHback to summary
private static final int DEFAULT_MAX_RECORD_LENGTH
DEFAULT_MAX_STRING_LENGTHback to summary
private static final int DEFAULT_MAX_STRING_LENGTH
fileNameback to summary
private String fileName
fileName2back to summary
private String fileName2
flags1back to summary
private short flags1
flags2back to summary
private short flags2
labelback to summary
private String label
label2back to summary
private String label2
MAX_RECORD_LENGTHback to summary
private static int MAX_RECORD_LENGTH
MAX_STRING_LENGTHback to summary
private static int MAX_STRING_LENGTH
modeback to summary
private Ole10Native.EncodingMode mode
OLE10_NATIVEback to summary
public static final String OLE10_NATIVE
OLE_MARKER_BYTESback to summary
private static final byte[] OLE_MARKER_BYTES

Default content of the Ole entry

OLE_MARKER_NAMEback to summary
private static final String OLE_MARKER_NAME
totalSizeback to summary
private int totalSize
unknown1back to summary
private short unknown1
UTF8back to summary
private static final Charset UTF8

Constructor Detail

Ole10Nativeback to summary
public Ole10Native(String label, String filename, String command, byte[] data)

Creates an instance and fills the fields based on ... the fields

Ole10Nativeback to summary
public Ole10Native(final byte[] data, final int offset) throws Ole10NativeException

Creates an instance and fills the fields based on the data in the given buffer.

Parameters
data:byte[]

The buffer containing the Ole10Native record

offset:int

The start offset of the record in the buffer

Exceptions
Ole10NativeException:
on invalid or unexcepted data format

Method Detail

createFromEmbeddedOleObjectback to summary
public static Ole10Native createFromEmbeddedOleObject(POIFSFileSystem poifs) throws IOException, Ole10NativeException

Creates an instance of this class from an embedded OLE Object. The OLE Object is expected to include a stream "{01}Ole10Native" which contains the actual data relevant for this class.

Parameters
poifs:POIFSFileSystem

POI Filesystem object

Returns:Ole10Native

Returns an instance of this class

Exceptions
IOException:
on IO error
Ole10NativeException:
on invalid or unexcepted data format
createFromEmbeddedOleObjectback to summary
public static Ole10Native createFromEmbeddedOleObject(DirectoryNode directory) throws IOException, Ole10NativeException

Creates an instance of this class from an embedded OLE Object. The OLE Object is expected to include a stream "{01}Ole10Native" which contains the actual data relevant for this class.

Parameters
directory:DirectoryNode

POI Filesystem object

Returns:Ole10Native

Returns an instance of this class

Exceptions
IOException:
on IO error
Ole10NativeException:
on invalid or unexcepted data format
createOleMarkerEntryback to summary
public static void createOleMarkerEntry(final DirectoryEntry parent) throws IOException

Add the \1OLE marker entry, which is not the Ole10Native entry. Beside this "Ole" record there were several other records, e.g. CompObj, OlePresXXX, but it seems, that they aren't necessary

createOleMarkerEntryback to summary
public static void createOleMarkerEntry(final POIFSFileSystem poifs) throws IOException

Add the \1OLE marker entry, which is not the Ole10Native entry. Beside this "Ole" record there were several other records, e.g. CompObj, OlePresXXX, but it seems, that they aren't necessary

getCommandback to summary
public String getCommand()

Returns the command field - usually the name of the file being embedded including the full path, may be a command specified during embedding the file.

Returns:String

the command

getCommand2back to summary
public String getCommand2()

Get Command string of UTF16 extended OLE packages or null if not set or not UTF16 extended

getDataBufferback to summary
public byte[] getDataBuffer()

Returns the buffer containing the embedded file's data, or null if no data was embedded. Note that an embedding may provide information about the data, but the actual data is not included. (So label, filename etc. are available, but this method returns null.)

Returns:byte[]

the dataBuffer

getDataSizeback to summary
public int getDataSize()

Returns the size of the embedded file. If the size is 0 (zero), no data has been embedded. To be sure, that no data has been embedded, check whether getDataBuffer() returns null.

Returns:int

the dataSize

getFileNameback to summary
public String getFileName()

Returns the fileName field - usually the name of the file being embedded including the full path.

Returns:String

the fileName

getFileName2back to summary
public String getFileName2()

Get filename string for UTF16 extended OLE packages or null if not set or not UTF16 extended

getFlags1back to summary
public short getFlags1()

Returns flags1 - currently unknown - usually 0x0002.

Returns:short

the flags1

getFlags2back to summary
public short getFlags2()

Returns flags2 - currently unknown - mostly 0x0000.

Returns:short

the flags2

getLabelback to summary
public String getLabel()

Returns the label field - usually the name of the file (without directory) but probably may be any name specified during packaging/embedding the data.

Returns:String

the label

getLabel2back to summary
public String getLabel2()

Get Label string for UTF16 extended OLE packages or null if not set or not UTF16 extended

getMaxRecordLengthback to summary
public static int getMaxRecordLength()
Returns:int

the max record length allowed for Ole10Native

getMaxStringLengthback to summary
public static int getMaxStringLength()
Returns:int

the max string length allowed for Ole10Native

getTotalSizeback to summary
public int getTotalSize()

Returns the value of the totalSize field - the total length of the structure is totalSize + 4 (value of this field + size of this field).

Returns:int

the totalSize

getUnknown1back to summary
public short getUnknown1()

Returns unknown1 field - currently unknown.

Returns:short

the unknown1

readAsciiLenback to summary
private static String readAsciiLen(LittleEndianByteArrayInputStream leis) throws IOException
readAsciiZback to summary
private static String readAsciiZ(LittleEndianInput is) throws Ole10NativeException

Read zero terminated string (ASCIIZ).

readCompactback to summary
private void readCompact(LittleEndianByteArrayInputStream leis) throws IOException
readParsedback to summary
private void readParsed(LittleEndianByteArrayInputStream leis) throws Ole10NativeException, IOException
readUnparsedback to summary
private void readUnparsed(LittleEndianByteArrayInputStream leis) throws IOException
readUtf16back to summary
private static String readUtf16(LittleEndianByteArrayInputStream leis) throws IOException
setCommandback to summary
public void setCommand(String command)
setCommand2back to summary
public void setCommand2(String command2)

Set Command string for UTF16 extended OLE packages or null if not set or not UTF16 extended

setDataBufferback to summary
public void setDataBuffer(byte[] dataBuffer)
setFileNameback to summary
public void setFileName(String fileName)
setFileName2back to summary
public void setFileName2(String fileName2)

Set filename string for UTF16 extended OLE packages or null if not set or not UTF16 extended

setFlags1back to summary
public void setFlags1(short flags1)
setFlags2back to summary
public void setFlags2(short flags2)
setLabelback to summary
public void setLabel(String label)
setLabel2back to summary
public void setLabel2(String label2)

Set Label string for UTF16 extended OLE packages or null if not set or not UTF16 extended

setMaxRecordLengthback to summary
public static void setMaxRecordLength(int length)
Parameters
length:int

the max record length allowed for Ole10Native

setMaxStringLengthback to summary
public static void setMaxStringLength(int length)
Parameters
length:int

the max string length allowed for Ole10Native

setUnknown1back to summary
public void setUnknown1(short unknown1)
writeOutback to summary
public void writeOut(OutputStream out) throws IOException

Have the contents printer out into an OutputStream, used when writing a file back out to disk (Normally, atom classes will keep their bytes around, but non atom classes will just request the bytes from their children, then chuck on their header and return)

org.apache.poi.poifs.filesystem back to summary

private final Enum Ole10Native.EncodingMode

extends Enum<Ole10Native.EncodingMode>
Class Inheritance

the field encoding mode - merely a try-and-error guess ...

Field Summary

Modifier and TypeField and Description
public static final Ole10Native.EncodingMode
compact

the data is stored raw after the length field and the flags1 field

public static final Ole10Native.EncodingMode
parsed

the data is stored in parsed format - including label, command, etc.

public static final Ole10Native.EncodingMode
unparsed

the data is stored raw after the length field

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Ole10Native.EncodingMode
public static Ole10Native.EncodingMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

compactback to summary
public static final Ole10Native.EncodingMode compact

the data is stored raw after the length field and the flags1 field

parsedback to summary
public static final Ole10Native.EncodingMode parsed

the data is stored in parsed format - including label, command, etc.

unparsedback to summary
public static final Ole10Native.EncodingMode unparsed

the data is stored raw after the length field

Constructor Detail

EncodingModeback to summary
private EncodingMode()

Method Detail

valueOfback to summary
public static Ole10Native.EncodingMode valueOf(String name)
valuesback to summary
public static Ole10Native.EncodingMode[] values()