public final class MPPUtility extends Object
Modifier and Type | Field and Description |
---|---|
static LocalDateTime |
EPOCH_DATE
Epoch date for MPP date calculation is 31/12/1983.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
cloneSubArray(byte[] data,
int offset,
int size)
This method allows a subsection of a byte array to be copied.
|
static void |
convertRateFromHours(ProjectFile file,
Resource resource,
ResourceField rateField,
ResourceField unitsField)
Convert from the internal representation of a rate as an amount per hour to the
format presented to the user.
|
static void |
dataDump(ProjectProperties properties,
byte[] data,
boolean dumpShort,
boolean dumpInt,
boolean dumpDouble,
boolean dumpTimeStamp,
boolean dumpDuration,
boolean dumpDate,
boolean dumpTime,
boolean dumpAdjustedDuration)
Dump out all the possible variables within the given data block.
|
static void |
decodeBuffer(byte[] data,
byte encryptionCode)
This method decodes a byte array with the given encryption code
using XOR encryption.
|
static String |
decodePassword(byte[] data,
byte encryptionCode)
Decode the password from the given data.
|
static void |
dumpBlockData(int headerSize,
int blockSize,
byte[] data)
Dumps the contents of a structured block made up from a header
and fixed sized records.
|
static void |
fileDump(String fileName,
byte[] data)
Writes a large byte array to a file.
|
static void |
fileHexDump(String fileName,
byte[] data)
Writes a hex dump to a file for a large byte array.
|
static void |
fileHexDump(String fileName,
InputStream is)
Writes a hex dump to a file from a POI input stream.
|
static Duration |
getAdjustedDuration(ProjectProperties properties,
int duration,
TimeUnit timeUnit)
Given a duration and the time units for the duration extracted from an MPP
file, this method creates a new Duration to represent the given
duration.
|
static int |
getByte(byte[] data,
int offset)
This method reads a single byte from the input array.
|
static void |
getByteArray(byte[] data,
int offset,
int size,
byte[] buffer,
int bufferOffset)
This method extracts a portion of a byte array and writes it into
another byte array.
|
static Color |
getColor(byte[] data,
int offset)
Reads a color value represented by three bytes, for R, G, and B
components, plus a flag byte indicating if this is an automatic color.
|
static LocalDateTime |
getDate(byte[] data,
int offset)
Reads a date value.
|
static double |
getDouble(byte[] data,
int offset)
This method reads an eight byte double from the input array.
|
static long |
getDuration(byte[] data,
int offset)
Reads a duration value in milliseconds.
|
static Duration |
getDuration(double value,
TimeUnit type)
Reads a duration value.
|
static Duration |
getDuration(int value,
TimeUnit type)
Reads a duration value.
|
static TimeUnit |
getDurationTimeUnits(int type)
This method converts between the duration units representation
used in the MPP file, and the standard MPX duration units.
|
static TimeUnit |
getDurationTimeUnits(int type,
TimeUnit projectDefaultDurationUnits)
This method converts between the duration units representation
used in the MPP file, and the standard MPX duration units.
|
static UUID |
getGUID(byte[] data,
int offset)
Reads a UUID/GUID from a data block.
|
static int |
getInt(byte[] data,
int offset)
This method reads a four byte integer from the input array.
|
static long |
getLong(byte[] data,
int offset)
This method reads an eight byte integer from the input array.
|
static long |
getLong6(byte[] data,
int offset)
This method reads a six byte long from the input array.
|
static Double |
getPercentage(byte[] data,
int offset)
Utility method to read a percentage value.
|
static int |
getShort(byte[] data,
int offset)
This method reads a two byte integer from the input array.
|
static String |
getString(byte[] data,
int offset)
Reads a string of single byte characters from the input array.
|
static CurrencySymbolPosition |
getSymbolPosition(int value)
This method maps the currency symbol position from the
representation used in the MPP file to the representation
used by MPX.
|
static LocalTime |
getTime(byte[] data,
int offset)
Reads a time value.
|
static LocalDateTime |
getTimestamp(byte[] data,
int offset)
Reads a combined date and time value.
|
static LocalDateTime |
getTimestampFromTenths(byte[] data,
int offset)
Reads a combined date and time value expressed in tenths of a minute.
|
static String |
getUnicodeString(byte[] data,
int offset)
Reads a string of two byte characters from the input array.
|
static String |
getUnicodeString(byte[] data,
int offset,
int maxLength)
Reads a string of two byte characters from the input array.
|
static TimeUnit |
getWorkTimeUnits(int value)
This method maps from the value used to specify default work units in the
MPP file to a standard TimeUnit.
|
static String |
removeAmpersands(String name)
Utility method to remove ampersands embedded in names.
|
static void |
varDataDump(net.sf.mpxj.mpp.Var2Data data,
Integer id,
boolean dumpShort,
boolean dumpInt,
boolean dumpDouble,
boolean dumpTimeStamp,
boolean dumpUnicodeString,
boolean dumpString)
Dump out all the possible variables within the given data block.
|
public static final LocalDateTime EPOCH_DATE
public static final void decodeBuffer(byte[] data, byte encryptionCode)
data
- Source dataencryptionCode
- Encryption codepublic static final String decodePassword(byte[] data, byte encryptionCode)
data
- encrypted data blockencryptionCode
- encryption codepublic static final void getByteArray(byte[] data, int offset, int size, byte[] buffer, int bufferOffset)
data
- Source dataoffset
- Offset into source datasize
- Required size to be extracted from the source databuffer
- Destination bufferbufferOffset
- Offset into destination bufferpublic static final int getByte(byte[] data, int offset)
data
- byte array of dataoffset
- offset of byte data in the arraypublic static final int getShort(byte[] data, int offset)
data
- the input arrayoffset
- offset of integer data in the arraypublic static final int getInt(byte[] data, int offset)
data
- the input arrayoffset
- offset of integer data in the arraypublic static final long getLong(byte[] data, int offset)
data
- the input arrayoffset
- offset of integer data in the arraypublic static final long getLong6(byte[] data, int offset)
data
- the input arrayoffset
- offset of integer data in the arraypublic static final double getDouble(byte[] data, int offset)
data
- the input arrayoffset
- offset of double data in the arraypublic static final UUID getGUID(byte[] data, int offset)
data
- data blockoffset
- offset into the data blockpublic static final LocalDateTime getDate(byte[] data, int offset)
data
- byte array of dataoffset
- location of data as offset into the arraypublic static final LocalTime getTime(byte[] data, int offset)
data
- byte array of dataoffset
- location of data as offset into the arraypublic static final long getDuration(byte[] data, int offset)
data
- byte array of dataoffset
- location of data as offset into the arraypublic static final LocalDateTime getTimestamp(byte[] data, int offset)
data
- byte array of dataoffset
- location of data as offset into the arraypublic static final LocalDateTime getTimestampFromTenths(byte[] data, int offset)
data
- byte array of dataoffset
- location of data as offset into the arraypublic static final String getUnicodeString(byte[] data, int offset)
data
- byte array of dataoffset
- start point of unicode stringpublic static final String getUnicodeString(byte[] data, int offset, int maxLength)
data
- byte array of dataoffset
- start point of unicode stringmaxLength
- length in bytes of the stringpublic static final String getString(byte[] data, int offset)
data
- byte array of dataoffset
- offset into the arraypublic static final Duration getDuration(int value, TimeUnit type)
value
- Duration valuetype
- type of units of the durationpublic static final Color getColor(byte[] data, int offset)
data
- byte array of dataoffset
- offset into arraypublic static final Duration getDuration(double value, TimeUnit type)
value
- Duration valuetype
- type of units of the durationpublic static final TimeUnit getDurationTimeUnits(int type)
type
- MPP unitspublic static final TimeUnit getDurationTimeUnits(int type, TimeUnit projectDefaultDurationUnits)
type
- MPP unitsprojectDefaultDurationUnits
- default duration units for this projectpublic static Duration getAdjustedDuration(ProjectProperties properties, int duration, TimeUnit timeUnit)
properties
- project propertiesduration
- duration lengthtimeUnit
- duration unitspublic static TimeUnit getWorkTimeUnits(int value)
value
- Default work unitspublic static CurrencySymbolPosition getSymbolPosition(int value)
value
- MPP symbol positionpublic static final String removeAmpersands(String name)
name
- name textpublic static final Double getPercentage(byte[] data, int offset)
data
- data blockoffset
- offset into data blockpublic static void convertRateFromHours(ProjectFile file, Resource resource, ResourceField rateField, ResourceField unitsField)
file
- parent fileresource
- parent resourcerateField
- field holding the rateunitsField
- field holding the rate's time unitspublic static final byte[] cloneSubArray(byte[] data, int offset, int size)
data
- source dataoffset
- offset into the source datasize
- length of the source data to copypublic static final void fileHexDump(String fileName, byte[] data)
fileName
- output file namedata
- target datapublic static final void fileHexDump(String fileName, InputStream is)
fileName
- output file nameis
- input streampublic static final void fileDump(String fileName, byte[] data)
fileName
- output file namedata
- target datapublic static final void dataDump(ProjectProperties properties, byte[] data, boolean dumpShort, boolean dumpInt, boolean dumpDouble, boolean dumpTimeStamp, boolean dumpDuration, boolean dumpDate, boolean dumpTime, boolean dumpAdjustedDuration)
properties
- project propertiesdata
- data to dump fromdumpShort
- true to dump all the data as shortsdumpInt
- true to dump all the data as intsdumpDouble
- true to dump all the data as DoublesdumpTimeStamp
- true to dump all the data as TimeStampsdumpDuration
- true to dump all the data as Durations (long)dumpDate
- true to dump all the data as DatesdumpTime
- true to dump all the data as Dates (time)dumpAdjustedDuration
- true to dump all data as adjusted durationspublic static final void varDataDump(net.sf.mpxj.mpp.Var2Data data, Integer id, boolean dumpShort, boolean dumpInt, boolean dumpDouble, boolean dumpTimeStamp, boolean dumpUnicodeString, boolean dumpString)
data
- data to dump fromid
- unique IDdumpShort
- true to dump all the data as shortsdumpInt
- true to dump all the data as intsdumpDouble
- true to dump all the data as DoublesdumpTimeStamp
- true to dump all the data as TimeStampsdumpUnicodeString
- true to dump all the data as Unicode stringsdumpString
- true to dump all the data as stringspublic static void dumpBlockData(int headerSize, int blockSize, byte[] data)
headerSize
- header zieblockSize
- block sizedata
- data blockCopyright © 2000–2024 Packwood Software. All rights reserved.