code
stringlengths
73
34.1k
label
stringclasses
1 value
public List<TimephasedCost> getTimephasedBaselineCost(int index) { return m_timephasedBaselineCost[index] == null ? null : m_timephasedBaselineCost[index].getData(); }
java
public ProjectCalendar getCalendar() { ProjectCalendar calendar = null; Resource resource = getResource(); if (resource != null) { calendar = resource.getResourceCalendar(); } Task task = getTask(); if (calendar == null || task.getIgnoreResourceCalendar()) { ...
java
public void setEnterpriseCost(int index, Number value) { set(selectField(AssignmentFieldLists.ENTERPRISE_COST, index), value); }
java
public void setEnterpriseDate(int index, Date value) { set(selectField(AssignmentFieldLists.ENTERPRISE_DATE, index), value); }
java
public void setEnterpriseDuration(int index, Duration value) { set(selectField(AssignmentFieldLists.ENTERPRISE_DURATION, index), value); }
java
public void setEnterpriseNumber(int index, Number value) { set(selectField(AssignmentFieldLists.ENTERPRISE_NUMBER, index), value); }
java
public void setEnterpriseText(int index, String value) { set(selectField(AssignmentFieldLists.ENTERPRISE_TEXT, index), value); }
java
public Number getOvertimeCost() { Number cost = (Number) getCachedValue(AssignmentField.OVERTIME_COST); if (cost == null) { Number actual = getActualOvertimeCost(); Number remaining = getRemainingOvertimeCost(); if (actual != null && remaining != null) { ...
java
public Number getPercentageWorkComplete() { Number pct = (Number) getCachedValue(AssignmentField.PERCENT_WORK_COMPLETE); if (pct == null) { Duration actualWork = getActualWork(); Duration work = getWork(); if (actualWork != null && work != null && work.getDuration() != 0)...
java
public Duration getStartVariance() { Duration variance = (Duration) getCachedValue(AssignmentField.START_VARIANCE); if (variance == null) { TimeUnit format = getParentFile().getProjectProperties().getDefaultDurationUnits(); variance = DateHelper.getVariance(getTask(), getBaselineS...
java
public Duration getFinishVariance() { Duration variance = (Duration) getCachedValue(AssignmentField.FINISH_VARIANCE); if (variance == null) { TimeUnit format = getParentFile().getProjectProperties().getDefaultDurationUnits(); variance = DateHelper.getVariance(getTask(), getBaselin...
java
public int getCostRateTableIndex() { Integer value = (Integer) getCachedValue(AssignmentField.COST_RATE_TABLE); return value == null ? 0 : value.intValue(); }
java
private AssignmentField selectField(AssignmentField[] fields, int index) { if (index < 1 || index > fields.length) { throw new IllegalArgumentException(index + " is not a valid field index"); } return (fields[index - 1]); }
java
public void sort(ChildTaskContainer container) { // Do we have any tasks? List<Task> tasks = container.getChildTasks(); if (!tasks.isEmpty()) { for (Task task : tasks) { // // Sort child activities // sort(task); /...
java
public void read(File file, Table table) throws IOException { //System.out.println("Reading " + file.getName()); InputStream is = null; try { is = new FileInputStream(file); read(is, table); } finally { StreamHelper.closeQuietly(is); } }
java
private void readPage(byte[] buffer, Table table) { int magicNumber = getShort(buffer, 0); if (magicNumber == 0x4400) { //System.out.println(ByteArrayHelper.hexdump(buffer, 0, 6, true, 16, "")); int recordSize = m_definition.getRecordSize(); RowValidator rowValidator = m_...
java
private void populateMap(byte[] data, Integer previousItemOffset, Integer previousItemKey, Integer itemOffset) { if (previousItemOffset != null) { int itemSize = itemOffset.intValue() - previousItemOffset.intValue(); byte[] itemData = new byte[itemSize]; System.arraycopy(data, ...
java
public void viewDocument(DocumentEntry entry) { InputStream is = null; try { is = new DocumentInputStream(entry); byte[] data = new byte[is.available()]; is.read(data); m_model.setData(data); updateTables(); } catch (IOException ex) {...
java
protected void updateTables() { byte[] data = m_model.getData(); int columns = m_model.getColumns(); int rows = (data.length / columns) + 1; int offset = m_model.getOffset(); String[][] hexData = new String[rows][columns]; String[][] asciiData = new String[rows][columns]; ...
java
public static final FieldType getInstance(int fieldID) { FieldType result; int prefix = fieldID & 0xFFFF0000; int index = fieldID & 0x0000FFFF; switch (prefix) { case MPPTaskField.TASK_FIELD_BASE: { result = MPPTaskField.getInstance(index); if ...
java
private static FieldType getPlaceholder(final Class<?> type, final int fieldID) { return new FieldType() { @Override public FieldTypeClass getFieldTypeClass() { return FieldTypeClass.UNKNOWN; } @Override public String name() { return "...
java
public static final boolean valueIsNotDefault(FieldType type, Object value) { boolean result = true; if (value == null) { result = false; } else { DataType dataType = type.getDataType(); switch (dataType) { case BOOLEAN: ...
java
public List<ProjectFile> readAll(InputStream is, boolean linkCrossProjectRelations) throws MPXJException { try { m_tables = new HashMap<String, List<Row>>(); m_numberFormat = new DecimalFormat(); processFile(is); List<Row> rows = getRows("project", null, null); ...
java
private void processFile(InputStream is) throws MPXJException { int line = 1; try { // // Test the header and extract the separator. If this is successful, // we reset the stream back as far as we can. The design of the // BufferedInputStream class means that we...
java
private Charset getCharset() { Charset result = m_charset; if (result == null) { // We default to CP1252 as this seems to be the most common encoding result = m_encoding == null ? CharsetHelper.CP1252 : Charset.forName(m_encoding); } return result; }
java
private void processProjectID() { if (m_projectID == null) { List<Row> rows = getRows("project", null, null); if (!rows.isEmpty()) { Row row = rows.get(0); m_projectID = row.getInteger("proj_id"); } } }
java
private void processCurrency(Row row) { String currencyName = row.getString("curr_short_name"); DecimalFormatSymbols symbols = new DecimalFormatSymbols(); symbols.setDecimalSeparator(row.getString("decimal_symbol").charAt(0)); symbols.setGroupingSeparator(row.getString("digit_group_symbol").c...
java
public Map<Integer, String> listProjects(InputStream is) throws MPXJException { try { m_tables = new HashMap<String, List<Row>>(); processFile(is); Map<Integer, String> result = new HashMap<Integer, String>(); List<Row> rows = getRows("project", null, null); ...
java
private void processScheduleOptions() { List<Row> rows = getRows("schedoptions", "proj_id", m_projectID); if (rows.isEmpty() == false) { Row row = rows.get(0); Map<String, Object> customProperties = new HashMap<String, Object>(); customProperties.put("LagCalendar", row.ge...
java
private void readRecord(Tokenizer tk, List<String> record) throws IOException { record.clear(); while (tk.nextToken() == Tokenizer.TT_WORD) { record.add(tk.getToken()); } }
java
private boolean processRecord(List<String> record) throws MPXJException { boolean done = false; XerRecordType type = RECORD_TYPE_MAP.get(record.get(0)); if (type == null) { throw new MPXJException(MPXJException.INVALID_FORMAT); } switch (type) { case HEAD...
java
private List<Row> getRows(String tableName, String columnName, Integer id) { List<Row> result; List<Row> table = m_tables.get(tableName); if (table == null) { result = Collections.<Row> emptyList(); } else { if (columnName == null) { re...
java
protected Object getTypedValue(int type, byte[] value) { Object result; switch (type) { case 4: // Date { result = MPPUtility.getTimestamp(value, 0); break; } case 6: // Duration { TimeUnit units = MPPUtility.getDura...
java
public void addRow(String primaryKeyColumnName, Map<String, Object> map) { Integer rowNumber = Integer.valueOf(m_rowNumber++); map.put("ROW_NUMBER", rowNumber); Object primaryKey = null; if (primaryKeyColumnName != null) { primaryKey = map.get(primaryKeyColumnName); } ...
java
public static List<List<RTFEmbeddedObject>> getEmbeddedObjects(String text) { List<List<RTFEmbeddedObject>> objects = null; List<RTFEmbeddedObject> objectData; int offset = text.indexOf(OBJDATA); if (offset != -1) { objects = new LinkedList<List<RTFEmbeddedObject>>(); ...
java
private int getInt(List<byte[]> blocks) { int result; if (blocks.isEmpty() == false) { byte[] data = blocks.remove(0); result = MPPUtility.getInt(data, 0); } else { result = 0; } return (result); }
java
private byte[] getData(List<byte[]> blocks, int length) { byte[] result; if (blocks.isEmpty() == false) { if (length < 4) { length = 4; } result = new byte[length]; int offset = 0; byte[] data; while (offset < length) ...
java
private static int readObjectData(int offset, String text, List<RTFEmbeddedObject> objects) { LinkedList<byte[]> blocks = new LinkedList<byte[]>(); offset += (OBJDATA.length()); offset = skipEndOfLine(text, offset); int length; int lastOffset = offset; while (offset != -1) ...
java
private static int skipEndOfLine(String text, int offset) { char c; boolean finished = false; while (finished == false) { c = text.charAt(offset); switch (c) { case ' ': // found that OBJDATA could be followed by a space the EOL case '\r': ...
java
private static int getBlockLength(String text, int offset) { int startIndex = offset; boolean finished = false; char c; while (finished == false) { c = text.charAt(offset); switch (c) { case '\r': case '\n': case '}': ...
java
private static int readDataBlock(String text, int offset, int length, List<byte[]> blocks) { int bytes = length / 2; byte[] data = new byte[bytes]; for (int index = 0; index < bytes; index++) { data[index] = (byte) Integer.parseInt(text.substring(offset, offset + 2), 16); o...
java
private SubProject readSubProject(byte[] data, int uniqueIDOffset, int filePathOffset, int fileNameOffset, int subprojectIndex) { try { SubProject sp = new SubProject(); int type = SUBPROJECT_TASKUNIQUEID0; if (uniqueIDOffset != -1) { int value = MPPUtilit...
java
private void readRecord(byte[] buffer, Table table) { //System.out.println(ByteArrayHelper.hexdump(buffer, true, 16, "")); int deletedFlag = getShort(buffer, 0); if (deletedFlag != 0) { Map<String, Object> row = new HashMap<String, Object>(); for (ColumnDefinition column : m...
java
public static final void decodeBuffer(byte[] data, byte encryptionCode) { for (int i = 0; i < data.length; i++) { data[i] = (byte) (data[i] ^ encryptionCode); } }
java
public static final String decodePassword(byte[] data, byte encryptionCode) { String result; if (data.length < MINIMUM_PASSWORD_DATA_LENGTH) { result = null; } else { MPPUtility.decodeBuffer(data, encryptionCode); StringBuilder buffer = new StringBuild...
java
public static final void getByteArray(byte[] data, int offset, int size, byte[] buffer, int bufferOffset) { System.arraycopy(data, offset, buffer, bufferOffset, size); }
java
public static final long getLong6(byte[] data, int offset) { long result = 0; int i = offset; for (int shiftBy = 0; shiftBy < 48; shiftBy += 8) { result |= ((long) (data[i] & 0xff)) << shiftBy; ++i; } return result; }
java
public static final Date getTime(byte[] data, int offset) { int time = getShort(data, offset) / 10; Calendar cal = DateHelper.popCalendar(EPOCH_DATE); cal.set(Calendar.HOUR_OF_DAY, (time / 60)); cal.set(Calendar.MINUTE, (time % 60)); cal.set(Calendar.SECOND, 0); cal.set(Calendar.M...
java
public static final Date getTimestamp(byte[] data, int offset) { Date result; long days = getShort(data, offset + 2); if (days < 100) { // We are seeing some files which have very small values for the number of days. // When the relevant field is shown in MS Project it appe...
java
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 String getUnicodeString(byte[] data, int offset) { int length = getUnicodeStringLengthInBytes(data, offset); return length == 0 ? "" : new String(data, offset, length, CharsetHelper.UTF16LE); }
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) ...
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; } buff...
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); } ...
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 = na...
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; }
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); }
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(ByteArrayHel...
java
@Deprecated public Duration getDuration(Date startDate, Date endDate) throws MPXJException { return (getDuration("Standard", 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); } ...
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; } // // Sel...
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; } // // S...
java
public ProjectCalendar getDefaultCalendar() { String calendarName = m_properties.getDefaultCalendarName(); ProjectCalendar calendar = getCalendarByName(calendarName); if (calendar == null) { if (m_calendars.isEmpty()) { calendar = addDefaultBaseCalendar(); ...
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 Calend...
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...
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) ...
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(typ...
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(in...
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); criteri...
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(dat...
java
public byte[] getByteArray(Integer offset) { byte[] result = null; if (offset != null) { result = m_map.get(offset); } return (result); }
java
public byte[] getByteArray(Integer id, Integer type) { return (getByteArray(m_meta.getOffset(id, type))); }
java
public String getUnicodeString(Integer id, Integer type) { return (getUnicodeString(m_meta.getOffset(id, type))); }
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); }
java
public String getString(Integer id, Integer type) { return (getString(m_meta.getOffset(id, type))); }
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); ...
java
public double getDouble(Integer id, Integer type) { double result = Double.longBitsToDouble(getLong(id, type)); if (Double.isNaN(result)) { result = 0; } 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); }
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; ...
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: ...
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) - ...
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, getListNe...
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...
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 ...
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); ...
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; }
java
public byte[] getByteArrayValue(int index) { byte[] result = null; if (m_array[index] != null) { result = (byte[]) m_array[index]; } 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); }
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); }
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); }
java
public void writeStartObject(String name) throws IOException { writeComma(); writeNewLineIndent(); if (name != null) { writeName(name); writeNewLineIndent(); } m_writer.write("{"); increaseIndent(); }
java
public void writeStartList(String name) throws IOException { writeComma(); writeNewLineIndent(); writeName(name); writeNewLineIndent(); m_writer.write("["); increaseIndent(); }
java
public void writeNameValuePair(String name, String value) throws IOException { internalWriteNameValuePair(name, escapeString(value)); }
java
public void writeNameValuePair(String name, int value) throws IOException { internalWriteNameValuePair(name, Integer.toString(value)); }
java
public void writeNameValuePair(String name, long value) throws IOException { internalWriteNameValuePair(name, Long.toString(value)); }
java
public void writeNameValuePair(String name, double value) throws IOException { internalWriteNameValuePair(name, Double.toString(value)); }
java
public void writeNameValuePair(String name, Date value) throws IOException { internalWriteNameValuePair(name, m_format.format(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); }
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("\\\""); ...
java
private void writeComma() throws IOException { if (m_firstNameValuePair.peek().booleanValue()) { m_firstNameValuePair.pop(); m_firstNameValuePair.push(Boolean.FALSE); } else { m_writer.write(','); } }
java