id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
157,500
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPPUtility.java
MPPUtility.getTimestampFromTenths
public static final Date getTimestampFromTenths(byte[] data, int offset) { long ms = ((long) getInt(data, offset)) * 6000; return (DateHelper.getTimestampFromLong(EPOCH + ms)); }
java
public static final Date getTimestampFromTenths(byte[] data, int offset) { long ms = ((long) getInt(data, offset)) * 6000; return (DateHelper.getTimestampFromLong(EPOCH + ms)); }
[ "public", "static", "final", "Date", "getTimestampFromTenths", "(", "byte", "[", "]", "data", ",", "int", "offset", ")", "{", "long", "ms", "=", "(", "(", "long", ")", "getInt", "(", "data", ",", "offset", ")", ")", "*", "6000", ";", "return", "(", "DateHelper", ".", "getTimestampFromLong", "(", "EPOCH", "+", "ms", ")", ")", ";", "}" ]
Reads a combined date and time value expressed in tenths of a minute. @param data byte array of data @param offset location of data as offset into the array @return time value
[ "Reads", "a", "combined", "date", "and", "time", "value", "expressed", "in", "tenths", "of", "a", "minute", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPUtility.java#L406-L410
157,501
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPPUtility.java
MPPUtility.getUnicodeString
public static final String getUnicodeString(byte[] data, int offset) { int length = getUnicodeStringLengthInBytes(data, offset); return length == 0 ? "" : new String(data, offset, length, CharsetHelper.UTF16LE); }
java
public static final String getUnicodeString(byte[] data, int offset) { int length = getUnicodeStringLengthInBytes(data, offset); return length == 0 ? "" : new String(data, offset, length, CharsetHelper.UTF16LE); }
[ "public", "static", "final", "String", "getUnicodeString", "(", "byte", "[", "]", "data", ",", "int", "offset", ")", "{", "int", "length", "=", "getUnicodeStringLengthInBytes", "(", "data", ",", "offset", ")", ";", "return", "length", "==", "0", "?", "\"\"", ":", "new", "String", "(", "data", ",", "offset", ",", "length", ",", "CharsetHelper", ".", "UTF16LE", ")", ";", "}" ]
Reads a string of two byte characters from the input array. This method assumes that the string finishes either at the end of the array, or when char zero is encountered. The value starts at the position specified by the offset parameter. @param data byte array of data @param offset start point of unicode string @return string value
[ "Reads", "a", "string", "of", "two", "byte", "characters", "from", "the", "input", "array", ".", "This", "method", "assumes", "that", "the", "string", "finishes", "either", "at", "the", "end", "of", "the", "array", "or", "when", "char", "zero", "is", "encountered", ".", "The", "value", "starts", "at", "the", "position", "specified", "by", "the", "offset", "parameter", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPUtility.java#L423-L427
157,502
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPPUtility.java
MPPUtility.getUnicodeStringLengthInBytes
private static final int getUnicodeStringLengthInBytes(byte[] data, int offset) { int result; if (data == null || offset >= data.length) { result = 0; } else { result = data.length - offset; for (int loop = offset; loop < (data.length - 1); loop += 2) { if (data[loop] == 0 && data[loop + 1] == 0) { result = loop - offset; break; } } } return result; }
java
private static final int getUnicodeStringLengthInBytes(byte[] data, int offset) { int result; if (data == null || offset >= data.length) { result = 0; } else { result = data.length - offset; for (int loop = offset; loop < (data.length - 1); loop += 2) { if (data[loop] == 0 && data[loop + 1] == 0) { result = loop - offset; break; } } } return result; }
[ "private", "static", "final", "int", "getUnicodeStringLengthInBytes", "(", "byte", "[", "]", "data", ",", "int", "offset", ")", "{", "int", "result", ";", "if", "(", "data", "==", "null", "||", "offset", ">=", "data", ".", "length", ")", "{", "result", "=", "0", ";", "}", "else", "{", "result", "=", "data", ".", "length", "-", "offset", ";", "for", "(", "int", "loop", "=", "offset", ";", "loop", "<", "(", "data", ".", "length", "-", "1", ")", ";", "loop", "+=", "2", ")", "{", "if", "(", "data", "[", "loop", "]", "==", "0", "&&", "data", "[", "loop", "+", "1", "]", "==", "0", ")", "{", "result", "=", "loop", "-", "offset", ";", "break", ";", "}", "}", "}", "return", "result", ";", "}" ]
Determine the length of a nul terminated UTF16LE string in bytes. @param data string data @param offset offset into string data @return length in bytes
[ "Determine", "the", "length", "of", "a", "nul", "terminated", "UTF16LE", "string", "in", "bytes", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPUtility.java#L459-L480
157,503
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPPUtility.java
MPPUtility.getString
public static final String getString(byte[] data, int offset) { StringBuilder buffer = new StringBuilder(); char c; for (int loop = 0; offset + loop < data.length; loop++) { c = (char) data[offset + loop]; if (c == 0) { break; } buffer.append(c); } return (buffer.toString()); }
java
public static final String getString(byte[] data, int offset) { StringBuilder buffer = new StringBuilder(); char c; for (int loop = 0; offset + loop < data.length; loop++) { c = (char) data[offset + loop]; if (c == 0) { break; } buffer.append(c); } return (buffer.toString()); }
[ "public", "static", "final", "String", "getString", "(", "byte", "[", "]", "data", ",", "int", "offset", ")", "{", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "char", "c", ";", "for", "(", "int", "loop", "=", "0", ";", "offset", "+", "loop", "<", "data", ".", "length", ";", "loop", "++", ")", "{", "c", "=", "(", "char", ")", "data", "[", "offset", "+", "loop", "]", ";", "if", "(", "c", "==", "0", ")", "{", "break", ";", "}", "buffer", ".", "append", "(", "c", ")", ";", "}", "return", "(", "buffer", ".", "toString", "(", ")", ")", ";", "}" ]
Reads a string of single byte characters from the input array. This method assumes that the string finishes either at the end of the array, or when char zero is encountered. Reading begins at the supplied offset into the array. @param data byte array of data @param offset offset into the array @return string value
[ "Reads", "a", "string", "of", "single", "byte", "characters", "from", "the", "input", "array", ".", "This", "method", "assumes", "that", "the", "string", "finishes", "either", "at", "the", "end", "of", "the", "array", "or", "when", "char", "zero", "is", "encountered", ".", "Reading", "begins", "at", "the", "supplied", "offset", "into", "the", "array", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPUtility.java#L492-L510
157,504
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPPUtility.java
MPPUtility.getColor
public static final Color getColor(byte[] data, int offset) { Color result = null; if (getByte(data, offset + 3) == 0) { int r = getByte(data, offset); int g = getByte(data, offset + 1); int b = getByte(data, offset + 2); result = new Color(r, g, b); } return result; }
java
public static final Color getColor(byte[] data, int offset) { Color result = null; if (getByte(data, offset + 3) == 0) { int r = getByte(data, offset); int g = getByte(data, offset + 1); int b = getByte(data, offset + 2); result = new Color(r, g, b); } return result; }
[ "public", "static", "final", "Color", "getColor", "(", "byte", "[", "]", "data", ",", "int", "offset", ")", "{", "Color", "result", "=", "null", ";", "if", "(", "getByte", "(", "data", ",", "offset", "+", "3", ")", "==", "0", ")", "{", "int", "r", "=", "getByte", "(", "data", ",", "offset", ")", ";", "int", "g", "=", "getByte", "(", "data", ",", "offset", "+", "1", ")", ";", "int", "b", "=", "getByte", "(", "data", ",", "offset", "+", "2", ")", ";", "result", "=", "new", "Color", "(", "r", ",", "g", ",", "b", ")", ";", "}", "return", "result", ";", "}" ]
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. Returns null if the color type is "Automatic". @param data byte array of data @param offset offset into array @return new Color instance
[ "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", ".", "Returns", "null", "if", "the", "color", "type", "is", "Automatic", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPUtility.java#L534-L547
157,505
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPPUtility.java
MPPUtility.removeAmpersands
public static final String removeAmpersands(String name) { if (name != null) { if (name.indexOf('&') != -1) { StringBuilder sb = new StringBuilder(); int index = 0; char c; while (index < name.length()) { c = name.charAt(index); if (c != '&') { sb.append(c); } ++index; } name = sb.toString(); } } return (name); }
java
public static final String removeAmpersands(String name) { if (name != null) { if (name.indexOf('&') != -1) { StringBuilder sb = new StringBuilder(); int index = 0; char c; while (index < name.length()) { c = name.charAt(index); if (c != '&') { sb.append(c); } ++index; } name = sb.toString(); } } return (name); }
[ "public", "static", "final", "String", "removeAmpersands", "(", "String", "name", ")", "{", "if", "(", "name", "!=", "null", ")", "{", "if", "(", "name", ".", "indexOf", "(", "'", "'", ")", "!=", "-", "1", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "int", "index", "=", "0", ";", "char", "c", ";", "while", "(", "index", "<", "name", ".", "length", "(", ")", ")", "{", "c", "=", "name", ".", "charAt", "(", "index", ")", ";", "if", "(", "c", "!=", "'", "'", ")", "{", "sb", ".", "append", "(", "c", ")", ";", "}", "++", "index", ";", "}", "name", "=", "sb", ".", "toString", "(", ")", ";", "}", "}", "return", "(", "name", ")", ";", "}" ]
Utility method to remove ampersands embedded in names. @param name name text @return name text without embedded ampersands
[ "Utility", "method", "to", "remove", "ampersands", "embedded", "in", "names", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPUtility.java#L889-L914
157,506
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPPUtility.java
MPPUtility.getPercentage
public static final Double getPercentage(byte[] data, int offset) { int value = MPPUtility.getShort(data, offset); Double result = null; if (value >= 0 && value <= 100) { result = NumberHelper.getDouble(value); } return result; }
java
public static final Double getPercentage(byte[] data, int offset) { int value = MPPUtility.getShort(data, offset); Double result = null; if (value >= 0 && value <= 100) { result = NumberHelper.getDouble(value); } return result; }
[ "public", "static", "final", "Double", "getPercentage", "(", "byte", "[", "]", "data", ",", "int", "offset", ")", "{", "int", "value", "=", "MPPUtility", ".", "getShort", "(", "data", ",", "offset", ")", ";", "Double", "result", "=", "null", ";", "if", "(", "value", ">=", "0", "&&", "value", "<=", "100", ")", "{", "result", "=", "NumberHelper", ".", "getDouble", "(", "value", ")", ";", "}", "return", "result", ";", "}" ]
Utility method to read a percentage value. @param data data block @param offset offset into data block @return percentage value
[ "Utility", "method", "to", "read", "a", "percentage", "value", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPUtility.java#L923-L932
157,507
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPPUtility.java
MPPUtility.cloneSubArray
public static final byte[] cloneSubArray(byte[] data, int offset, int size) { byte[] newData = new byte[size]; System.arraycopy(data, offset, newData, 0, size); return (newData); }
java
public static final byte[] cloneSubArray(byte[] data, int offset, int size) { byte[] newData = new byte[size]; System.arraycopy(data, offset, newData, 0, size); return (newData); }
[ "public", "static", "final", "byte", "[", "]", "cloneSubArray", "(", "byte", "[", "]", "data", ",", "int", "offset", ",", "int", "size", ")", "{", "byte", "[", "]", "newData", "=", "new", "byte", "[", "size", "]", ";", "System", ".", "arraycopy", "(", "data", ",", "offset", ",", "newData", ",", "0", ",", "size", ")", ";", "return", "(", "newData", ")", ";", "}" ]
This method allows a subsection of a byte array to be copied. @param data source data @param offset offset into the source data @param size length of the source data to copy @return new byte array containing copied data
[ "This", "method", "allows", "a", "subsection", "of", "a", "byte", "array", "to", "be", "copied", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPUtility.java#L942-L947
157,508
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/MPPUtility.java
MPPUtility.dumpBlockData
public static void dumpBlockData(int headerSize, int blockSize, byte[] data) { if (data != null) { System.out.println(ByteArrayHelper.hexdump(data, 0, headerSize, false)); int index = headerSize; while (index < data.length) { System.out.println(ByteArrayHelper.hexdump(data, index, blockSize, false)); index += blockSize; } } }
java
public static void dumpBlockData(int headerSize, int blockSize, byte[] data) { if (data != null) { System.out.println(ByteArrayHelper.hexdump(data, 0, headerSize, false)); int index = headerSize; while (index < data.length) { System.out.println(ByteArrayHelper.hexdump(data, index, blockSize, false)); index += blockSize; } } }
[ "public", "static", "void", "dumpBlockData", "(", "int", "headerSize", ",", "int", "blockSize", ",", "byte", "[", "]", "data", ")", "{", "if", "(", "data", "!=", "null", ")", "{", "System", ".", "out", ".", "println", "(", "ByteArrayHelper", ".", "hexdump", "(", "data", ",", "0", ",", "headerSize", ",", "false", ")", ")", ";", "int", "index", "=", "headerSize", ";", "while", "(", "index", "<", "data", ".", "length", ")", "{", "System", ".", "out", ".", "println", "(", "ByteArrayHelper", ".", "hexdump", "(", "data", ",", "index", ",", "blockSize", ",", "false", ")", ")", ";", "index", "+=", "blockSize", ";", "}", "}", "}" ]
Dumps the contents of a structured block made up from a header and fixed sized records. @param headerSize header zie @param blockSize block size @param data data block
[ "Dumps", "the", "contents", "of", "a", "structured", "block", "made", "up", "from", "a", "header", "and", "fixed", "sized", "records", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/MPPUtility.java#L1256-L1268
157,509
joniles/mpxj
src/main/java/net/sf/mpxj/ProjectFile.java
ProjectFile.getDuration
@Deprecated public Duration getDuration(Date startDate, Date endDate) throws MPXJException { return (getDuration("Standard", startDate, endDate)); }
java
@Deprecated public Duration getDuration(Date startDate, Date endDate) throws MPXJException { return (getDuration("Standard", startDate, endDate)); }
[ "@", "Deprecated", "public", "Duration", "getDuration", "(", "Date", "startDate", ",", "Date", "endDate", ")", "throws", "MPXJException", "{", "return", "(", "getDuration", "(", "\"Standard\"", ",", "startDate", ",", "endDate", ")", ")", ";", "}" ]
This method is used to calculate the duration of work between two fixed dates according to the work schedule defined in the named calendar. The calendar used is the "Standard" calendar. If this calendar does not exist, and exception will be thrown. @param startDate start of the period @param endDate end of the period @return new Duration object @throws MPXJException normally when no Standard calendar is available @deprecated use calendar.getDuration(startDate, endDate)
[ "This", "method", "is", "used", "to", "calculate", "the", "duration", "of", "work", "between", "two", "fixed", "dates", "according", "to", "the", "work", "schedule", "defined", "in", "the", "named", "calendar", ".", "The", "calendar", "used", "is", "the", "Standard", "calendar", ".", "If", "this", "calendar", "does", "not", "exist", "and", "exception", "will", "be", "thrown", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectFile.java#L336-L339
157,510
joniles/mpxj
src/main/java/net/sf/mpxj/ProjectFile.java
ProjectFile.getDuration
@Deprecated public Duration getDuration(String calendarName, Date startDate, Date endDate) throws MPXJException { ProjectCalendar calendar = getCalendarByName(calendarName); if (calendar == null) { throw new MPXJException(MPXJException.CALENDAR_ERROR + ": " + calendarName); } return (calendar.getDuration(startDate, endDate)); }
java
@Deprecated public Duration getDuration(String calendarName, Date startDate, Date endDate) throws MPXJException { ProjectCalendar calendar = getCalendarByName(calendarName); if (calendar == null) { throw new MPXJException(MPXJException.CALENDAR_ERROR + ": " + calendarName); } return (calendar.getDuration(startDate, endDate)); }
[ "@", "Deprecated", "public", "Duration", "getDuration", "(", "String", "calendarName", ",", "Date", "startDate", ",", "Date", "endDate", ")", "throws", "MPXJException", "{", "ProjectCalendar", "calendar", "=", "getCalendarByName", "(", "calendarName", ")", ";", "if", "(", "calendar", "==", "null", ")", "{", "throw", "new", "MPXJException", "(", "MPXJException", ".", "CALENDAR_ERROR", "+", "\": \"", "+", "calendarName", ")", ";", "}", "return", "(", "calendar", ".", "getDuration", "(", "startDate", ",", "endDate", ")", ")", ";", "}" ]
This method is used to calculate the duration of work between two fixed dates according to the work schedule defined in the named calendar. The name of the calendar to be used is passed as an argument. @param calendarName name of the calendar to use @param startDate start of the period @param endDate end of the period @return new Duration object @throws MPXJException normally when no Standard calendar is available @deprecated use calendar.getDuration(startDate, endDate)
[ "This", "method", "is", "used", "to", "calculate", "the", "duration", "of", "work", "between", "two", "fixed", "dates", "according", "to", "the", "work", "schedule", "defined", "in", "the", "named", "calendar", ".", "The", "name", "of", "the", "calendar", "to", "be", "used", "is", "passed", "as", "an", "argument", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectFile.java#L353-L363
157,511
joniles/mpxj
src/main/java/net/sf/mpxj/ProjectFile.java
ProjectFile.getStartDate
public Date getStartDate() { Date startDate = null; for (Task task : m_tasks) { // // If a hidden "summary" task is present we ignore it // if (NumberHelper.getInt(task.getUniqueID()) == 0) { continue; } // // Select the actual or forecast start date. Note that the // behaviour is different for milestones. The milestone end date // is always correct, the milestone start date may be different // to reflect a missed deadline. // Date taskStartDate; if (task.getMilestone() == true) { taskStartDate = task.getActualFinish(); if (taskStartDate == null) { taskStartDate = task.getFinish(); } } else { taskStartDate = task.getActualStart(); if (taskStartDate == null) { taskStartDate = task.getStart(); } } if (taskStartDate != null) { if (startDate == null) { startDate = taskStartDate; } else { if (taskStartDate.getTime() < startDate.getTime()) { startDate = taskStartDate; } } } } return (startDate); }
java
public Date getStartDate() { Date startDate = null; for (Task task : m_tasks) { // // If a hidden "summary" task is present we ignore it // if (NumberHelper.getInt(task.getUniqueID()) == 0) { continue; } // // Select the actual or forecast start date. Note that the // behaviour is different for milestones. The milestone end date // is always correct, the milestone start date may be different // to reflect a missed deadline. // Date taskStartDate; if (task.getMilestone() == true) { taskStartDate = task.getActualFinish(); if (taskStartDate == null) { taskStartDate = task.getFinish(); } } else { taskStartDate = task.getActualStart(); if (taskStartDate == null) { taskStartDate = task.getStart(); } } if (taskStartDate != null) { if (startDate == null) { startDate = taskStartDate; } else { if (taskStartDate.getTime() < startDate.getTime()) { startDate = taskStartDate; } } } } return (startDate); }
[ "public", "Date", "getStartDate", "(", ")", "{", "Date", "startDate", "=", "null", ";", "for", "(", "Task", "task", ":", "m_tasks", ")", "{", "//", "// If a hidden \"summary\" task is present we ignore it", "//", "if", "(", "NumberHelper", ".", "getInt", "(", "task", ".", "getUniqueID", "(", ")", ")", "==", "0", ")", "{", "continue", ";", "}", "//", "// Select the actual or forecast start date. Note that the", "// behaviour is different for milestones. The milestone end date", "// is always correct, the milestone start date may be different", "// to reflect a missed deadline.", "//", "Date", "taskStartDate", ";", "if", "(", "task", ".", "getMilestone", "(", ")", "==", "true", ")", "{", "taskStartDate", "=", "task", ".", "getActualFinish", "(", ")", ";", "if", "(", "taskStartDate", "==", "null", ")", "{", "taskStartDate", "=", "task", ".", "getFinish", "(", ")", ";", "}", "}", "else", "{", "taskStartDate", "=", "task", ".", "getActualStart", "(", ")", ";", "if", "(", "taskStartDate", "==", "null", ")", "{", "taskStartDate", "=", "task", ".", "getStart", "(", ")", ";", "}", "}", "if", "(", "taskStartDate", "!=", "null", ")", "{", "if", "(", "startDate", "==", "null", ")", "{", "startDate", "=", "taskStartDate", ";", "}", "else", "{", "if", "(", "taskStartDate", ".", "getTime", "(", ")", "<", "startDate", ".", "getTime", "(", ")", ")", "{", "startDate", "=", "taskStartDate", ";", "}", "}", "}", "}", "return", "(", "startDate", ")", ";", "}" ]
Find the earliest task start date. We treat this as the start date for the project. @return start date
[ "Find", "the", "earliest", "task", "start", "date", ".", "We", "treat", "this", "as", "the", "start", "date", "for", "the", "project", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectFile.java#L430-L485
157,512
joniles/mpxj
src/main/java/net/sf/mpxj/ProjectFile.java
ProjectFile.getFinishDate
public Date getFinishDate() { Date finishDate = null; for (Task task : m_tasks) { // // If a hidden "summary" task is present we ignore it // if (NumberHelper.getInt(task.getUniqueID()) == 0) { continue; } // // Select the actual or forecast start date // Date taskFinishDate; taskFinishDate = task.getActualFinish(); if (taskFinishDate == null) { taskFinishDate = task.getFinish(); } if (taskFinishDate != null) { if (finishDate == null) { finishDate = taskFinishDate; } else { if (taskFinishDate.getTime() > finishDate.getTime()) { finishDate = taskFinishDate; } } } } return (finishDate); }
java
public Date getFinishDate() { Date finishDate = null; for (Task task : m_tasks) { // // If a hidden "summary" task is present we ignore it // if (NumberHelper.getInt(task.getUniqueID()) == 0) { continue; } // // Select the actual or forecast start date // Date taskFinishDate; taskFinishDate = task.getActualFinish(); if (taskFinishDate == null) { taskFinishDate = task.getFinish(); } if (taskFinishDate != null) { if (finishDate == null) { finishDate = taskFinishDate; } else { if (taskFinishDate.getTime() > finishDate.getTime()) { finishDate = taskFinishDate; } } } } return (finishDate); }
[ "public", "Date", "getFinishDate", "(", ")", "{", "Date", "finishDate", "=", "null", ";", "for", "(", "Task", "task", ":", "m_tasks", ")", "{", "//", "// If a hidden \"summary\" task is present we ignore it", "//", "if", "(", "NumberHelper", ".", "getInt", "(", "task", ".", "getUniqueID", "(", ")", ")", "==", "0", ")", "{", "continue", ";", "}", "//", "// Select the actual or forecast start date", "//", "Date", "taskFinishDate", ";", "taskFinishDate", "=", "task", ".", "getActualFinish", "(", ")", ";", "if", "(", "taskFinishDate", "==", "null", ")", "{", "taskFinishDate", "=", "task", ".", "getFinish", "(", ")", ";", "}", "if", "(", "taskFinishDate", "!=", "null", ")", "{", "if", "(", "finishDate", "==", "null", ")", "{", "finishDate", "=", "taskFinishDate", ";", "}", "else", "{", "if", "(", "taskFinishDate", ".", "getTime", "(", ")", ">", "finishDate", ".", "getTime", "(", ")", ")", "{", "finishDate", "=", "taskFinishDate", ";", "}", "}", "}", "}", "return", "(", "finishDate", ")", ";", "}" ]
Find the latest task finish date. We treat this as the finish date for the project. @return finish date
[ "Find", "the", "latest", "task", "finish", "date", ".", "We", "treat", "this", "as", "the", "finish", "date", "for", "the", "project", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectFile.java#L493-L534
157,513
joniles/mpxj
src/main/java/net/sf/mpxj/ProjectFile.java
ProjectFile.getDefaultCalendar
public ProjectCalendar getDefaultCalendar() { String calendarName = m_properties.getDefaultCalendarName(); ProjectCalendar calendar = getCalendarByName(calendarName); if (calendar == null) { if (m_calendars.isEmpty()) { calendar = addDefaultBaseCalendar(); } else { calendar = m_calendars.get(0); } } return calendar; }
java
public ProjectCalendar getDefaultCalendar() { String calendarName = m_properties.getDefaultCalendarName(); ProjectCalendar calendar = getCalendarByName(calendarName); if (calendar == null) { if (m_calendars.isEmpty()) { calendar = addDefaultBaseCalendar(); } else { calendar = m_calendars.get(0); } } return calendar; }
[ "public", "ProjectCalendar", "getDefaultCalendar", "(", ")", "{", "String", "calendarName", "=", "m_properties", ".", "getDefaultCalendarName", "(", ")", ";", "ProjectCalendar", "calendar", "=", "getCalendarByName", "(", "calendarName", ")", ";", "if", "(", "calendar", "==", "null", ")", "{", "if", "(", "m_calendars", ".", "isEmpty", "(", ")", ")", "{", "calendar", "=", "addDefaultBaseCalendar", "(", ")", ";", "}", "else", "{", "calendar", "=", "m_calendars", ".", "get", "(", "0", ")", ";", "}", "}", "return", "calendar", ";", "}" ]
Retrieves the default calendar for this project based on the calendar name given in the project properties. If a calendar of this name cannot be found, then the first calendar listed for the project will be returned. If the project contains no calendars, then a default calendar is added. @return default projectCalendar instance
[ "Retrieves", "the", "default", "calendar", "for", "this", "project", "based", "on", "the", "calendar", "name", "given", "in", "the", "project", "properties", ".", "If", "a", "calendar", "of", "this", "name", "cannot", "be", "found", "then", "the", "first", "calendar", "listed", "for", "the", "project", "will", "be", "returned", ".", "If", "the", "project", "contains", "no", "calendars", "then", "a", "default", "calendar", "is", "added", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectFile.java#L624-L640
157,514
joniles/mpxj
src/main/java/net/sf/mpxj/ProjectFile.java
ProjectFile.getBaselineCalendar
public ProjectCalendar getBaselineCalendar() { // // Attempt to locate the calendar normally used by baselines // If this isn't present, fall back to using the default // project calendar. // ProjectCalendar result = getCalendarByName("Used for Microsoft Project 98 Baseline Calendar"); if (result == null) { result = getDefaultCalendar(); } return result; }
java
public ProjectCalendar getBaselineCalendar() { // // Attempt to locate the calendar normally used by baselines // If this isn't present, fall back to using the default // project calendar. // ProjectCalendar result = getCalendarByName("Used for Microsoft Project 98 Baseline Calendar"); if (result == null) { result = getDefaultCalendar(); } return result; }
[ "public", "ProjectCalendar", "getBaselineCalendar", "(", ")", "{", "//", "// Attempt to locate the calendar normally used by baselines", "// If this isn't present, fall back to using the default", "// project calendar.", "//", "ProjectCalendar", "result", "=", "getCalendarByName", "(", "\"Used for Microsoft Project 98 Baseline Calendar\"", ")", ";", "if", "(", "result", "==", "null", ")", "{", "result", "=", "getDefaultCalendar", "(", ")", ";", "}", "return", "result", ";", "}" ]
Retrieve the calendar used internally for timephased baseline calculation. @return baseline calendar
[ "Retrieve", "the", "calendar", "used", "internally", "for", "timephased", "baseline", "calculation", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectFile.java#L657-L670
157,515
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/GraphicalIndicatorReader.java
GraphicalIndicatorReader.process
public void process(CustomFieldContainer indicators, ProjectProperties properties, Props props) { m_container = indicators; m_properties = properties; m_data = props.getByteArray(Props.TASK_FIELD_ATTRIBUTES); if (m_data != null) { int columnsCount = MPPUtility.getInt(m_data, 4); m_headerOffset = 8; for (int loop = 0; loop < columnsCount; loop++) { processColumns(); } } }
java
public void process(CustomFieldContainer indicators, ProjectProperties properties, Props props) { m_container = indicators; m_properties = properties; m_data = props.getByteArray(Props.TASK_FIELD_ATTRIBUTES); if (m_data != null) { int columnsCount = MPPUtility.getInt(m_data, 4); m_headerOffset = 8; for (int loop = 0; loop < columnsCount; loop++) { processColumns(); } } }
[ "public", "void", "process", "(", "CustomFieldContainer", "indicators", ",", "ProjectProperties", "properties", ",", "Props", "props", ")", "{", "m_container", "=", "indicators", ";", "m_properties", "=", "properties", ";", "m_data", "=", "props", ".", "getByteArray", "(", "Props", ".", "TASK_FIELD_ATTRIBUTES", ")", ";", "if", "(", "m_data", "!=", "null", ")", "{", "int", "columnsCount", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "4", ")", ";", "m_headerOffset", "=", "8", ";", "for", "(", "int", "loop", "=", "0", ";", "loop", "<", "columnsCount", ";", "loop", "++", ")", "{", "processColumns", "(", ")", ";", "}", "}", "}" ]
The main entry point for processing graphical indicator definitions. @param indicators graphical indicators container @param properties project properties @param props properties data
[ "The", "main", "entry", "point", "for", "processing", "graphical", "indicator", "definitions", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/GraphicalIndicatorReader.java#L50-L65
157,516
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/GraphicalIndicatorReader.java
GraphicalIndicatorReader.processColumns
private void processColumns() { int fieldID = MPPUtility.getInt(m_data, m_headerOffset); m_headerOffset += 4; m_dataOffset = MPPUtility.getInt(m_data, m_headerOffset); m_headerOffset += 4; FieldType type = FieldTypeHelper.getInstance(fieldID); if (type.getDataType() != null) { processKnownType(type); } }
java
private void processColumns() { int fieldID = MPPUtility.getInt(m_data, m_headerOffset); m_headerOffset += 4; m_dataOffset = MPPUtility.getInt(m_data, m_headerOffset); m_headerOffset += 4; FieldType type = FieldTypeHelper.getInstance(fieldID); if (type.getDataType() != null) { processKnownType(type); } }
[ "private", "void", "processColumns", "(", ")", "{", "int", "fieldID", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_headerOffset", ")", ";", "m_headerOffset", "+=", "4", ";", "m_dataOffset", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_headerOffset", ")", ";", "m_headerOffset", "+=", "4", ";", "FieldType", "type", "=", "FieldTypeHelper", ".", "getInstance", "(", "fieldID", ")", ";", "if", "(", "type", ".", "getDataType", "(", ")", "!=", "null", ")", "{", "processKnownType", "(", "type", ")", ";", "}", "}" ]
Processes graphical indicator definitions for each column.
[ "Processes", "graphical", "indicator", "definitions", "for", "each", "column", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/GraphicalIndicatorReader.java#L70-L83
157,517
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/GraphicalIndicatorReader.java
GraphicalIndicatorReader.processKnownType
private void processKnownType(FieldType type) { //System.out.println("Header: " + type); //System.out.println(ByteArrayHelper.hexdump(m_data, m_dataOffset, 36, false, 16, "")); GraphicalIndicator indicator = m_container.getCustomField(type).getGraphicalIndicator(); indicator.setFieldType(type); int flags = m_data[m_dataOffset]; indicator.setProjectSummaryInheritsFromSummaryRows((flags & 0x08) != 0); indicator.setSummaryRowsInheritFromNonSummaryRows((flags & 0x04) != 0); indicator.setDisplayGraphicalIndicators((flags & 0x02) != 0); indicator.setShowDataValuesInToolTips((flags & 0x01) != 0); m_dataOffset += 20; int nonSummaryRowOffset = MPPUtility.getInt(m_data, m_dataOffset) - 36; m_dataOffset += 4; int summaryRowOffset = MPPUtility.getInt(m_data, m_dataOffset) - 36; m_dataOffset += 4; int projectSummaryOffset = MPPUtility.getInt(m_data, m_dataOffset) - 36; m_dataOffset += 4; int dataSize = MPPUtility.getInt(m_data, m_dataOffset) - 36; m_dataOffset += 4; //System.out.println("Data"); //System.out.println(ByteArrayHelper.hexdump(m_data, m_dataOffset, dataSize, false, 16, "")); int maxNonSummaryRowOffset = m_dataOffset + summaryRowOffset; int maxSummaryRowOffset = m_dataOffset + projectSummaryOffset; int maxProjectSummaryOffset = m_dataOffset + dataSize; m_dataOffset += nonSummaryRowOffset; while (m_dataOffset + 2 < maxNonSummaryRowOffset) { indicator.addNonSummaryRowCriteria(processCriteria(type)); } while (m_dataOffset + 2 < maxSummaryRowOffset) { indicator.addSummaryRowCriteria(processCriteria(type)); } while (m_dataOffset + 2 < maxProjectSummaryOffset) { indicator.addProjectSummaryCriteria(processCriteria(type)); } }
java
private void processKnownType(FieldType type) { //System.out.println("Header: " + type); //System.out.println(ByteArrayHelper.hexdump(m_data, m_dataOffset, 36, false, 16, "")); GraphicalIndicator indicator = m_container.getCustomField(type).getGraphicalIndicator(); indicator.setFieldType(type); int flags = m_data[m_dataOffset]; indicator.setProjectSummaryInheritsFromSummaryRows((flags & 0x08) != 0); indicator.setSummaryRowsInheritFromNonSummaryRows((flags & 0x04) != 0); indicator.setDisplayGraphicalIndicators((flags & 0x02) != 0); indicator.setShowDataValuesInToolTips((flags & 0x01) != 0); m_dataOffset += 20; int nonSummaryRowOffset = MPPUtility.getInt(m_data, m_dataOffset) - 36; m_dataOffset += 4; int summaryRowOffset = MPPUtility.getInt(m_data, m_dataOffset) - 36; m_dataOffset += 4; int projectSummaryOffset = MPPUtility.getInt(m_data, m_dataOffset) - 36; m_dataOffset += 4; int dataSize = MPPUtility.getInt(m_data, m_dataOffset) - 36; m_dataOffset += 4; //System.out.println("Data"); //System.out.println(ByteArrayHelper.hexdump(m_data, m_dataOffset, dataSize, false, 16, "")); int maxNonSummaryRowOffset = m_dataOffset + summaryRowOffset; int maxSummaryRowOffset = m_dataOffset + projectSummaryOffset; int maxProjectSummaryOffset = m_dataOffset + dataSize; m_dataOffset += nonSummaryRowOffset; while (m_dataOffset + 2 < maxNonSummaryRowOffset) { indicator.addNonSummaryRowCriteria(processCriteria(type)); } while (m_dataOffset + 2 < maxSummaryRowOffset) { indicator.addSummaryRowCriteria(processCriteria(type)); } while (m_dataOffset + 2 < maxProjectSummaryOffset) { indicator.addProjectSummaryCriteria(processCriteria(type)); } }
[ "private", "void", "processKnownType", "(", "FieldType", "type", ")", "{", "//System.out.println(\"Header: \" + type);", "//System.out.println(ByteArrayHelper.hexdump(m_data, m_dataOffset, 36, false, 16, \"\"));", "GraphicalIndicator", "indicator", "=", "m_container", ".", "getCustomField", "(", "type", ")", ".", "getGraphicalIndicator", "(", ")", ";", "indicator", ".", "setFieldType", "(", "type", ")", ";", "int", "flags", "=", "m_data", "[", "m_dataOffset", "]", ";", "indicator", ".", "setProjectSummaryInheritsFromSummaryRows", "(", "(", "flags", "&", "0x08", ")", "!=", "0", ")", ";", "indicator", ".", "setSummaryRowsInheritFromNonSummaryRows", "(", "(", "flags", "&", "0x04", ")", "!=", "0", ")", ";", "indicator", ".", "setDisplayGraphicalIndicators", "(", "(", "flags", "&", "0x02", ")", "!=", "0", ")", ";", "indicator", ".", "setShowDataValuesInToolTips", "(", "(", "flags", "&", "0x01", ")", "!=", "0", ")", ";", "m_dataOffset", "+=", "20", ";", "int", "nonSummaryRowOffset", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_dataOffset", ")", "-", "36", ";", "m_dataOffset", "+=", "4", ";", "int", "summaryRowOffset", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_dataOffset", ")", "-", "36", ";", "m_dataOffset", "+=", "4", ";", "int", "projectSummaryOffset", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_dataOffset", ")", "-", "36", ";", "m_dataOffset", "+=", "4", ";", "int", "dataSize", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_dataOffset", ")", "-", "36", ";", "m_dataOffset", "+=", "4", ";", "//System.out.println(\"Data\");", "//System.out.println(ByteArrayHelper.hexdump(m_data, m_dataOffset, dataSize, false, 16, \"\"));", "int", "maxNonSummaryRowOffset", "=", "m_dataOffset", "+", "summaryRowOffset", ";", "int", "maxSummaryRowOffset", "=", "m_dataOffset", "+", "projectSummaryOffset", ";", "int", "maxProjectSummaryOffset", "=", "m_dataOffset", "+", "dataSize", ";", "m_dataOffset", "+=", "nonSummaryRowOffset", ";", "while", "(", "m_dataOffset", "+", "2", "<", "maxNonSummaryRowOffset", ")", "{", "indicator", ".", "addNonSummaryRowCriteria", "(", "processCriteria", "(", "type", ")", ")", ";", "}", "while", "(", "m_dataOffset", "+", "2", "<", "maxSummaryRowOffset", ")", "{", "indicator", ".", "addSummaryRowCriteria", "(", "processCriteria", "(", "type", ")", ")", ";", "}", "while", "(", "m_dataOffset", "+", "2", "<", "maxProjectSummaryOffset", ")", "{", "indicator", ".", "addProjectSummaryCriteria", "(", "processCriteria", "(", "type", ")", ")", ";", "}", "}" ]
Process a graphical indicator definition for a known type. @param type field type
[ "Process", "a", "graphical", "indicator", "definition", "for", "a", "known", "type", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/GraphicalIndicatorReader.java#L90-L139
157,518
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/GraphicalIndicatorReader.java
GraphicalIndicatorReader.processCriteria
private GraphicalIndicatorCriteria processCriteria(FieldType type) { GraphicalIndicatorCriteria criteria = new GraphicalIndicatorCriteria(m_properties); criteria.setLeftValue(type); int indicatorType = MPPUtility.getInt(m_data, m_dataOffset); m_dataOffset += 4; criteria.setIndicator(indicatorType); if (m_dataOffset + 4 < m_data.length) { int operatorValue = MPPUtility.getInt(m_data, m_dataOffset); m_dataOffset += 4; TestOperator operator = (operatorValue == 0 ? TestOperator.IS_ANY_VALUE : TestOperator.getInstance(operatorValue - 0x3E7)); criteria.setOperator(operator); if (operator != TestOperator.IS_ANY_VALUE) { processOperandValue(0, type, criteria); if (operator == TestOperator.IS_WITHIN || operator == TestOperator.IS_NOT_WITHIN) { processOperandValue(1, type, criteria); } } } return (criteria); }
java
private GraphicalIndicatorCriteria processCriteria(FieldType type) { GraphicalIndicatorCriteria criteria = new GraphicalIndicatorCriteria(m_properties); criteria.setLeftValue(type); int indicatorType = MPPUtility.getInt(m_data, m_dataOffset); m_dataOffset += 4; criteria.setIndicator(indicatorType); if (m_dataOffset + 4 < m_data.length) { int operatorValue = MPPUtility.getInt(m_data, m_dataOffset); m_dataOffset += 4; TestOperator operator = (operatorValue == 0 ? TestOperator.IS_ANY_VALUE : TestOperator.getInstance(operatorValue - 0x3E7)); criteria.setOperator(operator); if (operator != TestOperator.IS_ANY_VALUE) { processOperandValue(0, type, criteria); if (operator == TestOperator.IS_WITHIN || operator == TestOperator.IS_NOT_WITHIN) { processOperandValue(1, type, criteria); } } } return (criteria); }
[ "private", "GraphicalIndicatorCriteria", "processCriteria", "(", "FieldType", "type", ")", "{", "GraphicalIndicatorCriteria", "criteria", "=", "new", "GraphicalIndicatorCriteria", "(", "m_properties", ")", ";", "criteria", ".", "setLeftValue", "(", "type", ")", ";", "int", "indicatorType", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_dataOffset", ")", ";", "m_dataOffset", "+=", "4", ";", "criteria", ".", "setIndicator", "(", "indicatorType", ")", ";", "if", "(", "m_dataOffset", "+", "4", "<", "m_data", ".", "length", ")", "{", "int", "operatorValue", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_dataOffset", ")", ";", "m_dataOffset", "+=", "4", ";", "TestOperator", "operator", "=", "(", "operatorValue", "==", "0", "?", "TestOperator", ".", "IS_ANY_VALUE", ":", "TestOperator", ".", "getInstance", "(", "operatorValue", "-", "0x3E7", ")", ")", ";", "criteria", ".", "setOperator", "(", "operator", ")", ";", "if", "(", "operator", "!=", "TestOperator", ".", "IS_ANY_VALUE", ")", "{", "processOperandValue", "(", "0", ",", "type", ",", "criteria", ")", ";", "if", "(", "operator", "==", "TestOperator", ".", "IS_WITHIN", "||", "operator", "==", "TestOperator", ".", "IS_NOT_WITHIN", ")", "{", "processOperandValue", "(", "1", ",", "type", ",", "criteria", ")", ";", "}", "}", "}", "return", "(", "criteria", ")", ";", "}" ]
Process the graphical indicator criteria for a single column. @param type field type @return indicator criteria data
[ "Process", "the", "graphical", "indicator", "criteria", "for", "a", "single", "column", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/GraphicalIndicatorReader.java#L147-L175
157,519
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/GraphicalIndicatorReader.java
GraphicalIndicatorReader.processOperandValue
private void processOperandValue(int index, FieldType type, GraphicalIndicatorCriteria criteria) { boolean valueFlag = (MPPUtility.getInt(m_data, m_dataOffset) == 1); m_dataOffset += 4; if (valueFlag == false) { int fieldID = MPPUtility.getInt(m_data, m_dataOffset); criteria.setRightValue(index, FieldTypeHelper.getInstance(fieldID)); m_dataOffset += 4; } else { //int dataTypeValue = MPPUtility.getShort(m_data, m_dataOffset); m_dataOffset += 2; switch (type.getDataType()) { case DURATION: // 0x03 { Duration value = MPPUtility.getAdjustedDuration(m_properties, MPPUtility.getInt(m_data, m_dataOffset), MPPUtility.getDurationTimeUnits(MPPUtility.getShort(m_data, m_dataOffset + 4))); m_dataOffset += 6; criteria.setRightValue(index, value); break; } case NUMERIC: // 0x05 { Double value = Double.valueOf(MPPUtility.getDouble(m_data, m_dataOffset)); m_dataOffset += 8; criteria.setRightValue(index, value); break; } case CURRENCY: // 0x06 { Double value = Double.valueOf(MPPUtility.getDouble(m_data, m_dataOffset) / 100); m_dataOffset += 8; criteria.setRightValue(index, value); break; } case STRING: // 0x08 { String value = MPPUtility.getUnicodeString(m_data, m_dataOffset); m_dataOffset += ((value.length() + 1) * 2); criteria.setRightValue(index, value); break; } case BOOLEAN: // 0x0B { int value = MPPUtility.getShort(m_data, m_dataOffset); m_dataOffset += 2; criteria.setRightValue(index, value == 1 ? Boolean.TRUE : Boolean.FALSE); break; } case DATE: // 0x13 { Date value = MPPUtility.getTimestamp(m_data, m_dataOffset); m_dataOffset += 4; criteria.setRightValue(index, value); break; } default: { break; } } } }
java
private void processOperandValue(int index, FieldType type, GraphicalIndicatorCriteria criteria) { boolean valueFlag = (MPPUtility.getInt(m_data, m_dataOffset) == 1); m_dataOffset += 4; if (valueFlag == false) { int fieldID = MPPUtility.getInt(m_data, m_dataOffset); criteria.setRightValue(index, FieldTypeHelper.getInstance(fieldID)); m_dataOffset += 4; } else { //int dataTypeValue = MPPUtility.getShort(m_data, m_dataOffset); m_dataOffset += 2; switch (type.getDataType()) { case DURATION: // 0x03 { Duration value = MPPUtility.getAdjustedDuration(m_properties, MPPUtility.getInt(m_data, m_dataOffset), MPPUtility.getDurationTimeUnits(MPPUtility.getShort(m_data, m_dataOffset + 4))); m_dataOffset += 6; criteria.setRightValue(index, value); break; } case NUMERIC: // 0x05 { Double value = Double.valueOf(MPPUtility.getDouble(m_data, m_dataOffset)); m_dataOffset += 8; criteria.setRightValue(index, value); break; } case CURRENCY: // 0x06 { Double value = Double.valueOf(MPPUtility.getDouble(m_data, m_dataOffset) / 100); m_dataOffset += 8; criteria.setRightValue(index, value); break; } case STRING: // 0x08 { String value = MPPUtility.getUnicodeString(m_data, m_dataOffset); m_dataOffset += ((value.length() + 1) * 2); criteria.setRightValue(index, value); break; } case BOOLEAN: // 0x0B { int value = MPPUtility.getShort(m_data, m_dataOffset); m_dataOffset += 2; criteria.setRightValue(index, value == 1 ? Boolean.TRUE : Boolean.FALSE); break; } case DATE: // 0x13 { Date value = MPPUtility.getTimestamp(m_data, m_dataOffset); m_dataOffset += 4; criteria.setRightValue(index, value); break; } default: { break; } } } }
[ "private", "void", "processOperandValue", "(", "int", "index", ",", "FieldType", "type", ",", "GraphicalIndicatorCriteria", "criteria", ")", "{", "boolean", "valueFlag", "=", "(", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_dataOffset", ")", "==", "1", ")", ";", "m_dataOffset", "+=", "4", ";", "if", "(", "valueFlag", "==", "false", ")", "{", "int", "fieldID", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_dataOffset", ")", ";", "criteria", ".", "setRightValue", "(", "index", ",", "FieldTypeHelper", ".", "getInstance", "(", "fieldID", ")", ")", ";", "m_dataOffset", "+=", "4", ";", "}", "else", "{", "//int dataTypeValue = MPPUtility.getShort(m_data, m_dataOffset);", "m_dataOffset", "+=", "2", ";", "switch", "(", "type", ".", "getDataType", "(", ")", ")", "{", "case", "DURATION", ":", "// 0x03", "{", "Duration", "value", "=", "MPPUtility", ".", "getAdjustedDuration", "(", "m_properties", ",", "MPPUtility", ".", "getInt", "(", "m_data", ",", "m_dataOffset", ")", ",", "MPPUtility", ".", "getDurationTimeUnits", "(", "MPPUtility", ".", "getShort", "(", "m_data", ",", "m_dataOffset", "+", "4", ")", ")", ")", ";", "m_dataOffset", "+=", "6", ";", "criteria", ".", "setRightValue", "(", "index", ",", "value", ")", ";", "break", ";", "}", "case", "NUMERIC", ":", "// 0x05", "{", "Double", "value", "=", "Double", ".", "valueOf", "(", "MPPUtility", ".", "getDouble", "(", "m_data", ",", "m_dataOffset", ")", ")", ";", "m_dataOffset", "+=", "8", ";", "criteria", ".", "setRightValue", "(", "index", ",", "value", ")", ";", "break", ";", "}", "case", "CURRENCY", ":", "// 0x06", "{", "Double", "value", "=", "Double", ".", "valueOf", "(", "MPPUtility", ".", "getDouble", "(", "m_data", ",", "m_dataOffset", ")", "/", "100", ")", ";", "m_dataOffset", "+=", "8", ";", "criteria", ".", "setRightValue", "(", "index", ",", "value", ")", ";", "break", ";", "}", "case", "STRING", ":", "// 0x08", "{", "String", "value", "=", "MPPUtility", ".", "getUnicodeString", "(", "m_data", ",", "m_dataOffset", ")", ";", "m_dataOffset", "+=", "(", "(", "value", ".", "length", "(", ")", "+", "1", ")", "*", "2", ")", ";", "criteria", ".", "setRightValue", "(", "index", ",", "value", ")", ";", "break", ";", "}", "case", "BOOLEAN", ":", "// 0x0B", "{", "int", "value", "=", "MPPUtility", ".", "getShort", "(", "m_data", ",", "m_dataOffset", ")", ";", "m_dataOffset", "+=", "2", ";", "criteria", ".", "setRightValue", "(", "index", ",", "value", "==", "1", "?", "Boolean", ".", "TRUE", ":", "Boolean", ".", "FALSE", ")", ";", "break", ";", "}", "case", "DATE", ":", "// 0x13", "{", "Date", "value", "=", "MPPUtility", ".", "getTimestamp", "(", "m_data", ",", "m_dataOffset", ")", ";", "m_dataOffset", "+=", "4", ";", "criteria", ".", "setRightValue", "(", "index", ",", "value", ")", ";", "break", ";", "}", "default", ":", "{", "break", ";", "}", "}", "}", "}" ]
Process an operand value used in the definition of the graphical indicator criteria. @param index position in operand list @param type field type @param criteria indicator criteria
[ "Process", "an", "operand", "value", "used", "in", "the", "definition", "of", "the", "graphical", "indicator", "criteria", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/GraphicalIndicatorReader.java#L185-L257
157,520
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/GanttChartView12.java
GanttChartView12.getGridLines
private GridLines getGridLines(byte[] data, int offset) { Color normalLineColor = ColorType.getInstance(data[offset]).getColor(); LineStyle normalLineStyle = LineStyle.getInstance(data[offset + 3]); int intervalNumber = data[offset + 4]; LineStyle intervalLineStyle = LineStyle.getInstance(data[offset + 5]); Color intervalLineColor = ColorType.getInstance(data[offset + 6]).getColor(); return new GridLines(normalLineColor, normalLineStyle, intervalNumber, intervalLineStyle, intervalLineColor); }
java
private GridLines getGridLines(byte[] data, int offset) { Color normalLineColor = ColorType.getInstance(data[offset]).getColor(); LineStyle normalLineStyle = LineStyle.getInstance(data[offset + 3]); int intervalNumber = data[offset + 4]; LineStyle intervalLineStyle = LineStyle.getInstance(data[offset + 5]); Color intervalLineColor = ColorType.getInstance(data[offset + 6]).getColor(); return new GridLines(normalLineColor, normalLineStyle, intervalNumber, intervalLineStyle, intervalLineColor); }
[ "private", "GridLines", "getGridLines", "(", "byte", "[", "]", "data", ",", "int", "offset", ")", "{", "Color", "normalLineColor", "=", "ColorType", ".", "getInstance", "(", "data", "[", "offset", "]", ")", ".", "getColor", "(", ")", ";", "LineStyle", "normalLineStyle", "=", "LineStyle", ".", "getInstance", "(", "data", "[", "offset", "+", "3", "]", ")", ";", "int", "intervalNumber", "=", "data", "[", "offset", "+", "4", "]", ";", "LineStyle", "intervalLineStyle", "=", "LineStyle", ".", "getInstance", "(", "data", "[", "offset", "+", "5", "]", ")", ";", "Color", "intervalLineColor", "=", "ColorType", ".", "getInstance", "(", "data", "[", "offset", "+", "6", "]", ")", ".", "getColor", "(", ")", ";", "return", "new", "GridLines", "(", "normalLineColor", ",", "normalLineStyle", ",", "intervalNumber", ",", "intervalLineStyle", ",", "intervalLineColor", ")", ";", "}" ]
Creates a new GridLines instance. @param data data block @param offset offset into data block @return new GridLines instance
[ "Creates", "a", "new", "GridLines", "instance", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/GanttChartView12.java#L229-L237
157,521
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/Var2Data.java
Var2Data.getByteArray
public byte[] getByteArray(Integer offset) { byte[] result = null; if (offset != null) { result = m_map.get(offset); } return (result); }
java
public byte[] getByteArray(Integer offset) { byte[] result = null; if (offset != null) { result = m_map.get(offset); } return (result); }
[ "public", "byte", "[", "]", "getByteArray", "(", "Integer", "offset", ")", "{", "byte", "[", "]", "result", "=", "null", ";", "if", "(", "offset", "!=", "null", ")", "{", "result", "=", "m_map", ".", "get", "(", "offset", ")", ";", "}", "return", "(", "result", ")", ";", "}" ]
This method retrieves a byte array containing the data at the given offset in the block. If no data is found at the given offset this method returns null. @param offset offset of required data @return byte array containing required data
[ "This", "method", "retrieves", "a", "byte", "array", "containing", "the", "data", "at", "the", "given", "offset", "in", "the", "block", ".", "If", "no", "data", "is", "found", "at", "the", "given", "offset", "this", "method", "returns", "null", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/Var2Data.java#L119-L129
157,522
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/Var2Data.java
Var2Data.getByteArray
public byte[] getByteArray(Integer id, Integer type) { return (getByteArray(m_meta.getOffset(id, type))); }
java
public byte[] getByteArray(Integer id, Integer type) { return (getByteArray(m_meta.getOffset(id, type))); }
[ "public", "byte", "[", "]", "getByteArray", "(", "Integer", "id", ",", "Integer", "type", ")", "{", "return", "(", "getByteArray", "(", "m_meta", ".", "getOffset", "(", "id", ",", "type", ")", ")", ")", ";", "}" ]
This method retrieves a byte array of the specified type, belonging to the item with the specified unique ID. @param id unique ID of entity to which this data belongs @param type data type identifier @return byte array containing required data
[ "This", "method", "retrieves", "a", "byte", "array", "of", "the", "specified", "type", "belonging", "to", "the", "item", "with", "the", "specified", "unique", "ID", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/Var2Data.java#L139-L142
157,523
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/Var2Data.java
Var2Data.getUnicodeString
public String getUnicodeString(Integer id, Integer type) { return (getUnicodeString(m_meta.getOffset(id, type))); }
java
public String getUnicodeString(Integer id, Integer type) { return (getUnicodeString(m_meta.getOffset(id, type))); }
[ "public", "String", "getUnicodeString", "(", "Integer", "id", ",", "Integer", "type", ")", "{", "return", "(", "getUnicodeString", "(", "m_meta", ".", "getOffset", "(", "id", ",", "type", ")", ")", ")", ";", "}" ]
This method retrieves a String of the specified type, belonging to the item with the specified unique ID. @param id unique ID of entity to which this data belongs @param type data type identifier @return string containing required data
[ "This", "method", "retrieves", "a", "String", "of", "the", "specified", "type", "belonging", "to", "the", "item", "with", "the", "specified", "unique", "ID", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/Var2Data.java#L176-L179
157,524
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/Var2Data.java
Var2Data.getString
public String getString(Integer offset) { String result = null; if (offset != null) { byte[] value = m_map.get(offset); if (value != null) { result = MPPUtility.getString(value, 0); } } return (result); }
java
public String getString(Integer offset) { String result = null; if (offset != null) { byte[] value = m_map.get(offset); if (value != null) { result = MPPUtility.getString(value, 0); } } return (result); }
[ "public", "String", "getString", "(", "Integer", "offset", ")", "{", "String", "result", "=", "null", ";", "if", "(", "offset", "!=", "null", ")", "{", "byte", "[", "]", "value", "=", "m_map", ".", "get", "(", "offset", ")", ";", "if", "(", "value", "!=", "null", ")", "{", "result", "=", "MPPUtility", ".", "getString", "(", "value", ",", "0", ")", ";", "}", "}", "return", "(", "result", ")", ";", "}" ]
This method retrieves the data at the given offset and returns it as a String, assuming the underlying data is composed of single byte characters. @param offset offset of required data @return string containing required data
[ "This", "method", "retrieves", "the", "data", "at", "the", "given", "offset", "and", "returns", "it", "as", "a", "String", "assuming", "the", "underlying", "data", "is", "composed", "of", "single", "byte", "characters", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/Var2Data.java#L215-L229
157,525
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/Var2Data.java
Var2Data.getString
public String getString(Integer id, Integer type) { return (getString(m_meta.getOffset(id, type))); }
java
public String getString(Integer id, Integer type) { return (getString(m_meta.getOffset(id, type))); }
[ "public", "String", "getString", "(", "Integer", "id", ",", "Integer", "type", ")", "{", "return", "(", "getString", "(", "m_meta", ".", "getOffset", "(", "id", ",", "type", ")", ")", ")", ";", "}" ]
This method retrieves a string of the specified type, belonging to the item with the specified unique ID. @param id unique ID of entity to which this data belongs @param type data type identifier @return required string data
[ "This", "method", "retrieves", "a", "string", "of", "the", "specified", "type", "belonging", "to", "the", "item", "with", "the", "specified", "unique", "ID", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/Var2Data.java#L239-L242
157,526
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/Var2Data.java
Var2Data.getShort
public int getShort(Integer id, Integer type) { int result = 0; Integer offset = m_meta.getOffset(id, type); if (offset != null) { byte[] value = m_map.get(offset); if (value != null && value.length >= 2) { result = MPPUtility.getShort(value, 0); } } return (result); }
java
public int getShort(Integer id, Integer type) { int result = 0; Integer offset = m_meta.getOffset(id, type); if (offset != null) { byte[] value = m_map.get(offset); if (value != null && value.length >= 2) { result = MPPUtility.getShort(value, 0); } } return (result); }
[ "public", "int", "getShort", "(", "Integer", "id", ",", "Integer", "type", ")", "{", "int", "result", "=", "0", ";", "Integer", "offset", "=", "m_meta", ".", "getOffset", "(", "id", ",", "type", ")", ";", "if", "(", "offset", "!=", "null", ")", "{", "byte", "[", "]", "value", "=", "m_map", ".", "get", "(", "offset", ")", ";", "if", "(", "value", "!=", "null", "&&", "value", ".", "length", ">=", "2", ")", "{", "result", "=", "MPPUtility", ".", "getShort", "(", "value", ",", "0", ")", ";", "}", "}", "return", "(", "result", ")", ";", "}" ]
This method retrieves an integer of the specified type, belonging to the item with the specified unique ID. @param id unique ID of entity to which this data belongs @param type data type identifier @return required integer data
[ "This", "method", "retrieves", "an", "integer", "of", "the", "specified", "type", "belonging", "to", "the", "item", "with", "the", "specified", "unique", "ID", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/Var2Data.java#L252-L269
157,527
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/Var2Data.java
Var2Data.getDouble
public double getDouble(Integer id, Integer type) { double result = Double.longBitsToDouble(getLong(id, type)); if (Double.isNaN(result)) { result = 0; } return result; }
java
public double getDouble(Integer id, Integer type) { double result = Double.longBitsToDouble(getLong(id, type)); if (Double.isNaN(result)) { result = 0; } return result; }
[ "public", "double", "getDouble", "(", "Integer", "id", ",", "Integer", "type", ")", "{", "double", "result", "=", "Double", ".", "longBitsToDouble", "(", "getLong", "(", "id", ",", "type", ")", ")", ";", "if", "(", "Double", ".", "isNaN", "(", "result", ")", ")", "{", "result", "=", "0", ";", "}", "return", "result", ";", "}" ]
This method retrieves a double of the specified type, belonging to the item with the specified unique ID. @param id unique ID of entity to which this data belongs @param type data type identifier @return required double data
[ "This", "method", "retrieves", "a", "double", "of", "the", "specified", "type", "belonging", "to", "the", "item", "with", "the", "specified", "unique", "ID", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/Var2Data.java#L390-L398
157,528
joniles/mpxj
src/main/java/net/sf/mpxj/ProjectCalendarDateRanges.java
ProjectCalendarDateRanges.getRange
public DateRange getRange(int index) { DateRange result; if (index >= 0 && index < m_ranges.size()) { result = m_ranges.get(index); } else { result = DateRange.EMPTY_RANGE; } return (result); }
java
public DateRange getRange(int index) { DateRange result; if (index >= 0 && index < m_ranges.size()) { result = m_ranges.get(index); } else { result = DateRange.EMPTY_RANGE; } return (result); }
[ "public", "DateRange", "getRange", "(", "int", "index", ")", "{", "DateRange", "result", ";", "if", "(", "index", ">=", "0", "&&", "index", "<", "m_ranges", ".", "size", "(", ")", ")", "{", "result", "=", "m_ranges", ".", "get", "(", "index", ")", ";", "}", "else", "{", "result", "=", "DateRange", ".", "EMPTY_RANGE", ";", "}", "return", "(", "result", ")", ";", "}" ]
Retrieve the date range at the specified index. The index is zero based, and this method will return null if the requested date range does not exist. @param index range index @return date range instance
[ "Retrieve", "the", "date", "range", "at", "the", "specified", "index", ".", "The", "index", "is", "zero", "based", "and", "this", "method", "will", "return", "null", "if", "the", "requested", "date", "range", "does", "not", "exist", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/ProjectCalendarDateRanges.java#L53-L67
157,529
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/CriteriaReader.java
CriteriaReader.process
public GenericCriteria process(ProjectProperties properties, byte[] data, int dataOffset, int entryOffset, List<GenericCriteriaPrompt> prompts, List<FieldType> fields, boolean[] criteriaType) { m_properties = properties; m_prompts = prompts; m_fields = fields; m_criteriaType = criteriaType; m_dataOffset = dataOffset; if (m_criteriaType != null) { m_criteriaType[0] = true; m_criteriaType[1] = true; } m_criteriaBlockMap.clear(); m_criteriaData = data; m_criteriaTextStart = MPPUtility.getShort(m_criteriaData, m_dataOffset + getCriteriaTextStartOffset()); // // Populate the map // int criteriaStartOffset = getCriteriaStartOffset(); int criteriaBlockSize = getCriteriaBlockSize(); //System.out.println(); //System.out.println(ByteArrayHelper.hexdump(data, dataOffset, criteriaStartOffset, false)); if (m_criteriaData.length <= m_criteriaTextStart) { return null; // bad data } while (criteriaStartOffset + criteriaBlockSize <= m_criteriaTextStart) { byte[] block = new byte[criteriaBlockSize]; System.arraycopy(m_criteriaData, m_dataOffset + criteriaStartOffset, block, 0, criteriaBlockSize); m_criteriaBlockMap.put(Integer.valueOf(criteriaStartOffset), block); //System.out.println(Integer.toHexString(criteriaStartOffset) + ": " + ByteArrayHelper.hexdump(block, false)); criteriaStartOffset += criteriaBlockSize; } if (entryOffset == -1) { entryOffset = getCriteriaStartOffset(); } List<GenericCriteria> list = new LinkedList<GenericCriteria>(); processBlock(list, m_criteriaBlockMap.get(Integer.valueOf(entryOffset))); GenericCriteria criteria; if (list.isEmpty()) { criteria = null; } else { criteria = list.get(0); } return criteria; }
java
public GenericCriteria process(ProjectProperties properties, byte[] data, int dataOffset, int entryOffset, List<GenericCriteriaPrompt> prompts, List<FieldType> fields, boolean[] criteriaType) { m_properties = properties; m_prompts = prompts; m_fields = fields; m_criteriaType = criteriaType; m_dataOffset = dataOffset; if (m_criteriaType != null) { m_criteriaType[0] = true; m_criteriaType[1] = true; } m_criteriaBlockMap.clear(); m_criteriaData = data; m_criteriaTextStart = MPPUtility.getShort(m_criteriaData, m_dataOffset + getCriteriaTextStartOffset()); // // Populate the map // int criteriaStartOffset = getCriteriaStartOffset(); int criteriaBlockSize = getCriteriaBlockSize(); //System.out.println(); //System.out.println(ByteArrayHelper.hexdump(data, dataOffset, criteriaStartOffset, false)); if (m_criteriaData.length <= m_criteriaTextStart) { return null; // bad data } while (criteriaStartOffset + criteriaBlockSize <= m_criteriaTextStart) { byte[] block = new byte[criteriaBlockSize]; System.arraycopy(m_criteriaData, m_dataOffset + criteriaStartOffset, block, 0, criteriaBlockSize); m_criteriaBlockMap.put(Integer.valueOf(criteriaStartOffset), block); //System.out.println(Integer.toHexString(criteriaStartOffset) + ": " + ByteArrayHelper.hexdump(block, false)); criteriaStartOffset += criteriaBlockSize; } if (entryOffset == -1) { entryOffset = getCriteriaStartOffset(); } List<GenericCriteria> list = new LinkedList<GenericCriteria>(); processBlock(list, m_criteriaBlockMap.get(Integer.valueOf(entryOffset))); GenericCriteria criteria; if (list.isEmpty()) { criteria = null; } else { criteria = list.get(0); } return criteria; }
[ "public", "GenericCriteria", "process", "(", "ProjectProperties", "properties", ",", "byte", "[", "]", "data", ",", "int", "dataOffset", ",", "int", "entryOffset", ",", "List", "<", "GenericCriteriaPrompt", ">", "prompts", ",", "List", "<", "FieldType", ">", "fields", ",", "boolean", "[", "]", "criteriaType", ")", "{", "m_properties", "=", "properties", ";", "m_prompts", "=", "prompts", ";", "m_fields", "=", "fields", ";", "m_criteriaType", "=", "criteriaType", ";", "m_dataOffset", "=", "dataOffset", ";", "if", "(", "m_criteriaType", "!=", "null", ")", "{", "m_criteriaType", "[", "0", "]", "=", "true", ";", "m_criteriaType", "[", "1", "]", "=", "true", ";", "}", "m_criteriaBlockMap", ".", "clear", "(", ")", ";", "m_criteriaData", "=", "data", ";", "m_criteriaTextStart", "=", "MPPUtility", ".", "getShort", "(", "m_criteriaData", ",", "m_dataOffset", "+", "getCriteriaTextStartOffset", "(", ")", ")", ";", "//", "// Populate the map", "//", "int", "criteriaStartOffset", "=", "getCriteriaStartOffset", "(", ")", ";", "int", "criteriaBlockSize", "=", "getCriteriaBlockSize", "(", ")", ";", "//System.out.println();", "//System.out.println(ByteArrayHelper.hexdump(data, dataOffset, criteriaStartOffset, false));", "if", "(", "m_criteriaData", ".", "length", "<=", "m_criteriaTextStart", ")", "{", "return", "null", ";", "// bad data", "}", "while", "(", "criteriaStartOffset", "+", "criteriaBlockSize", "<=", "m_criteriaTextStart", ")", "{", "byte", "[", "]", "block", "=", "new", "byte", "[", "criteriaBlockSize", "]", ";", "System", ".", "arraycopy", "(", "m_criteriaData", ",", "m_dataOffset", "+", "criteriaStartOffset", ",", "block", ",", "0", ",", "criteriaBlockSize", ")", ";", "m_criteriaBlockMap", ".", "put", "(", "Integer", ".", "valueOf", "(", "criteriaStartOffset", ")", ",", "block", ")", ";", "//System.out.println(Integer.toHexString(criteriaStartOffset) + \": \" + ByteArrayHelper.hexdump(block, false));", "criteriaStartOffset", "+=", "criteriaBlockSize", ";", "}", "if", "(", "entryOffset", "==", "-", "1", ")", "{", "entryOffset", "=", "getCriteriaStartOffset", "(", ")", ";", "}", "List", "<", "GenericCriteria", ">", "list", "=", "new", "LinkedList", "<", "GenericCriteria", ">", "(", ")", ";", "processBlock", "(", "list", ",", "m_criteriaBlockMap", ".", "get", "(", "Integer", ".", "valueOf", "(", "entryOffset", ")", ")", ")", ";", "GenericCriteria", "criteria", ";", "if", "(", "list", ".", "isEmpty", "(", ")", ")", "{", "criteria", "=", "null", ";", "}", "else", "{", "criteria", "=", "list", ".", "get", "(", "0", ")", ";", "}", "return", "criteria", ";", "}" ]
Main entry point to read criteria data. @param properties project properties @param data criteria data block @param dataOffset offset of the data start within the larger data block @param entryOffset offset of start node for walking the tree @param prompts optional list to hold prompts @param fields optional list of hold fields @param criteriaType optional array representing criteria types @return first node of the criteria
[ "Main", "entry", "point", "to", "read", "criteria", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/CriteriaReader.java#L131-L189
157,530
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/CriteriaReader.java
CriteriaReader.processBlock
private void processBlock(List<GenericCriteria> list, byte[] block) { if (block != null) { if (MPPUtility.getShort(block, 0) > 0x3E6) { addCriteria(list, block); } else { switch (block[0]) { case (byte) 0x0B: { processBlock(list, getChildBlock(block)); break; } case (byte) 0x06: { processBlock(list, getListNextBlock(block)); break; } case (byte) 0xED: // EQUALS { addCriteria(list, block); break; } case (byte) 0x19: // AND case (byte) 0x1B: { addBlock(list, block, TestOperator.AND); break; } case (byte) 0x1A: // OR case (byte) 0x1C: { addBlock(list, block, TestOperator.OR); break; } } } } }
java
private void processBlock(List<GenericCriteria> list, byte[] block) { if (block != null) { if (MPPUtility.getShort(block, 0) > 0x3E6) { addCriteria(list, block); } else { switch (block[0]) { case (byte) 0x0B: { processBlock(list, getChildBlock(block)); break; } case (byte) 0x06: { processBlock(list, getListNextBlock(block)); break; } case (byte) 0xED: // EQUALS { addCriteria(list, block); break; } case (byte) 0x19: // AND case (byte) 0x1B: { addBlock(list, block, TestOperator.AND); break; } case (byte) 0x1A: // OR case (byte) 0x1C: { addBlock(list, block, TestOperator.OR); break; } } } } }
[ "private", "void", "processBlock", "(", "List", "<", "GenericCriteria", ">", "list", ",", "byte", "[", "]", "block", ")", "{", "if", "(", "block", "!=", "null", ")", "{", "if", "(", "MPPUtility", ".", "getShort", "(", "block", ",", "0", ")", ">", "0x3E6", ")", "{", "addCriteria", "(", "list", ",", "block", ")", ";", "}", "else", "{", "switch", "(", "block", "[", "0", "]", ")", "{", "case", "(", "byte", ")", "0x0B", ":", "{", "processBlock", "(", "list", ",", "getChildBlock", "(", "block", ")", ")", ";", "break", ";", "}", "case", "(", "byte", ")", "0x06", ":", "{", "processBlock", "(", "list", ",", "getListNextBlock", "(", "block", ")", ")", ";", "break", ";", "}", "case", "(", "byte", ")", "0xED", ":", "// EQUALS", "{", "addCriteria", "(", "list", ",", "block", ")", ";", "break", ";", "}", "case", "(", "byte", ")", "0x19", ":", "// AND", "case", "(", "byte", ")", "0x1B", ":", "{", "addBlock", "(", "list", ",", "block", ",", "TestOperator", ".", "AND", ")", ";", "break", ";", "}", "case", "(", "byte", ")", "0x1A", ":", "// OR", "case", "(", "byte", ")", "0x1C", ":", "{", "addBlock", "(", "list", ",", "block", ",", "TestOperator", ".", "OR", ")", ";", "break", ";", "}", "}", "}", "}", "}" ]
Process a single criteria block. @param list parent criteria list @param block current block
[ "Process", "a", "single", "criteria", "block", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/CriteriaReader.java#L197-L243
157,531
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/CriteriaReader.java
CriteriaReader.addCriteria
private void addCriteria(List<GenericCriteria> list, byte[] block) { byte[] leftBlock = getChildBlock(block); byte[] rightBlock1 = getListNextBlock(leftBlock); byte[] rightBlock2 = getListNextBlock(rightBlock1); TestOperator operator = TestOperator.getInstance(MPPUtility.getShort(block, 0) - 0x3E7); FieldType leftValue = getFieldType(leftBlock); Object rightValue1 = getValue(leftValue, rightBlock1); Object rightValue2 = rightBlock2 == null ? null : getValue(leftValue, rightBlock2); GenericCriteria criteria = new GenericCriteria(m_properties); criteria.setLeftValue(leftValue); criteria.setOperator(operator); criteria.setRightValue(0, rightValue1); criteria.setRightValue(1, rightValue2); list.add(criteria); if (m_criteriaType != null) { m_criteriaType[0] = leftValue.getFieldTypeClass() == FieldTypeClass.TASK; m_criteriaType[1] = !m_criteriaType[0]; } if (m_fields != null) { m_fields.add(leftValue); } processBlock(list, getListNextBlock(block)); }
java
private void addCriteria(List<GenericCriteria> list, byte[] block) { byte[] leftBlock = getChildBlock(block); byte[] rightBlock1 = getListNextBlock(leftBlock); byte[] rightBlock2 = getListNextBlock(rightBlock1); TestOperator operator = TestOperator.getInstance(MPPUtility.getShort(block, 0) - 0x3E7); FieldType leftValue = getFieldType(leftBlock); Object rightValue1 = getValue(leftValue, rightBlock1); Object rightValue2 = rightBlock2 == null ? null : getValue(leftValue, rightBlock2); GenericCriteria criteria = new GenericCriteria(m_properties); criteria.setLeftValue(leftValue); criteria.setOperator(operator); criteria.setRightValue(0, rightValue1); criteria.setRightValue(1, rightValue2); list.add(criteria); if (m_criteriaType != null) { m_criteriaType[0] = leftValue.getFieldTypeClass() == FieldTypeClass.TASK; m_criteriaType[1] = !m_criteriaType[0]; } if (m_fields != null) { m_fields.add(leftValue); } processBlock(list, getListNextBlock(block)); }
[ "private", "void", "addCriteria", "(", "List", "<", "GenericCriteria", ">", "list", ",", "byte", "[", "]", "block", ")", "{", "byte", "[", "]", "leftBlock", "=", "getChildBlock", "(", "block", ")", ";", "byte", "[", "]", "rightBlock1", "=", "getListNextBlock", "(", "leftBlock", ")", ";", "byte", "[", "]", "rightBlock2", "=", "getListNextBlock", "(", "rightBlock1", ")", ";", "TestOperator", "operator", "=", "TestOperator", ".", "getInstance", "(", "MPPUtility", ".", "getShort", "(", "block", ",", "0", ")", "-", "0x3E7", ")", ";", "FieldType", "leftValue", "=", "getFieldType", "(", "leftBlock", ")", ";", "Object", "rightValue1", "=", "getValue", "(", "leftValue", ",", "rightBlock1", ")", ";", "Object", "rightValue2", "=", "rightBlock2", "==", "null", "?", "null", ":", "getValue", "(", "leftValue", ",", "rightBlock2", ")", ";", "GenericCriteria", "criteria", "=", "new", "GenericCriteria", "(", "m_properties", ")", ";", "criteria", ".", "setLeftValue", "(", "leftValue", ")", ";", "criteria", ".", "setOperator", "(", "operator", ")", ";", "criteria", ".", "setRightValue", "(", "0", ",", "rightValue1", ")", ";", "criteria", ".", "setRightValue", "(", "1", ",", "rightValue2", ")", ";", "list", ".", "add", "(", "criteria", ")", ";", "if", "(", "m_criteriaType", "!=", "null", ")", "{", "m_criteriaType", "[", "0", "]", "=", "leftValue", ".", "getFieldTypeClass", "(", ")", "==", "FieldTypeClass", ".", "TASK", ";", "m_criteriaType", "[", "1", "]", "=", "!", "m_criteriaType", "[", "0", "]", ";", "}", "if", "(", "m_fields", "!=", "null", ")", "{", "m_fields", ".", "add", "(", "leftValue", ")", ";", "}", "processBlock", "(", "list", ",", "getListNextBlock", "(", "block", ")", ")", ";", "}" ]
Adds a basic LHS OPERATOR RHS block. @param list parent criteria list @param block current block
[ "Adds", "a", "basic", "LHS", "OPERATOR", "RHS", "block", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/CriteriaReader.java#L251-L280
157,532
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/CriteriaReader.java
CriteriaReader.addBlock
private void addBlock(List<GenericCriteria> list, byte[] block, TestOperator operator) { GenericCriteria result = new GenericCriteria(m_properties); result.setOperator(operator); list.add(result); processBlock(result.getCriteriaList(), getChildBlock(block)); processBlock(list, getListNextBlock(block)); }
java
private void addBlock(List<GenericCriteria> list, byte[] block, TestOperator operator) { GenericCriteria result = new GenericCriteria(m_properties); result.setOperator(operator); list.add(result); processBlock(result.getCriteriaList(), getChildBlock(block)); processBlock(list, getListNextBlock(block)); }
[ "private", "void", "addBlock", "(", "List", "<", "GenericCriteria", ">", "list", ",", "byte", "[", "]", "block", ",", "TestOperator", "operator", ")", "{", "GenericCriteria", "result", "=", "new", "GenericCriteria", "(", "m_properties", ")", ";", "result", ".", "setOperator", "(", "operator", ")", ";", "list", ".", "add", "(", "result", ")", ";", "processBlock", "(", "result", ".", "getCriteriaList", "(", ")", ",", "getChildBlock", "(", "block", ")", ")", ";", "processBlock", "(", "list", ",", "getListNextBlock", "(", "block", ")", ")", ";", "}" ]
Adds a logical operator block. @param list parent criteria list @param block current block @param operator logical operator represented by this block
[ "Adds", "a", "logical", "operator", "block", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/CriteriaReader.java#L289-L296
157,533
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/CriteriaReader.java
CriteriaReader.getValue
private Object getValue(FieldType field, byte[] block) { Object result = null; switch (block[0]) { case 0x07: // Field { result = getFieldType(block); break; } case 0x01: // Constant value { result = getConstantValue(field, block); break; } case 0x00: // Prompt { result = getPromptValue(field, block); break; } } return result; }
java
private Object getValue(FieldType field, byte[] block) { Object result = null; switch (block[0]) { case 0x07: // Field { result = getFieldType(block); break; } case 0x01: // Constant value { result = getConstantValue(field, block); break; } case 0x00: // Prompt { result = getPromptValue(field, block); break; } } return result; }
[ "private", "Object", "getValue", "(", "FieldType", "field", ",", "byte", "[", "]", "block", ")", "{", "Object", "result", "=", "null", ";", "switch", "(", "block", "[", "0", "]", ")", "{", "case", "0x07", ":", "// Field", "{", "result", "=", "getFieldType", "(", "block", ")", ";", "break", ";", "}", "case", "0x01", ":", "// Constant value", "{", "result", "=", "getConstantValue", "(", "field", ",", "block", ")", ";", "break", ";", "}", "case", "0x00", ":", "// Prompt", "{", "result", "=", "getPromptValue", "(", "field", ",", "block", ")", ";", "break", ";", "}", "}", "return", "result", ";", "}" ]
Retrieves the value component of a criteria expression. @param field field type @param block block data @return field value
[ "Retrieves", "the", "value", "component", "of", "a", "criteria", "expression", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/CriteriaReader.java#L305-L331
157,534
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/CriteriaReader.java
CriteriaReader.getConstantValue
private Object getConstantValue(FieldType type, byte[] block) { Object value; DataType dataType = type.getDataType(); if (dataType == null) { value = null; } else { switch (dataType) { case DURATION: { value = MPPUtility.getAdjustedDuration(m_properties, MPPUtility.getInt(block, getValueOffset()), MPPUtility.getDurationTimeUnits(MPPUtility.getShort(block, getTimeUnitsOffset()))); break; } case NUMERIC: { value = Double.valueOf(MPPUtility.getDouble(block, getValueOffset())); break; } case PERCENTAGE: { value = Double.valueOf(MPPUtility.getShort(block, getValueOffset())); break; } case CURRENCY: { value = Double.valueOf(MPPUtility.getDouble(block, getValueOffset()) / 100); break; } case STRING: { int textOffset = getTextOffset(block); value = MPPUtility.getUnicodeString(m_criteriaData, m_dataOffset + m_criteriaTextStart + textOffset); break; } case BOOLEAN: { int intValue = MPPUtility.getShort(block, getValueOffset()); value = (intValue == 1 ? Boolean.TRUE : Boolean.FALSE); break; } case DATE: { value = MPPUtility.getTimestamp(block, getValueOffset()); break; } default: { value = null; break; } } } return value; }
java
private Object getConstantValue(FieldType type, byte[] block) { Object value; DataType dataType = type.getDataType(); if (dataType == null) { value = null; } else { switch (dataType) { case DURATION: { value = MPPUtility.getAdjustedDuration(m_properties, MPPUtility.getInt(block, getValueOffset()), MPPUtility.getDurationTimeUnits(MPPUtility.getShort(block, getTimeUnitsOffset()))); break; } case NUMERIC: { value = Double.valueOf(MPPUtility.getDouble(block, getValueOffset())); break; } case PERCENTAGE: { value = Double.valueOf(MPPUtility.getShort(block, getValueOffset())); break; } case CURRENCY: { value = Double.valueOf(MPPUtility.getDouble(block, getValueOffset()) / 100); break; } case STRING: { int textOffset = getTextOffset(block); value = MPPUtility.getUnicodeString(m_criteriaData, m_dataOffset + m_criteriaTextStart + textOffset); break; } case BOOLEAN: { int intValue = MPPUtility.getShort(block, getValueOffset()); value = (intValue == 1 ? Boolean.TRUE : Boolean.FALSE); break; } case DATE: { value = MPPUtility.getTimestamp(block, getValueOffset()); break; } default: { value = null; break; } } } return value; }
[ "private", "Object", "getConstantValue", "(", "FieldType", "type", ",", "byte", "[", "]", "block", ")", "{", "Object", "value", ";", "DataType", "dataType", "=", "type", ".", "getDataType", "(", ")", ";", "if", "(", "dataType", "==", "null", ")", "{", "value", "=", "null", ";", "}", "else", "{", "switch", "(", "dataType", ")", "{", "case", "DURATION", ":", "{", "value", "=", "MPPUtility", ".", "getAdjustedDuration", "(", "m_properties", ",", "MPPUtility", ".", "getInt", "(", "block", ",", "getValueOffset", "(", ")", ")", ",", "MPPUtility", ".", "getDurationTimeUnits", "(", "MPPUtility", ".", "getShort", "(", "block", ",", "getTimeUnitsOffset", "(", ")", ")", ")", ")", ";", "break", ";", "}", "case", "NUMERIC", ":", "{", "value", "=", "Double", ".", "valueOf", "(", "MPPUtility", ".", "getDouble", "(", "block", ",", "getValueOffset", "(", ")", ")", ")", ";", "break", ";", "}", "case", "PERCENTAGE", ":", "{", "value", "=", "Double", ".", "valueOf", "(", "MPPUtility", ".", "getShort", "(", "block", ",", "getValueOffset", "(", ")", ")", ")", ";", "break", ";", "}", "case", "CURRENCY", ":", "{", "value", "=", "Double", ".", "valueOf", "(", "MPPUtility", ".", "getDouble", "(", "block", ",", "getValueOffset", "(", ")", ")", "/", "100", ")", ";", "break", ";", "}", "case", "STRING", ":", "{", "int", "textOffset", "=", "getTextOffset", "(", "block", ")", ";", "value", "=", "MPPUtility", ".", "getUnicodeString", "(", "m_criteriaData", ",", "m_dataOffset", "+", "m_criteriaTextStart", "+", "textOffset", ")", ";", "break", ";", "}", "case", "BOOLEAN", ":", "{", "int", "intValue", "=", "MPPUtility", ".", "getShort", "(", "block", ",", "getValueOffset", "(", ")", ")", ";", "value", "=", "(", "intValue", "==", "1", "?", "Boolean", ".", "TRUE", ":", "Boolean", ".", "FALSE", ")", ";", "break", ";", "}", "case", "DATE", ":", "{", "value", "=", "MPPUtility", ".", "getTimestamp", "(", "block", ",", "getValueOffset", "(", ")", ")", ";", "break", ";", "}", "default", ":", "{", "value", "=", "null", ";", "break", ";", "}", "}", "}", "return", "value", ";", "}" ]
Retrieves a constant value. @param type field type @param block criteria data block @return constant value
[ "Retrieves", "a", "constant", "value", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/CriteriaReader.java#L340-L406
157,535
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/CriteriaReader.java
CriteriaReader.getPromptValue
private GenericCriteriaPrompt getPromptValue(FieldType field, byte[] block) { int textOffset = getPromptOffset(block); String value = MPPUtility.getUnicodeString(m_criteriaData, m_criteriaTextStart + textOffset); GenericCriteriaPrompt prompt = new GenericCriteriaPrompt(field.getDataType(), value); if (m_prompts != null) { m_prompts.add(prompt); } return prompt; }
java
private GenericCriteriaPrompt getPromptValue(FieldType field, byte[] block) { int textOffset = getPromptOffset(block); String value = MPPUtility.getUnicodeString(m_criteriaData, m_criteriaTextStart + textOffset); GenericCriteriaPrompt prompt = new GenericCriteriaPrompt(field.getDataType(), value); if (m_prompts != null) { m_prompts.add(prompt); } return prompt; }
[ "private", "GenericCriteriaPrompt", "getPromptValue", "(", "FieldType", "field", ",", "byte", "[", "]", "block", ")", "{", "int", "textOffset", "=", "getPromptOffset", "(", "block", ")", ";", "String", "value", "=", "MPPUtility", ".", "getUnicodeString", "(", "m_criteriaData", ",", "m_criteriaTextStart", "+", "textOffset", ")", ";", "GenericCriteriaPrompt", "prompt", "=", "new", "GenericCriteriaPrompt", "(", "field", ".", "getDataType", "(", ")", ",", "value", ")", ";", "if", "(", "m_prompts", "!=", "null", ")", "{", "m_prompts", ".", "add", "(", "prompt", ")", ";", "}", "return", "prompt", ";", "}" ]
Retrieves a prompt value. @param field field type @param block criteria data block @return prompt value
[ "Retrieves", "a", "prompt", "value", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/CriteriaReader.java#L415-L425
157,536
joniles/mpxj
src/main/java/net/sf/mpxj/synchro/PredecessorReader.java
PredecessorReader.getRelationType
private RelationType getRelationType(int type) { RelationType result; if (type > 0 && type < RELATION_TYPES.length) { result = RELATION_TYPES[type]; } else { result = RelationType.FINISH_START; } return result; }
java
private RelationType getRelationType(int type) { RelationType result; if (type > 0 && type < RELATION_TYPES.length) { result = RELATION_TYPES[type]; } else { result = RelationType.FINISH_START; } return result; }
[ "private", "RelationType", "getRelationType", "(", "int", "type", ")", "{", "RelationType", "result", ";", "if", "(", "type", ">", "0", "&&", "type", "<", "RELATION_TYPES", ".", "length", ")", "{", "result", "=", "RELATION_TYPES", "[", "type", "]", ";", "}", "else", "{", "result", "=", "RelationType", ".", "FINISH_START", ";", "}", "return", "result", ";", "}" ]
Convert an integer to a RelationType instance. @param type integer value @return RelationType instance
[ "Convert", "an", "integer", "to", "a", "RelationType", "instance", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/synchro/PredecessorReader.java#L77-L89
157,537
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/FixFix.java
FixFix.getByteArrayValue
public byte[] getByteArrayValue(int index) { byte[] result = null; if (m_array[index] != null) { result = (byte[]) m_array[index]; } return (result); }
java
public byte[] getByteArrayValue(int index) { byte[] result = null; if (m_array[index] != null) { result = (byte[]) m_array[index]; } return (result); }
[ "public", "byte", "[", "]", "getByteArrayValue", "(", "int", "index", ")", "{", "byte", "[", "]", "result", "=", "null", ";", "if", "(", "m_array", "[", "index", "]", "!=", "null", ")", "{", "result", "=", "(", "byte", "[", "]", ")", "m_array", "[", "index", "]", ";", "}", "return", "(", "result", ")", ";", "}" ]
This method retrieves a byte array containing the data at the given index in the block. If no data is found at the given index this method returns null. @param index index of the data item to be retrieved @return byte array containing the requested data
[ "This", "method", "retrieves", "a", "byte", "array", "containing", "the", "data", "at", "the", "given", "index", "in", "the", "block", ".", "If", "no", "data", "is", "found", "at", "the", "given", "index", "this", "method", "returns", "null", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FixFix.java#L97-L107
157,538
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/Props.java
Props.getByte
public byte getByte(Integer type) { byte result = 0; byte[] item = m_map.get(type); if (item != null) { result = item[0]; } return (result); }
java
public byte getByte(Integer type) { byte result = 0; byte[] item = m_map.get(type); if (item != null) { result = item[0]; } return (result); }
[ "public", "byte", "getByte", "(", "Integer", "type", ")", "{", "byte", "result", "=", "0", ";", "byte", "[", "]", "item", "=", "m_map", ".", "get", "(", "type", ")", ";", "if", "(", "item", "!=", "null", ")", "{", "result", "=", "item", "[", "0", "]", ";", "}", "return", "(", "result", ")", ";", "}" ]
Retrieves a byte value from the property data. @param type Type identifier @return byte value
[ "Retrieves", "a", "byte", "value", "from", "the", "property", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/Props.java#L61-L72
157,539
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/Props.java
Props.getTime
public Date getTime(Integer type) { Date result = null; byte[] item = m_map.get(type); if (item != null) { result = MPPUtility.getTime(item, 0); } return (result); }
java
public Date getTime(Integer type) { Date result = null; byte[] item = m_map.get(type); if (item != null) { result = MPPUtility.getTime(item, 0); } return (result); }
[ "public", "Date", "getTime", "(", "Integer", "type", ")", "{", "Date", "result", "=", "null", ";", "byte", "[", "]", "item", "=", "m_map", ".", "get", "(", "type", ")", ";", "if", "(", "item", "!=", "null", ")", "{", "result", "=", "MPPUtility", ".", "getTime", "(", "item", ",", "0", ")", ";", "}", "return", "(", "result", ")", ";", "}" ]
Retrieves a timestamp from the property data. @param type Type identifier @return timestamp
[ "Retrieves", "a", "timestamp", "from", "the", "property", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/Props.java#L137-L148
157,540
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/Props.java
Props.getUnicodeString
public String getUnicodeString(Integer type) { String result = null; byte[] item = m_map.get(type); if (item != null) { result = MPPUtility.getUnicodeString(item, 0); } return (result); }
java
public String getUnicodeString(Integer type) { String result = null; byte[] item = m_map.get(type); if (item != null) { result = MPPUtility.getUnicodeString(item, 0); } return (result); }
[ "public", "String", "getUnicodeString", "(", "Integer", "type", ")", "{", "String", "result", "=", "null", ";", "byte", "[", "]", "item", "=", "m_map", ".", "get", "(", "type", ")", ";", "if", "(", "item", "!=", "null", ")", "{", "result", "=", "MPPUtility", ".", "getUnicodeString", "(", "item", ",", "0", ")", ";", "}", "return", "(", "result", ")", ";", "}" ]
Retrieves a string value from the property data. @param type Type identifier @return string value
[ "Retrieves", "a", "string", "value", "from", "the", "property", "data", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/Props.java#L194-L205
157,541
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.writeStartObject
public void writeStartObject(String name) throws IOException { writeComma(); writeNewLineIndent(); if (name != null) { writeName(name); writeNewLineIndent(); } m_writer.write("{"); increaseIndent(); }
java
public void writeStartObject(String name) throws IOException { writeComma(); writeNewLineIndent(); if (name != null) { writeName(name); writeNewLineIndent(); } m_writer.write("{"); increaseIndent(); }
[ "public", "void", "writeStartObject", "(", "String", "name", ")", "throws", "IOException", "{", "writeComma", "(", ")", ";", "writeNewLineIndent", "(", ")", ";", "if", "(", "name", "!=", "null", ")", "{", "writeName", "(", "name", ")", ";", "writeNewLineIndent", "(", ")", ";", "}", "m_writer", ".", "write", "(", "\"{\"", ")", ";", "increaseIndent", "(", ")", ";", "}" ]
Begin writing a named object attribute. @param name attribute name
[ "Begin", "writing", "a", "named", "object", "attribute", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L86-L99
157,542
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.writeStartList
public void writeStartList(String name) throws IOException { writeComma(); writeNewLineIndent(); writeName(name); writeNewLineIndent(); m_writer.write("["); increaseIndent(); }
java
public void writeStartList(String name) throws IOException { writeComma(); writeNewLineIndent(); writeName(name); writeNewLineIndent(); m_writer.write("["); increaseIndent(); }
[ "public", "void", "writeStartList", "(", "String", "name", ")", "throws", "IOException", "{", "writeComma", "(", ")", ";", "writeNewLineIndent", "(", ")", ";", "writeName", "(", "name", ")", ";", "writeNewLineIndent", "(", ")", ";", "m_writer", ".", "write", "(", "\"[\"", ")", ";", "increaseIndent", "(", ")", ";", "}" ]
Begin writing a named list attribute. @param name attribute name
[ "Begin", "writing", "a", "named", "list", "attribute", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L106-L114
157,543
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.writeNameValuePair
public void writeNameValuePair(String name, String value) throws IOException { internalWriteNameValuePair(name, escapeString(value)); }
java
public void writeNameValuePair(String name, String value) throws IOException { internalWriteNameValuePair(name, escapeString(value)); }
[ "public", "void", "writeNameValuePair", "(", "String", "name", ",", "String", "value", ")", "throws", "IOException", "{", "internalWriteNameValuePair", "(", "name", ",", "escapeString", "(", "value", ")", ")", ";", "}" ]
Write a string attribute. @param name attribute name @param value attribute value
[ "Write", "a", "string", "attribute", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L140-L143
157,544
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.writeNameValuePair
public void writeNameValuePair(String name, int value) throws IOException { internalWriteNameValuePair(name, Integer.toString(value)); }
java
public void writeNameValuePair(String name, int value) throws IOException { internalWriteNameValuePair(name, Integer.toString(value)); }
[ "public", "void", "writeNameValuePair", "(", "String", "name", ",", "int", "value", ")", "throws", "IOException", "{", "internalWriteNameValuePair", "(", "name", ",", "Integer", ".", "toString", "(", "value", ")", ")", ";", "}" ]
Write an int attribute. @param name attribute name @param value attribute value
[ "Write", "an", "int", "attribute", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L151-L154
157,545
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.writeNameValuePair
public void writeNameValuePair(String name, long value) throws IOException { internalWriteNameValuePair(name, Long.toString(value)); }
java
public void writeNameValuePair(String name, long value) throws IOException { internalWriteNameValuePair(name, Long.toString(value)); }
[ "public", "void", "writeNameValuePair", "(", "String", "name", ",", "long", "value", ")", "throws", "IOException", "{", "internalWriteNameValuePair", "(", "name", ",", "Long", ".", "toString", "(", "value", ")", ")", ";", "}" ]
Write a long attribute. @param name attribute name @param value attribute value
[ "Write", "a", "long", "attribute", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L162-L165
157,546
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.writeNameValuePair
public void writeNameValuePair(String name, double value) throws IOException { internalWriteNameValuePair(name, Double.toString(value)); }
java
public void writeNameValuePair(String name, double value) throws IOException { internalWriteNameValuePair(name, Double.toString(value)); }
[ "public", "void", "writeNameValuePair", "(", "String", "name", ",", "double", "value", ")", "throws", "IOException", "{", "internalWriteNameValuePair", "(", "name", ",", "Double", ".", "toString", "(", "value", ")", ")", ";", "}" ]
Write a double attribute. @param name attribute name @param value attribute value
[ "Write", "a", "double", "attribute", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L173-L176
157,547
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.writeNameValuePair
public void writeNameValuePair(String name, Date value) throws IOException { internalWriteNameValuePair(name, m_format.format(value)); }
java
public void writeNameValuePair(String name, Date value) throws IOException { internalWriteNameValuePair(name, m_format.format(value)); }
[ "public", "void", "writeNameValuePair", "(", "String", "name", ",", "Date", "value", ")", "throws", "IOException", "{", "internalWriteNameValuePair", "(", "name", ",", "m_format", ".", "format", "(", "value", ")", ")", ";", "}" ]
Write a Date attribute. @param name attribute name @param value attribute value
[ "Write", "a", "Date", "attribute", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L195-L198
157,548
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.internalWriteNameValuePair
private void internalWriteNameValuePair(String name, String value) throws IOException { writeComma(); writeNewLineIndent(); writeName(name); if (m_pretty) { m_writer.write(' '); } m_writer.write(value); }
java
private void internalWriteNameValuePair(String name, String value) throws IOException { writeComma(); writeNewLineIndent(); writeName(name); if (m_pretty) { m_writer.write(' '); } m_writer.write(value); }
[ "private", "void", "internalWriteNameValuePair", "(", "String", "name", ",", "String", "value", ")", "throws", "IOException", "{", "writeComma", "(", ")", ";", "writeNewLineIndent", "(", ")", ";", "writeName", "(", "name", ")", ";", "if", "(", "m_pretty", ")", "{", "m_writer", ".", "write", "(", "'", "'", ")", ";", "}", "m_writer", ".", "write", "(", "value", ")", ";", "}" ]
Core write attribute implementation. @param name attribute name @param value attribute value
[ "Core", "write", "attribute", "implementation", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L206-L218
157,549
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.escapeString
private String escapeString(String value) { m_buffer.setLength(0); m_buffer.append('"'); for (int index = 0; index < value.length(); index++) { char c = value.charAt(index); switch (c) { case '"': { m_buffer.append("\\\""); break; } case '\\': { m_buffer.append("\\\\"); break; } case '/': { m_buffer.append("\\/"); break; } case '\b': { m_buffer.append("\\b"); break; } case '\f': { m_buffer.append("\\f"); break; } case '\n': { m_buffer.append("\\n"); break; } case '\r': { m_buffer.append("\\r"); break; } case '\t': { m_buffer.append("\\t"); break; } default: { // Append if it's not a control character (0x00 to 0x1f) if (c > 0x1f) { m_buffer.append(c); } break; } } } m_buffer.append('"'); return m_buffer.toString(); }
java
private String escapeString(String value) { m_buffer.setLength(0); m_buffer.append('"'); for (int index = 0; index < value.length(); index++) { char c = value.charAt(index); switch (c) { case '"': { m_buffer.append("\\\""); break; } case '\\': { m_buffer.append("\\\\"); break; } case '/': { m_buffer.append("\\/"); break; } case '\b': { m_buffer.append("\\b"); break; } case '\f': { m_buffer.append("\\f"); break; } case '\n': { m_buffer.append("\\n"); break; } case '\r': { m_buffer.append("\\r"); break; } case '\t': { m_buffer.append("\\t"); break; } default: { // Append if it's not a control character (0x00 to 0x1f) if (c > 0x1f) { m_buffer.append(c); } break; } } } m_buffer.append('"'); return m_buffer.toString(); }
[ "private", "String", "escapeString", "(", "String", "value", ")", "{", "m_buffer", ".", "setLength", "(", "0", ")", ";", "m_buffer", ".", "append", "(", "'", "'", ")", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "value", ".", "length", "(", ")", ";", "index", "++", ")", "{", "char", "c", "=", "value", ".", "charAt", "(", "index", ")", ";", "switch", "(", "c", ")", "{", "case", "'", "'", ":", "{", "m_buffer", ".", "append", "(", "\"\\\\\\\"\"", ")", ";", "break", ";", "}", "case", "'", "'", ":", "{", "m_buffer", ".", "append", "(", "\"\\\\\\\\\"", ")", ";", "break", ";", "}", "case", "'", "'", ":", "{", "m_buffer", ".", "append", "(", "\"\\\\/\"", ")", ";", "break", ";", "}", "case", "'", "'", ":", "{", "m_buffer", ".", "append", "(", "\"\\\\b\"", ")", ";", "break", ";", "}", "case", "'", "'", ":", "{", "m_buffer", ".", "append", "(", "\"\\\\f\"", ")", ";", "break", ";", "}", "case", "'", "'", ":", "{", "m_buffer", ".", "append", "(", "\"\\\\n\"", ")", ";", "break", ";", "}", "case", "'", "'", ":", "{", "m_buffer", ".", "append", "(", "\"\\\\r\"", ")", ";", "break", ";", "}", "case", "'", "'", ":", "{", "m_buffer", ".", "append", "(", "\"\\\\t\"", ")", ";", "break", ";", "}", "default", ":", "{", "// Append if it's not a control character (0x00 to 0x1f)", "if", "(", "c", ">", "0x1f", ")", "{", "m_buffer", ".", "append", "(", "c", ")", ";", "}", "break", ";", "}", "}", "}", "m_buffer", ".", "append", "(", "'", "'", ")", ";", "return", "m_buffer", ".", "toString", "(", ")", ";", "}" ]
Escape text to ensure valid JSON. @param value value @return escaped value
[ "Escape", "text", "to", "ensure", "valid", "JSON", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L226-L296
157,550
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.writeComma
private void writeComma() throws IOException { if (m_firstNameValuePair.peek().booleanValue()) { m_firstNameValuePair.pop(); m_firstNameValuePair.push(Boolean.FALSE); } else { m_writer.write(','); } }
java
private void writeComma() throws IOException { if (m_firstNameValuePair.peek().booleanValue()) { m_firstNameValuePair.pop(); m_firstNameValuePair.push(Boolean.FALSE); } else { m_writer.write(','); } }
[ "private", "void", "writeComma", "(", ")", "throws", "IOException", "{", "if", "(", "m_firstNameValuePair", ".", "peek", "(", ")", ".", "booleanValue", "(", ")", ")", "{", "m_firstNameValuePair", ".", "pop", "(", ")", ";", "m_firstNameValuePair", ".", "push", "(", "Boolean", ".", "FALSE", ")", ";", "}", "else", "{", "m_writer", ".", "write", "(", "'", "'", ")", ";", "}", "}" ]
Write a comma to the output stream if required.
[ "Write", "a", "comma", "to", "the", "output", "stream", "if", "required", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L301-L312
157,551
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.writeNewLineIndent
private void writeNewLineIndent() throws IOException { if (m_pretty) { if (!m_indent.isEmpty()) { m_writer.write('\n'); m_writer.write(m_indent); } } }
java
private void writeNewLineIndent() throws IOException { if (m_pretty) { if (!m_indent.isEmpty()) { m_writer.write('\n'); m_writer.write(m_indent); } } }
[ "private", "void", "writeNewLineIndent", "(", ")", "throws", "IOException", "{", "if", "(", "m_pretty", ")", "{", "if", "(", "!", "m_indent", ".", "isEmpty", "(", ")", ")", "{", "m_writer", ".", "write", "(", "'", "'", ")", ";", "m_writer", ".", "write", "(", "m_indent", ")", ";", "}", "}", "}" ]
Write a new line and indent.
[ "Write", "a", "new", "line", "and", "indent", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L317-L327
157,552
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.writeName
private void writeName(String name) throws IOException { m_writer.write('"'); m_writer.write(name); m_writer.write('"'); m_writer.write(":"); }
java
private void writeName(String name) throws IOException { m_writer.write('"'); m_writer.write(name); m_writer.write('"'); m_writer.write(":"); }
[ "private", "void", "writeName", "(", "String", "name", ")", "throws", "IOException", "{", "m_writer", ".", "write", "(", "'", "'", ")", ";", "m_writer", ".", "write", "(", "name", ")", ";", "m_writer", ".", "write", "(", "'", "'", ")", ";", "m_writer", ".", "write", "(", "\":\"", ")", ";", "}" ]
Write an attribute name. @param name attribute name
[ "Write", "an", "attribute", "name", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L334-L340
157,553
joniles/mpxj
src/main/java/net/sf/mpxj/json/JsonStreamWriter.java
JsonStreamWriter.decreaseIndent
private void decreaseIndent() throws IOException { if (m_pretty) { m_writer.write('\n'); m_indent = m_indent.substring(0, m_indent.length() - INDENT.length()); m_writer.write(m_indent); } m_firstNameValuePair.pop(); }
java
private void decreaseIndent() throws IOException { if (m_pretty) { m_writer.write('\n'); m_indent = m_indent.substring(0, m_indent.length() - INDENT.length()); m_writer.write(m_indent); } m_firstNameValuePair.pop(); }
[ "private", "void", "decreaseIndent", "(", ")", "throws", "IOException", "{", "if", "(", "m_pretty", ")", "{", "m_writer", ".", "write", "(", "'", "'", ")", ";", "m_indent", "=", "m_indent", ".", "substring", "(", "0", ",", "m_indent", ".", "length", "(", ")", "-", "INDENT", ".", "length", "(", ")", ")", ";", "m_writer", ".", "write", "(", "m_indent", ")", ";", "}", "m_firstNameValuePair", ".", "pop", "(", ")", ";", "}" ]
Decrease the indent level.
[ "Decrease", "the", "indent", "level", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/json/JsonStreamWriter.java#L357-L366
157,554
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/AvailabilityFactory.java
AvailabilityFactory.process
public void process(AvailabilityTable table, byte[] data) { if (data != null) { Calendar cal = DateHelper.popCalendar(); int items = MPPUtility.getShort(data, 0); int offset = 12; for (int loop = 0; loop < items; loop++) { double unitsValue = MPPUtility.getDouble(data, offset + 4); if (unitsValue != 0) { Date startDate = MPPUtility.getTimestampFromTenths(data, offset); Date endDate = MPPUtility.getTimestampFromTenths(data, offset + 20); cal.setTime(endDate); cal.add(Calendar.MINUTE, -1); endDate = cal.getTime(); Double units = NumberHelper.getDouble(unitsValue / 100); Availability item = new Availability(startDate, endDate, units); table.add(item); } offset += 20; } DateHelper.pushCalendar(cal); Collections.sort(table); } }
java
public void process(AvailabilityTable table, byte[] data) { if (data != null) { Calendar cal = DateHelper.popCalendar(); int items = MPPUtility.getShort(data, 0); int offset = 12; for (int loop = 0; loop < items; loop++) { double unitsValue = MPPUtility.getDouble(data, offset + 4); if (unitsValue != 0) { Date startDate = MPPUtility.getTimestampFromTenths(data, offset); Date endDate = MPPUtility.getTimestampFromTenths(data, offset + 20); cal.setTime(endDate); cal.add(Calendar.MINUTE, -1); endDate = cal.getTime(); Double units = NumberHelper.getDouble(unitsValue / 100); Availability item = new Availability(startDate, endDate, units); table.add(item); } offset += 20; } DateHelper.pushCalendar(cal); Collections.sort(table); } }
[ "public", "void", "process", "(", "AvailabilityTable", "table", ",", "byte", "[", "]", "data", ")", "{", "if", "(", "data", "!=", "null", ")", "{", "Calendar", "cal", "=", "DateHelper", ".", "popCalendar", "(", ")", ";", "int", "items", "=", "MPPUtility", ".", "getShort", "(", "data", ",", "0", ")", ";", "int", "offset", "=", "12", ";", "for", "(", "int", "loop", "=", "0", ";", "loop", "<", "items", ";", "loop", "++", ")", "{", "double", "unitsValue", "=", "MPPUtility", ".", "getDouble", "(", "data", ",", "offset", "+", "4", ")", ";", "if", "(", "unitsValue", "!=", "0", ")", "{", "Date", "startDate", "=", "MPPUtility", ".", "getTimestampFromTenths", "(", "data", ",", "offset", ")", ";", "Date", "endDate", "=", "MPPUtility", ".", "getTimestampFromTenths", "(", "data", ",", "offset", "+", "20", ")", ";", "cal", ".", "setTime", "(", "endDate", ")", ";", "cal", ".", "add", "(", "Calendar", ".", "MINUTE", ",", "-", "1", ")", ";", "endDate", "=", "cal", ".", "getTime", "(", ")", ";", "Double", "units", "=", "NumberHelper", ".", "getDouble", "(", "unitsValue", "/", "100", ")", ";", "Availability", "item", "=", "new", "Availability", "(", "startDate", ",", "endDate", ",", "units", ")", ";", "table", ".", "add", "(", "item", ")", ";", "}", "offset", "+=", "20", ";", "}", "DateHelper", ".", "pushCalendar", "(", "cal", ")", ";", "Collections", ".", "sort", "(", "table", ")", ";", "}", "}" ]
Populates a resource availability table. @param table resource availability table @param data file data
[ "Populates", "a", "resource", "availability", "table", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/AvailabilityFactory.java#L46-L73
157,555
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/LocaleData.java
LocaleData.getObject
public static final Object getObject(Locale locale, String key) { ResourceBundle bundle = ResourceBundle.getBundle(LocaleData.class.getName(), locale); return (bundle.getObject(key)); }
java
public static final Object getObject(Locale locale, String key) { ResourceBundle bundle = ResourceBundle.getBundle(LocaleData.class.getName(), locale); return (bundle.getObject(key)); }
[ "public", "static", "final", "Object", "getObject", "(", "Locale", "locale", ",", "String", "key", ")", "{", "ResourceBundle", "bundle", "=", "ResourceBundle", ".", "getBundle", "(", "LocaleData", ".", "class", ".", "getName", "(", ")", ",", "locale", ")", ";", "return", "(", "bundle", ".", "getObject", "(", "key", ")", ")", ";", "}" ]
Convenience method for retrieving an Object resource. @param locale locale identifier @param key resource key @return resource value
[ "Convenience", "method", "for", "retrieving", "an", "Object", "resource", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/LocaleData.java#L99-L103
157,556
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/LocaleData.java
LocaleData.getMap
@SuppressWarnings("rawtypes") public static final Map getMap(Locale locale, String key) { ResourceBundle bundle = ResourceBundle.getBundle(LocaleData.class.getName(), locale); return ((Map) bundle.getObject(key)); }
java
@SuppressWarnings("rawtypes") public static final Map getMap(Locale locale, String key) { ResourceBundle bundle = ResourceBundle.getBundle(LocaleData.class.getName(), locale); return ((Map) bundle.getObject(key)); }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "static", "final", "Map", "getMap", "(", "Locale", "locale", ",", "String", "key", ")", "{", "ResourceBundle", "bundle", "=", "ResourceBundle", ".", "getBundle", "(", "LocaleData", ".", "class", ".", "getName", "(", ")", ",", "locale", ")", ";", "return", "(", "(", "Map", ")", "bundle", ".", "getObject", "(", "key", ")", ")", ";", "}" ]
Convenience method for retrieving a Map resource. @param locale locale identifier @param key resource key @return resource value
[ "Convenience", "method", "for", "retrieving", "a", "Map", "resource", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/LocaleData.java#L112-L116
157,557
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/LocaleData.java
LocaleData.getInteger
public static final Integer getInteger(Locale locale, String key) { ResourceBundle bundle = ResourceBundle.getBundle(LocaleData.class.getName(), locale); return ((Integer) bundle.getObject(key)); }
java
public static final Integer getInteger(Locale locale, String key) { ResourceBundle bundle = ResourceBundle.getBundle(LocaleData.class.getName(), locale); return ((Integer) bundle.getObject(key)); }
[ "public", "static", "final", "Integer", "getInteger", "(", "Locale", "locale", ",", "String", "key", ")", "{", "ResourceBundle", "bundle", "=", "ResourceBundle", ".", "getBundle", "(", "LocaleData", ".", "class", ".", "getName", "(", ")", ",", "locale", ")", ";", "return", "(", "(", "Integer", ")", "bundle", ".", "getObject", "(", "key", ")", ")", ";", "}" ]
Convenience method for retrieving an Integer resource. @param locale locale identifier @param key resource key @return resource value
[ "Convenience", "method", "for", "retrieving", "an", "Integer", "resource", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/LocaleData.java#L125-L129
157,558
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/LocaleData.java
LocaleData.getChar
public static final char getChar(Locale locale, String key) { ResourceBundle bundle = ResourceBundle.getBundle(LocaleData.class.getName(), locale); return (bundle.getString(key).charAt(0)); }
java
public static final char getChar(Locale locale, String key) { ResourceBundle bundle = ResourceBundle.getBundle(LocaleData.class.getName(), locale); return (bundle.getString(key).charAt(0)); }
[ "public", "static", "final", "char", "getChar", "(", "Locale", "locale", ",", "String", "key", ")", "{", "ResourceBundle", "bundle", "=", "ResourceBundle", ".", "getBundle", "(", "LocaleData", ".", "class", ".", "getName", "(", ")", ",", "locale", ")", ";", "return", "(", "bundle", ".", "getString", "(", "key", ")", ".", "charAt", "(", "0", ")", ")", ";", "}" ]
Convenience method for retrieving a char resource. @param locale locale identifier @param key resource key @return resource value
[ "Convenience", "method", "for", "retrieving", "a", "char", "resource", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/LocaleData.java#L138-L142
157,559
joniles/mpxj
src/main/java/net/sf/mpxj/Resource.java
Resource.getOverAllocated
public boolean getOverAllocated() { Boolean overallocated = (Boolean) getCachedValue(ResourceField.OVERALLOCATED); if (overallocated == null) { Number peakUnits = getPeakUnits(); Number maxUnits = getMaxUnits(); overallocated = Boolean.valueOf(NumberHelper.getDouble(peakUnits) > NumberHelper.getDouble(maxUnits)); set(ResourceField.OVERALLOCATED, overallocated); } return (overallocated.booleanValue()); }
java
public boolean getOverAllocated() { Boolean overallocated = (Boolean) getCachedValue(ResourceField.OVERALLOCATED); if (overallocated == null) { Number peakUnits = getPeakUnits(); Number maxUnits = getMaxUnits(); overallocated = Boolean.valueOf(NumberHelper.getDouble(peakUnits) > NumberHelper.getDouble(maxUnits)); set(ResourceField.OVERALLOCATED, overallocated); } return (overallocated.booleanValue()); }
[ "public", "boolean", "getOverAllocated", "(", ")", "{", "Boolean", "overallocated", "=", "(", "Boolean", ")", "getCachedValue", "(", "ResourceField", ".", "OVERALLOCATED", ")", ";", "if", "(", "overallocated", "==", "null", ")", "{", "Number", "peakUnits", "=", "getPeakUnits", "(", ")", ";", "Number", "maxUnits", "=", "getMaxUnits", "(", ")", ";", "overallocated", "=", "Boolean", ".", "valueOf", "(", "NumberHelper", ".", "getDouble", "(", "peakUnits", ")", ">", "NumberHelper", ".", "getDouble", "(", "maxUnits", ")", ")", ";", "set", "(", "ResourceField", ".", "OVERALLOCATED", ",", "overallocated", ")", ";", "}", "return", "(", "overallocated", ".", "booleanValue", "(", ")", ")", ";", "}" ]
Retrieves the overallocated flag. @return overallocated flag
[ "Retrieves", "the", "overallocated", "flag", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L401-L412
157,560
joniles/mpxj
src/main/java/net/sf/mpxj/Resource.java
Resource.getStart
public Date getStart() { Date result = null; for (ResourceAssignment assignment : m_assignments) { if (result == null || DateHelper.compare(result, assignment.getStart()) > 0) { result = assignment.getStart(); } } return (result); }
java
public Date getStart() { Date result = null; for (ResourceAssignment assignment : m_assignments) { if (result == null || DateHelper.compare(result, assignment.getStart()) > 0) { result = assignment.getStart(); } } return (result); }
[ "public", "Date", "getStart", "(", ")", "{", "Date", "result", "=", "null", ";", "for", "(", "ResourceAssignment", "assignment", ":", "m_assignments", ")", "{", "if", "(", "result", "==", "null", "||", "DateHelper", ".", "compare", "(", "result", ",", "assignment", ".", "getStart", "(", ")", ")", ">", "0", ")", "{", "result", "=", "assignment", ".", "getStart", "(", ")", ";", "}", "}", "return", "(", "result", ")", ";", "}" ]
Retrieves the earliest start date for all assigned tasks. @return start date
[ "Retrieves", "the", "earliest", "start", "date", "for", "all", "assigned", "tasks", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L459-L470
157,561
joniles/mpxj
src/main/java/net/sf/mpxj/Resource.java
Resource.getWorkVariance
public Duration getWorkVariance() { Duration variance = (Duration) getCachedValue(ResourceField.WORK_VARIANCE); if (variance == null) { Duration work = getWork(); Duration baselineWork = getBaselineWork(); if (work != null && baselineWork != null) { variance = Duration.getInstance(work.getDuration() - baselineWork.convertUnits(work.getUnits(), getParentFile().getProjectProperties()).getDuration(), work.getUnits()); set(ResourceField.WORK_VARIANCE, variance); } } return (variance); }
java
public Duration getWorkVariance() { Duration variance = (Duration) getCachedValue(ResourceField.WORK_VARIANCE); if (variance == null) { Duration work = getWork(); Duration baselineWork = getBaselineWork(); if (work != null && baselineWork != null) { variance = Duration.getInstance(work.getDuration() - baselineWork.convertUnits(work.getUnits(), getParentFile().getProjectProperties()).getDuration(), work.getUnits()); set(ResourceField.WORK_VARIANCE, variance); } } return (variance); }
[ "public", "Duration", "getWorkVariance", "(", ")", "{", "Duration", "variance", "=", "(", "Duration", ")", "getCachedValue", "(", "ResourceField", ".", "WORK_VARIANCE", ")", ";", "if", "(", "variance", "==", "null", ")", "{", "Duration", "work", "=", "getWork", "(", ")", ";", "Duration", "baselineWork", "=", "getBaselineWork", "(", ")", ";", "if", "(", "work", "!=", "null", "&&", "baselineWork", "!=", "null", ")", "{", "variance", "=", "Duration", ".", "getInstance", "(", "work", ".", "getDuration", "(", ")", "-", "baselineWork", ".", "convertUnits", "(", "work", ".", "getUnits", "(", ")", ",", "getParentFile", "(", ")", ".", "getProjectProperties", "(", ")", ")", ".", "getDuration", "(", ")", ",", "work", ".", "getUnits", "(", ")", ")", ";", "set", "(", "ResourceField", ".", "WORK_VARIANCE", ",", "variance", ")", ";", "}", "}", "return", "(", "variance", ")", ";", "}" ]
Retrieves the work variance. @return work variance
[ "Retrieves", "the", "work", "variance", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L935-L949
157,562
joniles/mpxj
src/main/java/net/sf/mpxj/Resource.java
Resource.getNotes
public String getNotes() { String notes = (String) getCachedValue(ResourceField.NOTES); return (notes == null ? "" : notes); }
java
public String getNotes() { String notes = (String) getCachedValue(ResourceField.NOTES); return (notes == null ? "" : notes); }
[ "public", "String", "getNotes", "(", ")", "{", "String", "notes", "=", "(", "String", ")", "getCachedValue", "(", "ResourceField", ".", "NOTES", ")", ";", "return", "(", "notes", "==", "null", "?", "\"\"", ":", "notes", ")", ";", "}" ]
Retrieves the notes text for this resource. @return notes text
[ "Retrieves", "the", "notes", "text", "for", "this", "resource", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L1074-L1078
157,563
joniles/mpxj
src/main/java/net/sf/mpxj/Resource.java
Resource.setResourceCalendar
public void setResourceCalendar(ProjectCalendar calendar) { set(ResourceField.CALENDAR, calendar); if (calendar == null) { setResourceCalendarUniqueID(null); } else { calendar.setResource(this); setResourceCalendarUniqueID(calendar.getUniqueID()); } }
java
public void setResourceCalendar(ProjectCalendar calendar) { set(ResourceField.CALENDAR, calendar); if (calendar == null) { setResourceCalendarUniqueID(null); } else { calendar.setResource(this); setResourceCalendarUniqueID(calendar.getUniqueID()); } }
[ "public", "void", "setResourceCalendar", "(", "ProjectCalendar", "calendar", ")", "{", "set", "(", "ResourceField", ".", "CALENDAR", ",", "calendar", ")", ";", "if", "(", "calendar", "==", "null", ")", "{", "setResourceCalendarUniqueID", "(", "null", ")", ";", "}", "else", "{", "calendar", ".", "setResource", "(", "this", ")", ";", "setResourceCalendarUniqueID", "(", "calendar", ".", "getUniqueID", "(", ")", ")", ";", "}", "}" ]
This method allows a pre-existing resource calendar to be attached to a resource. @param calendar resource calendar
[ "This", "method", "allows", "a", "pre", "-", "existing", "resource", "calendar", "to", "be", "attached", "to", "a", "resource", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L1340-L1352
157,564
joniles/mpxj
src/main/java/net/sf/mpxj/Resource.java
Resource.addResourceCalendar
public ProjectCalendar addResourceCalendar() throws MPXJException { if (getResourceCalendar() != null) { throw new MPXJException(MPXJException.MAXIMUM_RECORDS); } ProjectCalendar calendar = new ProjectCalendar(getParentFile()); setResourceCalendar(calendar); return calendar; }
java
public ProjectCalendar addResourceCalendar() throws MPXJException { if (getResourceCalendar() != null) { throw new MPXJException(MPXJException.MAXIMUM_RECORDS); } ProjectCalendar calendar = new ProjectCalendar(getParentFile()); setResourceCalendar(calendar); return calendar; }
[ "public", "ProjectCalendar", "addResourceCalendar", "(", ")", "throws", "MPXJException", "{", "if", "(", "getResourceCalendar", "(", ")", "!=", "null", ")", "{", "throw", "new", "MPXJException", "(", "MPXJException", ".", "MAXIMUM_RECORDS", ")", ";", "}", "ProjectCalendar", "calendar", "=", "new", "ProjectCalendar", "(", "getParentFile", "(", ")", ")", ";", "setResourceCalendar", "(", "calendar", ")", ";", "return", "calendar", ";", "}" ]
This method allows a resource calendar to be added to a resource. @return ResourceCalendar @throws MPXJException if more than one calendar is added
[ "This", "method", "allows", "a", "resource", "calendar", "to", "be", "added", "to", "a", "resource", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L1380-L1390
157,565
joniles/mpxj
src/main/java/net/sf/mpxj/Resource.java
Resource.setBaseCalendar
public void setBaseCalendar(String val) { set(ResourceField.BASE_CALENDAR, val == null || val.length() == 0 ? "Standard" : val); }
java
public void setBaseCalendar(String val) { set(ResourceField.BASE_CALENDAR, val == null || val.length() == 0 ? "Standard" : val); }
[ "public", "void", "setBaseCalendar", "(", "String", "val", ")", "{", "set", "(", "ResourceField", ".", "BASE_CALENDAR", ",", "val", "==", "null", "||", "val", ".", "length", "(", ")", "==", "0", "?", "\"Standard\"", ":", "val", ")", ";", "}" ]
Sets the Base Calendar field indicates which calendar is the base calendar for a resource calendar. The list includes the three built-in calendars, as well as any new base calendars you have created in the Change Working Time dialog box. @param val calendar name
[ "Sets", "the", "Base", "Calendar", "field", "indicates", "which", "calendar", "is", "the", "base", "calendar", "for", "a", "resource", "calendar", ".", "The", "list", "includes", "the", "three", "built", "-", "in", "calendars", "as", "well", "as", "any", "new", "base", "calendars", "you", "have", "created", "in", "the", "Change", "Working", "Time", "dialog", "box", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L1400-L1403
157,566
joniles/mpxj
src/main/java/net/sf/mpxj/Resource.java
Resource.setID
@Override public void setID(Integer val) { ProjectFile parent = getParentFile(); Integer previous = getID(); if (previous != null) { parent.getResources().unmapID(previous); } parent.getResources().mapID(val, this); set(ResourceField.ID, val); }
java
@Override public void setID(Integer val) { ProjectFile parent = getParentFile(); Integer previous = getID(); if (previous != null) { parent.getResources().unmapID(previous); } parent.getResources().mapID(val, this); set(ResourceField.ID, val); }
[ "@", "Override", "public", "void", "setID", "(", "Integer", "val", ")", "{", "ProjectFile", "parent", "=", "getParentFile", "(", ")", ";", "Integer", "previous", "=", "getID", "(", ")", ";", "if", "(", "previous", "!=", "null", ")", "{", "parent", ".", "getResources", "(", ")", ".", "unmapID", "(", "previous", ")", ";", "}", "parent", ".", "getResources", "(", ")", ".", "mapID", "(", "val", ",", "this", ")", ";", "set", "(", "ResourceField", ".", "ID", ",", "val", ")", ";", "}" ]
Sets ID field value. @param val value
[ "Sets", "ID", "field", "value", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L1431-L1442
157,567
joniles/mpxj
src/main/java/net/sf/mpxj/Resource.java
Resource.getFlag
public boolean getFlag(int index) { return BooleanHelper.getBoolean((Boolean) getCachedValue(selectField(ResourceFieldLists.CUSTOM_FLAG, index))); }
java
public boolean getFlag(int index) { return BooleanHelper.getBoolean((Boolean) getCachedValue(selectField(ResourceFieldLists.CUSTOM_FLAG, index))); }
[ "public", "boolean", "getFlag", "(", "int", "index", ")", "{", "return", "BooleanHelper", ".", "getBoolean", "(", "(", "Boolean", ")", "getCachedValue", "(", "selectField", "(", "ResourceFieldLists", ".", "CUSTOM_FLAG", ",", "index", ")", ")", ")", ";", "}" ]
Retrieve a flag value. @param index flag index (1-20) @return flag value
[ "Retrieve", "a", "flag", "value", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L1738-L1741
157,568
joniles/mpxj
src/main/java/net/sf/mpxj/Resource.java
Resource.selectField
private ResourceField selectField(ResourceField[] fields, int index) { if (index < 1 || index > fields.length) { throw new IllegalArgumentException(index + " is not a valid field index"); } return (fields[index - 1]); }
java
private ResourceField selectField(ResourceField[] fields, int index) { if (index < 1 || index > fields.length) { throw new IllegalArgumentException(index + " is not a valid field index"); } return (fields[index - 1]); }
[ "private", "ResourceField", "selectField", "(", "ResourceField", "[", "]", "fields", ",", "int", "index", ")", "{", "if", "(", "index", "<", "1", "||", "index", ">", "fields", ".", "length", ")", "{", "throw", "new", "IllegalArgumentException", "(", "index", "+", "\" is not a valid field index\"", ")", ";", "}", "return", "(", "fields", "[", "index", "-", "1", "]", ")", ";", "}" ]
Maps a field index to a ResourceField instance. @param fields array of fields used as the basis for the mapping. @param index required field index @return ResourceField instance
[ "Maps", "a", "field", "index", "to", "a", "ResourceField", "instance", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Resource.java#L2317-L2324
157,569
joniles/mpxj
src/main/java/net/sf/mpxj/common/AbstractTimephasedWorkNormaliser.java
AbstractTimephasedWorkNormaliser.mergeSameWork
protected void mergeSameWork(LinkedList<TimephasedWork> list) { LinkedList<TimephasedWork> result = new LinkedList<TimephasedWork>(); TimephasedWork previousAssignment = null; for (TimephasedWork assignment : list) { if (previousAssignment == null) { assignment.setAmountPerDay(assignment.getTotalAmount()); result.add(assignment); } else { Duration previousAssignmentWork = previousAssignment.getAmountPerDay(); Duration assignmentWork = assignment.getTotalAmount(); if (NumberHelper.equals(previousAssignmentWork.getDuration(), assignmentWork.getDuration(), 0.01)) { Date assignmentStart = previousAssignment.getStart(); Date assignmentFinish = assignment.getFinish(); double total = previousAssignment.getTotalAmount().getDuration(); total += assignmentWork.getDuration(); Duration totalWork = Duration.getInstance(total, TimeUnit.MINUTES); TimephasedWork merged = new TimephasedWork(); merged.setStart(assignmentStart); merged.setFinish(assignmentFinish); merged.setAmountPerDay(assignmentWork); merged.setTotalAmount(totalWork); result.removeLast(); assignment = merged; } else { assignment.setAmountPerDay(assignment.getTotalAmount()); } result.add(assignment); } previousAssignment = assignment; } list.clear(); list.addAll(result); }
java
protected void mergeSameWork(LinkedList<TimephasedWork> list) { LinkedList<TimephasedWork> result = new LinkedList<TimephasedWork>(); TimephasedWork previousAssignment = null; for (TimephasedWork assignment : list) { if (previousAssignment == null) { assignment.setAmountPerDay(assignment.getTotalAmount()); result.add(assignment); } else { Duration previousAssignmentWork = previousAssignment.getAmountPerDay(); Duration assignmentWork = assignment.getTotalAmount(); if (NumberHelper.equals(previousAssignmentWork.getDuration(), assignmentWork.getDuration(), 0.01)) { Date assignmentStart = previousAssignment.getStart(); Date assignmentFinish = assignment.getFinish(); double total = previousAssignment.getTotalAmount().getDuration(); total += assignmentWork.getDuration(); Duration totalWork = Duration.getInstance(total, TimeUnit.MINUTES); TimephasedWork merged = new TimephasedWork(); merged.setStart(assignmentStart); merged.setFinish(assignmentFinish); merged.setAmountPerDay(assignmentWork); merged.setTotalAmount(totalWork); result.removeLast(); assignment = merged; } else { assignment.setAmountPerDay(assignment.getTotalAmount()); } result.add(assignment); } previousAssignment = assignment; } list.clear(); list.addAll(result); }
[ "protected", "void", "mergeSameWork", "(", "LinkedList", "<", "TimephasedWork", ">", "list", ")", "{", "LinkedList", "<", "TimephasedWork", ">", "result", "=", "new", "LinkedList", "<", "TimephasedWork", ">", "(", ")", ";", "TimephasedWork", "previousAssignment", "=", "null", ";", "for", "(", "TimephasedWork", "assignment", ":", "list", ")", "{", "if", "(", "previousAssignment", "==", "null", ")", "{", "assignment", ".", "setAmountPerDay", "(", "assignment", ".", "getTotalAmount", "(", ")", ")", ";", "result", ".", "add", "(", "assignment", ")", ";", "}", "else", "{", "Duration", "previousAssignmentWork", "=", "previousAssignment", ".", "getAmountPerDay", "(", ")", ";", "Duration", "assignmentWork", "=", "assignment", ".", "getTotalAmount", "(", ")", ";", "if", "(", "NumberHelper", ".", "equals", "(", "previousAssignmentWork", ".", "getDuration", "(", ")", ",", "assignmentWork", ".", "getDuration", "(", ")", ",", "0.01", ")", ")", "{", "Date", "assignmentStart", "=", "previousAssignment", ".", "getStart", "(", ")", ";", "Date", "assignmentFinish", "=", "assignment", ".", "getFinish", "(", ")", ";", "double", "total", "=", "previousAssignment", ".", "getTotalAmount", "(", ")", ".", "getDuration", "(", ")", ";", "total", "+=", "assignmentWork", ".", "getDuration", "(", ")", ";", "Duration", "totalWork", "=", "Duration", ".", "getInstance", "(", "total", ",", "TimeUnit", ".", "MINUTES", ")", ";", "TimephasedWork", "merged", "=", "new", "TimephasedWork", "(", ")", ";", "merged", ".", "setStart", "(", "assignmentStart", ")", ";", "merged", ".", "setFinish", "(", "assignmentFinish", ")", ";", "merged", ".", "setAmountPerDay", "(", "assignmentWork", ")", ";", "merged", ".", "setTotalAmount", "(", "totalWork", ")", ";", "result", ".", "removeLast", "(", ")", ";", "assignment", "=", "merged", ";", "}", "else", "{", "assignment", ".", "setAmountPerDay", "(", "assignment", ".", "getTotalAmount", "(", ")", ")", ";", "}", "result", ".", "add", "(", "assignment", ")", ";", "}", "previousAssignment", "=", "assignment", ";", "}", "list", ".", "clear", "(", ")", ";", "list", ".", "addAll", "(", "result", ")", ";", "}" ]
Merges individual days together into time spans where the same work is undertaken each day. @param list assignment data
[ "Merges", "individual", "days", "together", "into", "time", "spans", "where", "the", "same", "work", "is", "undertaken", "each", "day", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/common/AbstractTimephasedWorkNormaliser.java#L55-L101
157,570
joniles/mpxj
src/main/java/net/sf/mpxj/common/AbstractTimephasedWorkNormaliser.java
AbstractTimephasedWorkNormaliser.convertToHours
protected void convertToHours(LinkedList<TimephasedWork> list) { for (TimephasedWork assignment : list) { Duration totalWork = assignment.getTotalAmount(); Duration workPerDay = assignment.getAmountPerDay(); totalWork = Duration.getInstance(totalWork.getDuration() / 60, TimeUnit.HOURS); workPerDay = Duration.getInstance(workPerDay.getDuration() / 60, TimeUnit.HOURS); assignment.setTotalAmount(totalWork); assignment.setAmountPerDay(workPerDay); } }
java
protected void convertToHours(LinkedList<TimephasedWork> list) { for (TimephasedWork assignment : list) { Duration totalWork = assignment.getTotalAmount(); Duration workPerDay = assignment.getAmountPerDay(); totalWork = Duration.getInstance(totalWork.getDuration() / 60, TimeUnit.HOURS); workPerDay = Duration.getInstance(workPerDay.getDuration() / 60, TimeUnit.HOURS); assignment.setTotalAmount(totalWork); assignment.setAmountPerDay(workPerDay); } }
[ "protected", "void", "convertToHours", "(", "LinkedList", "<", "TimephasedWork", ">", "list", ")", "{", "for", "(", "TimephasedWork", "assignment", ":", "list", ")", "{", "Duration", "totalWork", "=", "assignment", ".", "getTotalAmount", "(", ")", ";", "Duration", "workPerDay", "=", "assignment", ".", "getAmountPerDay", "(", ")", ";", "totalWork", "=", "Duration", ".", "getInstance", "(", "totalWork", ".", "getDuration", "(", ")", "/", "60", ",", "TimeUnit", ".", "HOURS", ")", ";", "workPerDay", "=", "Duration", ".", "getInstance", "(", "workPerDay", ".", "getDuration", "(", ")", "/", "60", ",", "TimeUnit", ".", "HOURS", ")", ";", "assignment", ".", "setTotalAmount", "(", "totalWork", ")", ";", "assignment", ".", "setAmountPerDay", "(", "workPerDay", ")", ";", "}", "}" ]
Converts assignment duration values from minutes to hours. @param list assignment data
[ "Converts", "assignment", "duration", "values", "from", "minutes", "to", "hours", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/common/AbstractTimephasedWorkNormaliser.java#L108-L119
157,571
joniles/mpxj
src/main/java/net/sf/mpxj/fasttrack/FastTrackTable.java
FastTrackTable.addColumn
public void addColumn(FastTrackColumn column) { FastTrackField type = column.getType(); Object[] data = column.getData(); for (int index = 0; index < data.length; index++) { MapRow row = getRow(index); row.getMap().put(type, data[index]); } }
java
public void addColumn(FastTrackColumn column) { FastTrackField type = column.getType(); Object[] data = column.getData(); for (int index = 0; index < data.length; index++) { MapRow row = getRow(index); row.getMap().put(type, data[index]); } }
[ "public", "void", "addColumn", "(", "FastTrackColumn", "column", ")", "{", "FastTrackField", "type", "=", "column", ".", "getType", "(", ")", ";", "Object", "[", "]", "data", "=", "column", ".", "getData", "(", ")", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "data", ".", "length", ";", "index", "++", ")", "{", "MapRow", "row", "=", "getRow", "(", "index", ")", ";", "row", ".", "getMap", "(", ")", ".", "put", "(", "type", ",", "data", "[", "index", "]", ")", ";", "}", "}" ]
Add data for a column to this table. @param column column data
[ "Add", "data", "for", "a", "column", "to", "this", "table", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/fasttrack/FastTrackTable.java#L83-L92
157,572
joniles/mpxj
src/main/java/net/sf/mpxj/fasttrack/FastTrackTable.java
FastTrackTable.getRow
private MapRow getRow(int index) { MapRow result; if (index == m_rows.size()) { result = new MapRow(this, new HashMap<FastTrackField, Object>()); m_rows.add(result); } else { result = m_rows.get(index); } return result; }
java
private MapRow getRow(int index) { MapRow result; if (index == m_rows.size()) { result = new MapRow(this, new HashMap<FastTrackField, Object>()); m_rows.add(result); } else { result = m_rows.get(index); } return result; }
[ "private", "MapRow", "getRow", "(", "int", "index", ")", "{", "MapRow", "result", ";", "if", "(", "index", "==", "m_rows", ".", "size", "(", ")", ")", "{", "result", "=", "new", "MapRow", "(", "this", ",", "new", "HashMap", "<", "FastTrackField", ",", "Object", ">", "(", ")", ")", ";", "m_rows", ".", "add", "(", "result", ")", ";", "}", "else", "{", "result", "=", "m_rows", ".", "get", "(", "index", ")", ";", "}", "return", "result", ";", "}" ]
Retrieve a specific row by index number, creating a blank row if this row does not exist. @param index index number @return MapRow instance
[ "Retrieve", "a", "specific", "row", "by", "index", "number", "creating", "a", "blank", "row", "if", "this", "row", "does", "not", "exist", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/fasttrack/FastTrackTable.java#L108-L123
157,573
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.setRecordNumber
private void setRecordNumber(LinkedList<String> list) { try { String number = list.remove(0); m_recordNumber = Integer.valueOf(number); } catch (NumberFormatException ex) { // Malformed MPX file: the record number isn't a valid integer // Catch the exception here, leaving m_recordNumber as null // so we will skip this record entirely. } }
java
private void setRecordNumber(LinkedList<String> list) { try { String number = list.remove(0); m_recordNumber = Integer.valueOf(number); } catch (NumberFormatException ex) { // Malformed MPX file: the record number isn't a valid integer // Catch the exception here, leaving m_recordNumber as null // so we will skip this record entirely. } }
[ "private", "void", "setRecordNumber", "(", "LinkedList", "<", "String", ">", "list", ")", "{", "try", "{", "String", "number", "=", "list", ".", "remove", "(", "0", ")", ";", "m_recordNumber", "=", "Integer", ".", "valueOf", "(", "number", ")", ";", "}", "catch", "(", "NumberFormatException", "ex", ")", "{", "// Malformed MPX file: the record number isn't a valid integer", "// Catch the exception here, leaving m_recordNumber as null", "// so we will skip this record entirely.", "}", "}" ]
Pop the record number from the front of the list, and parse it to ensure that it is a valid integer. @param list MPX record
[ "Pop", "the", "record", "number", "from", "the", "front", "of", "the", "list", "and", "parse", "it", "to", "ensure", "that", "it", "is", "a", "valid", "integer", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L95-L108
157,574
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.getString
public String getString(int field) { String result; if (field < m_fields.length) { result = m_fields[field]; if (result != null) { result = result.replace(MPXConstants.EOL_PLACEHOLDER, '\n'); } } else { result = null; } return (result); }
java
public String getString(int field) { String result; if (field < m_fields.length) { result = m_fields[field]; if (result != null) { result = result.replace(MPXConstants.EOL_PLACEHOLDER, '\n'); } } else { result = null; } return (result); }
[ "public", "String", "getString", "(", "int", "field", ")", "{", "String", "result", ";", "if", "(", "field", "<", "m_fields", ".", "length", ")", "{", "result", "=", "m_fields", "[", "field", "]", ";", "if", "(", "result", "!=", "null", ")", "{", "result", "=", "result", ".", "replace", "(", "MPXConstants", ".", "EOL_PLACEHOLDER", ",", "'", "'", ")", ";", "}", "}", "else", "{", "result", "=", "null", ";", "}", "return", "(", "result", ")", ";", "}" ]
Accessor method used to retrieve a String object representing the contents of an individual field. If the field does not exist in the record, null is returned. @param field the index number of the field to be retrieved @return the value of the required field
[ "Accessor", "method", "used", "to", "retrieve", "a", "String", "object", "representing", "the", "contents", "of", "an", "individual", "field", ".", "If", "the", "field", "does", "not", "exist", "in", "the", "record", "null", "is", "returned", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L128-L147
157,575
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.getCharacter
public Character getCharacter(int field) { Character result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = Character.valueOf(m_fields[field].charAt(0)); } else { result = null; } return (result); }
java
public Character getCharacter(int field) { Character result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = Character.valueOf(m_fields[field].charAt(0)); } else { result = null; } return (result); }
[ "public", "Character", "getCharacter", "(", "int", "field", ")", "{", "Character", "result", ";", "if", "(", "(", "field", "<", "m_fields", ".", "length", ")", "&&", "(", "m_fields", "[", "field", "]", ".", "length", "(", ")", "!=", "0", ")", ")", "{", "result", "=", "Character", ".", "valueOf", "(", "m_fields", "[", "field", "]", ".", "charAt", "(", "0", ")", ")", ";", "}", "else", "{", "result", "=", "null", ";", "}", "return", "(", "result", ")", ";", "}" ]
Accessor method used to retrieve a char representing the contents of an individual field. If the field does not exist in the record, the default character is returned. @param field the index number of the field to be retrieved @return the value of the required field
[ "Accessor", "method", "used", "to", "retrieve", "a", "char", "representing", "the", "contents", "of", "an", "individual", "field", ".", "If", "the", "field", "does", "not", "exist", "in", "the", "record", "the", "default", "character", "is", "returned", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L157-L171
157,576
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.getFloat
public Number getFloat(int field) throws MPXJException { try { Number result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = m_formats.getDecimalFormat().parse(m_fields[field]); } else { result = null; } return (result); } catch (ParseException ex) { throw new MPXJException("Failed to parse float", ex); } }
java
public Number getFloat(int field) throws MPXJException { try { Number result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = m_formats.getDecimalFormat().parse(m_fields[field]); } else { result = null; } return (result); } catch (ParseException ex) { throw new MPXJException("Failed to parse float", ex); } }
[ "public", "Number", "getFloat", "(", "int", "field", ")", "throws", "MPXJException", "{", "try", "{", "Number", "result", ";", "if", "(", "(", "field", "<", "m_fields", ".", "length", ")", "&&", "(", "m_fields", "[", "field", "]", ".", "length", "(", ")", "!=", "0", ")", ")", "{", "result", "=", "m_formats", ".", "getDecimalFormat", "(", ")", ".", "parse", "(", "m_fields", "[", "field", "]", ")", ";", "}", "else", "{", "result", "=", "null", ";", "}", "return", "(", "result", ")", ";", "}", "catch", "(", "ParseException", "ex", ")", "{", "throw", "new", "MPXJException", "(", "\"Failed to parse float\"", ",", "ex", ")", ";", "}", "}" ]
Accessor method used to retrieve a Float object representing the contents of an individual field. If the field does not exist in the record, null is returned. @param field the index number of the field to be retrieved @return the value of the required field
[ "Accessor", "method", "used", "to", "retrieve", "a", "Float", "object", "representing", "the", "contents", "of", "an", "individual", "field", ".", "If", "the", "field", "does", "not", "exist", "in", "the", "record", "null", "is", "returned", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L181-L203
157,577
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.getNumericBoolean
public boolean getNumericBoolean(int field) { boolean result = false; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = Integer.parseInt(m_fields[field]) == 1; } return (result); }
java
public boolean getNumericBoolean(int field) { boolean result = false; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = Integer.parseInt(m_fields[field]) == 1; } return (result); }
[ "public", "boolean", "getNumericBoolean", "(", "int", "field", ")", "{", "boolean", "result", "=", "false", ";", "if", "(", "(", "field", "<", "m_fields", ".", "length", ")", "&&", "(", "m_fields", "[", "field", "]", ".", "length", "(", ")", "!=", "0", ")", ")", "{", "result", "=", "Integer", ".", "parseInt", "(", "m_fields", "[", "field", "]", ")", "==", "1", ";", "}", "return", "(", "result", ")", ";", "}" ]
Accessor method used to retrieve a Boolean object representing the contents of an individual field. If the field does not exist in the record, null is returned. @param field the index number of the field to be retrieved @return the value of the required field
[ "Accessor", "method", "used", "to", "retrieve", "a", "Boolean", "object", "representing", "the", "contents", "of", "an", "individual", "field", ".", "If", "the", "field", "does", "not", "exist", "in", "the", "record", "null", "is", "returned", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L348-L358
157,578
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.getRate
public Rate getRate(int field) throws MPXJException { Rate result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { try { String rate = m_fields[field]; int index = rate.indexOf('/'); double amount; TimeUnit units; if (index == -1) { amount = m_formats.getCurrencyFormat().parse(rate).doubleValue(); units = TimeUnit.HOURS; } else { amount = m_formats.getCurrencyFormat().parse(rate.substring(0, index)).doubleValue(); units = TimeUnitUtility.getInstance(rate.substring(index + 1), m_locale); } result = new Rate(amount, units); } catch (ParseException ex) { throw new MPXJException("Failed to parse rate", ex); } } else { result = null; } return (result); }
java
public Rate getRate(int field) throws MPXJException { Rate result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { try { String rate = m_fields[field]; int index = rate.indexOf('/'); double amount; TimeUnit units; if (index == -1) { amount = m_formats.getCurrencyFormat().parse(rate).doubleValue(); units = TimeUnit.HOURS; } else { amount = m_formats.getCurrencyFormat().parse(rate.substring(0, index)).doubleValue(); units = TimeUnitUtility.getInstance(rate.substring(index + 1), m_locale); } result = new Rate(amount, units); } catch (ParseException ex) { throw new MPXJException("Failed to parse rate", ex); } } else { result = null; } return (result); }
[ "public", "Rate", "getRate", "(", "int", "field", ")", "throws", "MPXJException", "{", "Rate", "result", ";", "if", "(", "(", "field", "<", "m_fields", ".", "length", ")", "&&", "(", "m_fields", "[", "field", "]", ".", "length", "(", ")", "!=", "0", ")", ")", "{", "try", "{", "String", "rate", "=", "m_fields", "[", "field", "]", ";", "int", "index", "=", "rate", ".", "indexOf", "(", "'", "'", ")", ";", "double", "amount", ";", "TimeUnit", "units", ";", "if", "(", "index", "==", "-", "1", ")", "{", "amount", "=", "m_formats", ".", "getCurrencyFormat", "(", ")", ".", "parse", "(", "rate", ")", ".", "doubleValue", "(", ")", ";", "units", "=", "TimeUnit", ".", "HOURS", ";", "}", "else", "{", "amount", "=", "m_formats", ".", "getCurrencyFormat", "(", ")", ".", "parse", "(", "rate", ".", "substring", "(", "0", ",", "index", ")", ")", ".", "doubleValue", "(", ")", ";", "units", "=", "TimeUnitUtility", ".", "getInstance", "(", "rate", ".", "substring", "(", "index", "+", "1", ")", ",", "m_locale", ")", ";", "}", "result", "=", "new", "Rate", "(", "amount", ",", "units", ")", ";", "}", "catch", "(", "ParseException", "ex", ")", "{", "throw", "new", "MPXJException", "(", "\"Failed to parse rate\"", ",", "ex", ")", ";", "}", "}", "else", "{", "result", "=", "null", ";", "}", "return", "(", "result", ")", ";", "}" ]
Accessor method used to retrieve an Rate object representing the contents of an individual field. If the field does not exist in the record, null is returned. @param field the index number of the field to be retrieved @return the value of the required field @throws MPXJException normally thrown when parsing fails
[ "Accessor", "method", "used", "to", "retrieve", "an", "Rate", "object", "representing", "the", "contents", "of", "an", "individual", "field", ".", "If", "the", "field", "does", "not", "exist", "in", "the", "record", "null", "is", "returned", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L369-L407
157,579
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.getDuration
public Duration getDuration(int field) throws MPXJException { Duration result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = DurationUtility.getInstance(m_fields[field], m_formats.getDurationDecimalFormat(), m_locale); } else { result = null; } return (result); }
java
public Duration getDuration(int field) throws MPXJException { Duration result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = DurationUtility.getInstance(m_fields[field], m_formats.getDurationDecimalFormat(), m_locale); } else { result = null; } return (result); }
[ "public", "Duration", "getDuration", "(", "int", "field", ")", "throws", "MPXJException", "{", "Duration", "result", ";", "if", "(", "(", "field", "<", "m_fields", ".", "length", ")", "&&", "(", "m_fields", "[", "field", "]", ".", "length", "(", ")", "!=", "0", ")", ")", "{", "result", "=", "DurationUtility", ".", "getInstance", "(", "m_fields", "[", "field", "]", ",", "m_formats", ".", "getDurationDecimalFormat", "(", ")", ",", "m_locale", ")", ";", "}", "else", "{", "result", "=", "null", ";", "}", "return", "(", "result", ")", ";", "}" ]
Accessor method used to retrieve an Duration object representing the contents of an individual field. If the field does not exist in the record, null is returned. @param field the index number of the field to be retrieved @return the value of the required field @throws MPXJException normally thrown when parsing fails
[ "Accessor", "method", "used", "to", "retrieve", "an", "Duration", "object", "representing", "the", "contents", "of", "an", "individual", "field", ".", "If", "the", "field", "does", "not", "exist", "in", "the", "record", "null", "is", "returned", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L484-L498
157,580
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.getUnits
public Number getUnits(int field) throws MPXJException { Number result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { try { result = Double.valueOf(m_formats.getUnitsDecimalFormat().parse(m_fields[field]).doubleValue() * 100); } catch (ParseException ex) { throw new MPXJException("Failed to parse units", ex); } } else { result = null; } return (result); }
java
public Number getUnits(int field) throws MPXJException { Number result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { try { result = Double.valueOf(m_formats.getUnitsDecimalFormat().parse(m_fields[field]).doubleValue() * 100); } catch (ParseException ex) { throw new MPXJException("Failed to parse units", ex); } } else { result = null; } return (result); }
[ "public", "Number", "getUnits", "(", "int", "field", ")", "throws", "MPXJException", "{", "Number", "result", ";", "if", "(", "(", "field", "<", "m_fields", ".", "length", ")", "&&", "(", "m_fields", "[", "field", "]", ".", "length", "(", ")", "!=", "0", ")", ")", "{", "try", "{", "result", "=", "Double", ".", "valueOf", "(", "m_formats", ".", "getUnitsDecimalFormat", "(", ")", ".", "parse", "(", "m_fields", "[", "field", "]", ")", ".", "doubleValue", "(", ")", "*", "100", ")", ";", "}", "catch", "(", "ParseException", "ex", ")", "{", "throw", "new", "MPXJException", "(", "\"Failed to parse units\"", ",", "ex", ")", ";", "}", "}", "else", "{", "result", "=", "null", ";", "}", "return", "(", "result", ")", ";", "}" ]
Accessor method used to retrieve a Number instance representing the contents of an individual field. If the field does not exist in the record, null is returned. @param field the index number of the field to be retrieved @return the value of the required field @throws MPXJException normally thrown when parsing fails
[ "Accessor", "method", "used", "to", "retrieve", "a", "Number", "instance", "representing", "the", "contents", "of", "an", "individual", "field", ".", "If", "the", "field", "does", "not", "exist", "in", "the", "record", "null", "is", "returned", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L509-L531
157,581
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.getCodePage
public CodePage getCodePage(int field) { CodePage result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = CodePage.getInstance(m_fields[field]); } else { result = CodePage.getInstance(null); } return (result); }
java
public CodePage getCodePage(int field) { CodePage result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = CodePage.getInstance(m_fields[field]); } else { result = CodePage.getInstance(null); } return (result); }
[ "public", "CodePage", "getCodePage", "(", "int", "field", ")", "{", "CodePage", "result", ";", "if", "(", "(", "field", "<", "m_fields", ".", "length", ")", "&&", "(", "m_fields", "[", "field", "]", ".", "length", "(", ")", "!=", "0", ")", ")", "{", "result", "=", "CodePage", ".", "getInstance", "(", "m_fields", "[", "field", "]", ")", ";", "}", "else", "{", "result", "=", "CodePage", ".", "getInstance", "(", "null", ")", ";", "}", "return", "(", "result", ")", ";", "}" ]
Retrieves a CodePage instance. Defaults to ANSI. @param field the index number of the field to be retrieved @return the value of the required field
[ "Retrieves", "a", "CodePage", "instance", ".", "Defaults", "to", "ANSI", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L683-L697
157,582
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.getAccrueType
public AccrueType getAccrueType(int field) { AccrueType result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = AccrueTypeUtility.getInstance(m_fields[field], m_locale); } else { result = null; } return (result); }
java
public AccrueType getAccrueType(int field) { AccrueType result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = AccrueTypeUtility.getInstance(m_fields[field], m_locale); } else { result = null; } return (result); }
[ "public", "AccrueType", "getAccrueType", "(", "int", "field", ")", "{", "AccrueType", "result", ";", "if", "(", "(", "field", "<", "m_fields", ".", "length", ")", "&&", "(", "m_fields", "[", "field", "]", ".", "length", "(", ")", "!=", "0", ")", ")", "{", "result", "=", "AccrueTypeUtility", ".", "getInstance", "(", "m_fields", "[", "field", "]", ",", "m_locale", ")", ";", "}", "else", "{", "result", "=", "null", ";", "}", "return", "(", "result", ")", ";", "}" ]
Accessor method to retrieve an accrue type instance. @param field the index number of the field to be retrieved @return the value of the required field
[ "Accessor", "method", "to", "retrieve", "an", "accrue", "type", "instance", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L705-L719
157,583
joniles/mpxj
src/main/java/net/sf/mpxj/mpx/Record.java
Record.getBoolean
public Boolean getBoolean(int field, String falseText) { Boolean result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = ((m_fields[field].equalsIgnoreCase(falseText) == true) ? Boolean.FALSE : Boolean.TRUE); } else { result = null; } return (result); }
java
public Boolean getBoolean(int field, String falseText) { Boolean result; if ((field < m_fields.length) && (m_fields[field].length() != 0)) { result = ((m_fields[field].equalsIgnoreCase(falseText) == true) ? Boolean.FALSE : Boolean.TRUE); } else { result = null; } return (result); }
[ "public", "Boolean", "getBoolean", "(", "int", "field", ",", "String", "falseText", ")", "{", "Boolean", "result", ";", "if", "(", "(", "field", "<", "m_fields", ".", "length", ")", "&&", "(", "m_fields", "[", "field", "]", ".", "length", "(", ")", "!=", "0", ")", ")", "{", "result", "=", "(", "(", "m_fields", "[", "field", "]", ".", "equalsIgnoreCase", "(", "falseText", ")", "==", "true", ")", "?", "Boolean", ".", "FALSE", ":", "Boolean", ".", "TRUE", ")", ";", "}", "else", "{", "result", "=", "null", ";", "}", "return", "(", "result", ")", ";", "}" ]
Accessor method to retrieve a Boolean instance. @param field the index number of the field to be retrieved @param falseText locale specific text representing false @return the value of the required field
[ "Accessor", "method", "to", "retrieve", "a", "Boolean", "instance", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/Record.java#L728-L742
157,584
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/FixedData.java
FixedData.getIndexFromOffset
public int getIndexFromOffset(int offset) { int result = -1; for (int loop = 0; loop < m_offset.length; loop++) { if (m_offset[loop] == offset) { result = loop; break; } } return (result); }
java
public int getIndexFromOffset(int offset) { int result = -1; for (int loop = 0; loop < m_offset.length; loop++) { if (m_offset[loop] == offset) { result = loop; break; } } return (result); }
[ "public", "int", "getIndexFromOffset", "(", "int", "offset", ")", "{", "int", "result", "=", "-", "1", ";", "for", "(", "int", "loop", "=", "0", ";", "loop", "<", "m_offset", ".", "length", ";", "loop", "++", ")", "{", "if", "(", "m_offset", "[", "loop", "]", "==", "offset", ")", "{", "result", "=", "loop", ";", "break", ";", "}", "}", "return", "(", "result", ")", ";", "}" ]
This method converts an offset value into an array index, which in turn allows the data present in the fixed block to be retrieved. Note that if the requested offset is not found, then this method returns -1. @param offset Offset of the data in the fixed block @return Index of data item within the fixed data block
[ "This", "method", "converts", "an", "offset", "value", "into", "an", "array", "index", "which", "in", "turn", "allows", "the", "data", "present", "in", "the", "fixed", "block", "to", "be", "retrieved", ".", "Note", "that", "if", "the", "requested", "offset", "is", "not", "found", "then", "this", "method", "returns", "-", "1", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FixedData.java#L344-L358
157,585
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/FixDeferFix.java
FixDeferFix.getByteArray
public byte[] getByteArray(int offset) { byte[] result = null; if (offset > 0 && offset < m_data.length) { int nextBlockOffset = MPPUtility.getInt(m_data, offset); offset += 4; int itemSize = MPPUtility.getInt(m_data, offset); offset += 4; if (itemSize > 0 && itemSize < m_data.length) { int blockRemainingSize = 28; if (nextBlockOffset != -1 || itemSize <= blockRemainingSize) { int itemRemainingSize = itemSize; result = new byte[itemSize]; int resultOffset = 0; while (nextBlockOffset != -1) { MPPUtility.getByteArray(m_data, offset, blockRemainingSize, result, resultOffset); resultOffset += blockRemainingSize; offset += blockRemainingSize; itemRemainingSize -= blockRemainingSize; if (offset != nextBlockOffset) { offset = nextBlockOffset; } nextBlockOffset = MPPUtility.getInt(m_data, offset); offset += 4; blockRemainingSize = 32; } MPPUtility.getByteArray(m_data, offset, itemRemainingSize, result, resultOffset); } } } return (result); }
java
public byte[] getByteArray(int offset) { byte[] result = null; if (offset > 0 && offset < m_data.length) { int nextBlockOffset = MPPUtility.getInt(m_data, offset); offset += 4; int itemSize = MPPUtility.getInt(m_data, offset); offset += 4; if (itemSize > 0 && itemSize < m_data.length) { int blockRemainingSize = 28; if (nextBlockOffset != -1 || itemSize <= blockRemainingSize) { int itemRemainingSize = itemSize; result = new byte[itemSize]; int resultOffset = 0; while (nextBlockOffset != -1) { MPPUtility.getByteArray(m_data, offset, blockRemainingSize, result, resultOffset); resultOffset += blockRemainingSize; offset += blockRemainingSize; itemRemainingSize -= blockRemainingSize; if (offset != nextBlockOffset) { offset = nextBlockOffset; } nextBlockOffset = MPPUtility.getInt(m_data, offset); offset += 4; blockRemainingSize = 32; } MPPUtility.getByteArray(m_data, offset, itemRemainingSize, result, resultOffset); } } } return (result); }
[ "public", "byte", "[", "]", "getByteArray", "(", "int", "offset", ")", "{", "byte", "[", "]", "result", "=", "null", ";", "if", "(", "offset", ">", "0", "&&", "offset", "<", "m_data", ".", "length", ")", "{", "int", "nextBlockOffset", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "offset", ")", ";", "offset", "+=", "4", ";", "int", "itemSize", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "offset", ")", ";", "offset", "+=", "4", ";", "if", "(", "itemSize", ">", "0", "&&", "itemSize", "<", "m_data", ".", "length", ")", "{", "int", "blockRemainingSize", "=", "28", ";", "if", "(", "nextBlockOffset", "!=", "-", "1", "||", "itemSize", "<=", "blockRemainingSize", ")", "{", "int", "itemRemainingSize", "=", "itemSize", ";", "result", "=", "new", "byte", "[", "itemSize", "]", ";", "int", "resultOffset", "=", "0", ";", "while", "(", "nextBlockOffset", "!=", "-", "1", ")", "{", "MPPUtility", ".", "getByteArray", "(", "m_data", ",", "offset", ",", "blockRemainingSize", ",", "result", ",", "resultOffset", ")", ";", "resultOffset", "+=", "blockRemainingSize", ";", "offset", "+=", "blockRemainingSize", ";", "itemRemainingSize", "-=", "blockRemainingSize", ";", "if", "(", "offset", "!=", "nextBlockOffset", ")", "{", "offset", "=", "nextBlockOffset", ";", "}", "nextBlockOffset", "=", "MPPUtility", ".", "getInt", "(", "m_data", ",", "offset", ")", ";", "offset", "+=", "4", ";", "blockRemainingSize", "=", "32", ";", "}", "MPPUtility", ".", "getByteArray", "(", "m_data", ",", "offset", ",", "itemRemainingSize", ",", "result", ",", "resultOffset", ")", ";", "}", "}", "}", "return", "(", "result", ")", ";", "}" ]
Retrieve a byte array of containing the data starting at the supplied offset in the FixDeferFix file. Note that this method will return null if the requested data is not found for some reason. @param offset Offset into the file @return Byte array containing the requested data
[ "Retrieve", "a", "byte", "array", "of", "containing", "the", "data", "starting", "at", "the", "supplied", "offset", "in", "the", "FixDeferFix", "file", ".", "Note", "that", "this", "method", "will", "return", "null", "if", "the", "requested", "data", "is", "not", "found", "for", "some", "reason", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/FixDeferFix.java#L61-L106
157,586
joniles/mpxj
src/main/java/net/sf/mpxj/primavera/schema/ResourceRequestType.java
ResourceRequestType.getResourceRequestCriterion
public List<ResourceRequestType.ResourceRequestCriterion> getResourceRequestCriterion() { if (resourceRequestCriterion == null) { resourceRequestCriterion = new ArrayList<ResourceRequestType.ResourceRequestCriterion>(); } return this.resourceRequestCriterion; }
java
public List<ResourceRequestType.ResourceRequestCriterion> getResourceRequestCriterion() { if (resourceRequestCriterion == null) { resourceRequestCriterion = new ArrayList<ResourceRequestType.ResourceRequestCriterion>(); } return this.resourceRequestCriterion; }
[ "public", "List", "<", "ResourceRequestType", ".", "ResourceRequestCriterion", ">", "getResourceRequestCriterion", "(", ")", "{", "if", "(", "resourceRequestCriterion", "==", "null", ")", "{", "resourceRequestCriterion", "=", "new", "ArrayList", "<", "ResourceRequestType", ".", "ResourceRequestCriterion", ">", "(", ")", ";", "}", "return", "this", ".", "resourceRequestCriterion", ";", "}" ]
Gets the value of the resourceRequestCriterion property. <p> This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for the resourceRequestCriterion property. <p> For example, to add a new item, do as follows: <pre> getResourceRequestCriterion().add(newItem); </pre> <p> Objects of the following type(s) are allowed in the list {@link ResourceRequestType.ResourceRequestCriterion }
[ "Gets", "the", "value", "of", "the", "resourceRequestCriterion", "property", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/schema/ResourceRequestType.java#L390-L397
157,587
joniles/mpxj
src/main/java/net/sf/mpxj/mpp/CustomFieldValueReader12.java
CustomFieldValueReader12.populateCustomFieldMap
private Map<UUID, FieldType> populateCustomFieldMap() { byte[] data = m_taskProps.getByteArray(Props.CUSTOM_FIELDS); int length = MPPUtility.getInt(data, 0); int index = length + 36; // 4 byte record count int recordCount = MPPUtility.getInt(data, index); index += 4; // 8 bytes per record index += (8 * recordCount); Map<UUID, FieldType> map = new HashMap<UUID, FieldType>(); while (index < data.length) { int blockLength = MPPUtility.getInt(data, index); if (blockLength <= 0 || index + blockLength > data.length) { break; } int fieldID = MPPUtility.getInt(data, index + 4); FieldType field = FieldTypeHelper.getInstance(fieldID); UUID guid = MPPUtility.getGUID(data, index + 160); map.put(guid, field); index += blockLength; } return map; }
java
private Map<UUID, FieldType> populateCustomFieldMap() { byte[] data = m_taskProps.getByteArray(Props.CUSTOM_FIELDS); int length = MPPUtility.getInt(data, 0); int index = length + 36; // 4 byte record count int recordCount = MPPUtility.getInt(data, index); index += 4; // 8 bytes per record index += (8 * recordCount); Map<UUID, FieldType> map = new HashMap<UUID, FieldType>(); while (index < data.length) { int blockLength = MPPUtility.getInt(data, index); if (blockLength <= 0 || index + blockLength > data.length) { break; } int fieldID = MPPUtility.getInt(data, index + 4); FieldType field = FieldTypeHelper.getInstance(fieldID); UUID guid = MPPUtility.getGUID(data, index + 160); map.put(guid, field); index += blockLength; } return map; }
[ "private", "Map", "<", "UUID", ",", "FieldType", ">", "populateCustomFieldMap", "(", ")", "{", "byte", "[", "]", "data", "=", "m_taskProps", ".", "getByteArray", "(", "Props", ".", "CUSTOM_FIELDS", ")", ";", "int", "length", "=", "MPPUtility", ".", "getInt", "(", "data", ",", "0", ")", ";", "int", "index", "=", "length", "+", "36", ";", "// 4 byte record count", "int", "recordCount", "=", "MPPUtility", ".", "getInt", "(", "data", ",", "index", ")", ";", "index", "+=", "4", ";", "// 8 bytes per record", "index", "+=", "(", "8", "*", "recordCount", ")", ";", "Map", "<", "UUID", ",", "FieldType", ">", "map", "=", "new", "HashMap", "<", "UUID", ",", "FieldType", ">", "(", ")", ";", "while", "(", "index", "<", "data", ".", "length", ")", "{", "int", "blockLength", "=", "MPPUtility", ".", "getInt", "(", "data", ",", "index", ")", ";", "if", "(", "blockLength", "<=", "0", "||", "index", "+", "blockLength", ">", "data", ".", "length", ")", "{", "break", ";", "}", "int", "fieldID", "=", "MPPUtility", ".", "getInt", "(", "data", ",", "index", "+", "4", ")", ";", "FieldType", "field", "=", "FieldTypeHelper", ".", "getInstance", "(", "fieldID", ")", ";", "UUID", "guid", "=", "MPPUtility", ".", "getGUID", "(", "data", ",", "index", "+", "160", ")", ";", "map", ".", "put", "(", "guid", ",", "field", ")", ";", "index", "+=", "blockLength", ";", "}", "return", "map", ";", "}" ]
Generate a map of UUID values to field types. @return UUID field value map
[ "Generate", "a", "map", "of", "UUID", "values", "to", "field", "types", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpp/CustomFieldValueReader12.java#L94-L123
157,588
joniles/mpxj
src/main/java/net/sf/mpxj/common/FileHelper.java
FileHelper.deleteQuietly
public static final void deleteQuietly(File file) { if (file != null) { if (file.isDirectory()) { File[] children = file.listFiles(); if (children != null) { for (File child : children) { deleteQuietly(child); } } } file.delete(); } }
java
public static final void deleteQuietly(File file) { if (file != null) { if (file.isDirectory()) { File[] children = file.listFiles(); if (children != null) { for (File child : children) { deleteQuietly(child); } } } file.delete(); } }
[ "public", "static", "final", "void", "deleteQuietly", "(", "File", "file", ")", "{", "if", "(", "file", "!=", "null", ")", "{", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "File", "[", "]", "children", "=", "file", ".", "listFiles", "(", ")", ";", "if", "(", "children", "!=", "null", ")", "{", "for", "(", "File", "child", ":", "children", ")", "{", "deleteQuietly", "(", "child", ")", ";", "}", "}", "}", "file", ".", "delete", "(", ")", ";", "}", "}" ]
Delete a file ignoring failures. @param file file to delete
[ "Delete", "a", "file", "ignoring", "failures", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/common/FileHelper.java#L55-L72
157,589
joniles/mpxj
src/main/java/net/sf/mpxj/primavera/p3/P3PRXFileReader.java
P3PRXFileReader.extractFile
private void extractFile(InputStream stream, File dir) throws IOException { byte[] header = new byte[8]; byte[] fileName = new byte[13]; byte[] dataSize = new byte[4]; stream.read(header); stream.read(fileName); stream.read(dataSize); int dataSizeValue = getInt(dataSize, 0); String fileNameValue = getString(fileName, 0); File file = new File(dir, fileNameValue); if (dataSizeValue == 0) { FileHelper.createNewFile(file); } else { OutputStream os = new FileOutputStream(file); FixedLengthInputStream inputStream = new FixedLengthInputStream(stream, dataSizeValue); Blast blast = new Blast(); blast.blast(inputStream, os); os.close(); } }
java
private void extractFile(InputStream stream, File dir) throws IOException { byte[] header = new byte[8]; byte[] fileName = new byte[13]; byte[] dataSize = new byte[4]; stream.read(header); stream.read(fileName); stream.read(dataSize); int dataSizeValue = getInt(dataSize, 0); String fileNameValue = getString(fileName, 0); File file = new File(dir, fileNameValue); if (dataSizeValue == 0) { FileHelper.createNewFile(file); } else { OutputStream os = new FileOutputStream(file); FixedLengthInputStream inputStream = new FixedLengthInputStream(stream, dataSizeValue); Blast blast = new Blast(); blast.blast(inputStream, os); os.close(); } }
[ "private", "void", "extractFile", "(", "InputStream", "stream", ",", "File", "dir", ")", "throws", "IOException", "{", "byte", "[", "]", "header", "=", "new", "byte", "[", "8", "]", ";", "byte", "[", "]", "fileName", "=", "new", "byte", "[", "13", "]", ";", "byte", "[", "]", "dataSize", "=", "new", "byte", "[", "4", "]", ";", "stream", ".", "read", "(", "header", ")", ";", "stream", ".", "read", "(", "fileName", ")", ";", "stream", ".", "read", "(", "dataSize", ")", ";", "int", "dataSizeValue", "=", "getInt", "(", "dataSize", ",", "0", ")", ";", "String", "fileNameValue", "=", "getString", "(", "fileName", ",", "0", ")", ";", "File", "file", "=", "new", "File", "(", "dir", ",", "fileNameValue", ")", ";", "if", "(", "dataSizeValue", "==", "0", ")", "{", "FileHelper", ".", "createNewFile", "(", "file", ")", ";", "}", "else", "{", "OutputStream", "os", "=", "new", "FileOutputStream", "(", "file", ")", ";", "FixedLengthInputStream", "inputStream", "=", "new", "FixedLengthInputStream", "(", "stream", ",", "dataSizeValue", ")", ";", "Blast", "blast", "=", "new", "Blast", "(", ")", ";", "blast", ".", "blast", "(", "inputStream", ",", "os", ")", ";", "os", ".", "close", "(", ")", ";", "}", "}" ]
Extracts the data for a single file from the input stream and writes it to a target directory. @param stream input stream @param dir target directory
[ "Extracts", "the", "data", "for", "a", "single", "file", "from", "the", "input", "stream", "and", "writes", "it", "to", "a", "target", "directory", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/p3/P3PRXFileReader.java#L105-L131
157,590
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.matchesFingerprint
private boolean matchesFingerprint(byte[] buffer, byte[] fingerprint) { return Arrays.equals(fingerprint, Arrays.copyOf(buffer, fingerprint.length)); }
java
private boolean matchesFingerprint(byte[] buffer, byte[] fingerprint) { return Arrays.equals(fingerprint, Arrays.copyOf(buffer, fingerprint.length)); }
[ "private", "boolean", "matchesFingerprint", "(", "byte", "[", "]", "buffer", ",", "byte", "[", "]", "fingerprint", ")", "{", "return", "Arrays", ".", "equals", "(", "fingerprint", ",", "Arrays", ".", "copyOf", "(", "buffer", ",", "fingerprint", ".", "length", ")", ")", ";", "}" ]
Determine if the start of the buffer matches a fingerprint byte array. @param buffer bytes from file @param fingerprint fingerprint bytes @return true if the file matches the fingerprint
[ "Determine", "if", "the", "start", "of", "the", "buffer", "matches", "a", "fingerprint", "byte", "array", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L329-L332
157,591
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.matchesFingerprint
private boolean matchesFingerprint(byte[] buffer, Pattern fingerprint) { return fingerprint.matcher(m_charset == null ? new String(buffer) : new String(buffer, m_charset)).matches(); }
java
private boolean matchesFingerprint(byte[] buffer, Pattern fingerprint) { return fingerprint.matcher(m_charset == null ? new String(buffer) : new String(buffer, m_charset)).matches(); }
[ "private", "boolean", "matchesFingerprint", "(", "byte", "[", "]", "buffer", ",", "Pattern", "fingerprint", ")", "{", "return", "fingerprint", ".", "matcher", "(", "m_charset", "==", "null", "?", "new", "String", "(", "buffer", ")", ":", "new", "String", "(", "buffer", ",", "m_charset", ")", ")", ".", "matches", "(", ")", ";", "}" ]
Determine if the buffer, when expressed as text, matches a fingerprint regular expression. @param buffer bytes from file @param fingerprint fingerprint regular expression @return true if the file matches the fingerprint
[ "Determine", "if", "the", "buffer", "when", "expressed", "as", "text", "matches", "a", "fingerprint", "regular", "expression", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L341-L344
157,592
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.readProjectFile
private ProjectFile readProjectFile(ProjectReader reader, InputStream stream) throws MPXJException { addListeners(reader); return reader.read(stream); }
java
private ProjectFile readProjectFile(ProjectReader reader, InputStream stream) throws MPXJException { addListeners(reader); return reader.read(stream); }
[ "private", "ProjectFile", "readProjectFile", "(", "ProjectReader", "reader", ",", "InputStream", "stream", ")", "throws", "MPXJException", "{", "addListeners", "(", "reader", ")", ";", "return", "reader", ".", "read", "(", "stream", ")", ";", "}" ]
Adds listeners and reads from a stream. @param reader reader for file type @param stream schedule data @return ProjectFile instance
[ "Adds", "listeners", "and", "reads", "from", "a", "stream", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L353-L357
157,593
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.readProjectFile
private ProjectFile readProjectFile(ProjectReader reader, File file) throws MPXJException { addListeners(reader); return reader.read(file); }
java
private ProjectFile readProjectFile(ProjectReader reader, File file) throws MPXJException { addListeners(reader); return reader.read(file); }
[ "private", "ProjectFile", "readProjectFile", "(", "ProjectReader", "reader", ",", "File", "file", ")", "throws", "MPXJException", "{", "addListeners", "(", "reader", ")", ";", "return", "reader", ".", "read", "(", "file", ")", ";", "}" ]
Adds listeners and reads from a file. @param reader reader for file type @param file schedule data @return ProjectFile instance
[ "Adds", "listeners", "and", "reads", "from", "a", "file", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L366-L370
157,594
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.handleOleCompoundDocument
private ProjectFile handleOleCompoundDocument(InputStream stream) throws Exception { POIFSFileSystem fs = new POIFSFileSystem(POIFSFileSystem.createNonClosingInputStream(stream)); String fileFormat = MPPReader.getFileFormat(fs); if (fileFormat != null && fileFormat.startsWith("MSProject")) { MPPReader reader = new MPPReader(); addListeners(reader); return reader.read(fs); } return null; }
java
private ProjectFile handleOleCompoundDocument(InputStream stream) throws Exception { POIFSFileSystem fs = new POIFSFileSystem(POIFSFileSystem.createNonClosingInputStream(stream)); String fileFormat = MPPReader.getFileFormat(fs); if (fileFormat != null && fileFormat.startsWith("MSProject")) { MPPReader reader = new MPPReader(); addListeners(reader); return reader.read(fs); } return null; }
[ "private", "ProjectFile", "handleOleCompoundDocument", "(", "InputStream", "stream", ")", "throws", "Exception", "{", "POIFSFileSystem", "fs", "=", "new", "POIFSFileSystem", "(", "POIFSFileSystem", ".", "createNonClosingInputStream", "(", "stream", ")", ")", ";", "String", "fileFormat", "=", "MPPReader", ".", "getFileFormat", "(", "fs", ")", ";", "if", "(", "fileFormat", "!=", "null", "&&", "fileFormat", ".", "startsWith", "(", "\"MSProject\"", ")", ")", "{", "MPPReader", "reader", "=", "new", "MPPReader", "(", ")", ";", "addListeners", "(", "reader", ")", ";", "return", "reader", ".", "read", "(", "fs", ")", ";", "}", "return", "null", ";", "}" ]
We have an OLE compound document... but is it an MPP file? @param stream file input stream @return ProjectFile instance
[ "We", "have", "an", "OLE", "compound", "document", "...", "but", "is", "it", "an", "MPP", "file?" ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L378-L389
157,595
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.handleMDBFile
private ProjectFile handleMDBFile(InputStream stream) throws Exception { File file = InputStreamHelper.writeStreamToTempFile(stream, ".mdb"); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ=" + file.getCanonicalPath(); Set<String> tableNames = populateTableNames(url); if (tableNames.contains("MSP_PROJECTS")) { return readProjectFile(new MPDDatabaseReader(), file); } if (tableNames.contains("EXCEPTIONN")) { return readProjectFile(new AstaDatabaseReader(), file); } return null; } finally { FileHelper.deleteQuietly(file); } }
java
private ProjectFile handleMDBFile(InputStream stream) throws Exception { File file = InputStreamHelper.writeStreamToTempFile(stream, ".mdb"); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ=" + file.getCanonicalPath(); Set<String> tableNames = populateTableNames(url); if (tableNames.contains("MSP_PROJECTS")) { return readProjectFile(new MPDDatabaseReader(), file); } if (tableNames.contains("EXCEPTIONN")) { return readProjectFile(new AstaDatabaseReader(), file); } return null; } finally { FileHelper.deleteQuietly(file); } }
[ "private", "ProjectFile", "handleMDBFile", "(", "InputStream", "stream", ")", "throws", "Exception", "{", "File", "file", "=", "InputStreamHelper", ".", "writeStreamToTempFile", "(", "stream", ",", "\".mdb\"", ")", ";", "try", "{", "Class", ".", "forName", "(", "\"sun.jdbc.odbc.JdbcOdbcDriver\"", ")", ";", "String", "url", "=", "\"jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ=\"", "+", "file", ".", "getCanonicalPath", "(", ")", ";", "Set", "<", "String", ">", "tableNames", "=", "populateTableNames", "(", "url", ")", ";", "if", "(", "tableNames", ".", "contains", "(", "\"MSP_PROJECTS\"", ")", ")", "{", "return", "readProjectFile", "(", "new", "MPDDatabaseReader", "(", ")", ",", "file", ")", ";", "}", "if", "(", "tableNames", ".", "contains", "(", "\"EXCEPTIONN\"", ")", ")", "{", "return", "readProjectFile", "(", "new", "AstaDatabaseReader", "(", ")", ",", "file", ")", ";", "}", "return", "null", ";", "}", "finally", "{", "FileHelper", ".", "deleteQuietly", "(", "file", ")", ";", "}", "}" ]
We have identified that we have an MDB file. This could be a Microsoft Project database or an Asta database. Open the database and use the table names present to determine which type this is. @param stream schedule data @return ProjectFile instance
[ "We", "have", "identified", "that", "we", "have", "an", "MDB", "file", ".", "This", "could", "be", "a", "Microsoft", "Project", "database", "or", "an", "Asta", "database", ".", "Open", "the", "database", "and", "use", "the", "table", "names", "present", "to", "determine", "which", "type", "this", "is", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L417-L444
157,596
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.handleSQLiteFile
private ProjectFile handleSQLiteFile(InputStream stream) throws Exception { File file = InputStreamHelper.writeStreamToTempFile(stream, ".sqlite"); try { Class.forName("org.sqlite.JDBC"); String url = "jdbc:sqlite:" + file.getCanonicalPath(); Set<String> tableNames = populateTableNames(url); if (tableNames.contains("EXCEPTIONN")) { return readProjectFile(new AstaDatabaseFileReader(), file); } if (tableNames.contains("PROJWBS")) { Connection connection = null; try { Properties props = new Properties(); props.setProperty("date_string_format", "yyyy-MM-dd HH:mm:ss"); connection = DriverManager.getConnection(url, props); PrimaveraDatabaseReader reader = new PrimaveraDatabaseReader(); reader.setConnection(connection); addListeners(reader); return reader.read(); } finally { if (connection != null) { connection.close(); } } } if (tableNames.contains("ZSCHEDULEITEM")) { return readProjectFile(new MerlinReader(), file); } return null; } finally { FileHelper.deleteQuietly(file); } }
java
private ProjectFile handleSQLiteFile(InputStream stream) throws Exception { File file = InputStreamHelper.writeStreamToTempFile(stream, ".sqlite"); try { Class.forName("org.sqlite.JDBC"); String url = "jdbc:sqlite:" + file.getCanonicalPath(); Set<String> tableNames = populateTableNames(url); if (tableNames.contains("EXCEPTIONN")) { return readProjectFile(new AstaDatabaseFileReader(), file); } if (tableNames.contains("PROJWBS")) { Connection connection = null; try { Properties props = new Properties(); props.setProperty("date_string_format", "yyyy-MM-dd HH:mm:ss"); connection = DriverManager.getConnection(url, props); PrimaveraDatabaseReader reader = new PrimaveraDatabaseReader(); reader.setConnection(connection); addListeners(reader); return reader.read(); } finally { if (connection != null) { connection.close(); } } } if (tableNames.contains("ZSCHEDULEITEM")) { return readProjectFile(new MerlinReader(), file); } return null; } finally { FileHelper.deleteQuietly(file); } }
[ "private", "ProjectFile", "handleSQLiteFile", "(", "InputStream", "stream", ")", "throws", "Exception", "{", "File", "file", "=", "InputStreamHelper", ".", "writeStreamToTempFile", "(", "stream", ",", "\".sqlite\"", ")", ";", "try", "{", "Class", ".", "forName", "(", "\"org.sqlite.JDBC\"", ")", ";", "String", "url", "=", "\"jdbc:sqlite:\"", "+", "file", ".", "getCanonicalPath", "(", ")", ";", "Set", "<", "String", ">", "tableNames", "=", "populateTableNames", "(", "url", ")", ";", "if", "(", "tableNames", ".", "contains", "(", "\"EXCEPTIONN\"", ")", ")", "{", "return", "readProjectFile", "(", "new", "AstaDatabaseFileReader", "(", ")", ",", "file", ")", ";", "}", "if", "(", "tableNames", ".", "contains", "(", "\"PROJWBS\"", ")", ")", "{", "Connection", "connection", "=", "null", ";", "try", "{", "Properties", "props", "=", "new", "Properties", "(", ")", ";", "props", ".", "setProperty", "(", "\"date_string_format\"", ",", "\"yyyy-MM-dd HH:mm:ss\"", ")", ";", "connection", "=", "DriverManager", ".", "getConnection", "(", "url", ",", "props", ")", ";", "PrimaveraDatabaseReader", "reader", "=", "new", "PrimaveraDatabaseReader", "(", ")", ";", "reader", ".", "setConnection", "(", "connection", ")", ";", "addListeners", "(", "reader", ")", ";", "return", "reader", ".", "read", "(", ")", ";", "}", "finally", "{", "if", "(", "connection", "!=", "null", ")", "{", "connection", ".", "close", "(", ")", ";", "}", "}", "}", "if", "(", "tableNames", ".", "contains", "(", "\"ZSCHEDULEITEM\"", ")", ")", "{", "return", "readProjectFile", "(", "new", "MerlinReader", "(", ")", ",", "file", ")", ";", "}", "return", "null", ";", "}", "finally", "{", "FileHelper", ".", "deleteQuietly", "(", "file", ")", ";", "}", "}" ]
We have identified that we have a SQLite file. This could be a Primavera Project database or an Asta database. Open the database and use the table names present to determine which type this is. @param stream schedule data @return ProjectFile instance
[ "We", "have", "identified", "that", "we", "have", "a", "SQLite", "file", ".", "This", "could", "be", "a", "Primavera", "Project", "database", "or", "an", "Asta", "database", ".", "Open", "the", "database", "and", "use", "the", "table", "names", "present", "to", "determine", "which", "type", "this", "is", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L454-L503
157,597
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.handleZipFile
private ProjectFile handleZipFile(InputStream stream) throws Exception { File dir = null; try { dir = InputStreamHelper.writeZipStreamToTempDir(stream); ProjectFile result = handleDirectory(dir); if (result != null) { return result; } } finally { FileHelper.deleteQuietly(dir); } return null; }
java
private ProjectFile handleZipFile(InputStream stream) throws Exception { File dir = null; try { dir = InputStreamHelper.writeZipStreamToTempDir(stream); ProjectFile result = handleDirectory(dir); if (result != null) { return result; } } finally { FileHelper.deleteQuietly(dir); } return null; }
[ "private", "ProjectFile", "handleZipFile", "(", "InputStream", "stream", ")", "throws", "Exception", "{", "File", "dir", "=", "null", ";", "try", "{", "dir", "=", "InputStreamHelper", ".", "writeZipStreamToTempDir", "(", "stream", ")", ";", "ProjectFile", "result", "=", "handleDirectory", "(", "dir", ")", ";", "if", "(", "result", "!=", "null", ")", "{", "return", "result", ";", "}", "}", "finally", "{", "FileHelper", ".", "deleteQuietly", "(", "dir", ")", ";", "}", "return", "null", ";", "}" ]
We have identified that we have a zip file. Extract the contents into a temporary directory and process. @param stream schedule data @return ProjectFile instance
[ "We", "have", "identified", "that", "we", "have", "a", "zip", "file", ".", "Extract", "the", "contents", "into", "a", "temporary", "directory", "and", "process", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L512-L532
157,598
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.handleDirectory
private ProjectFile handleDirectory(File directory) throws Exception { ProjectFile result = handleDatabaseInDirectory(directory); if (result == null) { result = handleFileInDirectory(directory); } return result; }
java
private ProjectFile handleDirectory(File directory) throws Exception { ProjectFile result = handleDatabaseInDirectory(directory); if (result == null) { result = handleFileInDirectory(directory); } return result; }
[ "private", "ProjectFile", "handleDirectory", "(", "File", "directory", ")", "throws", "Exception", "{", "ProjectFile", "result", "=", "handleDatabaseInDirectory", "(", "directory", ")", ";", "if", "(", "result", "==", "null", ")", "{", "result", "=", "handleFileInDirectory", "(", "directory", ")", ";", "}", "return", "result", ";", "}" ]
We have a directory. Determine if this contains a multi-file database we understand, if so process it. If it does not contain a database, test each file within the directory structure to determine if it contains a file whose format we understand. @param directory directory to process @return ProjectFile instance if we can process anything, or null
[ "We", "have", "a", "directory", ".", "Determine", "if", "this", "contains", "a", "multi", "-", "file", "database", "we", "understand", "if", "so", "process", "it", ".", "If", "it", "does", "not", "contain", "a", "database", "test", "each", "file", "within", "the", "directory", "structure", "to", "determine", "if", "it", "contains", "a", "file", "whose", "format", "we", "understand", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L542-L550
157,599
joniles/mpxj
src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java
UniversalProjectReader.handleDatabaseInDirectory
private ProjectFile handleDatabaseInDirectory(File directory) throws Exception { byte[] buffer = new byte[BUFFER_SIZE]; File[] files = directory.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { continue; } FileInputStream fis = new FileInputStream(file); int bytesRead = fis.read(buffer); fis.close(); // // If the file is smaller than the buffer we are peeking into, // it's probably not a valid schedule file. // if (bytesRead != BUFFER_SIZE) { continue; } if (matchesFingerprint(buffer, BTRIEVE_FINGERPRINT)) { return handleP3BtrieveDatabase(directory); } if (matchesFingerprint(buffer, STW_FINGERPRINT)) { return handleSureTrakDatabase(directory); } } } return null; }
java
private ProjectFile handleDatabaseInDirectory(File directory) throws Exception { byte[] buffer = new byte[BUFFER_SIZE]; File[] files = directory.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { continue; } FileInputStream fis = new FileInputStream(file); int bytesRead = fis.read(buffer); fis.close(); // // If the file is smaller than the buffer we are peeking into, // it's probably not a valid schedule file. // if (bytesRead != BUFFER_SIZE) { continue; } if (matchesFingerprint(buffer, BTRIEVE_FINGERPRINT)) { return handleP3BtrieveDatabase(directory); } if (matchesFingerprint(buffer, STW_FINGERPRINT)) { return handleSureTrakDatabase(directory); } } } return null; }
[ "private", "ProjectFile", "handleDatabaseInDirectory", "(", "File", "directory", ")", "throws", "Exception", "{", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "BUFFER_SIZE", "]", ";", "File", "[", "]", "files", "=", "directory", ".", "listFiles", "(", ")", ";", "if", "(", "files", "!=", "null", ")", "{", "for", "(", "File", "file", ":", "files", ")", "{", "if", "(", "file", ".", "isDirectory", "(", ")", ")", "{", "continue", ";", "}", "FileInputStream", "fis", "=", "new", "FileInputStream", "(", "file", ")", ";", "int", "bytesRead", "=", "fis", ".", "read", "(", "buffer", ")", ";", "fis", ".", "close", "(", ")", ";", "//", "// If the file is smaller than the buffer we are peeking into,", "// it's probably not a valid schedule file.", "//", "if", "(", "bytesRead", "!=", "BUFFER_SIZE", ")", "{", "continue", ";", "}", "if", "(", "matchesFingerprint", "(", "buffer", ",", "BTRIEVE_FINGERPRINT", ")", ")", "{", "return", "handleP3BtrieveDatabase", "(", "directory", ")", ";", "}", "if", "(", "matchesFingerprint", "(", "buffer", ",", "STW_FINGERPRINT", ")", ")", "{", "return", "handleSureTrakDatabase", "(", "directory", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
Given a directory, determine if it contains a multi-file database whose format we can process. @param directory directory to process @return ProjectFile instance if we can process anything, or null
[ "Given", "a", "directory", "determine", "if", "it", "contains", "a", "multi", "-", "file", "database", "whose", "format", "we", "can", "process", "." ]
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/reader/UniversalProjectReader.java#L559-L597