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,700
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpx/MPXResourceField.java
|
MPXResourceField.getMpxjField
|
public static ResourceField getMpxjField(int value)
{
ResourceField result = null;
if (value >= 0 && value < MPX_MPXJ_ARRAY.length)
{
result = MPX_MPXJ_ARRAY[value];
}
return (result);
}
|
java
|
public static ResourceField getMpxjField(int value)
{
ResourceField result = null;
if (value >= 0 && value < MPX_MPXJ_ARRAY.length)
{
result = MPX_MPXJ_ARRAY[value];
}
return (result);
}
|
[
"public",
"static",
"ResourceField",
"getMpxjField",
"(",
"int",
"value",
")",
"{",
"ResourceField",
"result",
"=",
"null",
";",
"if",
"(",
"value",
">=",
"0",
"&&",
"value",
"<",
"MPX_MPXJ_ARRAY",
".",
"length",
")",
"{",
"result",
"=",
"MPX_MPXJ_ARRAY",
"[",
"value",
"]",
";",
"}",
"return",
"(",
"result",
")",
";",
"}"
] |
Retrieve an instance of the ResourceField class based on the data read from an
MPX file.
@param value value from an MS Project file
@return instance of this class
|
[
"Retrieve",
"an",
"instance",
"of",
"the",
"ResourceField",
"class",
"based",
"on",
"the",
"data",
"read",
"from",
"an",
"MPX",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/MPXResourceField.java#L42-L52
|
157,701
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Filter.java
|
Filter.evaluate
|
public boolean evaluate(FieldContainer container, Map<GenericCriteriaPrompt, Object> promptValues)
{
boolean result = true;
if (m_criteria != null)
{
result = m_criteria.evaluate(container, promptValues);
//
// If this row has failed, but it is a summary row, and we are
// including related summary rows, then we need to recursively test
// its children
//
if (!result && m_showRelatedSummaryRows && container instanceof Task)
{
for (Task task : ((Task) container).getChildTasks())
{
if (evaluate(task, promptValues))
{
result = true;
break;
}
}
}
}
return (result);
}
|
java
|
public boolean evaluate(FieldContainer container, Map<GenericCriteriaPrompt, Object> promptValues)
{
boolean result = true;
if (m_criteria != null)
{
result = m_criteria.evaluate(container, promptValues);
//
// If this row has failed, but it is a summary row, and we are
// including related summary rows, then we need to recursively test
// its children
//
if (!result && m_showRelatedSummaryRows && container instanceof Task)
{
for (Task task : ((Task) container).getChildTasks())
{
if (evaluate(task, promptValues))
{
result = true;
break;
}
}
}
}
return (result);
}
|
[
"public",
"boolean",
"evaluate",
"(",
"FieldContainer",
"container",
",",
"Map",
"<",
"GenericCriteriaPrompt",
",",
"Object",
">",
"promptValues",
")",
"{",
"boolean",
"result",
"=",
"true",
";",
"if",
"(",
"m_criteria",
"!=",
"null",
")",
"{",
"result",
"=",
"m_criteria",
".",
"evaluate",
"(",
"container",
",",
"promptValues",
")",
";",
"//",
"// If this row has failed, but it is a summary row, and we are",
"// including related summary rows, then we need to recursively test",
"// its children",
"//",
"if",
"(",
"!",
"result",
"&&",
"m_showRelatedSummaryRows",
"&&",
"container",
"instanceof",
"Task",
")",
"{",
"for",
"(",
"Task",
"task",
":",
"(",
"(",
"Task",
")",
"container",
")",
".",
"getChildTasks",
"(",
")",
")",
"{",
"if",
"(",
"evaluate",
"(",
"task",
",",
"promptValues",
")",
")",
"{",
"result",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"}",
"return",
"(",
"result",
")",
";",
"}"
] |
Evaluates the filter, returns true if the supplied Task or Resource
instance matches the filter criteria.
@param container Task or Resource instance
@param promptValues respose to prompts
@return boolean flag
|
[
"Evaluates",
"the",
"filter",
"returns",
"true",
"if",
"the",
"supplied",
"Task",
"or",
"Resource",
"instance",
"matches",
"the",
"filter",
"criteria",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Filter.java#L163-L189
|
157,702
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/primavera/common/AbstractWbsFormat.java
|
AbstractWbsFormat.parseRawValue
|
public void parseRawValue(String value)
{
int valueIndex = 0;
int elementIndex = 0;
m_elements.clear();
while (valueIndex < value.length() && elementIndex < m_elements.size())
{
int elementLength = m_lengths.get(elementIndex).intValue();
if (elementIndex > 0)
{
m_elements.add(m_separators.get(elementIndex - 1));
}
int endIndex = valueIndex + elementLength;
if (endIndex > value.length())
{
endIndex = value.length();
}
String element = value.substring(valueIndex, endIndex);
m_elements.add(element);
valueIndex += elementLength;
elementIndex++;
}
}
|
java
|
public void parseRawValue(String value)
{
int valueIndex = 0;
int elementIndex = 0;
m_elements.clear();
while (valueIndex < value.length() && elementIndex < m_elements.size())
{
int elementLength = m_lengths.get(elementIndex).intValue();
if (elementIndex > 0)
{
m_elements.add(m_separators.get(elementIndex - 1));
}
int endIndex = valueIndex + elementLength;
if (endIndex > value.length())
{
endIndex = value.length();
}
String element = value.substring(valueIndex, endIndex);
m_elements.add(element);
valueIndex += elementLength;
elementIndex++;
}
}
|
[
"public",
"void",
"parseRawValue",
"(",
"String",
"value",
")",
"{",
"int",
"valueIndex",
"=",
"0",
";",
"int",
"elementIndex",
"=",
"0",
";",
"m_elements",
".",
"clear",
"(",
")",
";",
"while",
"(",
"valueIndex",
"<",
"value",
".",
"length",
"(",
")",
"&&",
"elementIndex",
"<",
"m_elements",
".",
"size",
"(",
")",
")",
"{",
"int",
"elementLength",
"=",
"m_lengths",
".",
"get",
"(",
"elementIndex",
")",
".",
"intValue",
"(",
")",
";",
"if",
"(",
"elementIndex",
">",
"0",
")",
"{",
"m_elements",
".",
"add",
"(",
"m_separators",
".",
"get",
"(",
"elementIndex",
"-",
"1",
")",
")",
";",
"}",
"int",
"endIndex",
"=",
"valueIndex",
"+",
"elementLength",
";",
"if",
"(",
"endIndex",
">",
"value",
".",
"length",
"(",
")",
")",
"{",
"endIndex",
"=",
"value",
".",
"length",
"(",
")",
";",
"}",
"String",
"element",
"=",
"value",
".",
"substring",
"(",
"valueIndex",
",",
"endIndex",
")",
";",
"m_elements",
".",
"add",
"(",
"element",
")",
";",
"valueIndex",
"+=",
"elementLength",
";",
"elementIndex",
"++",
";",
"}",
"}"
] |
Parses a raw WBS value from the database and breaks it into
component parts ready for formatting.
@param value raw WBS value
|
[
"Parses",
"a",
"raw",
"WBS",
"value",
"from",
"the",
"database",
"and",
"breaks",
"it",
"into",
"component",
"parts",
"ready",
"for",
"formatting",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/common/AbstractWbsFormat.java#L40-L62
|
157,703
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/primavera/common/AbstractWbsFormat.java
|
AbstractWbsFormat.getFormattedParentValue
|
public String getFormattedParentValue()
{
String result = null;
if (m_elements.size() > 2)
{
result = joinElements(m_elements.size() - 2);
}
return result;
}
|
java
|
public String getFormattedParentValue()
{
String result = null;
if (m_elements.size() > 2)
{
result = joinElements(m_elements.size() - 2);
}
return result;
}
|
[
"public",
"String",
"getFormattedParentValue",
"(",
")",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"m_elements",
".",
"size",
"(",
")",
">",
"2",
")",
"{",
"result",
"=",
"joinElements",
"(",
"m_elements",
".",
"size",
"(",
")",
"-",
"2",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieves the formatted parent WBS value.
@return formatted parent WBS value
|
[
"Retrieves",
"the",
"formatted",
"parent",
"WBS",
"value",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/common/AbstractWbsFormat.java#L89-L97
|
157,704
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/primavera/common/AbstractWbsFormat.java
|
AbstractWbsFormat.joinElements
|
private String joinElements(int length)
{
StringBuilder sb = new StringBuilder();
for (int index = 0; index < length; index++)
{
sb.append(m_elements.get(index));
}
return sb.toString();
}
|
java
|
private String joinElements(int length)
{
StringBuilder sb = new StringBuilder();
for (int index = 0; index < length; index++)
{
sb.append(m_elements.get(index));
}
return sb.toString();
}
|
[
"private",
"String",
"joinElements",
"(",
"int",
"length",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"length",
";",
"index",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"m_elements",
".",
"get",
"(",
"index",
")",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Joins the individual WBS elements to make the formated value.
@param length number of elements to join
@return formatted WBS value
|
[
"Joins",
"the",
"individual",
"WBS",
"elements",
"to",
"make",
"the",
"formated",
"value",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/common/AbstractWbsFormat.java#L105-L113
|
157,705
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addTasks
|
private void addTasks(MpxjTreeNode parentNode, ChildTaskContainer parent)
{
for (Task task : parent.getChildTasks())
{
final Task t = task;
MpxjTreeNode childNode = new MpxjTreeNode(task, TASK_EXCLUDED_METHODS)
{
@Override public String toString()
{
return t.getName();
}
};
parentNode.add(childNode);
addTasks(childNode, task);
}
}
|
java
|
private void addTasks(MpxjTreeNode parentNode, ChildTaskContainer parent)
{
for (Task task : parent.getChildTasks())
{
final Task t = task;
MpxjTreeNode childNode = new MpxjTreeNode(task, TASK_EXCLUDED_METHODS)
{
@Override public String toString()
{
return t.getName();
}
};
parentNode.add(childNode);
addTasks(childNode, task);
}
}
|
[
"private",
"void",
"addTasks",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ChildTaskContainer",
"parent",
")",
"{",
"for",
"(",
"Task",
"task",
":",
"parent",
".",
"getChildTasks",
"(",
")",
")",
"{",
"final",
"Task",
"t",
"=",
"task",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"task",
",",
"TASK_EXCLUDED_METHODS",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"t",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"addTasks",
"(",
"childNode",
",",
"task",
")",
";",
"}",
"}"
] |
Add tasks to the tree.
@param parentNode parent tree node
@param parent parent task container
|
[
"Add",
"tasks",
"to",
"the",
"tree",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L198-L213
|
157,706
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addResources
|
private void addResources(MpxjTreeNode parentNode, ProjectFile file)
{
for (Resource resource : file.getResources())
{
final Resource r = resource;
MpxjTreeNode childNode = new MpxjTreeNode(resource)
{
@Override public String toString()
{
return r.getName();
}
};
parentNode.add(childNode);
}
}
|
java
|
private void addResources(MpxjTreeNode parentNode, ProjectFile file)
{
for (Resource resource : file.getResources())
{
final Resource r = resource;
MpxjTreeNode childNode = new MpxjTreeNode(resource)
{
@Override public String toString()
{
return r.getName();
}
};
parentNode.add(childNode);
}
}
|
[
"private",
"void",
"addResources",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectFile",
"file",
")",
"{",
"for",
"(",
"Resource",
"resource",
":",
"file",
".",
"getResources",
"(",
")",
")",
"{",
"final",
"Resource",
"r",
"=",
"resource",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"resource",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"r",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"}",
"}"
] |
Add resources to the tree.
@param parentNode parent tree node
@param file resource container
|
[
"Add",
"resources",
"to",
"the",
"tree",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L221-L235
|
157,707
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addCalendars
|
private void addCalendars(MpxjTreeNode parentNode, ProjectFile file)
{
for (ProjectCalendar calendar : file.getCalendars())
{
addCalendar(parentNode, calendar);
}
}
|
java
|
private void addCalendars(MpxjTreeNode parentNode, ProjectFile file)
{
for (ProjectCalendar calendar : file.getCalendars())
{
addCalendar(parentNode, calendar);
}
}
|
[
"private",
"void",
"addCalendars",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectFile",
"file",
")",
"{",
"for",
"(",
"ProjectCalendar",
"calendar",
":",
"file",
".",
"getCalendars",
"(",
")",
")",
"{",
"addCalendar",
"(",
"parentNode",
",",
"calendar",
")",
";",
"}",
"}"
] |
Add calendars to the tree.
@param parentNode parent tree node
@param file calendar container
|
[
"Add",
"calendars",
"to",
"the",
"tree",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L243-L249
|
157,708
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addCalendar
|
private void addCalendar(MpxjTreeNode parentNode, final ProjectCalendar calendar)
{
MpxjTreeNode calendarNode = new MpxjTreeNode(calendar, CALENDAR_EXCLUDED_METHODS)
{
@Override public String toString()
{
return calendar.getName();
}
};
parentNode.add(calendarNode);
MpxjTreeNode daysFolder = new MpxjTreeNode("Days");
calendarNode.add(daysFolder);
for (Day day : Day.values())
{
addCalendarDay(daysFolder, calendar, day);
}
MpxjTreeNode exceptionsFolder = new MpxjTreeNode("Exceptions");
calendarNode.add(exceptionsFolder);
for (ProjectCalendarException exception : calendar.getCalendarExceptions())
{
addCalendarException(exceptionsFolder, exception);
}
}
|
java
|
private void addCalendar(MpxjTreeNode parentNode, final ProjectCalendar calendar)
{
MpxjTreeNode calendarNode = new MpxjTreeNode(calendar, CALENDAR_EXCLUDED_METHODS)
{
@Override public String toString()
{
return calendar.getName();
}
};
parentNode.add(calendarNode);
MpxjTreeNode daysFolder = new MpxjTreeNode("Days");
calendarNode.add(daysFolder);
for (Day day : Day.values())
{
addCalendarDay(daysFolder, calendar, day);
}
MpxjTreeNode exceptionsFolder = new MpxjTreeNode("Exceptions");
calendarNode.add(exceptionsFolder);
for (ProjectCalendarException exception : calendar.getCalendarExceptions())
{
addCalendarException(exceptionsFolder, exception);
}
}
|
[
"private",
"void",
"addCalendar",
"(",
"MpxjTreeNode",
"parentNode",
",",
"final",
"ProjectCalendar",
"calendar",
")",
"{",
"MpxjTreeNode",
"calendarNode",
"=",
"new",
"MpxjTreeNode",
"(",
"calendar",
",",
"CALENDAR_EXCLUDED_METHODS",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"calendar",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"calendarNode",
")",
";",
"MpxjTreeNode",
"daysFolder",
"=",
"new",
"MpxjTreeNode",
"(",
"\"Days\"",
")",
";",
"calendarNode",
".",
"add",
"(",
"daysFolder",
")",
";",
"for",
"(",
"Day",
"day",
":",
"Day",
".",
"values",
"(",
")",
")",
"{",
"addCalendarDay",
"(",
"daysFolder",
",",
"calendar",
",",
"day",
")",
";",
"}",
"MpxjTreeNode",
"exceptionsFolder",
"=",
"new",
"MpxjTreeNode",
"(",
"\"Exceptions\"",
")",
";",
"calendarNode",
".",
"add",
"(",
"exceptionsFolder",
")",
";",
"for",
"(",
"ProjectCalendarException",
"exception",
":",
"calendar",
".",
"getCalendarExceptions",
"(",
")",
")",
"{",
"addCalendarException",
"(",
"exceptionsFolder",
",",
"exception",
")",
";",
"}",
"}"
] |
Add a calendar node.
@param parentNode parent node
@param calendar calendar
|
[
"Add",
"a",
"calendar",
"node",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L257-L283
|
157,709
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addCalendarDay
|
private void addCalendarDay(MpxjTreeNode parentNode, ProjectCalendar calendar, final Day day)
{
MpxjTreeNode dayNode = new MpxjTreeNode(day)
{
@Override public String toString()
{
return day.name();
}
};
parentNode.add(dayNode);
addHours(dayNode, calendar.getHours(day));
}
|
java
|
private void addCalendarDay(MpxjTreeNode parentNode, ProjectCalendar calendar, final Day day)
{
MpxjTreeNode dayNode = new MpxjTreeNode(day)
{
@Override public String toString()
{
return day.name();
}
};
parentNode.add(dayNode);
addHours(dayNode, calendar.getHours(day));
}
|
[
"private",
"void",
"addCalendarDay",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectCalendar",
"calendar",
",",
"final",
"Day",
"day",
")",
"{",
"MpxjTreeNode",
"dayNode",
"=",
"new",
"MpxjTreeNode",
"(",
"day",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"day",
".",
"name",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"dayNode",
")",
";",
"addHours",
"(",
"dayNode",
",",
"calendar",
".",
"getHours",
"(",
"day",
")",
")",
";",
"}"
] |
Add a calendar day node.
@param parentNode parent node
@param calendar ProjectCalendar instance
@param day calendar day
|
[
"Add",
"a",
"calendar",
"day",
"node",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L292-L303
|
157,710
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addHours
|
private void addHours(MpxjTreeNode parentNode, ProjectCalendarDateRanges hours)
{
for (DateRange range : hours)
{
final DateRange r = range;
MpxjTreeNode rangeNode = new MpxjTreeNode(range)
{
@Override public String toString()
{
return m_timeFormat.format(r.getStart()) + " - " + m_timeFormat.format(r.getEnd());
}
};
parentNode.add(rangeNode);
}
}
|
java
|
private void addHours(MpxjTreeNode parentNode, ProjectCalendarDateRanges hours)
{
for (DateRange range : hours)
{
final DateRange r = range;
MpxjTreeNode rangeNode = new MpxjTreeNode(range)
{
@Override public String toString()
{
return m_timeFormat.format(r.getStart()) + " - " + m_timeFormat.format(r.getEnd());
}
};
parentNode.add(rangeNode);
}
}
|
[
"private",
"void",
"addHours",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectCalendarDateRanges",
"hours",
")",
"{",
"for",
"(",
"DateRange",
"range",
":",
"hours",
")",
"{",
"final",
"DateRange",
"r",
"=",
"range",
";",
"MpxjTreeNode",
"rangeNode",
"=",
"new",
"MpxjTreeNode",
"(",
"range",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"m_timeFormat",
".",
"format",
"(",
"r",
".",
"getStart",
"(",
")",
")",
"+",
"\" - \"",
"+",
"m_timeFormat",
".",
"format",
"(",
"r",
".",
"getEnd",
"(",
")",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"rangeNode",
")",
";",
"}",
"}"
] |
Add hours to a parent object.
@param parentNode parent node
@param hours list of ranges
|
[
"Add",
"hours",
"to",
"a",
"parent",
"object",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L311-L325
|
157,711
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addCalendarException
|
private void addCalendarException(MpxjTreeNode parentNode, final ProjectCalendarException exception)
{
MpxjTreeNode exceptionNode = new MpxjTreeNode(exception, CALENDAR_EXCEPTION_EXCLUDED_METHODS)
{
@Override public String toString()
{
return m_dateFormat.format(exception.getFromDate());
}
};
parentNode.add(exceptionNode);
addHours(exceptionNode, exception);
}
|
java
|
private void addCalendarException(MpxjTreeNode parentNode, final ProjectCalendarException exception)
{
MpxjTreeNode exceptionNode = new MpxjTreeNode(exception, CALENDAR_EXCEPTION_EXCLUDED_METHODS)
{
@Override public String toString()
{
return m_dateFormat.format(exception.getFromDate());
}
};
parentNode.add(exceptionNode);
addHours(exceptionNode, exception);
}
|
[
"private",
"void",
"addCalendarException",
"(",
"MpxjTreeNode",
"parentNode",
",",
"final",
"ProjectCalendarException",
"exception",
")",
"{",
"MpxjTreeNode",
"exceptionNode",
"=",
"new",
"MpxjTreeNode",
"(",
"exception",
",",
"CALENDAR_EXCEPTION_EXCLUDED_METHODS",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"m_dateFormat",
".",
"format",
"(",
"exception",
".",
"getFromDate",
"(",
")",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"exceptionNode",
")",
";",
"addHours",
"(",
"exceptionNode",
",",
"exception",
")",
";",
"}"
] |
Add an exception to a calendar.
@param parentNode parent node
@param exception calendar exceptions
|
[
"Add",
"an",
"exception",
"to",
"a",
"calendar",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L333-L344
|
157,712
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addGroups
|
private void addGroups(MpxjTreeNode parentNode, ProjectFile file)
{
for (Group group : file.getGroups())
{
final Group g = group;
MpxjTreeNode childNode = new MpxjTreeNode(group)
{
@Override public String toString()
{
return g.getName();
}
};
parentNode.add(childNode);
}
}
|
java
|
private void addGroups(MpxjTreeNode parentNode, ProjectFile file)
{
for (Group group : file.getGroups())
{
final Group g = group;
MpxjTreeNode childNode = new MpxjTreeNode(group)
{
@Override public String toString()
{
return g.getName();
}
};
parentNode.add(childNode);
}
}
|
[
"private",
"void",
"addGroups",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectFile",
"file",
")",
"{",
"for",
"(",
"Group",
"group",
":",
"file",
".",
"getGroups",
"(",
")",
")",
"{",
"final",
"Group",
"g",
"=",
"group",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"group",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"g",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"}",
"}"
] |
Add groups to the tree.
@param parentNode parent tree node
@param file group container
|
[
"Add",
"groups",
"to",
"the",
"tree",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L352-L366
|
157,713
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addCustomFields
|
private void addCustomFields(MpxjTreeNode parentNode, ProjectFile file)
{
for (CustomField field : file.getCustomFields())
{
final CustomField c = field;
MpxjTreeNode childNode = new MpxjTreeNode(field)
{
@Override public String toString()
{
FieldType type = c.getFieldType();
return type == null ? "(unknown)" : type.getFieldTypeClass() + "." + type.toString();
}
};
parentNode.add(childNode);
}
}
|
java
|
private void addCustomFields(MpxjTreeNode parentNode, ProjectFile file)
{
for (CustomField field : file.getCustomFields())
{
final CustomField c = field;
MpxjTreeNode childNode = new MpxjTreeNode(field)
{
@Override public String toString()
{
FieldType type = c.getFieldType();
return type == null ? "(unknown)" : type.getFieldTypeClass() + "." + type.toString();
}
};
parentNode.add(childNode);
}
}
|
[
"private",
"void",
"addCustomFields",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectFile",
"file",
")",
"{",
"for",
"(",
"CustomField",
"field",
":",
"file",
".",
"getCustomFields",
"(",
")",
")",
"{",
"final",
"CustomField",
"c",
"=",
"field",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"field",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"FieldType",
"type",
"=",
"c",
".",
"getFieldType",
"(",
")",
";",
"return",
"type",
"==",
"null",
"?",
"\"(unknown)\"",
":",
"type",
".",
"getFieldTypeClass",
"(",
")",
"+",
"\".\"",
"+",
"type",
".",
"toString",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"}",
"}"
] |
Add custom fields to the tree.
@param parentNode parent tree node
@param file custom fields container
|
[
"Add",
"custom",
"fields",
"to",
"the",
"tree",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L374-L390
|
157,714
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addViews
|
private void addViews(MpxjTreeNode parentNode, ProjectFile file)
{
for (View view : file.getViews())
{
final View v = view;
MpxjTreeNode childNode = new MpxjTreeNode(view)
{
@Override public String toString()
{
return v.getName();
}
};
parentNode.add(childNode);
}
}
|
java
|
private void addViews(MpxjTreeNode parentNode, ProjectFile file)
{
for (View view : file.getViews())
{
final View v = view;
MpxjTreeNode childNode = new MpxjTreeNode(view)
{
@Override public String toString()
{
return v.getName();
}
};
parentNode.add(childNode);
}
}
|
[
"private",
"void",
"addViews",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectFile",
"file",
")",
"{",
"for",
"(",
"View",
"view",
":",
"file",
".",
"getViews",
"(",
")",
")",
"{",
"final",
"View",
"v",
"=",
"view",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"view",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"v",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"}",
"}"
] |
Add views to the tree.
@param parentNode parent tree node
@param file views container
|
[
"Add",
"views",
"to",
"the",
"tree",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L398-L412
|
157,715
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addTables
|
private void addTables(MpxjTreeNode parentNode, ProjectFile file)
{
for (Table table : file.getTables())
{
final Table t = table;
MpxjTreeNode childNode = new MpxjTreeNode(table, TABLE_EXCLUDED_METHODS)
{
@Override public String toString()
{
return t.getName();
}
};
parentNode.add(childNode);
addColumns(childNode, table);
}
}
|
java
|
private void addTables(MpxjTreeNode parentNode, ProjectFile file)
{
for (Table table : file.getTables())
{
final Table t = table;
MpxjTreeNode childNode = new MpxjTreeNode(table, TABLE_EXCLUDED_METHODS)
{
@Override public String toString()
{
return t.getName();
}
};
parentNode.add(childNode);
addColumns(childNode, table);
}
}
|
[
"private",
"void",
"addTables",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectFile",
"file",
")",
"{",
"for",
"(",
"Table",
"table",
":",
"file",
".",
"getTables",
"(",
")",
")",
"{",
"final",
"Table",
"t",
"=",
"table",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"table",
",",
"TABLE_EXCLUDED_METHODS",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"t",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"addColumns",
"(",
"childNode",
",",
"table",
")",
";",
"}",
"}"
] |
Add tables to the tree.
@param parentNode parent tree node
@param file tables container
|
[
"Add",
"tables",
"to",
"the",
"tree",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L420-L436
|
157,716
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addColumns
|
private void addColumns(MpxjTreeNode parentNode, Table table)
{
for (Column column : table.getColumns())
{
final Column c = column;
MpxjTreeNode childNode = new MpxjTreeNode(column)
{
@Override public String toString()
{
return c.getTitle();
}
};
parentNode.add(childNode);
}
}
|
java
|
private void addColumns(MpxjTreeNode parentNode, Table table)
{
for (Column column : table.getColumns())
{
final Column c = column;
MpxjTreeNode childNode = new MpxjTreeNode(column)
{
@Override public String toString()
{
return c.getTitle();
}
};
parentNode.add(childNode);
}
}
|
[
"private",
"void",
"addColumns",
"(",
"MpxjTreeNode",
"parentNode",
",",
"Table",
"table",
")",
"{",
"for",
"(",
"Column",
"column",
":",
"table",
".",
"getColumns",
"(",
")",
")",
"{",
"final",
"Column",
"c",
"=",
"column",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"column",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"c",
".",
"getTitle",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"}",
"}"
] |
Add columns to the tree.
@param parentNode parent tree node
@param table columns container
|
[
"Add",
"columns",
"to",
"the",
"tree",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L444-L458
|
157,717
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addFilters
|
private void addFilters(MpxjTreeNode parentNode, List<Filter> filters)
{
for (Filter field : filters)
{
final Filter f = field;
MpxjTreeNode childNode = new MpxjTreeNode(field)
{
@Override public String toString()
{
return f.getName();
}
};
parentNode.add(childNode);
}
}
|
java
|
private void addFilters(MpxjTreeNode parentNode, List<Filter> filters)
{
for (Filter field : filters)
{
final Filter f = field;
MpxjTreeNode childNode = new MpxjTreeNode(field)
{
@Override public String toString()
{
return f.getName();
}
};
parentNode.add(childNode);
}
}
|
[
"private",
"void",
"addFilters",
"(",
"MpxjTreeNode",
"parentNode",
",",
"List",
"<",
"Filter",
">",
"filters",
")",
"{",
"for",
"(",
"Filter",
"field",
":",
"filters",
")",
"{",
"final",
"Filter",
"f",
"=",
"field",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"field",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"f",
".",
"getName",
"(",
")",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"}",
"}"
] |
Add filters to the tree.
@param parentNode parent tree node
@param filters list of filters
|
[
"Add",
"filters",
"to",
"the",
"tree",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L466-L480
|
157,718
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.addAssignments
|
private void addAssignments(MpxjTreeNode parentNode, ProjectFile file)
{
for (ResourceAssignment assignment : file.getResourceAssignments())
{
final ResourceAssignment a = assignment;
MpxjTreeNode childNode = new MpxjTreeNode(a)
{
@Override public String toString()
{
Resource resource = a.getResource();
String resourceName = resource == null ? "(unknown resource)" : resource.getName();
Task task = a.getTask();
String taskName = task == null ? "(unknown task)" : task.getName();
return resourceName + "->" + taskName;
}
};
parentNode.add(childNode);
}
}
|
java
|
private void addAssignments(MpxjTreeNode parentNode, ProjectFile file)
{
for (ResourceAssignment assignment : file.getResourceAssignments())
{
final ResourceAssignment a = assignment;
MpxjTreeNode childNode = new MpxjTreeNode(a)
{
@Override public String toString()
{
Resource resource = a.getResource();
String resourceName = resource == null ? "(unknown resource)" : resource.getName();
Task task = a.getTask();
String taskName = task == null ? "(unknown task)" : task.getName();
return resourceName + "->" + taskName;
}
};
parentNode.add(childNode);
}
}
|
[
"private",
"void",
"addAssignments",
"(",
"MpxjTreeNode",
"parentNode",
",",
"ProjectFile",
"file",
")",
"{",
"for",
"(",
"ResourceAssignment",
"assignment",
":",
"file",
".",
"getResourceAssignments",
"(",
")",
")",
"{",
"final",
"ResourceAssignment",
"a",
"=",
"assignment",
";",
"MpxjTreeNode",
"childNode",
"=",
"new",
"MpxjTreeNode",
"(",
"a",
")",
"{",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"Resource",
"resource",
"=",
"a",
".",
"getResource",
"(",
")",
";",
"String",
"resourceName",
"=",
"resource",
"==",
"null",
"?",
"\"(unknown resource)\"",
":",
"resource",
".",
"getName",
"(",
")",
";",
"Task",
"task",
"=",
"a",
".",
"getTask",
"(",
")",
";",
"String",
"taskName",
"=",
"task",
"==",
"null",
"?",
"\"(unknown task)\"",
":",
"task",
".",
"getName",
"(",
")",
";",
"return",
"resourceName",
"+",
"\"->\"",
"+",
"taskName",
";",
"}",
"}",
";",
"parentNode",
".",
"add",
"(",
"childNode",
")",
";",
"}",
"}"
] |
Add assignments to the tree.
@param parentNode parent tree node
@param file assignments container
|
[
"Add",
"assignments",
"to",
"the",
"tree",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L488-L506
|
157,719
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.saveFile
|
public void saveFile(File file, String type)
{
try
{
Class<? extends ProjectWriter> fileClass = WRITER_MAP.get(type);
if (fileClass == null)
{
throw new IllegalArgumentException("Cannot write files of type: " + type);
}
ProjectWriter writer = fileClass.newInstance();
writer.write(m_projectFile, file);
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
}
|
java
|
public void saveFile(File file, String type)
{
try
{
Class<? extends ProjectWriter> fileClass = WRITER_MAP.get(type);
if (fileClass == null)
{
throw new IllegalArgumentException("Cannot write files of type: " + type);
}
ProjectWriter writer = fileClass.newInstance();
writer.write(m_projectFile, file);
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
}
|
[
"public",
"void",
"saveFile",
"(",
"File",
"file",
",",
"String",
"type",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
"extends",
"ProjectWriter",
">",
"fileClass",
"=",
"WRITER_MAP",
".",
"get",
"(",
"type",
")",
";",
"if",
"(",
"fileClass",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot write files of type: \"",
"+",
"type",
")",
";",
"}",
"ProjectWriter",
"writer",
"=",
"fileClass",
".",
"newInstance",
"(",
")",
";",
"writer",
".",
"write",
"(",
"m_projectFile",
",",
"file",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ex",
")",
";",
"}",
"}"
] |
Save the current file as the given type.
@param file target file
@param type file type
|
[
"Save",
"the",
"current",
"file",
"as",
"the",
"given",
"type",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L514-L532
|
157,720
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java
|
ProjectTreeController.excludedMethods
|
private static Set<String> excludedMethods(String... methodNames)
{
Set<String> set = new HashSet<String>(MpxjTreeNode.DEFAULT_EXCLUDED_METHODS);
set.addAll(Arrays.asList(methodNames));
return set;
}
|
java
|
private static Set<String> excludedMethods(String... methodNames)
{
Set<String> set = new HashSet<String>(MpxjTreeNode.DEFAULT_EXCLUDED_METHODS);
set.addAll(Arrays.asList(methodNames));
return set;
}
|
[
"private",
"static",
"Set",
"<",
"String",
">",
"excludedMethods",
"(",
"String",
"...",
"methodNames",
")",
"{",
"Set",
"<",
"String",
">",
"set",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
"MpxjTreeNode",
".",
"DEFAULT_EXCLUDED_METHODS",
")",
";",
"set",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"methodNames",
")",
")",
";",
"return",
"set",
";",
"}"
] |
Generates a set of excluded method names.
@param methodNames method names
@return set of method names
|
[
"Generates",
"a",
"set",
"of",
"excluded",
"method",
"names",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/explorer/ProjectTreeController.java#L540-L545
|
157,721
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/common/FixedLengthInputStream.java
|
FixedLengthInputStream.close
|
@Override public void close() throws IOException
{
long skippedLast = 0;
if (m_remaining > 0)
{
skippedLast = skip(m_remaining);
while (m_remaining > 0 && skippedLast > 0)
{
skippedLast = skip(m_remaining);
}
}
}
|
java
|
@Override public void close() throws IOException
{
long skippedLast = 0;
if (m_remaining > 0)
{
skippedLast = skip(m_remaining);
while (m_remaining > 0 && skippedLast > 0)
{
skippedLast = skip(m_remaining);
}
}
}
|
[
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"long",
"skippedLast",
"=",
"0",
";",
"if",
"(",
"m_remaining",
">",
"0",
")",
"{",
"skippedLast",
"=",
"skip",
"(",
"m_remaining",
")",
";",
"while",
"(",
"m_remaining",
">",
"0",
"&&",
"skippedLast",
">",
"0",
")",
"{",
"skippedLast",
"=",
"skip",
"(",
"m_remaining",
")",
";",
"}",
"}",
"}"
] |
Closing will only skip to the end of this fixed length input stream and
not call the parent's close method.
@throws IOException if an I/O error occurs while closing stream
|
[
"Closing",
"will",
"only",
"skip",
"to",
"the",
"end",
"of",
"this",
"fixed",
"length",
"input",
"stream",
"and",
"not",
"call",
"the",
"parent",
"s",
"close",
"method",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/common/FixedLengthInputStream.java#L55-L66
|
157,722
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpx/LocaleUtility.java
|
LocaleUtility.setLocale
|
public static void setLocale(ProjectProperties properties, Locale locale)
{
properties.setMpxDelimiter(LocaleData.getChar(locale, LocaleData.FILE_DELIMITER));
properties.setMpxProgramName(LocaleData.getString(locale, LocaleData.PROGRAM_NAME));
properties.setMpxCodePage((CodePage) LocaleData.getObject(locale, LocaleData.CODE_PAGE));
properties.setCurrencySymbol(LocaleData.getString(locale, LocaleData.CURRENCY_SYMBOL));
properties.setSymbolPosition((CurrencySymbolPosition) LocaleData.getObject(locale, LocaleData.CURRENCY_SYMBOL_POSITION));
properties.setCurrencyDigits(LocaleData.getInteger(locale, LocaleData.CURRENCY_DIGITS));
properties.setThousandsSeparator(LocaleData.getChar(locale, LocaleData.CURRENCY_THOUSANDS_SEPARATOR));
properties.setDecimalSeparator(LocaleData.getChar(locale, LocaleData.CURRENCY_DECIMAL_SEPARATOR));
properties.setDateOrder((DateOrder) LocaleData.getObject(locale, LocaleData.DATE_ORDER));
properties.setTimeFormat((ProjectTimeFormat) LocaleData.getObject(locale, LocaleData.TIME_FORMAT));
properties.setDefaultStartTime(DateHelper.getTimeFromMinutesPastMidnight(LocaleData.getInteger(locale, LocaleData.DEFAULT_START_TIME)));
properties.setDateSeparator(LocaleData.getChar(locale, LocaleData.DATE_SEPARATOR));
properties.setTimeSeparator(LocaleData.getChar(locale, LocaleData.TIME_SEPARATOR));
properties.setAMText(LocaleData.getString(locale, LocaleData.AM_TEXT));
properties.setPMText(LocaleData.getString(locale, LocaleData.PM_TEXT));
properties.setDateFormat((ProjectDateFormat) LocaleData.getObject(locale, LocaleData.DATE_FORMAT));
properties.setBarTextDateFormat((ProjectDateFormat) LocaleData.getObject(locale, LocaleData.DATE_FORMAT));
}
|
java
|
public static void setLocale(ProjectProperties properties, Locale locale)
{
properties.setMpxDelimiter(LocaleData.getChar(locale, LocaleData.FILE_DELIMITER));
properties.setMpxProgramName(LocaleData.getString(locale, LocaleData.PROGRAM_NAME));
properties.setMpxCodePage((CodePage) LocaleData.getObject(locale, LocaleData.CODE_PAGE));
properties.setCurrencySymbol(LocaleData.getString(locale, LocaleData.CURRENCY_SYMBOL));
properties.setSymbolPosition((CurrencySymbolPosition) LocaleData.getObject(locale, LocaleData.CURRENCY_SYMBOL_POSITION));
properties.setCurrencyDigits(LocaleData.getInteger(locale, LocaleData.CURRENCY_DIGITS));
properties.setThousandsSeparator(LocaleData.getChar(locale, LocaleData.CURRENCY_THOUSANDS_SEPARATOR));
properties.setDecimalSeparator(LocaleData.getChar(locale, LocaleData.CURRENCY_DECIMAL_SEPARATOR));
properties.setDateOrder((DateOrder) LocaleData.getObject(locale, LocaleData.DATE_ORDER));
properties.setTimeFormat((ProjectTimeFormat) LocaleData.getObject(locale, LocaleData.TIME_FORMAT));
properties.setDefaultStartTime(DateHelper.getTimeFromMinutesPastMidnight(LocaleData.getInteger(locale, LocaleData.DEFAULT_START_TIME)));
properties.setDateSeparator(LocaleData.getChar(locale, LocaleData.DATE_SEPARATOR));
properties.setTimeSeparator(LocaleData.getChar(locale, LocaleData.TIME_SEPARATOR));
properties.setAMText(LocaleData.getString(locale, LocaleData.AM_TEXT));
properties.setPMText(LocaleData.getString(locale, LocaleData.PM_TEXT));
properties.setDateFormat((ProjectDateFormat) LocaleData.getObject(locale, LocaleData.DATE_FORMAT));
properties.setBarTextDateFormat((ProjectDateFormat) LocaleData.getObject(locale, LocaleData.DATE_FORMAT));
}
|
[
"public",
"static",
"void",
"setLocale",
"(",
"ProjectProperties",
"properties",
",",
"Locale",
"locale",
")",
"{",
"properties",
".",
"setMpxDelimiter",
"(",
"LocaleData",
".",
"getChar",
"(",
"locale",
",",
"LocaleData",
".",
"FILE_DELIMITER",
")",
")",
";",
"properties",
".",
"setMpxProgramName",
"(",
"LocaleData",
".",
"getString",
"(",
"locale",
",",
"LocaleData",
".",
"PROGRAM_NAME",
")",
")",
";",
"properties",
".",
"setMpxCodePage",
"(",
"(",
"CodePage",
")",
"LocaleData",
".",
"getObject",
"(",
"locale",
",",
"LocaleData",
".",
"CODE_PAGE",
")",
")",
";",
"properties",
".",
"setCurrencySymbol",
"(",
"LocaleData",
".",
"getString",
"(",
"locale",
",",
"LocaleData",
".",
"CURRENCY_SYMBOL",
")",
")",
";",
"properties",
".",
"setSymbolPosition",
"(",
"(",
"CurrencySymbolPosition",
")",
"LocaleData",
".",
"getObject",
"(",
"locale",
",",
"LocaleData",
".",
"CURRENCY_SYMBOL_POSITION",
")",
")",
";",
"properties",
".",
"setCurrencyDigits",
"(",
"LocaleData",
".",
"getInteger",
"(",
"locale",
",",
"LocaleData",
".",
"CURRENCY_DIGITS",
")",
")",
";",
"properties",
".",
"setThousandsSeparator",
"(",
"LocaleData",
".",
"getChar",
"(",
"locale",
",",
"LocaleData",
".",
"CURRENCY_THOUSANDS_SEPARATOR",
")",
")",
";",
"properties",
".",
"setDecimalSeparator",
"(",
"LocaleData",
".",
"getChar",
"(",
"locale",
",",
"LocaleData",
".",
"CURRENCY_DECIMAL_SEPARATOR",
")",
")",
";",
"properties",
".",
"setDateOrder",
"(",
"(",
"DateOrder",
")",
"LocaleData",
".",
"getObject",
"(",
"locale",
",",
"LocaleData",
".",
"DATE_ORDER",
")",
")",
";",
"properties",
".",
"setTimeFormat",
"(",
"(",
"ProjectTimeFormat",
")",
"LocaleData",
".",
"getObject",
"(",
"locale",
",",
"LocaleData",
".",
"TIME_FORMAT",
")",
")",
";",
"properties",
".",
"setDefaultStartTime",
"(",
"DateHelper",
".",
"getTimeFromMinutesPastMidnight",
"(",
"LocaleData",
".",
"getInteger",
"(",
"locale",
",",
"LocaleData",
".",
"DEFAULT_START_TIME",
")",
")",
")",
";",
"properties",
".",
"setDateSeparator",
"(",
"LocaleData",
".",
"getChar",
"(",
"locale",
",",
"LocaleData",
".",
"DATE_SEPARATOR",
")",
")",
";",
"properties",
".",
"setTimeSeparator",
"(",
"LocaleData",
".",
"getChar",
"(",
"locale",
",",
"LocaleData",
".",
"TIME_SEPARATOR",
")",
")",
";",
"properties",
".",
"setAMText",
"(",
"LocaleData",
".",
"getString",
"(",
"locale",
",",
"LocaleData",
".",
"AM_TEXT",
")",
")",
";",
"properties",
".",
"setPMText",
"(",
"LocaleData",
".",
"getString",
"(",
"locale",
",",
"LocaleData",
".",
"PM_TEXT",
")",
")",
";",
"properties",
".",
"setDateFormat",
"(",
"(",
"ProjectDateFormat",
")",
"LocaleData",
".",
"getObject",
"(",
"locale",
",",
"LocaleData",
".",
"DATE_FORMAT",
")",
")",
";",
"properties",
".",
"setBarTextDateFormat",
"(",
"(",
"ProjectDateFormat",
")",
"LocaleData",
".",
"getObject",
"(",
"locale",
",",
"LocaleData",
".",
"DATE_FORMAT",
")",
")",
";",
"}"
] |
This method is called when the locale of the parent file is updated.
It resets the locale specific currency attributes to the default values
for the new locale.
@param properties project properties
@param locale new locale
|
[
"This",
"method",
"is",
"called",
"when",
"the",
"locale",
"of",
"the",
"parent",
"file",
"is",
"updated",
".",
"It",
"resets",
"the",
"locale",
"specific",
"currency",
"attributes",
"to",
"the",
"default",
"values",
"for",
"the",
"new",
"locale",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/LocaleUtility.java#L58-L79
|
157,723
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Column.java
|
Column.getTitle
|
public String getTitle(Locale locale)
{
String result = null;
if (m_title != null)
{
result = m_title;
}
else
{
if (m_fieldType != null)
{
result = m_project.getCustomFields().getCustomField(m_fieldType).getAlias();
if (result == null)
{
result = m_fieldType.getName(locale);
}
}
}
return (result);
}
|
java
|
public String getTitle(Locale locale)
{
String result = null;
if (m_title != null)
{
result = m_title;
}
else
{
if (m_fieldType != null)
{
result = m_project.getCustomFields().getCustomField(m_fieldType).getAlias();
if (result == null)
{
result = m_fieldType.getName(locale);
}
}
}
return (result);
}
|
[
"public",
"String",
"getTitle",
"(",
"Locale",
"locale",
")",
"{",
"String",
"result",
"=",
"null",
";",
"if",
"(",
"m_title",
"!=",
"null",
")",
"{",
"result",
"=",
"m_title",
";",
"}",
"else",
"{",
"if",
"(",
"m_fieldType",
"!=",
"null",
")",
"{",
"result",
"=",
"m_project",
".",
"getCustomFields",
"(",
")",
".",
"getCustomField",
"(",
"m_fieldType",
")",
".",
"getAlias",
"(",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"m_fieldType",
".",
"getName",
"(",
"locale",
")",
";",
"}",
"}",
"}",
"return",
"(",
"result",
")",
";",
"}"
] |
Retrieves the column title for the given locale.
@param locale required locale for the default column title
@return column title
|
[
"Retrieves",
"the",
"column",
"title",
"for",
"the",
"given",
"locale",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Column.java#L97-L118
|
157,724
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/mpx/AccrueTypeUtility.java
|
AccrueTypeUtility.getInstance
|
public static AccrueType getInstance(String type, Locale locale)
{
AccrueType result = null;
String[] typeNames = LocaleData.getStringArray(locale, LocaleData.ACCRUE_TYPES);
for (int loop = 0; loop < typeNames.length; loop++)
{
if (typeNames[loop].equalsIgnoreCase(type) == true)
{
result = AccrueType.getInstance(loop + 1);
break;
}
}
if (result == null)
{
result = AccrueType.PRORATED;
}
return (result);
}
|
java
|
public static AccrueType getInstance(String type, Locale locale)
{
AccrueType result = null;
String[] typeNames = LocaleData.getStringArray(locale, LocaleData.ACCRUE_TYPES);
for (int loop = 0; loop < typeNames.length; loop++)
{
if (typeNames[loop].equalsIgnoreCase(type) == true)
{
result = AccrueType.getInstance(loop + 1);
break;
}
}
if (result == null)
{
result = AccrueType.PRORATED;
}
return (result);
}
|
[
"public",
"static",
"AccrueType",
"getInstance",
"(",
"String",
"type",
",",
"Locale",
"locale",
")",
"{",
"AccrueType",
"result",
"=",
"null",
";",
"String",
"[",
"]",
"typeNames",
"=",
"LocaleData",
".",
"getStringArray",
"(",
"locale",
",",
"LocaleData",
".",
"ACCRUE_TYPES",
")",
";",
"for",
"(",
"int",
"loop",
"=",
"0",
";",
"loop",
"<",
"typeNames",
".",
"length",
";",
"loop",
"++",
")",
"{",
"if",
"(",
"typeNames",
"[",
"loop",
"]",
".",
"equalsIgnoreCase",
"(",
"type",
")",
"==",
"true",
")",
"{",
"result",
"=",
"AccrueType",
".",
"getInstance",
"(",
"loop",
"+",
"1",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"AccrueType",
".",
"PRORATED",
";",
"}",
"return",
"(",
"result",
")",
";",
"}"
] |
This method takes the textual version of an accrue type name
and populates the class instance appropriately. Note that unrecognised
values are treated as "Prorated".
@param type text version of the accrue type
@param locale target locale
@return AccrueType class instance
|
[
"This",
"method",
"takes",
"the",
"textual",
"version",
"of",
"an",
"accrue",
"type",
"name",
"and",
"populates",
"the",
"class",
"instance",
"appropriately",
".",
"Note",
"that",
"unrecognised",
"values",
"are",
"treated",
"as",
"Prorated",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/mpx/AccrueTypeUtility.java#L53-L74
|
157,725
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/utility/DataExportUtility.java
|
DataExportUtility.process
|
public void process(Connection connection, String directory) throws Exception
{
connection.setAutoCommit(true);
//
// Retrieve meta data about the connection
//
DatabaseMetaData dmd = connection.getMetaData();
String[] types =
{
"TABLE"
};
FileWriter fw = new FileWriter(directory);
PrintWriter pw = new PrintWriter(fw);
pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
pw.println();
pw.println("<database>");
ResultSet tables = dmd.getTables(null, null, null, types);
while (tables.next() == true)
{
processTable(pw, connection, tables.getString("TABLE_NAME"));
}
pw.println("</database>");
pw.close();
tables.close();
}
|
java
|
public void process(Connection connection, String directory) throws Exception
{
connection.setAutoCommit(true);
//
// Retrieve meta data about the connection
//
DatabaseMetaData dmd = connection.getMetaData();
String[] types =
{
"TABLE"
};
FileWriter fw = new FileWriter(directory);
PrintWriter pw = new PrintWriter(fw);
pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
pw.println();
pw.println("<database>");
ResultSet tables = dmd.getTables(null, null, null, types);
while (tables.next() == true)
{
processTable(pw, connection, tables.getString("TABLE_NAME"));
}
pw.println("</database>");
pw.close();
tables.close();
}
|
[
"public",
"void",
"process",
"(",
"Connection",
"connection",
",",
"String",
"directory",
")",
"throws",
"Exception",
"{",
"connection",
".",
"setAutoCommit",
"(",
"true",
")",
";",
"//",
"// Retrieve meta data about the connection",
"//",
"DatabaseMetaData",
"dmd",
"=",
"connection",
".",
"getMetaData",
"(",
")",
";",
"String",
"[",
"]",
"types",
"=",
"{",
"\"TABLE\"",
"}",
";",
"FileWriter",
"fw",
"=",
"new",
"FileWriter",
"(",
"directory",
")",
";",
"PrintWriter",
"pw",
"=",
"new",
"PrintWriter",
"(",
"fw",
")",
";",
"pw",
".",
"println",
"(",
"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\"",
")",
";",
"pw",
".",
"println",
"(",
")",
";",
"pw",
".",
"println",
"(",
"\"<database>\"",
")",
";",
"ResultSet",
"tables",
"=",
"dmd",
".",
"getTables",
"(",
"null",
",",
"null",
",",
"null",
",",
"types",
")",
";",
"while",
"(",
"tables",
".",
"next",
"(",
")",
"==",
"true",
")",
"{",
"processTable",
"(",
"pw",
",",
"connection",
",",
"tables",
".",
"getString",
"(",
"\"TABLE_NAME\"",
")",
")",
";",
"}",
"pw",
".",
"println",
"(",
"\"</database>\"",
")",
";",
"pw",
".",
"close",
"(",
")",
";",
"tables",
".",
"close",
"(",
")",
";",
"}"
] |
Export data base contents to a directory using supplied connection.
@param connection database connection
@param directory target directory
@throws Exception
|
[
"Export",
"data",
"base",
"contents",
"to",
"a",
"directory",
"using",
"supplied",
"connection",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/utility/DataExportUtility.java#L103-L135
|
157,726
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/utility/DataExportUtility.java
|
DataExportUtility.escapeText
|
private String escapeText(StringBuilder sb, String text)
{
int length = text.length();
char c;
sb.setLength(0);
for (int loop = 0; loop < length; loop++)
{
c = text.charAt(loop);
switch (c)
{
case '<':
{
sb.append("<");
break;
}
case '>':
{
sb.append(">");
break;
}
case '&':
{
sb.append("&");
break;
}
default:
{
if (validXMLCharacter(c))
{
if (c > 127)
{
sb.append("&#" + (int) c + ";");
}
else
{
sb.append(c);
}
}
break;
}
}
}
return (sb.toString());
}
|
java
|
private String escapeText(StringBuilder sb, String text)
{
int length = text.length();
char c;
sb.setLength(0);
for (int loop = 0; loop < length; loop++)
{
c = text.charAt(loop);
switch (c)
{
case '<':
{
sb.append("<");
break;
}
case '>':
{
sb.append(">");
break;
}
case '&':
{
sb.append("&");
break;
}
default:
{
if (validXMLCharacter(c))
{
if (c > 127)
{
sb.append("&#" + (int) c + ";");
}
else
{
sb.append(c);
}
}
break;
}
}
}
return (sb.toString());
}
|
[
"private",
"String",
"escapeText",
"(",
"StringBuilder",
"sb",
",",
"String",
"text",
")",
"{",
"int",
"length",
"=",
"text",
".",
"length",
"(",
")",
";",
"char",
"c",
";",
"sb",
".",
"setLength",
"(",
"0",
")",
";",
"for",
"(",
"int",
"loop",
"=",
"0",
";",
"loop",
"<",
"length",
";",
"loop",
"++",
")",
"{",
"c",
"=",
"text",
".",
"charAt",
"(",
"loop",
")",
";",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
"'",
":",
"{",
"sb",
".",
"append",
"(",
"\"<\"",
")",
";",
"break",
";",
"}",
"case",
"'",
"'",
":",
"{",
"sb",
".",
"append",
"(",
"\">\"",
")",
";",
"break",
";",
"}",
"case",
"'",
"'",
":",
"{",
"sb",
".",
"append",
"(",
"\"&\"",
")",
";",
"break",
";",
"}",
"default",
":",
"{",
"if",
"(",
"validXMLCharacter",
"(",
"c",
")",
")",
"{",
"if",
"(",
"c",
">",
"127",
")",
"{",
"sb",
".",
"append",
"(",
"\"&#\"",
"+",
"(",
"int",
")",
"c",
"+",
"\";\"",
")",
";",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"break",
";",
"}",
"}",
"}",
"return",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Quick and dirty XML text escape.
@param sb working string buffer
@param text input text
@return escaped text
|
[
"Quick",
"and",
"dirty",
"XML",
"text",
"escape",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/utility/DataExportUtility.java#L328-L379
|
157,727
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/sdef/SDEFmethods.java
|
SDEFmethods.rset
|
public static String rset(String input, int width)
{
String result; // result to return
StringBuilder pad = new StringBuilder();
if (input == null)
{
for (int i = 0; i < width - 1; i++)
{
pad.append(' '); // put blanks into buffer
}
result = " " + pad; // one short to use + overload
}
else
{
if (input.length() >= width)
{
result = input.substring(0, width); // when input is too long, truncate
}
else
{
int padLength = width - input.length(); // number of blanks to add
for (int i = 0; i < padLength; i++)
{
pad.append(' '); // actually put blanks into buffer
}
result = pad + input; // concatenate
}
}
return result;
}
|
java
|
public static String rset(String input, int width)
{
String result; // result to return
StringBuilder pad = new StringBuilder();
if (input == null)
{
for (int i = 0; i < width - 1; i++)
{
pad.append(' '); // put blanks into buffer
}
result = " " + pad; // one short to use + overload
}
else
{
if (input.length() >= width)
{
result = input.substring(0, width); // when input is too long, truncate
}
else
{
int padLength = width - input.length(); // number of blanks to add
for (int i = 0; i < padLength; i++)
{
pad.append(' '); // actually put blanks into buffer
}
result = pad + input; // concatenate
}
}
return result;
}
|
[
"public",
"static",
"String",
"rset",
"(",
"String",
"input",
",",
"int",
"width",
")",
"{",
"String",
"result",
";",
"// result to return",
"StringBuilder",
"pad",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"input",
"==",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"width",
"-",
"1",
";",
"i",
"++",
")",
"{",
"pad",
".",
"append",
"(",
"'",
"'",
")",
";",
"// put blanks into buffer",
"}",
"result",
"=",
"\" \"",
"+",
"pad",
";",
"// one short to use + overload",
"}",
"else",
"{",
"if",
"(",
"input",
".",
"length",
"(",
")",
">=",
"width",
")",
"{",
"result",
"=",
"input",
".",
"substring",
"(",
"0",
",",
"width",
")",
";",
"// when input is too long, truncate",
"}",
"else",
"{",
"int",
"padLength",
"=",
"width",
"-",
"input",
".",
"length",
"(",
")",
";",
"// number of blanks to add",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"padLength",
";",
"i",
"++",
")",
"{",
"pad",
".",
"append",
"(",
"'",
"'",
")",
";",
"// actually put blanks into buffer",
"}",
"result",
"=",
"pad",
"+",
"input",
";",
"// concatenate",
"}",
"}",
"return",
"result",
";",
"}"
] |
Another method to force an input string into a fixed width field
and set it on the right with the left side filled with space ' ' characters.
@param input input string
@param width required width
@return formatted string
|
[
"Another",
"method",
"to",
"force",
"an",
"input",
"string",
"into",
"a",
"fixed",
"width",
"field",
"and",
"set",
"it",
"on",
"the",
"right",
"with",
"the",
"left",
"side",
"filled",
"with",
"space",
"characters",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/sdef/SDEFmethods.java#L82-L111
|
157,728
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/sdef/SDEFmethods.java
|
SDEFmethods.workDays
|
public static String workDays(ProjectCalendar input)
{
StringBuilder result = new StringBuilder();
DayType[] test = input.getDays(); // get the array from MPXJ ProjectCalendar
for (DayType i : test)
{ // go through every day in the given array
if (i == DayType.NON_WORKING)
{
result.append("N"); // only put N for non-working day of the week
}
else
{
result.append("Y"); // Assume WORKING day unless NON_WORKING
}
}
return result.toString(); // According to USACE specs., exceptions will be specified in HOLI records
}
|
java
|
public static String workDays(ProjectCalendar input)
{
StringBuilder result = new StringBuilder();
DayType[] test = input.getDays(); // get the array from MPXJ ProjectCalendar
for (DayType i : test)
{ // go through every day in the given array
if (i == DayType.NON_WORKING)
{
result.append("N"); // only put N for non-working day of the week
}
else
{
result.append("Y"); // Assume WORKING day unless NON_WORKING
}
}
return result.toString(); // According to USACE specs., exceptions will be specified in HOLI records
}
|
[
"public",
"static",
"String",
"workDays",
"(",
"ProjectCalendar",
"input",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"DayType",
"[",
"]",
"test",
"=",
"input",
".",
"getDays",
"(",
")",
";",
"// get the array from MPXJ ProjectCalendar",
"for",
"(",
"DayType",
"i",
":",
"test",
")",
"{",
"// go through every day in the given array",
"if",
"(",
"i",
"==",
"DayType",
".",
"NON_WORKING",
")",
"{",
"result",
".",
"append",
"(",
"\"N\"",
")",
";",
"// only put N for non-working day of the week",
"}",
"else",
"{",
"result",
".",
"append",
"(",
"\"Y\"",
")",
";",
"// Assume WORKING day unless NON_WORKING",
"}",
"}",
"return",
"result",
".",
"toString",
"(",
")",
";",
"// According to USACE specs., exceptions will be specified in HOLI records",
"}"
] |
This method takes a calendar of MPXJ library type, then returns a String of the
general working days USACE format. For example, the regular 5-day work week is
NYYYYYN
If you get Fridays off work, then the String becomes NYYYYNN
@param input ProjectCalendar instance
@return work days string
|
[
"This",
"method",
"takes",
"a",
"calendar",
"of",
"MPXJ",
"library",
"type",
"then",
"returns",
"a",
"String",
"of",
"the",
"general",
"working",
"days",
"USACE",
"format",
".",
"For",
"example",
"the",
"regular",
"5",
"-",
"day",
"work",
"week",
"is",
"NYYYYYN"
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/sdef/SDEFmethods.java#L123-L139
|
157,729
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/common/InputStreamHelper.java
|
InputStreamHelper.writeStreamToTempFile
|
public static File writeStreamToTempFile(InputStream inputStream, String tempFileSuffix) throws IOException
{
FileOutputStream outputStream = null;
try
{
File file = File.createTempFile("mpxj", tempFileSuffix);
outputStream = new FileOutputStream(file);
byte[] buffer = new byte[1024];
while (true)
{
int bytesRead = inputStream.read(buffer);
if (bytesRead == -1)
{
break;
}
outputStream.write(buffer, 0, bytesRead);
}
return file;
}
finally
{
if (outputStream != null)
{
outputStream.close();
}
}
}
|
java
|
public static File writeStreamToTempFile(InputStream inputStream, String tempFileSuffix) throws IOException
{
FileOutputStream outputStream = null;
try
{
File file = File.createTempFile("mpxj", tempFileSuffix);
outputStream = new FileOutputStream(file);
byte[] buffer = new byte[1024];
while (true)
{
int bytesRead = inputStream.read(buffer);
if (bytesRead == -1)
{
break;
}
outputStream.write(buffer, 0, bytesRead);
}
return file;
}
finally
{
if (outputStream != null)
{
outputStream.close();
}
}
}
|
[
"public",
"static",
"File",
"writeStreamToTempFile",
"(",
"InputStream",
"inputStream",
",",
"String",
"tempFileSuffix",
")",
"throws",
"IOException",
"{",
"FileOutputStream",
"outputStream",
"=",
"null",
";",
"try",
"{",
"File",
"file",
"=",
"File",
".",
"createTempFile",
"(",
"\"mpxj\"",
",",
"tempFileSuffix",
")",
";",
"outputStream",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"1024",
"]",
";",
"while",
"(",
"true",
")",
"{",
"int",
"bytesRead",
"=",
"inputStream",
".",
"read",
"(",
"buffer",
")",
";",
"if",
"(",
"bytesRead",
"==",
"-",
"1",
")",
"{",
"break",
";",
"}",
"outputStream",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"bytesRead",
")",
";",
"}",
"return",
"file",
";",
"}",
"finally",
"{",
"if",
"(",
"outputStream",
"!=",
"null",
")",
"{",
"outputStream",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] |
Copy the data from an InputStream to a temp file.
@param inputStream data source
@param tempFileSuffix suffix to use for temp file
@return File instance
|
[
"Copy",
"the",
"data",
"from",
"an",
"InputStream",
"to",
"a",
"temp",
"file",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/common/InputStreamHelper.java#L46-L74
|
157,730
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/primavera/Record.java
|
Record.getRecord
|
public static Record getRecord(String text)
{
Record root;
try
{
root = new Record(text);
}
//
// I've come across invalid calendar data in an otherwise fine Primavera
// database belonging to a customer. We deal with this gracefully here
// rather than propagating an exception.
//
catch (Exception ex)
{
root = null;
}
return root;
}
|
java
|
public static Record getRecord(String text)
{
Record root;
try
{
root = new Record(text);
}
//
// I've come across invalid calendar data in an otherwise fine Primavera
// database belonging to a customer. We deal with this gracefully here
// rather than propagating an exception.
//
catch (Exception ex)
{
root = null;
}
return root;
}
|
[
"public",
"static",
"Record",
"getRecord",
"(",
"String",
"text",
")",
"{",
"Record",
"root",
";",
"try",
"{",
"root",
"=",
"new",
"Record",
"(",
"text",
")",
";",
"}",
"//",
"// I've come across invalid calendar data in an otherwise fine Primavera",
"// database belonging to a customer. We deal with this gracefully here",
"// rather than propagating an exception.",
"//",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"root",
"=",
"null",
";",
"}",
"return",
"root",
";",
"}"
] |
Create a structured Record instance from the flat text data.
Null is returned if errors are encountered during parse.
@param text flat text data
@return Record instance
|
[
"Create",
"a",
"structured",
"Record",
"instance",
"from",
"the",
"flat",
"text",
"data",
".",
"Null",
"is",
"returned",
"if",
"errors",
"are",
"encountered",
"during",
"parse",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/Record.java#L63-L83
|
157,731
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/primavera/Record.java
|
Record.getChild
|
public Record getChild(String key)
{
Record result = null;
if (key != null)
{
for (Record record : m_records)
{
if (key.equals(record.getField()))
{
result = record;
break;
}
}
}
return result;
}
|
java
|
public Record getChild(String key)
{
Record result = null;
if (key != null)
{
for (Record record : m_records)
{
if (key.equals(record.getField()))
{
result = record;
break;
}
}
}
return result;
}
|
[
"public",
"Record",
"getChild",
"(",
"String",
"key",
")",
"{",
"Record",
"result",
"=",
"null",
";",
"if",
"(",
"key",
"!=",
"null",
")",
"{",
"for",
"(",
"Record",
"record",
":",
"m_records",
")",
"{",
"if",
"(",
"key",
".",
"equals",
"(",
"record",
".",
"getField",
"(",
")",
")",
")",
"{",
"result",
"=",
"record",
";",
"break",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] |
Retrieve a child record by name.
@param key child record name
@return child record
|
[
"Retrieve",
"a",
"child",
"record",
"by",
"name",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/Record.java#L121-L136
|
157,732
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/primavera/Record.java
|
Record.getClosingParenthesisPosition
|
private int getClosingParenthesisPosition(String text, int opening)
{
if (text.charAt(opening) != '(')
{
return -1;
}
int count = 0;
for (int i = opening; i < text.length(); i++)
{
char c = text.charAt(i);
switch (c)
{
case '(':
{
++count;
break;
}
case ')':
{
--count;
if (count == 0)
{
return i;
}
break;
}
}
}
return -1;
}
|
java
|
private int getClosingParenthesisPosition(String text, int opening)
{
if (text.charAt(opening) != '(')
{
return -1;
}
int count = 0;
for (int i = opening; i < text.length(); i++)
{
char c = text.charAt(i);
switch (c)
{
case '(':
{
++count;
break;
}
case ')':
{
--count;
if (count == 0)
{
return i;
}
break;
}
}
}
return -1;
}
|
[
"private",
"int",
"getClosingParenthesisPosition",
"(",
"String",
"text",
",",
"int",
"opening",
")",
"{",
"if",
"(",
"text",
".",
"charAt",
"(",
"opening",
")",
"!=",
"'",
"'",
")",
"{",
"return",
"-",
"1",
";",
"}",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"opening",
";",
"i",
"<",
"text",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"text",
".",
"charAt",
"(",
"i",
")",
";",
"switch",
"(",
"c",
")",
"{",
"case",
"'",
"'",
":",
"{",
"++",
"count",
";",
"break",
";",
"}",
"case",
"'",
"'",
":",
"{",
"--",
"count",
";",
"if",
"(",
"count",
"==",
"0",
")",
"{",
"return",
"i",
";",
"}",
"break",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Look for the closing parenthesis corresponding to the one at position
represented by the opening index.
@param text input expression
@param opening opening parenthesis index
@return closing parenthesis index
|
[
"Look",
"for",
"the",
"closing",
"parenthesis",
"corresponding",
"to",
"the",
"one",
"at",
"position",
"represented",
"by",
"the",
"opening",
"index",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/primavera/Record.java#L204-L236
|
157,733
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/fasttrack/FastTrackUtility.java
|
FastTrackUtility.getLong
|
public static final long getLong(byte[] data, int offset)
{
if (data.length != 8)
{
throw new UnexpectedStructureException();
}
long result = 0;
int i = offset;
for (int shiftBy = 0; shiftBy < 64; shiftBy += 8)
{
result |= ((long) (data[i] & 0xff)) << shiftBy;
++i;
}
return result;
}
|
java
|
public static final long getLong(byte[] data, int offset)
{
if (data.length != 8)
{
throw new UnexpectedStructureException();
}
long result = 0;
int i = offset;
for (int shiftBy = 0; shiftBy < 64; shiftBy += 8)
{
result |= ((long) (data[i] & 0xff)) << shiftBy;
++i;
}
return result;
}
|
[
"public",
"static",
"final",
"long",
"getLong",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"offset",
")",
"{",
"if",
"(",
"data",
".",
"length",
"!=",
"8",
")",
"{",
"throw",
"new",
"UnexpectedStructureException",
"(",
")",
";",
"}",
"long",
"result",
"=",
"0",
";",
"int",
"i",
"=",
"offset",
";",
"for",
"(",
"int",
"shiftBy",
"=",
"0",
";",
"shiftBy",
"<",
"64",
";",
"shiftBy",
"+=",
"8",
")",
"{",
"result",
"|=",
"(",
"(",
"long",
")",
"(",
"data",
"[",
"i",
"]",
"&",
"0xff",
")",
")",
"<<",
"shiftBy",
";",
"++",
"i",
";",
"}",
"return",
"result",
";",
"}"
] |
This method reads an eight byte integer from the input array.
@param data the input array
@param offset offset of integer data in the array
@return integer value
|
[
"This",
"method",
"reads",
"an",
"eight",
"byte",
"integer",
"from",
"the",
"input",
"array",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/fasttrack/FastTrackUtility.java#L107-L122
|
157,734
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/fasttrack/FastTrackUtility.java
|
FastTrackUtility.getTimeUnit
|
public static final TimeUnit getTimeUnit(int value)
{
TimeUnit result = null;
switch (value)
{
case 1:
{
// Appears to mean "use the document format"
result = TimeUnit.ELAPSED_DAYS;
break;
}
case 2:
{
result = TimeUnit.HOURS;
break;
}
case 4:
{
result = TimeUnit.DAYS;
break;
}
case 6:
{
result = TimeUnit.WEEKS;
break;
}
case 8:
case 10:
{
result = TimeUnit.MONTHS;
break;
}
case 12:
{
result = TimeUnit.YEARS;
break;
}
default:
{
break;
}
}
return result;
}
|
java
|
public static final TimeUnit getTimeUnit(int value)
{
TimeUnit result = null;
switch (value)
{
case 1:
{
// Appears to mean "use the document format"
result = TimeUnit.ELAPSED_DAYS;
break;
}
case 2:
{
result = TimeUnit.HOURS;
break;
}
case 4:
{
result = TimeUnit.DAYS;
break;
}
case 6:
{
result = TimeUnit.WEEKS;
break;
}
case 8:
case 10:
{
result = TimeUnit.MONTHS;
break;
}
case 12:
{
result = TimeUnit.YEARS;
break;
}
default:
{
break;
}
}
return result;
}
|
[
"public",
"static",
"final",
"TimeUnit",
"getTimeUnit",
"(",
"int",
"value",
")",
"{",
"TimeUnit",
"result",
"=",
"null",
";",
"switch",
"(",
"value",
")",
"{",
"case",
"1",
":",
"{",
"// Appears to mean \"use the document format\"",
"result",
"=",
"TimeUnit",
".",
"ELAPSED_DAYS",
";",
"break",
";",
"}",
"case",
"2",
":",
"{",
"result",
"=",
"TimeUnit",
".",
"HOURS",
";",
"break",
";",
"}",
"case",
"4",
":",
"{",
"result",
"=",
"TimeUnit",
".",
"DAYS",
";",
"break",
";",
"}",
"case",
"6",
":",
"{",
"result",
"=",
"TimeUnit",
".",
"WEEKS",
";",
"break",
";",
"}",
"case",
"8",
":",
"case",
"10",
":",
"{",
"result",
"=",
"TimeUnit",
".",
"MONTHS",
";",
"break",
";",
"}",
"case",
"12",
":",
"{",
"result",
"=",
"TimeUnit",
".",
"YEARS",
";",
"break",
";",
"}",
"default",
":",
"{",
"break",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Convert an integer value into a TimeUnit instance.
@param value time unit value
@return TimeUnit instance
|
[
"Convert",
"an",
"integer",
"value",
"into",
"a",
"TimeUnit",
"instance",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/fasttrack/FastTrackUtility.java#L165-L216
|
157,735
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/fasttrack/FastTrackUtility.java
|
FastTrackUtility.skipToNextMatchingShort
|
public static int skipToNextMatchingShort(byte[] buffer, int offset, int value)
{
int nextOffset = offset;
while (getShort(buffer, nextOffset) != value)
{
++nextOffset;
}
nextOffset += 2;
return nextOffset;
}
|
java
|
public static int skipToNextMatchingShort(byte[] buffer, int offset, int value)
{
int nextOffset = offset;
while (getShort(buffer, nextOffset) != value)
{
++nextOffset;
}
nextOffset += 2;
return nextOffset;
}
|
[
"public",
"static",
"int",
"skipToNextMatchingShort",
"(",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
",",
"int",
"value",
")",
"{",
"int",
"nextOffset",
"=",
"offset",
";",
"while",
"(",
"getShort",
"(",
"buffer",
",",
"nextOffset",
")",
"!=",
"value",
")",
"{",
"++",
"nextOffset",
";",
"}",
"nextOffset",
"+=",
"2",
";",
"return",
"nextOffset",
";",
"}"
] |
Skip to the next matching short value.
@param buffer input data array
@param offset start offset into the input array
@param value value to match
@return offset of matching pattern
|
[
"Skip",
"to",
"the",
"next",
"matching",
"short",
"value",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/fasttrack/FastTrackUtility.java#L226-L236
|
157,736
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/fasttrack/FastTrackUtility.java
|
FastTrackUtility.hexdump
|
public static final String hexdump(byte[] buffer, int offset, int length, boolean ascii, int columns, String prefix)
{
StringBuilder sb = new StringBuilder();
if (buffer != null)
{
int index = offset;
DecimalFormat df = new DecimalFormat("00000");
while (index < (offset + length))
{
if (index + columns > (offset + length))
{
columns = (offset + length) - index;
}
sb.append(prefix);
sb.append(df.format(index - offset));
sb.append(":");
sb.append(hexdump(buffer, index, columns, ascii));
sb.append('\n');
index += columns;
}
}
return (sb.toString());
}
|
java
|
public static final String hexdump(byte[] buffer, int offset, int length, boolean ascii, int columns, String prefix)
{
StringBuilder sb = new StringBuilder();
if (buffer != null)
{
int index = offset;
DecimalFormat df = new DecimalFormat("00000");
while (index < (offset + length))
{
if (index + columns > (offset + length))
{
columns = (offset + length) - index;
}
sb.append(prefix);
sb.append(df.format(index - offset));
sb.append(":");
sb.append(hexdump(buffer, index, columns, ascii));
sb.append('\n');
index += columns;
}
}
return (sb.toString());
}
|
[
"public",
"static",
"final",
"String",
"hexdump",
"(",
"byte",
"[",
"]",
"buffer",
",",
"int",
"offset",
",",
"int",
"length",
",",
"boolean",
"ascii",
",",
"int",
"columns",
",",
"String",
"prefix",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"buffer",
"!=",
"null",
")",
"{",
"int",
"index",
"=",
"offset",
";",
"DecimalFormat",
"df",
"=",
"new",
"DecimalFormat",
"(",
"\"00000\"",
")",
";",
"while",
"(",
"index",
"<",
"(",
"offset",
"+",
"length",
")",
")",
"{",
"if",
"(",
"index",
"+",
"columns",
">",
"(",
"offset",
"+",
"length",
")",
")",
"{",
"columns",
"=",
"(",
"offset",
"+",
"length",
")",
"-",
"index",
";",
"}",
"sb",
".",
"append",
"(",
"prefix",
")",
";",
"sb",
".",
"append",
"(",
"df",
".",
"format",
"(",
"index",
"-",
"offset",
")",
")",
";",
"sb",
".",
"append",
"(",
"\":\"",
")",
";",
"sb",
".",
"append",
"(",
"hexdump",
"(",
"buffer",
",",
"index",
",",
"columns",
",",
"ascii",
")",
")",
";",
"sb",
".",
"append",
"(",
"'",
"'",
")",
";",
"index",
"+=",
"columns",
";",
"}",
"}",
"return",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Dump raw data as hex.
@param buffer buffer
@param offset offset into buffer
@param length length of data to dump
@param ascii true if ASCII should also be printed
@param columns number of columns
@param prefix prefix when printing
@return hex dump
|
[
"Dump",
"raw",
"data",
"as",
"hex",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/fasttrack/FastTrackUtility.java#L249-L275
|
157,737
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.generateWBS
|
public void generateWBS(Task parent)
{
String wbs;
if (parent == null)
{
if (NumberHelper.getInt(getUniqueID()) == 0)
{
wbs = "0";
}
else
{
wbs = Integer.toString(getParentFile().getChildTasks().size() + 1);
}
}
else
{
wbs = parent.getWBS();
//
// Apparently I added the next lines to support MPX files generated by Artemis, back in 2005
// Unfortunately I have no test data which exercises this code, and it now breaks
// otherwise valid WBS values read (in this case) from XER files. So it's commented out
// until someone complains about their 2005-era Artemis MPX files not working!
//
// int index = wbs.lastIndexOf(".0");
// if (index != -1)
// {
// wbs = wbs.substring(0, index);
// }
int childTaskCount = parent.getChildTasks().size() + 1;
if (wbs.equals("0"))
{
wbs = Integer.toString(childTaskCount);
}
else
{
wbs += ("." + childTaskCount);
}
}
setWBS(wbs);
}
|
java
|
public void generateWBS(Task parent)
{
String wbs;
if (parent == null)
{
if (NumberHelper.getInt(getUniqueID()) == 0)
{
wbs = "0";
}
else
{
wbs = Integer.toString(getParentFile().getChildTasks().size() + 1);
}
}
else
{
wbs = parent.getWBS();
//
// Apparently I added the next lines to support MPX files generated by Artemis, back in 2005
// Unfortunately I have no test data which exercises this code, and it now breaks
// otherwise valid WBS values read (in this case) from XER files. So it's commented out
// until someone complains about their 2005-era Artemis MPX files not working!
//
// int index = wbs.lastIndexOf(".0");
// if (index != -1)
// {
// wbs = wbs.substring(0, index);
// }
int childTaskCount = parent.getChildTasks().size() + 1;
if (wbs.equals("0"))
{
wbs = Integer.toString(childTaskCount);
}
else
{
wbs += ("." + childTaskCount);
}
}
setWBS(wbs);
}
|
[
"public",
"void",
"generateWBS",
"(",
"Task",
"parent",
")",
"{",
"String",
"wbs",
";",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"if",
"(",
"NumberHelper",
".",
"getInt",
"(",
"getUniqueID",
"(",
")",
")",
"==",
"0",
")",
"{",
"wbs",
"=",
"\"0\"",
";",
"}",
"else",
"{",
"wbs",
"=",
"Integer",
".",
"toString",
"(",
"getParentFile",
"(",
")",
".",
"getChildTasks",
"(",
")",
".",
"size",
"(",
")",
"+",
"1",
")",
";",
"}",
"}",
"else",
"{",
"wbs",
"=",
"parent",
".",
"getWBS",
"(",
")",
";",
"//",
"// Apparently I added the next lines to support MPX files generated by Artemis, back in 2005",
"// Unfortunately I have no test data which exercises this code, and it now breaks",
"// otherwise valid WBS values read (in this case) from XER files. So it's commented out",
"// until someone complains about their 2005-era Artemis MPX files not working!",
"//",
"// int index = wbs.lastIndexOf(\".0\");",
"// if (index != -1)",
"// {",
"// wbs = wbs.substring(0, index);",
"// }",
"int",
"childTaskCount",
"=",
"parent",
".",
"getChildTasks",
"(",
")",
".",
"size",
"(",
")",
"+",
"1",
";",
"if",
"(",
"wbs",
".",
"equals",
"(",
"\"0\"",
")",
")",
"{",
"wbs",
"=",
"Integer",
".",
"toString",
"(",
"childTaskCount",
")",
";",
"}",
"else",
"{",
"wbs",
"+=",
"(",
"\".\"",
"+",
"childTaskCount",
")",
";",
"}",
"}",
"setWBS",
"(",
"wbs",
")",
";",
"}"
] |
This method is used to automatically generate a value
for the WBS field of this task.
@param parent Parent Task
|
[
"This",
"method",
"is",
"used",
"to",
"automatically",
"generate",
"a",
"value",
"for",
"the",
"WBS",
"field",
"of",
"this",
"task",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L105-L148
|
157,738
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.generateOutlineNumber
|
public void generateOutlineNumber(Task parent)
{
String outline;
if (parent == null)
{
if (NumberHelper.getInt(getUniqueID()) == 0)
{
outline = "0";
}
else
{
outline = Integer.toString(getParentFile().getChildTasks().size() + 1);
}
}
else
{
outline = parent.getOutlineNumber();
int index = outline.lastIndexOf(".0");
if (index != -1)
{
outline = outline.substring(0, index);
}
int childTaskCount = parent.getChildTasks().size() + 1;
if (outline.equals("0"))
{
outline = Integer.toString(childTaskCount);
}
else
{
outline += ("." + childTaskCount);
}
}
setOutlineNumber(outline);
}
|
java
|
public void generateOutlineNumber(Task parent)
{
String outline;
if (parent == null)
{
if (NumberHelper.getInt(getUniqueID()) == 0)
{
outline = "0";
}
else
{
outline = Integer.toString(getParentFile().getChildTasks().size() + 1);
}
}
else
{
outline = parent.getOutlineNumber();
int index = outline.lastIndexOf(".0");
if (index != -1)
{
outline = outline.substring(0, index);
}
int childTaskCount = parent.getChildTasks().size() + 1;
if (outline.equals("0"))
{
outline = Integer.toString(childTaskCount);
}
else
{
outline += ("." + childTaskCount);
}
}
setOutlineNumber(outline);
}
|
[
"public",
"void",
"generateOutlineNumber",
"(",
"Task",
"parent",
")",
"{",
"String",
"outline",
";",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"if",
"(",
"NumberHelper",
".",
"getInt",
"(",
"getUniqueID",
"(",
")",
")",
"==",
"0",
")",
"{",
"outline",
"=",
"\"0\"",
";",
"}",
"else",
"{",
"outline",
"=",
"Integer",
".",
"toString",
"(",
"getParentFile",
"(",
")",
".",
"getChildTasks",
"(",
")",
".",
"size",
"(",
")",
"+",
"1",
")",
";",
"}",
"}",
"else",
"{",
"outline",
"=",
"parent",
".",
"getOutlineNumber",
"(",
")",
";",
"int",
"index",
"=",
"outline",
".",
"lastIndexOf",
"(",
"\".0\"",
")",
";",
"if",
"(",
"index",
"!=",
"-",
"1",
")",
"{",
"outline",
"=",
"outline",
".",
"substring",
"(",
"0",
",",
"index",
")",
";",
"}",
"int",
"childTaskCount",
"=",
"parent",
".",
"getChildTasks",
"(",
")",
".",
"size",
"(",
")",
"+",
"1",
";",
"if",
"(",
"outline",
".",
"equals",
"(",
"\"0\"",
")",
")",
"{",
"outline",
"=",
"Integer",
".",
"toString",
"(",
"childTaskCount",
")",
";",
"}",
"else",
"{",
"outline",
"+=",
"(",
"\".\"",
"+",
"childTaskCount",
")",
";",
"}",
"}",
"setOutlineNumber",
"(",
"outline",
")",
";",
"}"
] |
This method is used to automatically generate a value
for the Outline Number field of this task.
@param parent Parent Task
|
[
"This",
"method",
"is",
"used",
"to",
"automatically",
"generate",
"a",
"value",
"for",
"the",
"Outline",
"Number",
"field",
"of",
"this",
"task",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L156-L194
|
157,739
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.addTask
|
@Override public Task addTask()
{
ProjectFile parent = getParentFile();
Task task = new Task(parent, this);
m_children.add(task);
parent.getTasks().add(task);
setSummary(true);
return (task);
}
|
java
|
@Override public Task addTask()
{
ProjectFile parent = getParentFile();
Task task = new Task(parent, this);
m_children.add(task);
parent.getTasks().add(task);
setSummary(true);
return (task);
}
|
[
"@",
"Override",
"public",
"Task",
"addTask",
"(",
")",
"{",
"ProjectFile",
"parent",
"=",
"getParentFile",
"(",
")",
";",
"Task",
"task",
"=",
"new",
"Task",
"(",
"parent",
",",
"this",
")",
";",
"m_children",
".",
"add",
"(",
"task",
")",
";",
"parent",
".",
"getTasks",
"(",
")",
".",
"add",
"(",
"task",
")",
";",
"setSummary",
"(",
"true",
")",
";",
"return",
"(",
"task",
")",
";",
"}"
] |
This method allows nested tasks to be added, with the WBS being
completed automatically.
@return new task
|
[
"This",
"method",
"allows",
"nested",
"tasks",
"to",
"be",
"added",
"with",
"the",
"WBS",
"being",
"completed",
"automatically",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L212-L225
|
157,740
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.addChildTask
|
public void addChildTask(Task child, int childOutlineLevel)
{
int outlineLevel = NumberHelper.getInt(getOutlineLevel());
if ((outlineLevel + 1) == childOutlineLevel)
{
m_children.add(child);
setSummary(true);
}
else
{
if (m_children.isEmpty() == false)
{
(m_children.get(m_children.size() - 1)).addChildTask(child, childOutlineLevel);
}
}
}
|
java
|
public void addChildTask(Task child, int childOutlineLevel)
{
int outlineLevel = NumberHelper.getInt(getOutlineLevel());
if ((outlineLevel + 1) == childOutlineLevel)
{
m_children.add(child);
setSummary(true);
}
else
{
if (m_children.isEmpty() == false)
{
(m_children.get(m_children.size() - 1)).addChildTask(child, childOutlineLevel);
}
}
}
|
[
"public",
"void",
"addChildTask",
"(",
"Task",
"child",
",",
"int",
"childOutlineLevel",
")",
"{",
"int",
"outlineLevel",
"=",
"NumberHelper",
".",
"getInt",
"(",
"getOutlineLevel",
"(",
")",
")",
";",
"if",
"(",
"(",
"outlineLevel",
"+",
"1",
")",
"==",
"childOutlineLevel",
")",
"{",
"m_children",
".",
"add",
"(",
"child",
")",
";",
"setSummary",
"(",
"true",
")",
";",
"}",
"else",
"{",
"if",
"(",
"m_children",
".",
"isEmpty",
"(",
")",
"==",
"false",
")",
"{",
"(",
"m_children",
".",
"get",
"(",
"m_children",
".",
"size",
"(",
")",
"-",
"1",
")",
")",
".",
"addChildTask",
"(",
"child",
",",
"childOutlineLevel",
")",
";",
"}",
"}",
"}"
] |
This method is used to associate a child task with the current
task instance. It has package access, and has been designed to
allow the hierarchical outline structure of tasks in an MPX
file to be constructed as the file is read in.
@param child Child task.
@param childOutlineLevel Outline level of the child task.
|
[
"This",
"method",
"is",
"used",
"to",
"associate",
"a",
"child",
"task",
"with",
"the",
"current",
"task",
"instance",
".",
"It",
"has",
"package",
"access",
"and",
"has",
"been",
"designed",
"to",
"allow",
"the",
"hierarchical",
"outline",
"structure",
"of",
"tasks",
"in",
"an",
"MPX",
"file",
"to",
"be",
"constructed",
"as",
"the",
"file",
"is",
"read",
"in",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L236-L252
|
157,741
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.addChildTask
|
public void addChildTask(Task child)
{
child.m_parent = this;
m_children.add(child);
setSummary(true);
if (getParentFile().getProjectConfig().getAutoOutlineLevel() == true)
{
child.setOutlineLevel(Integer.valueOf(NumberHelper.getInt(getOutlineLevel()) + 1));
}
}
|
java
|
public void addChildTask(Task child)
{
child.m_parent = this;
m_children.add(child);
setSummary(true);
if (getParentFile().getProjectConfig().getAutoOutlineLevel() == true)
{
child.setOutlineLevel(Integer.valueOf(NumberHelper.getInt(getOutlineLevel()) + 1));
}
}
|
[
"public",
"void",
"addChildTask",
"(",
"Task",
"child",
")",
"{",
"child",
".",
"m_parent",
"=",
"this",
";",
"m_children",
".",
"add",
"(",
"child",
")",
";",
"setSummary",
"(",
"true",
")",
";",
"if",
"(",
"getParentFile",
"(",
")",
".",
"getProjectConfig",
"(",
")",
".",
"getAutoOutlineLevel",
"(",
")",
"==",
"true",
")",
"{",
"child",
".",
"setOutlineLevel",
"(",
"Integer",
".",
"valueOf",
"(",
"NumberHelper",
".",
"getInt",
"(",
"getOutlineLevel",
"(",
")",
")",
"+",
"1",
")",
")",
";",
"}",
"}"
] |
This method is used to associate a child task with the current
task instance. It has been designed to
allow the hierarchical outline structure of tasks in an MPX
file to be updated once all of the task data has been read.
@param child child task
|
[
"This",
"method",
"is",
"used",
"to",
"associate",
"a",
"child",
"task",
"with",
"the",
"current",
"task",
"instance",
".",
"It",
"has",
"been",
"designed",
"to",
"allow",
"the",
"hierarchical",
"outline",
"structure",
"of",
"tasks",
"in",
"an",
"MPX",
"file",
"to",
"be",
"updated",
"once",
"all",
"of",
"the",
"task",
"data",
"has",
"been",
"read",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L262-L272
|
157,742
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.addChildTaskBefore
|
public void addChildTaskBefore(Task child, Task previousSibling)
{
int index = m_children.indexOf(previousSibling);
if (index == -1)
{
m_children.add(child);
}
else
{
m_children.add(index, child);
}
child.m_parent = this;
setSummary(true);
if (getParentFile().getProjectConfig().getAutoOutlineLevel() == true)
{
child.setOutlineLevel(Integer.valueOf(NumberHelper.getInt(getOutlineLevel()) + 1));
}
}
|
java
|
public void addChildTaskBefore(Task child, Task previousSibling)
{
int index = m_children.indexOf(previousSibling);
if (index == -1)
{
m_children.add(child);
}
else
{
m_children.add(index, child);
}
child.m_parent = this;
setSummary(true);
if (getParentFile().getProjectConfig().getAutoOutlineLevel() == true)
{
child.setOutlineLevel(Integer.valueOf(NumberHelper.getInt(getOutlineLevel()) + 1));
}
}
|
[
"public",
"void",
"addChildTaskBefore",
"(",
"Task",
"child",
",",
"Task",
"previousSibling",
")",
"{",
"int",
"index",
"=",
"m_children",
".",
"indexOf",
"(",
"previousSibling",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"m_children",
".",
"add",
"(",
"child",
")",
";",
"}",
"else",
"{",
"m_children",
".",
"add",
"(",
"index",
",",
"child",
")",
";",
"}",
"child",
".",
"m_parent",
"=",
"this",
";",
"setSummary",
"(",
"true",
")",
";",
"if",
"(",
"getParentFile",
"(",
")",
".",
"getProjectConfig",
"(",
")",
".",
"getAutoOutlineLevel",
"(",
")",
"==",
"true",
")",
"{",
"child",
".",
"setOutlineLevel",
"(",
"Integer",
".",
"valueOf",
"(",
"NumberHelper",
".",
"getInt",
"(",
"getOutlineLevel",
"(",
")",
")",
"+",
"1",
")",
")",
";",
"}",
"}"
] |
Inserts a child task prior to a given sibling task.
@param child new child task
@param previousSibling sibling task
|
[
"Inserts",
"a",
"child",
"task",
"prior",
"to",
"a",
"given",
"sibling",
"task",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L280-L299
|
157,743
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.removeChildTask
|
public void removeChildTask(Task child)
{
if (m_children.remove(child))
{
child.m_parent = null;
}
setSummary(!m_children.isEmpty());
}
|
java
|
public void removeChildTask(Task child)
{
if (m_children.remove(child))
{
child.m_parent = null;
}
setSummary(!m_children.isEmpty());
}
|
[
"public",
"void",
"removeChildTask",
"(",
"Task",
"child",
")",
"{",
"if",
"(",
"m_children",
".",
"remove",
"(",
"child",
")",
")",
"{",
"child",
".",
"m_parent",
"=",
"null",
";",
"}",
"setSummary",
"(",
"!",
"m_children",
".",
"isEmpty",
"(",
")",
")",
";",
"}"
] |
Removes a child task.
@param child child task instance
|
[
"Removes",
"a",
"child",
"task",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L306-L313
|
157,744
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.addResourceAssignment
|
public ResourceAssignment addResourceAssignment(Resource resource)
{
ResourceAssignment assignment = getExistingResourceAssignment(resource);
if (assignment == null)
{
assignment = new ResourceAssignment(getParentFile(), this);
m_assignments.add(assignment);
getParentFile().getResourceAssignments().add(assignment);
assignment.setTaskUniqueID(getUniqueID());
assignment.setWork(getDuration());
assignment.setUnits(ResourceAssignment.DEFAULT_UNITS);
if (resource != null)
{
assignment.setResourceUniqueID(resource.getUniqueID());
resource.addResourceAssignment(assignment);
}
}
return (assignment);
}
|
java
|
public ResourceAssignment addResourceAssignment(Resource resource)
{
ResourceAssignment assignment = getExistingResourceAssignment(resource);
if (assignment == null)
{
assignment = new ResourceAssignment(getParentFile(), this);
m_assignments.add(assignment);
getParentFile().getResourceAssignments().add(assignment);
assignment.setTaskUniqueID(getUniqueID());
assignment.setWork(getDuration());
assignment.setUnits(ResourceAssignment.DEFAULT_UNITS);
if (resource != null)
{
assignment.setResourceUniqueID(resource.getUniqueID());
resource.addResourceAssignment(assignment);
}
}
return (assignment);
}
|
[
"public",
"ResourceAssignment",
"addResourceAssignment",
"(",
"Resource",
"resource",
")",
"{",
"ResourceAssignment",
"assignment",
"=",
"getExistingResourceAssignment",
"(",
"resource",
")",
";",
"if",
"(",
"assignment",
"==",
"null",
")",
"{",
"assignment",
"=",
"new",
"ResourceAssignment",
"(",
"getParentFile",
"(",
")",
",",
"this",
")",
";",
"m_assignments",
".",
"add",
"(",
"assignment",
")",
";",
"getParentFile",
"(",
")",
".",
"getResourceAssignments",
"(",
")",
".",
"add",
"(",
"assignment",
")",
";",
"assignment",
".",
"setTaskUniqueID",
"(",
"getUniqueID",
"(",
")",
")",
";",
"assignment",
".",
"setWork",
"(",
"getDuration",
"(",
")",
")",
";",
"assignment",
".",
"setUnits",
"(",
"ResourceAssignment",
".",
"DEFAULT_UNITS",
")",
";",
"if",
"(",
"resource",
"!=",
"null",
")",
"{",
"assignment",
".",
"setResourceUniqueID",
"(",
"resource",
".",
"getUniqueID",
"(",
")",
")",
";",
"resource",
".",
"addResourceAssignment",
"(",
"assignment",
")",
";",
"}",
"}",
"return",
"(",
"assignment",
")",
";",
"}"
] |
This method allows a resource assignment to be added to the
current task.
@param resource the resource to assign
@return ResourceAssignment object
|
[
"This",
"method",
"allows",
"a",
"resource",
"assignment",
"to",
"be",
"added",
"to",
"the",
"current",
"task",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L379-L401
|
157,745
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.addResourceAssignment
|
public void addResourceAssignment(ResourceAssignment assignment)
{
if (getExistingResourceAssignment(assignment.getResource()) == null)
{
m_assignments.add(assignment);
getParentFile().getResourceAssignments().add(assignment);
Resource resource = assignment.getResource();
if (resource != null)
{
resource.addResourceAssignment(assignment);
}
}
}
|
java
|
public void addResourceAssignment(ResourceAssignment assignment)
{
if (getExistingResourceAssignment(assignment.getResource()) == null)
{
m_assignments.add(assignment);
getParentFile().getResourceAssignments().add(assignment);
Resource resource = assignment.getResource();
if (resource != null)
{
resource.addResourceAssignment(assignment);
}
}
}
|
[
"public",
"void",
"addResourceAssignment",
"(",
"ResourceAssignment",
"assignment",
")",
"{",
"if",
"(",
"getExistingResourceAssignment",
"(",
"assignment",
".",
"getResource",
"(",
")",
")",
"==",
"null",
")",
"{",
"m_assignments",
".",
"add",
"(",
"assignment",
")",
";",
"getParentFile",
"(",
")",
".",
"getResourceAssignments",
"(",
")",
".",
"add",
"(",
"assignment",
")",
";",
"Resource",
"resource",
"=",
"assignment",
".",
"getResource",
"(",
")",
";",
"if",
"(",
"resource",
"!=",
"null",
")",
"{",
"resource",
".",
"addResourceAssignment",
"(",
"assignment",
")",
";",
"}",
"}",
"}"
] |
Add a resource assignment which has been populated elsewhere.
@param assignment resource assignment
|
[
"Add",
"a",
"resource",
"assignment",
"which",
"has",
"been",
"populated",
"elsewhere",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L408-L421
|
157,746
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getExistingResourceAssignment
|
private ResourceAssignment getExistingResourceAssignment(Resource resource)
{
ResourceAssignment assignment = null;
Integer resourceUniqueID = null;
if (resource != null)
{
Iterator<ResourceAssignment> iter = m_assignments.iterator();
resourceUniqueID = resource.getUniqueID();
while (iter.hasNext() == true)
{
assignment = iter.next();
Integer uniqueID = assignment.getResourceUniqueID();
if (uniqueID != null && uniqueID.equals(resourceUniqueID) == true)
{
break;
}
assignment = null;
}
}
return assignment;
}
|
java
|
private ResourceAssignment getExistingResourceAssignment(Resource resource)
{
ResourceAssignment assignment = null;
Integer resourceUniqueID = null;
if (resource != null)
{
Iterator<ResourceAssignment> iter = m_assignments.iterator();
resourceUniqueID = resource.getUniqueID();
while (iter.hasNext() == true)
{
assignment = iter.next();
Integer uniqueID = assignment.getResourceUniqueID();
if (uniqueID != null && uniqueID.equals(resourceUniqueID) == true)
{
break;
}
assignment = null;
}
}
return assignment;
}
|
[
"private",
"ResourceAssignment",
"getExistingResourceAssignment",
"(",
"Resource",
"resource",
")",
"{",
"ResourceAssignment",
"assignment",
"=",
"null",
";",
"Integer",
"resourceUniqueID",
"=",
"null",
";",
"if",
"(",
"resource",
"!=",
"null",
")",
"{",
"Iterator",
"<",
"ResourceAssignment",
">",
"iter",
"=",
"m_assignments",
".",
"iterator",
"(",
")",
";",
"resourceUniqueID",
"=",
"resource",
".",
"getUniqueID",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
"==",
"true",
")",
"{",
"assignment",
"=",
"iter",
".",
"next",
"(",
")",
";",
"Integer",
"uniqueID",
"=",
"assignment",
".",
"getResourceUniqueID",
"(",
")",
";",
"if",
"(",
"uniqueID",
"!=",
"null",
"&&",
"uniqueID",
".",
"equals",
"(",
"resourceUniqueID",
")",
"==",
"true",
")",
"{",
"break",
";",
"}",
"assignment",
"=",
"null",
";",
"}",
"}",
"return",
"assignment",
";",
"}"
] |
Retrieves an existing resource assignment if one is present,
to prevent duplicate resource assignments being added.
@param resource resource to test for
@return existing resource assignment
|
[
"Retrieves",
"an",
"existing",
"resource",
"assignment",
"if",
"one",
"is",
"present",
"to",
"prevent",
"duplicate",
"resource",
"assignments",
"being",
"added",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L430-L453
|
157,747
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.addPredecessor
|
@SuppressWarnings("unchecked") public Relation addPredecessor(Task targetTask, RelationType type, Duration lag)
{
//
// Ensure that we have a valid lag duration
//
if (lag == null)
{
lag = Duration.getInstance(0, TimeUnit.DAYS);
}
//
// Retrieve the list of predecessors
//
List<Relation> predecessorList = (List<Relation>) getCachedValue(TaskField.PREDECESSORS);
//
// Ensure that there is only one predecessor relationship between
// these two tasks.
//
Relation predecessorRelation = null;
Iterator<Relation> iter = predecessorList.iterator();
while (iter.hasNext() == true)
{
predecessorRelation = iter.next();
if (predecessorRelation.getTargetTask() == targetTask)
{
if (predecessorRelation.getType() != type || predecessorRelation.getLag().compareTo(lag) != 0)
{
predecessorRelation = null;
}
break;
}
predecessorRelation = null;
}
//
// If necessary, create a new predecessor relationship
//
if (predecessorRelation == null)
{
predecessorRelation = new Relation(this, targetTask, type, lag);
predecessorList.add(predecessorRelation);
}
//
// Retrieve the list of successors
//
List<Relation> successorList = (List<Relation>) targetTask.getCachedValue(TaskField.SUCCESSORS);
//
// Ensure that there is only one successor relationship between
// these two tasks.
//
Relation successorRelation = null;
iter = successorList.iterator();
while (iter.hasNext() == true)
{
successorRelation = iter.next();
if (successorRelation.getTargetTask() == this)
{
if (successorRelation.getType() != type || successorRelation.getLag().compareTo(lag) != 0)
{
successorRelation = null;
}
break;
}
successorRelation = null;
}
//
// If necessary, create a new successor relationship
//
if (successorRelation == null)
{
successorRelation = new Relation(targetTask, this, type, lag);
successorList.add(successorRelation);
}
return (predecessorRelation);
}
|
java
|
@SuppressWarnings("unchecked") public Relation addPredecessor(Task targetTask, RelationType type, Duration lag)
{
//
// Ensure that we have a valid lag duration
//
if (lag == null)
{
lag = Duration.getInstance(0, TimeUnit.DAYS);
}
//
// Retrieve the list of predecessors
//
List<Relation> predecessorList = (List<Relation>) getCachedValue(TaskField.PREDECESSORS);
//
// Ensure that there is only one predecessor relationship between
// these two tasks.
//
Relation predecessorRelation = null;
Iterator<Relation> iter = predecessorList.iterator();
while (iter.hasNext() == true)
{
predecessorRelation = iter.next();
if (predecessorRelation.getTargetTask() == targetTask)
{
if (predecessorRelation.getType() != type || predecessorRelation.getLag().compareTo(lag) != 0)
{
predecessorRelation = null;
}
break;
}
predecessorRelation = null;
}
//
// If necessary, create a new predecessor relationship
//
if (predecessorRelation == null)
{
predecessorRelation = new Relation(this, targetTask, type, lag);
predecessorList.add(predecessorRelation);
}
//
// Retrieve the list of successors
//
List<Relation> successorList = (List<Relation>) targetTask.getCachedValue(TaskField.SUCCESSORS);
//
// Ensure that there is only one successor relationship between
// these two tasks.
//
Relation successorRelation = null;
iter = successorList.iterator();
while (iter.hasNext() == true)
{
successorRelation = iter.next();
if (successorRelation.getTargetTask() == this)
{
if (successorRelation.getType() != type || successorRelation.getLag().compareTo(lag) != 0)
{
successorRelation = null;
}
break;
}
successorRelation = null;
}
//
// If necessary, create a new successor relationship
//
if (successorRelation == null)
{
successorRelation = new Relation(targetTask, this, type, lag);
successorList.add(successorRelation);
}
return (predecessorRelation);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Relation",
"addPredecessor",
"(",
"Task",
"targetTask",
",",
"RelationType",
"type",
",",
"Duration",
"lag",
")",
"{",
"//",
"// Ensure that we have a valid lag duration",
"//",
"if",
"(",
"lag",
"==",
"null",
")",
"{",
"lag",
"=",
"Duration",
".",
"getInstance",
"(",
"0",
",",
"TimeUnit",
".",
"DAYS",
")",
";",
"}",
"//",
"// Retrieve the list of predecessors",
"//",
"List",
"<",
"Relation",
">",
"predecessorList",
"=",
"(",
"List",
"<",
"Relation",
">",
")",
"getCachedValue",
"(",
"TaskField",
".",
"PREDECESSORS",
")",
";",
"//",
"// Ensure that there is only one predecessor relationship between",
"// these two tasks.",
"//",
"Relation",
"predecessorRelation",
"=",
"null",
";",
"Iterator",
"<",
"Relation",
">",
"iter",
"=",
"predecessorList",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
"==",
"true",
")",
"{",
"predecessorRelation",
"=",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"predecessorRelation",
".",
"getTargetTask",
"(",
")",
"==",
"targetTask",
")",
"{",
"if",
"(",
"predecessorRelation",
".",
"getType",
"(",
")",
"!=",
"type",
"||",
"predecessorRelation",
".",
"getLag",
"(",
")",
".",
"compareTo",
"(",
"lag",
")",
"!=",
"0",
")",
"{",
"predecessorRelation",
"=",
"null",
";",
"}",
"break",
";",
"}",
"predecessorRelation",
"=",
"null",
";",
"}",
"//",
"// If necessary, create a new predecessor relationship",
"//",
"if",
"(",
"predecessorRelation",
"==",
"null",
")",
"{",
"predecessorRelation",
"=",
"new",
"Relation",
"(",
"this",
",",
"targetTask",
",",
"type",
",",
"lag",
")",
";",
"predecessorList",
".",
"add",
"(",
"predecessorRelation",
")",
";",
"}",
"//",
"// Retrieve the list of successors",
"//",
"List",
"<",
"Relation",
">",
"successorList",
"=",
"(",
"List",
"<",
"Relation",
">",
")",
"targetTask",
".",
"getCachedValue",
"(",
"TaskField",
".",
"SUCCESSORS",
")",
";",
"//",
"// Ensure that there is only one successor relationship between",
"// these two tasks.",
"//",
"Relation",
"successorRelation",
"=",
"null",
";",
"iter",
"=",
"successorList",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
"==",
"true",
")",
"{",
"successorRelation",
"=",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"successorRelation",
".",
"getTargetTask",
"(",
")",
"==",
"this",
")",
"{",
"if",
"(",
"successorRelation",
".",
"getType",
"(",
")",
"!=",
"type",
"||",
"successorRelation",
".",
"getLag",
"(",
")",
".",
"compareTo",
"(",
"lag",
")",
"!=",
"0",
")",
"{",
"successorRelation",
"=",
"null",
";",
"}",
"break",
";",
"}",
"successorRelation",
"=",
"null",
";",
"}",
"//",
"// If necessary, create a new successor relationship",
"//",
"if",
"(",
"successorRelation",
"==",
"null",
")",
"{",
"successorRelation",
"=",
"new",
"Relation",
"(",
"targetTask",
",",
"this",
",",
"type",
",",
"lag",
")",
";",
"successorList",
".",
"add",
"(",
"successorRelation",
")",
";",
"}",
"return",
"(",
"predecessorRelation",
")",
";",
"}"
] |
This method allows a predecessor relationship to be added to this
task instance.
@param targetTask the predecessor task
@param type relation type
@param lag relation lag
@return relationship
|
[
"This",
"method",
"allows",
"a",
"predecessor",
"relationship",
"to",
"be",
"added",
"to",
"this",
"task",
"instance",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L486-L565
|
157,748
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.setID
|
@Override public void setID(Integer val)
{
ProjectFile parent = getParentFile();
Integer previous = getID();
if (previous != null)
{
parent.getTasks().unmapID(previous);
}
parent.getTasks().mapID(val, this);
set(TaskField.ID, val);
}
|
java
|
@Override public void setID(Integer val)
{
ProjectFile parent = getParentFile();
Integer previous = getID();
if (previous != null)
{
parent.getTasks().unmapID(previous);
}
parent.getTasks().mapID(val, this);
set(TaskField.ID, val);
}
|
[
"@",
"Override",
"public",
"void",
"setID",
"(",
"Integer",
"val",
")",
"{",
"ProjectFile",
"parent",
"=",
"getParentFile",
"(",
")",
";",
"Integer",
"previous",
"=",
"getID",
"(",
")",
";",
"if",
"(",
"previous",
"!=",
"null",
")",
"{",
"parent",
".",
"getTasks",
"(",
")",
".",
"unmapID",
"(",
"previous",
")",
";",
"}",
"parent",
".",
"getTasks",
"(",
")",
".",
"mapID",
"(",
"val",
",",
"this",
")",
";",
"set",
"(",
"TaskField",
".",
"ID",
",",
"val",
")",
";",
"}"
] |
The ID field contains the identifier number that Microsoft Project
automatically assigns to each task as you add it to the project.
The ID indicates the position of a task with respect to the other tasks.
@param val ID
|
[
"The",
"ID",
"field",
"contains",
"the",
"identifier",
"number",
"that",
"Microsoft",
"Project",
"automatically",
"assigns",
"to",
"each",
"task",
"as",
"you",
"add",
"it",
"to",
"the",
"project",
".",
"The",
"ID",
"indicates",
"the",
"position",
"of",
"a",
"task",
"with",
"respect",
"to",
"the",
"other",
"tasks",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1073-L1086
|
157,749
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getBaselineDuration
|
public Duration getBaselineDuration()
{
Object result = getCachedValue(TaskField.BASELINE_DURATION);
if (result == null)
{
result = getCachedValue(TaskField.BASELINE_ESTIMATED_DURATION);
}
if (!(result instanceof Duration))
{
result = null;
}
return (Duration) result;
}
|
java
|
public Duration getBaselineDuration()
{
Object result = getCachedValue(TaskField.BASELINE_DURATION);
if (result == null)
{
result = getCachedValue(TaskField.BASELINE_ESTIMATED_DURATION);
}
if (!(result instanceof Duration))
{
result = null;
}
return (Duration) result;
}
|
[
"public",
"Duration",
"getBaselineDuration",
"(",
")",
"{",
"Object",
"result",
"=",
"getCachedValue",
"(",
"TaskField",
".",
"BASELINE_DURATION",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"getCachedValue",
"(",
"TaskField",
".",
"BASELINE_ESTIMATED_DURATION",
")",
";",
"}",
"if",
"(",
"!",
"(",
"result",
"instanceof",
"Duration",
")",
")",
"{",
"result",
"=",
"null",
";",
"}",
"return",
"(",
"Duration",
")",
"result",
";",
"}"
] |
The Baseline Duration field shows the original span of time planned
to complete a task.
@return - duration string
|
[
"The",
"Baseline",
"Duration",
"field",
"shows",
"the",
"original",
"span",
"of",
"time",
"planned",
"to",
"complete",
"a",
"task",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1587-L1600
|
157,750
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getBaselineDurationText
|
public String getBaselineDurationText()
{
Object result = getCachedValue(TaskField.BASELINE_DURATION);
if (result == null)
{
result = getCachedValue(TaskField.BASELINE_ESTIMATED_DURATION);
}
if (!(result instanceof String))
{
result = null;
}
return (String) result;
}
|
java
|
public String getBaselineDurationText()
{
Object result = getCachedValue(TaskField.BASELINE_DURATION);
if (result == null)
{
result = getCachedValue(TaskField.BASELINE_ESTIMATED_DURATION);
}
if (!(result instanceof String))
{
result = null;
}
return (String) result;
}
|
[
"public",
"String",
"getBaselineDurationText",
"(",
")",
"{",
"Object",
"result",
"=",
"getCachedValue",
"(",
"TaskField",
".",
"BASELINE_DURATION",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"getCachedValue",
"(",
"TaskField",
".",
"BASELINE_ESTIMATED_DURATION",
")",
";",
"}",
"if",
"(",
"!",
"(",
"result",
"instanceof",
"String",
")",
")",
"{",
"result",
"=",
"null",
";",
"}",
"return",
"(",
"String",
")",
"result",
";",
"}"
] |
Retrieves the text value for the baseline duration.
@return baseline duration text
|
[
"Retrieves",
"the",
"text",
"value",
"for",
"the",
"baseline",
"duration",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1607-L1620
|
157,751
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getBaselineFinish
|
public Date getBaselineFinish()
{
Object result = getCachedValue(TaskField.BASELINE_FINISH);
if (result == null)
{
result = getCachedValue(TaskField.BASELINE_ESTIMATED_FINISH);
}
if (!(result instanceof Date))
{
result = null;
}
return (Date) result;
}
|
java
|
public Date getBaselineFinish()
{
Object result = getCachedValue(TaskField.BASELINE_FINISH);
if (result == null)
{
result = getCachedValue(TaskField.BASELINE_ESTIMATED_FINISH);
}
if (!(result instanceof Date))
{
result = null;
}
return (Date) result;
}
|
[
"public",
"Date",
"getBaselineFinish",
"(",
")",
"{",
"Object",
"result",
"=",
"getCachedValue",
"(",
"TaskField",
".",
"BASELINE_FINISH",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"getCachedValue",
"(",
"TaskField",
".",
"BASELINE_ESTIMATED_FINISH",
")",
";",
"}",
"if",
"(",
"!",
"(",
"result",
"instanceof",
"Date",
")",
")",
"{",
"result",
"=",
"null",
";",
"}",
"return",
"(",
"Date",
")",
"result",
";",
"}"
] |
The Baseline Finish field shows the planned completion date for a task
at the time you saved a baseline. Information in this field becomes
available when you set a baseline for a task.
@return Date
|
[
"The",
"Baseline",
"Finish",
"field",
"shows",
"the",
"planned",
"completion",
"date",
"for",
"a",
"task",
"at",
"the",
"time",
"you",
"saved",
"a",
"baseline",
".",
"Information",
"in",
"this",
"field",
"becomes",
"available",
"when",
"you",
"set",
"a",
"baseline",
"for",
"a",
"task",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1639-L1652
|
157,752
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getBaselineStart
|
public Date getBaselineStart()
{
Object result = getCachedValue(TaskField.BASELINE_START);
if (result == null)
{
result = getCachedValue(TaskField.BASELINE_ESTIMATED_START);
}
if (!(result instanceof Date))
{
result = null;
}
return (Date) result;
}
|
java
|
public Date getBaselineStart()
{
Object result = getCachedValue(TaskField.BASELINE_START);
if (result == null)
{
result = getCachedValue(TaskField.BASELINE_ESTIMATED_START);
}
if (!(result instanceof Date))
{
result = null;
}
return (Date) result;
}
|
[
"public",
"Date",
"getBaselineStart",
"(",
")",
"{",
"Object",
"result",
"=",
"getCachedValue",
"(",
"TaskField",
".",
"BASELINE_START",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"getCachedValue",
"(",
"TaskField",
".",
"BASELINE_ESTIMATED_START",
")",
";",
"}",
"if",
"(",
"!",
"(",
"result",
"instanceof",
"Date",
")",
")",
"{",
"result",
"=",
"null",
";",
"}",
"return",
"(",
"Date",
")",
"result",
";",
"}"
] |
The Baseline Start field shows the planned beginning date for a task at
the time you saved a baseline. Information in this field becomes available
when you set a baseline.
@return Date
|
[
"The",
"Baseline",
"Start",
"field",
"shows",
"the",
"planned",
"beginning",
"date",
"for",
"a",
"task",
"at",
"the",
"time",
"you",
"saved",
"a",
"baseline",
".",
"Information",
"in",
"this",
"field",
"becomes",
"available",
"when",
"you",
"set",
"a",
"baseline",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1691-L1704
|
157,753
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getCostVariance
|
public Number getCostVariance()
{
Number variance = (Number) getCachedValue(TaskField.COST_VARIANCE);
if (variance == null)
{
Number cost = getCost();
Number baselineCost = getBaselineCost();
if (cost != null && baselineCost != null)
{
variance = NumberHelper.getDouble(cost.doubleValue() - baselineCost.doubleValue());
set(TaskField.COST_VARIANCE, variance);
}
}
return (variance);
}
|
java
|
public Number getCostVariance()
{
Number variance = (Number) getCachedValue(TaskField.COST_VARIANCE);
if (variance == null)
{
Number cost = getCost();
Number baselineCost = getBaselineCost();
if (cost != null && baselineCost != null)
{
variance = NumberHelper.getDouble(cost.doubleValue() - baselineCost.doubleValue());
set(TaskField.COST_VARIANCE, variance);
}
}
return (variance);
}
|
[
"public",
"Number",
"getCostVariance",
"(",
")",
"{",
"Number",
"variance",
"=",
"(",
"Number",
")",
"getCachedValue",
"(",
"TaskField",
".",
"COST_VARIANCE",
")",
";",
"if",
"(",
"variance",
"==",
"null",
")",
"{",
"Number",
"cost",
"=",
"getCost",
"(",
")",
";",
"Number",
"baselineCost",
"=",
"getBaselineCost",
"(",
")",
";",
"if",
"(",
"cost",
"!=",
"null",
"&&",
"baselineCost",
"!=",
"null",
")",
"{",
"variance",
"=",
"NumberHelper",
".",
"getDouble",
"(",
"cost",
".",
"doubleValue",
"(",
")",
"-",
"baselineCost",
".",
"doubleValue",
"(",
")",
")",
";",
"set",
"(",
"TaskField",
".",
"COST_VARIANCE",
",",
"variance",
")",
";",
"}",
"}",
"return",
"(",
"variance",
")",
";",
"}"
] |
The Cost Variance field shows the difference between the baseline cost
and total cost for a task. The total cost is the current estimate of costs
based on actual costs and remaining costs.
@return amount
|
[
"The",
"Cost",
"Variance",
"field",
"shows",
"the",
"difference",
"between",
"the",
"baseline",
"cost",
"and",
"total",
"cost",
"for",
"a",
"task",
".",
"The",
"total",
"cost",
"is",
"the",
"current",
"estimate",
"of",
"costs",
"based",
"on",
"actual",
"costs",
"and",
"remaining",
"costs",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1841-L1855
|
157,754
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getCritical
|
public boolean getCritical()
{
Boolean critical = (Boolean) getCachedValue(TaskField.CRITICAL);
if (critical == null)
{
Duration totalSlack = getTotalSlack();
ProjectProperties props = getParentFile().getProjectProperties();
int criticalSlackLimit = NumberHelper.getInt(props.getCriticalSlackLimit());
if (criticalSlackLimit != 0 && totalSlack.getDuration() != 0 && totalSlack.getUnits() != TimeUnit.DAYS)
{
totalSlack = totalSlack.convertUnits(TimeUnit.DAYS, props);
}
critical = Boolean.valueOf(totalSlack.getDuration() <= criticalSlackLimit && NumberHelper.getInt(getPercentageComplete()) != 100 && ((getTaskMode() == TaskMode.AUTO_SCHEDULED) || (getDurationText() == null && getStartText() == null && getFinishText() == null)));
set(TaskField.CRITICAL, critical);
}
return (BooleanHelper.getBoolean(critical));
}
|
java
|
public boolean getCritical()
{
Boolean critical = (Boolean) getCachedValue(TaskField.CRITICAL);
if (critical == null)
{
Duration totalSlack = getTotalSlack();
ProjectProperties props = getParentFile().getProjectProperties();
int criticalSlackLimit = NumberHelper.getInt(props.getCriticalSlackLimit());
if (criticalSlackLimit != 0 && totalSlack.getDuration() != 0 && totalSlack.getUnits() != TimeUnit.DAYS)
{
totalSlack = totalSlack.convertUnits(TimeUnit.DAYS, props);
}
critical = Boolean.valueOf(totalSlack.getDuration() <= criticalSlackLimit && NumberHelper.getInt(getPercentageComplete()) != 100 && ((getTaskMode() == TaskMode.AUTO_SCHEDULED) || (getDurationText() == null && getStartText() == null && getFinishText() == null)));
set(TaskField.CRITICAL, critical);
}
return (BooleanHelper.getBoolean(critical));
}
|
[
"public",
"boolean",
"getCritical",
"(",
")",
"{",
"Boolean",
"critical",
"=",
"(",
"Boolean",
")",
"getCachedValue",
"(",
"TaskField",
".",
"CRITICAL",
")",
";",
"if",
"(",
"critical",
"==",
"null",
")",
"{",
"Duration",
"totalSlack",
"=",
"getTotalSlack",
"(",
")",
";",
"ProjectProperties",
"props",
"=",
"getParentFile",
"(",
")",
".",
"getProjectProperties",
"(",
")",
";",
"int",
"criticalSlackLimit",
"=",
"NumberHelper",
".",
"getInt",
"(",
"props",
".",
"getCriticalSlackLimit",
"(",
")",
")",
";",
"if",
"(",
"criticalSlackLimit",
"!=",
"0",
"&&",
"totalSlack",
".",
"getDuration",
"(",
")",
"!=",
"0",
"&&",
"totalSlack",
".",
"getUnits",
"(",
")",
"!=",
"TimeUnit",
".",
"DAYS",
")",
"{",
"totalSlack",
"=",
"totalSlack",
".",
"convertUnits",
"(",
"TimeUnit",
".",
"DAYS",
",",
"props",
")",
";",
"}",
"critical",
"=",
"Boolean",
".",
"valueOf",
"(",
"totalSlack",
".",
"getDuration",
"(",
")",
"<=",
"criticalSlackLimit",
"&&",
"NumberHelper",
".",
"getInt",
"(",
"getPercentageComplete",
"(",
")",
")",
"!=",
"100",
"&&",
"(",
"(",
"getTaskMode",
"(",
")",
"==",
"TaskMode",
".",
"AUTO_SCHEDULED",
")",
"||",
"(",
"getDurationText",
"(",
")",
"==",
"null",
"&&",
"getStartText",
"(",
")",
"==",
"null",
"&&",
"getFinishText",
"(",
")",
"==",
"null",
")",
")",
")",
";",
"set",
"(",
"TaskField",
".",
"CRITICAL",
",",
"critical",
")",
";",
"}",
"return",
"(",
"BooleanHelper",
".",
"getBoolean",
"(",
"critical",
")",
")",
";",
"}"
] |
The Critical field indicates whether a task has any room in the schedule
to slip, or if a task is on the critical path. The Critical field contains
Yes if the task is critical and No if the task is not critical.
@return boolean
|
[
"The",
"Critical",
"field",
"indicates",
"whether",
"a",
"task",
"has",
"any",
"room",
"in",
"the",
"schedule",
"to",
"slip",
"or",
"if",
"a",
"task",
"is",
"on",
"the",
"critical",
"path",
".",
"The",
"Critical",
"field",
"contains",
"Yes",
"if",
"the",
"task",
"is",
"critical",
"and",
"No",
"if",
"the",
"task",
"is",
"not",
"critical",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1875-L1891
|
157,755
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.setOutlineCode
|
public void setOutlineCode(int index, String value)
{
set(selectField(TaskFieldLists.CUSTOM_OUTLINE_CODE, index), value);
}
|
java
|
public void setOutlineCode(int index, String value)
{
set(selectField(TaskFieldLists.CUSTOM_OUTLINE_CODE, index), value);
}
|
[
"public",
"void",
"setOutlineCode",
"(",
"int",
"index",
",",
"String",
"value",
")",
"{",
"set",
"(",
"selectField",
"(",
"TaskFieldLists",
".",
"CUSTOM_OUTLINE_CODE",
",",
"index",
")",
",",
"value",
")",
";",
"}"
] |
Set an outline code value.
@param index outline code index (1-10)
@param value outline code value
|
[
"Set",
"an",
"outline",
"code",
"value",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L2617-L2620
|
157,756
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getTotalSlack
|
public Duration getTotalSlack()
{
Duration totalSlack = (Duration) getCachedValue(TaskField.TOTAL_SLACK);
if (totalSlack == null)
{
Duration duration = getDuration();
if (duration == null)
{
duration = Duration.getInstance(0, TimeUnit.DAYS);
}
TimeUnit units = duration.getUnits();
Duration startSlack = getStartSlack();
if (startSlack == null)
{
startSlack = Duration.getInstance(0, units);
}
else
{
if (startSlack.getUnits() != units)
{
startSlack = startSlack.convertUnits(units, getParentFile().getProjectProperties());
}
}
Duration finishSlack = getFinishSlack();
if (finishSlack == null)
{
finishSlack = Duration.getInstance(0, units);
}
else
{
if (finishSlack.getUnits() != units)
{
finishSlack = finishSlack.convertUnits(units, getParentFile().getProjectProperties());
}
}
double startSlackDuration = startSlack.getDuration();
double finishSlackDuration = finishSlack.getDuration();
if (startSlackDuration == 0 || finishSlackDuration == 0)
{
if (startSlackDuration != 0)
{
totalSlack = startSlack;
}
else
{
totalSlack = finishSlack;
}
}
else
{
if (startSlackDuration < finishSlackDuration)
{
totalSlack = startSlack;
}
else
{
totalSlack = finishSlack;
}
}
set(TaskField.TOTAL_SLACK, totalSlack);
}
return (totalSlack);
}
|
java
|
public Duration getTotalSlack()
{
Duration totalSlack = (Duration) getCachedValue(TaskField.TOTAL_SLACK);
if (totalSlack == null)
{
Duration duration = getDuration();
if (duration == null)
{
duration = Duration.getInstance(0, TimeUnit.DAYS);
}
TimeUnit units = duration.getUnits();
Duration startSlack = getStartSlack();
if (startSlack == null)
{
startSlack = Duration.getInstance(0, units);
}
else
{
if (startSlack.getUnits() != units)
{
startSlack = startSlack.convertUnits(units, getParentFile().getProjectProperties());
}
}
Duration finishSlack = getFinishSlack();
if (finishSlack == null)
{
finishSlack = Duration.getInstance(0, units);
}
else
{
if (finishSlack.getUnits() != units)
{
finishSlack = finishSlack.convertUnits(units, getParentFile().getProjectProperties());
}
}
double startSlackDuration = startSlack.getDuration();
double finishSlackDuration = finishSlack.getDuration();
if (startSlackDuration == 0 || finishSlackDuration == 0)
{
if (startSlackDuration != 0)
{
totalSlack = startSlack;
}
else
{
totalSlack = finishSlack;
}
}
else
{
if (startSlackDuration < finishSlackDuration)
{
totalSlack = startSlack;
}
else
{
totalSlack = finishSlack;
}
}
set(TaskField.TOTAL_SLACK, totalSlack);
}
return (totalSlack);
}
|
[
"public",
"Duration",
"getTotalSlack",
"(",
")",
"{",
"Duration",
"totalSlack",
"=",
"(",
"Duration",
")",
"getCachedValue",
"(",
"TaskField",
".",
"TOTAL_SLACK",
")",
";",
"if",
"(",
"totalSlack",
"==",
"null",
")",
"{",
"Duration",
"duration",
"=",
"getDuration",
"(",
")",
";",
"if",
"(",
"duration",
"==",
"null",
")",
"{",
"duration",
"=",
"Duration",
".",
"getInstance",
"(",
"0",
",",
"TimeUnit",
".",
"DAYS",
")",
";",
"}",
"TimeUnit",
"units",
"=",
"duration",
".",
"getUnits",
"(",
")",
";",
"Duration",
"startSlack",
"=",
"getStartSlack",
"(",
")",
";",
"if",
"(",
"startSlack",
"==",
"null",
")",
"{",
"startSlack",
"=",
"Duration",
".",
"getInstance",
"(",
"0",
",",
"units",
")",
";",
"}",
"else",
"{",
"if",
"(",
"startSlack",
".",
"getUnits",
"(",
")",
"!=",
"units",
")",
"{",
"startSlack",
"=",
"startSlack",
".",
"convertUnits",
"(",
"units",
",",
"getParentFile",
"(",
")",
".",
"getProjectProperties",
"(",
")",
")",
";",
"}",
"}",
"Duration",
"finishSlack",
"=",
"getFinishSlack",
"(",
")",
";",
"if",
"(",
"finishSlack",
"==",
"null",
")",
"{",
"finishSlack",
"=",
"Duration",
".",
"getInstance",
"(",
"0",
",",
"units",
")",
";",
"}",
"else",
"{",
"if",
"(",
"finishSlack",
".",
"getUnits",
"(",
")",
"!=",
"units",
")",
"{",
"finishSlack",
"=",
"finishSlack",
".",
"convertUnits",
"(",
"units",
",",
"getParentFile",
"(",
")",
".",
"getProjectProperties",
"(",
")",
")",
";",
"}",
"}",
"double",
"startSlackDuration",
"=",
"startSlack",
".",
"getDuration",
"(",
")",
";",
"double",
"finishSlackDuration",
"=",
"finishSlack",
".",
"getDuration",
"(",
")",
";",
"if",
"(",
"startSlackDuration",
"==",
"0",
"||",
"finishSlackDuration",
"==",
"0",
")",
"{",
"if",
"(",
"startSlackDuration",
"!=",
"0",
")",
"{",
"totalSlack",
"=",
"startSlack",
";",
"}",
"else",
"{",
"totalSlack",
"=",
"finishSlack",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"startSlackDuration",
"<",
"finishSlackDuration",
")",
"{",
"totalSlack",
"=",
"startSlack",
";",
"}",
"else",
"{",
"totalSlack",
"=",
"finishSlack",
";",
"}",
"}",
"set",
"(",
"TaskField",
".",
"TOTAL_SLACK",
",",
"totalSlack",
")",
";",
"}",
"return",
"(",
"totalSlack",
")",
";",
"}"
] |
The Total Slack field contains the amount of time a task can be
delayed without delaying the project's finish date.
@return string representing duration
|
[
"The",
"Total",
"Slack",
"field",
"contains",
"the",
"amount",
"of",
"time",
"a",
"task",
"can",
"be",
"delayed",
"without",
"delaying",
"the",
"project",
"s",
"finish",
"date",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L2639-L2708
|
157,757
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.setCalendar
|
public void setCalendar(ProjectCalendar calendar)
{
set(TaskField.CALENDAR, calendar);
setCalendarUniqueID(calendar == null ? null : calendar.getUniqueID());
}
|
java
|
public void setCalendar(ProjectCalendar calendar)
{
set(TaskField.CALENDAR, calendar);
setCalendarUniqueID(calendar == null ? null : calendar.getUniqueID());
}
|
[
"public",
"void",
"setCalendar",
"(",
"ProjectCalendar",
"calendar",
")",
"{",
"set",
"(",
"TaskField",
".",
"CALENDAR",
",",
"calendar",
")",
";",
"setCalendarUniqueID",
"(",
"calendar",
"==",
"null",
"?",
"null",
":",
"calendar",
".",
"getUniqueID",
"(",
")",
")",
";",
"}"
] |
Sets the name of the base calendar associated with this task.
Note that this attribute appears in MPP9 and MSPDI files.
@param calendar calendar instance
|
[
"Sets",
"the",
"name",
"of",
"the",
"base",
"calendar",
"associated",
"with",
"this",
"task",
".",
"Note",
"that",
"this",
"attribute",
"appears",
"in",
"MPP9",
"and",
"MSPDI",
"files",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L3634-L3638
|
157,758
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getStartSlack
|
public Duration getStartSlack()
{
Duration startSlack = (Duration) getCachedValue(TaskField.START_SLACK);
if (startSlack == null)
{
Duration duration = getDuration();
if (duration != null)
{
startSlack = DateHelper.getVariance(this, getEarlyStart(), getLateStart(), duration.getUnits());
set(TaskField.START_SLACK, startSlack);
}
}
return (startSlack);
}
|
java
|
public Duration getStartSlack()
{
Duration startSlack = (Duration) getCachedValue(TaskField.START_SLACK);
if (startSlack == null)
{
Duration duration = getDuration();
if (duration != null)
{
startSlack = DateHelper.getVariance(this, getEarlyStart(), getLateStart(), duration.getUnits());
set(TaskField.START_SLACK, startSlack);
}
}
return (startSlack);
}
|
[
"public",
"Duration",
"getStartSlack",
"(",
")",
"{",
"Duration",
"startSlack",
"=",
"(",
"Duration",
")",
"getCachedValue",
"(",
"TaskField",
".",
"START_SLACK",
")",
";",
"if",
"(",
"startSlack",
"==",
"null",
")",
"{",
"Duration",
"duration",
"=",
"getDuration",
"(",
")",
";",
"if",
"(",
"duration",
"!=",
"null",
")",
"{",
"startSlack",
"=",
"DateHelper",
".",
"getVariance",
"(",
"this",
",",
"getEarlyStart",
"(",
")",
",",
"getLateStart",
"(",
")",
",",
"duration",
".",
"getUnits",
"(",
")",
")",
";",
"set",
"(",
"TaskField",
".",
"START_SLACK",
",",
"startSlack",
")",
";",
"}",
"}",
"return",
"(",
"startSlack",
")",
";",
"}"
] |
Retrieve the start slack.
@return start slack
|
[
"Retrieve",
"the",
"start",
"slack",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L3691-L3704
|
157,759
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getFinishSlack
|
public Duration getFinishSlack()
{
Duration finishSlack = (Duration) getCachedValue(TaskField.FINISH_SLACK);
if (finishSlack == null)
{
Duration duration = getDuration();
if (duration != null)
{
finishSlack = DateHelper.getVariance(this, getEarlyFinish(), getLateFinish(), duration.getUnits());
set(TaskField.FINISH_SLACK, finishSlack);
}
}
return (finishSlack);
}
|
java
|
public Duration getFinishSlack()
{
Duration finishSlack = (Duration) getCachedValue(TaskField.FINISH_SLACK);
if (finishSlack == null)
{
Duration duration = getDuration();
if (duration != null)
{
finishSlack = DateHelper.getVariance(this, getEarlyFinish(), getLateFinish(), duration.getUnits());
set(TaskField.FINISH_SLACK, finishSlack);
}
}
return (finishSlack);
}
|
[
"public",
"Duration",
"getFinishSlack",
"(",
")",
"{",
"Duration",
"finishSlack",
"=",
"(",
"Duration",
")",
"getCachedValue",
"(",
"TaskField",
".",
"FINISH_SLACK",
")",
";",
"if",
"(",
"finishSlack",
"==",
"null",
")",
"{",
"Duration",
"duration",
"=",
"getDuration",
"(",
")",
";",
"if",
"(",
"duration",
"!=",
"null",
")",
"{",
"finishSlack",
"=",
"DateHelper",
".",
"getVariance",
"(",
"this",
",",
"getEarlyFinish",
"(",
")",
",",
"getLateFinish",
"(",
")",
",",
"duration",
".",
"getUnits",
"(",
")",
")",
";",
"set",
"(",
"TaskField",
".",
"FINISH_SLACK",
",",
"finishSlack",
")",
";",
"}",
"}",
"return",
"(",
"finishSlack",
")",
";",
"}"
] |
Retrieve the finish slack.
@return finish slack
|
[
"Retrieve",
"the",
"finish",
"slack",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L3711-L3724
|
157,760
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getFieldByAlias
|
public Object getFieldByAlias(String alias)
{
return getCachedValue(getParentFile().getCustomFields().getFieldByAlias(FieldTypeClass.TASK, alias));
}
|
java
|
public Object getFieldByAlias(String alias)
{
return getCachedValue(getParentFile().getCustomFields().getFieldByAlias(FieldTypeClass.TASK, alias));
}
|
[
"public",
"Object",
"getFieldByAlias",
"(",
"String",
"alias",
")",
"{",
"return",
"getCachedValue",
"(",
"getParentFile",
"(",
")",
".",
"getCustomFields",
"(",
")",
".",
"getFieldByAlias",
"(",
"FieldTypeClass",
".",
"TASK",
",",
"alias",
")",
")",
";",
"}"
] |
Retrieve the value of a field using its alias.
@param alias field alias
@return field value
|
[
"Retrieve",
"the",
"value",
"of",
"a",
"field",
"using",
"its",
"alias",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L3732-L3735
|
157,761
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.setFieldByAlias
|
public void setFieldByAlias(String alias, Object value)
{
set(getParentFile().getCustomFields().getFieldByAlias(FieldTypeClass.TASK, alias), value);
}
|
java
|
public void setFieldByAlias(String alias, Object value)
{
set(getParentFile().getCustomFields().getFieldByAlias(FieldTypeClass.TASK, alias), value);
}
|
[
"public",
"void",
"setFieldByAlias",
"(",
"String",
"alias",
",",
"Object",
"value",
")",
"{",
"set",
"(",
"getParentFile",
"(",
")",
".",
"getCustomFields",
"(",
")",
".",
"getFieldByAlias",
"(",
"FieldTypeClass",
".",
"TASK",
",",
"alias",
")",
",",
"value",
")",
";",
"}"
] |
Set the value of a field using its alias.
@param alias field alias
@param value field value
|
[
"Set",
"the",
"value",
"of",
"a",
"field",
"using",
"its",
"alias",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L3743-L3746
|
157,762
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getEnterpriseFlag
|
public boolean getEnterpriseFlag(int index)
{
return (BooleanHelper.getBoolean((Boolean) getCachedValue(selectField(TaskFieldLists.ENTERPRISE_FLAG, index))));
}
|
java
|
public boolean getEnterpriseFlag(int index)
{
return (BooleanHelper.getBoolean((Boolean) getCachedValue(selectField(TaskFieldLists.ENTERPRISE_FLAG, index))));
}
|
[
"public",
"boolean",
"getEnterpriseFlag",
"(",
"int",
"index",
")",
"{",
"return",
"(",
"BooleanHelper",
".",
"getBoolean",
"(",
"(",
"Boolean",
")",
"getCachedValue",
"(",
"selectField",
"(",
"TaskFieldLists",
".",
"ENTERPRISE_FLAG",
",",
"index",
")",
")",
")",
")",
";",
"}"
] |
Retrieve an enterprise field value.
@param index field index
@return field value
|
[
"Retrieve",
"an",
"enterprise",
"field",
"value",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L3892-L3895
|
157,763
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getBaselineDurationText
|
public String getBaselineDurationText(int baselineNumber)
{
Object result = getCachedValue(selectField(TaskFieldLists.BASELINE_DURATIONS, baselineNumber));
if (result == null)
{
result = getCachedValue(selectField(TaskFieldLists.BASELINE_ESTIMATED_DURATIONS, baselineNumber));
}
if (!(result instanceof String))
{
result = null;
}
return (String) result;
}
|
java
|
public String getBaselineDurationText(int baselineNumber)
{
Object result = getCachedValue(selectField(TaskFieldLists.BASELINE_DURATIONS, baselineNumber));
if (result == null)
{
result = getCachedValue(selectField(TaskFieldLists.BASELINE_ESTIMATED_DURATIONS, baselineNumber));
}
if (!(result instanceof String))
{
result = null;
}
return (String) result;
}
|
[
"public",
"String",
"getBaselineDurationText",
"(",
"int",
"baselineNumber",
")",
"{",
"Object",
"result",
"=",
"getCachedValue",
"(",
"selectField",
"(",
"TaskFieldLists",
".",
"BASELINE_DURATIONS",
",",
"baselineNumber",
")",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"getCachedValue",
"(",
"selectField",
"(",
"TaskFieldLists",
".",
"BASELINE_ESTIMATED_DURATIONS",
",",
"baselineNumber",
")",
")",
";",
"}",
"if",
"(",
"!",
"(",
"result",
"instanceof",
"String",
")",
")",
"{",
"result",
"=",
"null",
";",
"}",
"return",
"(",
"String",
")",
"result",
";",
"}"
] |
Retrieves the baseline duration text value.
@param baselineNumber baseline number
@return baseline duration text value
|
[
"Retrieves",
"the",
"baseline",
"duration",
"text",
"value",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4067-L4080
|
157,764
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.setBaselineDurationText
|
public void setBaselineDurationText(int baselineNumber, String value)
{
set(selectField(TaskFieldLists.BASELINE_DURATIONS, baselineNumber), value);
}
|
java
|
public void setBaselineDurationText(int baselineNumber, String value)
{
set(selectField(TaskFieldLists.BASELINE_DURATIONS, baselineNumber), value);
}
|
[
"public",
"void",
"setBaselineDurationText",
"(",
"int",
"baselineNumber",
",",
"String",
"value",
")",
"{",
"set",
"(",
"selectField",
"(",
"TaskFieldLists",
".",
"BASELINE_DURATIONS",
",",
"baselineNumber",
")",
",",
"value",
")",
";",
"}"
] |
Sets the baseline duration text value.
@param baselineNumber baseline number
@param value baseline duration text value
|
[
"Sets",
"the",
"baseline",
"duration",
"text",
"value",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4088-L4091
|
157,765
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.setBaselineFinishText
|
public void setBaselineFinishText(int baselineNumber, String value)
{
set(selectField(TaskFieldLists.BASELINE_FINISHES, baselineNumber), value);
}
|
java
|
public void setBaselineFinishText(int baselineNumber, String value)
{
set(selectField(TaskFieldLists.BASELINE_FINISHES, baselineNumber), value);
}
|
[
"public",
"void",
"setBaselineFinishText",
"(",
"int",
"baselineNumber",
",",
"String",
"value",
")",
"{",
"set",
"(",
"selectField",
"(",
"TaskFieldLists",
".",
"BASELINE_FINISHES",
",",
"baselineNumber",
")",
",",
"value",
")",
";",
"}"
] |
Sets the baseline finish text value.
@param baselineNumber baseline number
@param value baseline finish text value
|
[
"Sets",
"the",
"baseline",
"finish",
"text",
"value",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4141-L4144
|
157,766
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.setBaselineStartText
|
public void setBaselineStartText(int baselineNumber, String value)
{
set(selectField(TaskFieldLists.BASELINE_STARTS, baselineNumber), value);
}
|
java
|
public void setBaselineStartText(int baselineNumber, String value)
{
set(selectField(TaskFieldLists.BASELINE_STARTS, baselineNumber), value);
}
|
[
"public",
"void",
"setBaselineStartText",
"(",
"int",
"baselineNumber",
",",
"String",
"value",
")",
"{",
"set",
"(",
"selectField",
"(",
"TaskFieldLists",
".",
"BASELINE_STARTS",
",",
"baselineNumber",
")",
",",
"value",
")",
";",
"}"
] |
Sets the baseline start text value.
@param baselineNumber baseline number
@param value baseline start text value
|
[
"Sets",
"the",
"baseline",
"start",
"text",
"value",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4194-L4197
|
157,767
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getCompleteThrough
|
public Date getCompleteThrough()
{
Date value = (Date) getCachedValue(TaskField.COMPLETE_THROUGH);
if (value == null)
{
int percentComplete = NumberHelper.getInt(getPercentageComplete());
switch (percentComplete)
{
case 0:
{
break;
}
case 100:
{
value = getActualFinish();
break;
}
default:
{
Date actualStart = getActualStart();
Duration duration = getDuration();
if (actualStart != null && duration != null)
{
double durationValue = (duration.getDuration() * percentComplete) / 100d;
duration = Duration.getInstance(durationValue, duration.getUnits());
ProjectCalendar calendar = getEffectiveCalendar();
value = calendar.getDate(actualStart, duration, true);
}
break;
}
}
set(TaskField.COMPLETE_THROUGH, value);
}
return value;
}
|
java
|
public Date getCompleteThrough()
{
Date value = (Date) getCachedValue(TaskField.COMPLETE_THROUGH);
if (value == null)
{
int percentComplete = NumberHelper.getInt(getPercentageComplete());
switch (percentComplete)
{
case 0:
{
break;
}
case 100:
{
value = getActualFinish();
break;
}
default:
{
Date actualStart = getActualStart();
Duration duration = getDuration();
if (actualStart != null && duration != null)
{
double durationValue = (duration.getDuration() * percentComplete) / 100d;
duration = Duration.getInstance(durationValue, duration.getUnits());
ProjectCalendar calendar = getEffectiveCalendar();
value = calendar.getDate(actualStart, duration, true);
}
break;
}
}
set(TaskField.COMPLETE_THROUGH, value);
}
return value;
}
|
[
"public",
"Date",
"getCompleteThrough",
"(",
")",
"{",
"Date",
"value",
"=",
"(",
"Date",
")",
"getCachedValue",
"(",
"TaskField",
".",
"COMPLETE_THROUGH",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"int",
"percentComplete",
"=",
"NumberHelper",
".",
"getInt",
"(",
"getPercentageComplete",
"(",
")",
")",
";",
"switch",
"(",
"percentComplete",
")",
"{",
"case",
"0",
":",
"{",
"break",
";",
"}",
"case",
"100",
":",
"{",
"value",
"=",
"getActualFinish",
"(",
")",
";",
"break",
";",
"}",
"default",
":",
"{",
"Date",
"actualStart",
"=",
"getActualStart",
"(",
")",
";",
"Duration",
"duration",
"=",
"getDuration",
"(",
")",
";",
"if",
"(",
"actualStart",
"!=",
"null",
"&&",
"duration",
"!=",
"null",
")",
"{",
"double",
"durationValue",
"=",
"(",
"duration",
".",
"getDuration",
"(",
")",
"*",
"percentComplete",
")",
"/",
"100d",
";",
"duration",
"=",
"Duration",
".",
"getInstance",
"(",
"durationValue",
",",
"duration",
".",
"getUnits",
"(",
")",
")",
";",
"ProjectCalendar",
"calendar",
"=",
"getEffectiveCalendar",
"(",
")",
";",
"value",
"=",
"calendar",
".",
"getDate",
"(",
"actualStart",
",",
"duration",
",",
"true",
")",
";",
"}",
"break",
";",
"}",
"}",
"set",
"(",
"TaskField",
".",
"COMPLETE_THROUGH",
",",
"value",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Retrieve the "complete through" date.
@return complete through date
|
[
"Retrieve",
"the",
"complete",
"through",
"date",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4215-L4252
|
157,768
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getTaskMode
|
public TaskMode getTaskMode()
{
return BooleanHelper.getBoolean((Boolean) getCachedValue(TaskField.TASK_MODE)) ? TaskMode.MANUALLY_SCHEDULED : TaskMode.AUTO_SCHEDULED;
}
|
java
|
public TaskMode getTaskMode()
{
return BooleanHelper.getBoolean((Boolean) getCachedValue(TaskField.TASK_MODE)) ? TaskMode.MANUALLY_SCHEDULED : TaskMode.AUTO_SCHEDULED;
}
|
[
"public",
"TaskMode",
"getTaskMode",
"(",
")",
"{",
"return",
"BooleanHelper",
".",
"getBoolean",
"(",
"(",
"Boolean",
")",
"getCachedValue",
"(",
"TaskField",
".",
"TASK_MODE",
")",
")",
"?",
"TaskMode",
".",
"MANUALLY_SCHEDULED",
":",
"TaskMode",
".",
"AUTO_SCHEDULED",
";",
"}"
] |
Retrieves the task mode.
@return task mode
|
[
"Retrieves",
"the",
"task",
"mode",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4300-L4303
|
157,769
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.getEffectiveCalendar
|
public ProjectCalendar getEffectiveCalendar()
{
ProjectCalendar result = getCalendar();
if (result == null)
{
result = getParentFile().getDefaultCalendar();
}
return result;
}
|
java
|
public ProjectCalendar getEffectiveCalendar()
{
ProjectCalendar result = getCalendar();
if (result == null)
{
result = getParentFile().getDefaultCalendar();
}
return result;
}
|
[
"public",
"ProjectCalendar",
"getEffectiveCalendar",
"(",
")",
"{",
"ProjectCalendar",
"result",
"=",
"getCalendar",
"(",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"result",
"=",
"getParentFile",
"(",
")",
".",
"getDefaultCalendar",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Retrieve the effective calendar for this task. If the task does not have
a specific calendar associated with it, fall back to using the default calendar
for the project.
@return ProjectCalendar instance
|
[
"Retrieve",
"the",
"effective",
"calendar",
"for",
"this",
"task",
".",
"If",
"the",
"task",
"does",
"not",
"have",
"a",
"specific",
"calendar",
"associated",
"with",
"it",
"fall",
"back",
"to",
"using",
"the",
"default",
"calendar",
"for",
"the",
"project",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4569-L4577
|
157,770
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.removePredecessor
|
public boolean removePredecessor(Task targetTask, RelationType type, Duration lag)
{
boolean matchFound = false;
//
// Retrieve the list of predecessors
//
List<Relation> predecessorList = getPredecessors();
if (!predecessorList.isEmpty())
{
//
// Ensure that we have a valid lag duration
//
if (lag == null)
{
lag = Duration.getInstance(0, TimeUnit.DAYS);
}
//
// Ensure that there is a predecessor relationship between
// these two tasks, and remove it.
//
matchFound = removeRelation(predecessorList, targetTask, type, lag);
//
// If we have removed a predecessor, then we must remove the
// corresponding successor entry from the target task list
//
if (matchFound)
{
//
// Retrieve the list of successors
//
List<Relation> successorList = targetTask.getSuccessors();
if (!successorList.isEmpty())
{
//
// Ensure that there is a successor relationship between
// these two tasks, and remove it.
//
removeRelation(successorList, this, type, lag);
}
}
}
return matchFound;
}
|
java
|
public boolean removePredecessor(Task targetTask, RelationType type, Duration lag)
{
boolean matchFound = false;
//
// Retrieve the list of predecessors
//
List<Relation> predecessorList = getPredecessors();
if (!predecessorList.isEmpty())
{
//
// Ensure that we have a valid lag duration
//
if (lag == null)
{
lag = Duration.getInstance(0, TimeUnit.DAYS);
}
//
// Ensure that there is a predecessor relationship between
// these two tasks, and remove it.
//
matchFound = removeRelation(predecessorList, targetTask, type, lag);
//
// If we have removed a predecessor, then we must remove the
// corresponding successor entry from the target task list
//
if (matchFound)
{
//
// Retrieve the list of successors
//
List<Relation> successorList = targetTask.getSuccessors();
if (!successorList.isEmpty())
{
//
// Ensure that there is a successor relationship between
// these two tasks, and remove it.
//
removeRelation(successorList, this, type, lag);
}
}
}
return matchFound;
}
|
[
"public",
"boolean",
"removePredecessor",
"(",
"Task",
"targetTask",
",",
"RelationType",
"type",
",",
"Duration",
"lag",
")",
"{",
"boolean",
"matchFound",
"=",
"false",
";",
"//",
"// Retrieve the list of predecessors",
"//",
"List",
"<",
"Relation",
">",
"predecessorList",
"=",
"getPredecessors",
"(",
")",
";",
"if",
"(",
"!",
"predecessorList",
".",
"isEmpty",
"(",
")",
")",
"{",
"//",
"// Ensure that we have a valid lag duration",
"//",
"if",
"(",
"lag",
"==",
"null",
")",
"{",
"lag",
"=",
"Duration",
".",
"getInstance",
"(",
"0",
",",
"TimeUnit",
".",
"DAYS",
")",
";",
"}",
"//",
"// Ensure that there is a predecessor relationship between",
"// these two tasks, and remove it.",
"//",
"matchFound",
"=",
"removeRelation",
"(",
"predecessorList",
",",
"targetTask",
",",
"type",
",",
"lag",
")",
";",
"//",
"// If we have removed a predecessor, then we must remove the",
"// corresponding successor entry from the target task list",
"//",
"if",
"(",
"matchFound",
")",
"{",
"//",
"// Retrieve the list of successors",
"//",
"List",
"<",
"Relation",
">",
"successorList",
"=",
"targetTask",
".",
"getSuccessors",
"(",
")",
";",
"if",
"(",
"!",
"successorList",
".",
"isEmpty",
"(",
")",
")",
"{",
"//",
"// Ensure that there is a successor relationship between",
"// these two tasks, and remove it.",
"//",
"removeRelation",
"(",
"successorList",
",",
"this",
",",
"type",
",",
"lag",
")",
";",
"}",
"}",
"}",
"return",
"matchFound",
";",
"}"
] |
This method allows a predecessor relationship to be removed from this
task instance. It will only delete relationships that exactly match the
given targetTask, type and lag time.
@param targetTask the predecessor task
@param type relation type
@param lag relation lag
@return returns true if the relation is found and removed
|
[
"This",
"method",
"allows",
"a",
"predecessor",
"relationship",
"to",
"be",
"removed",
"from",
"this",
"task",
"instance",
".",
"It",
"will",
"only",
"delete",
"relationships",
"that",
"exactly",
"match",
"the",
"given",
"targetTask",
"type",
"and",
"lag",
"time",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4589-L4635
|
157,771
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.removeRelation
|
private boolean removeRelation(List<Relation> relationList, Task targetTask, RelationType type, Duration lag)
{
boolean matchFound = false;
for (Relation relation : relationList)
{
if (relation.getTargetTask() == targetTask)
{
if (relation.getType() == type && relation.getLag().compareTo(lag) == 0)
{
matchFound = relationList.remove(relation);
break;
}
}
}
return matchFound;
}
|
java
|
private boolean removeRelation(List<Relation> relationList, Task targetTask, RelationType type, Duration lag)
{
boolean matchFound = false;
for (Relation relation : relationList)
{
if (relation.getTargetTask() == targetTask)
{
if (relation.getType() == type && relation.getLag().compareTo(lag) == 0)
{
matchFound = relationList.remove(relation);
break;
}
}
}
return matchFound;
}
|
[
"private",
"boolean",
"removeRelation",
"(",
"List",
"<",
"Relation",
">",
"relationList",
",",
"Task",
"targetTask",
",",
"RelationType",
"type",
",",
"Duration",
"lag",
")",
"{",
"boolean",
"matchFound",
"=",
"false",
";",
"for",
"(",
"Relation",
"relation",
":",
"relationList",
")",
"{",
"if",
"(",
"relation",
".",
"getTargetTask",
"(",
")",
"==",
"targetTask",
")",
"{",
"if",
"(",
"relation",
".",
"getType",
"(",
")",
"==",
"type",
"&&",
"relation",
".",
"getLag",
"(",
")",
".",
"compareTo",
"(",
"lag",
")",
"==",
"0",
")",
"{",
"matchFound",
"=",
"relationList",
".",
"remove",
"(",
"relation",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"matchFound",
";",
"}"
] |
Internal method used to locate an remove an item from a list Relations.
@param relationList list of Relation instances
@param targetTask target relationship task
@param type target relationship type
@param lag target relationship lag
@return true if a relationship was removed
|
[
"Internal",
"method",
"used",
"to",
"locate",
"an",
"remove",
"an",
"item",
"from",
"a",
"list",
"Relations",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4646-L4661
|
157,772
|
joniles/mpxj
|
src/main/java/net/sf/mpxj/Task.java
|
Task.isRelated
|
private boolean isRelated(Task task, List<Relation> list)
{
boolean result = false;
for (Relation relation : list)
{
if (relation.getTargetTask().getUniqueID().intValue() == task.getUniqueID().intValue())
{
result = true;
break;
}
}
return result;
}
|
java
|
private boolean isRelated(Task task, List<Relation> list)
{
boolean result = false;
for (Relation relation : list)
{
if (relation.getTargetTask().getUniqueID().intValue() == task.getUniqueID().intValue())
{
result = true;
break;
}
}
return result;
}
|
[
"private",
"boolean",
"isRelated",
"(",
"Task",
"task",
",",
"List",
"<",
"Relation",
">",
"list",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"for",
"(",
"Relation",
"relation",
":",
"list",
")",
"{",
"if",
"(",
"relation",
".",
"getTargetTask",
"(",
")",
".",
"getUniqueID",
"(",
")",
".",
"intValue",
"(",
")",
"==",
"task",
".",
"getUniqueID",
"(",
")",
".",
"intValue",
"(",
")",
")",
"{",
"result",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Internal method used to test for the existence of a relationship
with a task.
@param task target task
@param list list of relationships
@return boolean flag
|
[
"Internal",
"method",
"used",
"to",
"test",
"for",
"the",
"existence",
"of",
"a",
"relationship",
"with",
"a",
"task",
"."
] |
143ea0e195da59cd108f13b3b06328e9542337e8
|
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L5020-L5032
|
157,773
|
jensgerdes/sonar-pmd
|
sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/xml/PmdRuleSet.java
|
PmdRuleSet.writeTo
|
public void writeTo(Writer destination) {
Element eltRuleset = new Element("ruleset");
addAttribute(eltRuleset, "name", name);
addChild(eltRuleset, "description", description);
for (PmdRule pmdRule : rules) {
Element eltRule = new Element("rule");
addAttribute(eltRule, "ref", pmdRule.getRef());
addAttribute(eltRule, "class", pmdRule.getClazz());
addAttribute(eltRule, "message", pmdRule.getMessage());
addAttribute(eltRule, "name", pmdRule.getName());
addAttribute(eltRule, "language", pmdRule.getLanguage());
addChild(eltRule, "priority", String.valueOf(pmdRule.getPriority()));
if (pmdRule.hasProperties()) {
Element ruleProperties = processRuleProperties(pmdRule);
if (ruleProperties.getContentSize() > 0) {
eltRule.addContent(ruleProperties);
}
}
eltRuleset.addContent(eltRule);
}
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
try {
serializer.output(new Document(eltRuleset), destination);
} catch (IOException e) {
throw new IllegalStateException("An exception occurred while serializing PmdRuleSet.", e);
}
}
|
java
|
public void writeTo(Writer destination) {
Element eltRuleset = new Element("ruleset");
addAttribute(eltRuleset, "name", name);
addChild(eltRuleset, "description", description);
for (PmdRule pmdRule : rules) {
Element eltRule = new Element("rule");
addAttribute(eltRule, "ref", pmdRule.getRef());
addAttribute(eltRule, "class", pmdRule.getClazz());
addAttribute(eltRule, "message", pmdRule.getMessage());
addAttribute(eltRule, "name", pmdRule.getName());
addAttribute(eltRule, "language", pmdRule.getLanguage());
addChild(eltRule, "priority", String.valueOf(pmdRule.getPriority()));
if (pmdRule.hasProperties()) {
Element ruleProperties = processRuleProperties(pmdRule);
if (ruleProperties.getContentSize() > 0) {
eltRule.addContent(ruleProperties);
}
}
eltRuleset.addContent(eltRule);
}
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
try {
serializer.output(new Document(eltRuleset), destination);
} catch (IOException e) {
throw new IllegalStateException("An exception occurred while serializing PmdRuleSet.", e);
}
}
|
[
"public",
"void",
"writeTo",
"(",
"Writer",
"destination",
")",
"{",
"Element",
"eltRuleset",
"=",
"new",
"Element",
"(",
"\"ruleset\"",
")",
";",
"addAttribute",
"(",
"eltRuleset",
",",
"\"name\"",
",",
"name",
")",
";",
"addChild",
"(",
"eltRuleset",
",",
"\"description\"",
",",
"description",
")",
";",
"for",
"(",
"PmdRule",
"pmdRule",
":",
"rules",
")",
"{",
"Element",
"eltRule",
"=",
"new",
"Element",
"(",
"\"rule\"",
")",
";",
"addAttribute",
"(",
"eltRule",
",",
"\"ref\"",
",",
"pmdRule",
".",
"getRef",
"(",
")",
")",
";",
"addAttribute",
"(",
"eltRule",
",",
"\"class\"",
",",
"pmdRule",
".",
"getClazz",
"(",
")",
")",
";",
"addAttribute",
"(",
"eltRule",
",",
"\"message\"",
",",
"pmdRule",
".",
"getMessage",
"(",
")",
")",
";",
"addAttribute",
"(",
"eltRule",
",",
"\"name\"",
",",
"pmdRule",
".",
"getName",
"(",
")",
")",
";",
"addAttribute",
"(",
"eltRule",
",",
"\"language\"",
",",
"pmdRule",
".",
"getLanguage",
"(",
")",
")",
";",
"addChild",
"(",
"eltRule",
",",
"\"priority\"",
",",
"String",
".",
"valueOf",
"(",
"pmdRule",
".",
"getPriority",
"(",
")",
")",
")",
";",
"if",
"(",
"pmdRule",
".",
"hasProperties",
"(",
")",
")",
"{",
"Element",
"ruleProperties",
"=",
"processRuleProperties",
"(",
"pmdRule",
")",
";",
"if",
"(",
"ruleProperties",
".",
"getContentSize",
"(",
")",
">",
"0",
")",
"{",
"eltRule",
".",
"addContent",
"(",
"ruleProperties",
")",
";",
"}",
"}",
"eltRuleset",
".",
"addContent",
"(",
"eltRule",
")",
";",
"}",
"XMLOutputter",
"serializer",
"=",
"new",
"XMLOutputter",
"(",
"Format",
".",
"getPrettyFormat",
"(",
")",
")",
";",
"try",
"{",
"serializer",
".",
"output",
"(",
"new",
"Document",
"(",
"eltRuleset",
")",
",",
"destination",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"An exception occurred while serializing PmdRuleSet.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Serializes this RuleSet in an XML document.
@param destination The writer to which the XML document shall be written.
|
[
"Serializes",
"this",
"RuleSet",
"in",
"an",
"XML",
"document",
"."
] |
49b9272b2a71aa1b480972ec6cb4cc347bb50959
|
https://github.com/jensgerdes/sonar-pmd/blob/49b9272b2a71aa1b480972ec6cb4cc347bb50959/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/xml/PmdRuleSet.java#L76-L102
|
157,774
|
jensgerdes/sonar-pmd
|
sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/xml/factory/XmlRuleSetFactory.java
|
XmlRuleSetFactory.create
|
@Override
public PmdRuleSet create() {
final SAXBuilder parser = new SAXBuilder();
final Document dom;
try {
dom = parser.build(source);
} catch (JDOMException | IOException e) {
if (messages != null) {
messages.addErrorText(INVALID_INPUT + " : " + e.getMessage());
}
LOG.error(INVALID_INPUT, e);
return new PmdRuleSet();
}
final Element eltResultset = dom.getRootElement();
final Namespace namespace = eltResultset.getNamespace();
final PmdRuleSet result = new PmdRuleSet();
final String name = eltResultset.getAttributeValue("name");
final Element descriptionElement = getChild(eltResultset, namespace);
result.setName(name);
if (descriptionElement != null) {
result.setDescription(descriptionElement.getValue());
}
for (Element eltRule : getChildren(eltResultset, "rule", namespace)) {
PmdRule pmdRule = new PmdRule(eltRule.getAttributeValue("ref"));
pmdRule.setClazz(eltRule.getAttributeValue("class"));
pmdRule.setName(eltRule.getAttributeValue("name"));
pmdRule.setMessage(eltRule.getAttributeValue("message"));
parsePmdPriority(eltRule, pmdRule, namespace);
parsePmdProperties(eltRule, pmdRule, namespace);
result.addRule(pmdRule);
}
return result;
}
|
java
|
@Override
public PmdRuleSet create() {
final SAXBuilder parser = new SAXBuilder();
final Document dom;
try {
dom = parser.build(source);
} catch (JDOMException | IOException e) {
if (messages != null) {
messages.addErrorText(INVALID_INPUT + " : " + e.getMessage());
}
LOG.error(INVALID_INPUT, e);
return new PmdRuleSet();
}
final Element eltResultset = dom.getRootElement();
final Namespace namespace = eltResultset.getNamespace();
final PmdRuleSet result = new PmdRuleSet();
final String name = eltResultset.getAttributeValue("name");
final Element descriptionElement = getChild(eltResultset, namespace);
result.setName(name);
if (descriptionElement != null) {
result.setDescription(descriptionElement.getValue());
}
for (Element eltRule : getChildren(eltResultset, "rule", namespace)) {
PmdRule pmdRule = new PmdRule(eltRule.getAttributeValue("ref"));
pmdRule.setClazz(eltRule.getAttributeValue("class"));
pmdRule.setName(eltRule.getAttributeValue("name"));
pmdRule.setMessage(eltRule.getAttributeValue("message"));
parsePmdPriority(eltRule, pmdRule, namespace);
parsePmdProperties(eltRule, pmdRule, namespace);
result.addRule(pmdRule);
}
return result;
}
|
[
"@",
"Override",
"public",
"PmdRuleSet",
"create",
"(",
")",
"{",
"final",
"SAXBuilder",
"parser",
"=",
"new",
"SAXBuilder",
"(",
")",
";",
"final",
"Document",
"dom",
";",
"try",
"{",
"dom",
"=",
"parser",
".",
"build",
"(",
"source",
")",
";",
"}",
"catch",
"(",
"JDOMException",
"|",
"IOException",
"e",
")",
"{",
"if",
"(",
"messages",
"!=",
"null",
")",
"{",
"messages",
".",
"addErrorText",
"(",
"INVALID_INPUT",
"+",
"\" : \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"LOG",
".",
"error",
"(",
"INVALID_INPUT",
",",
"e",
")",
";",
"return",
"new",
"PmdRuleSet",
"(",
")",
";",
"}",
"final",
"Element",
"eltResultset",
"=",
"dom",
".",
"getRootElement",
"(",
")",
";",
"final",
"Namespace",
"namespace",
"=",
"eltResultset",
".",
"getNamespace",
"(",
")",
";",
"final",
"PmdRuleSet",
"result",
"=",
"new",
"PmdRuleSet",
"(",
")",
";",
"final",
"String",
"name",
"=",
"eltResultset",
".",
"getAttributeValue",
"(",
"\"name\"",
")",
";",
"final",
"Element",
"descriptionElement",
"=",
"getChild",
"(",
"eltResultset",
",",
"namespace",
")",
";",
"result",
".",
"setName",
"(",
"name",
")",
";",
"if",
"(",
"descriptionElement",
"!=",
"null",
")",
"{",
"result",
".",
"setDescription",
"(",
"descriptionElement",
".",
"getValue",
"(",
")",
")",
";",
"}",
"for",
"(",
"Element",
"eltRule",
":",
"getChildren",
"(",
"eltResultset",
",",
"\"rule\"",
",",
"namespace",
")",
")",
"{",
"PmdRule",
"pmdRule",
"=",
"new",
"PmdRule",
"(",
"eltRule",
".",
"getAttributeValue",
"(",
"\"ref\"",
")",
")",
";",
"pmdRule",
".",
"setClazz",
"(",
"eltRule",
".",
"getAttributeValue",
"(",
"\"class\"",
")",
")",
";",
"pmdRule",
".",
"setName",
"(",
"eltRule",
".",
"getAttributeValue",
"(",
"\"name\"",
")",
")",
";",
"pmdRule",
".",
"setMessage",
"(",
"eltRule",
".",
"getAttributeValue",
"(",
"\"message\"",
")",
")",
";",
"parsePmdPriority",
"(",
"eltRule",
",",
"pmdRule",
",",
"namespace",
")",
";",
"parsePmdProperties",
"(",
"eltRule",
",",
"pmdRule",
",",
"namespace",
")",
";",
"result",
".",
"addRule",
"(",
"pmdRule",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Parses the given Reader for PmdRuleSets.
@return The extracted PmdRuleSet - empty in case of problems, never null.
|
[
"Parses",
"the",
"given",
"Reader",
"for",
"PmdRuleSets",
"."
] |
49b9272b2a71aa1b480972ec6cb4cc347bb50959
|
https://github.com/jensgerdes/sonar-pmd/blob/49b9272b2a71aa1b480972ec6cb4cc347bb50959/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/xml/factory/XmlRuleSetFactory.java#L100-L137
|
157,775
|
jensgerdes/sonar-pmd
|
sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/TextRangeCalculator.java
|
TextRangeCalculator.calculateBeginLine
|
private static int calculateBeginLine(RuleViolation pmdViolation) {
int minLine = Math.min(pmdViolation.getBeginLine(), pmdViolation.getEndLine());
return minLine > 0 ? minLine : calculateEndLine(pmdViolation);
}
|
java
|
private static int calculateBeginLine(RuleViolation pmdViolation) {
int minLine = Math.min(pmdViolation.getBeginLine(), pmdViolation.getEndLine());
return minLine > 0 ? minLine : calculateEndLine(pmdViolation);
}
|
[
"private",
"static",
"int",
"calculateBeginLine",
"(",
"RuleViolation",
"pmdViolation",
")",
"{",
"int",
"minLine",
"=",
"Math",
".",
"min",
"(",
"pmdViolation",
".",
"getBeginLine",
"(",
")",
",",
"pmdViolation",
".",
"getEndLine",
"(",
")",
")",
";",
"return",
"minLine",
">",
"0",
"?",
"minLine",
":",
"calculateEndLine",
"(",
"pmdViolation",
")",
";",
"}"
] |
Calculates the beginLine of a violation report.
@param pmdViolation The violation for which the beginLine should be calculated.
@return The beginLine is assumed to be the line with the smallest number. However, if the smallest number is
out-of-range (non-positive), it takes the other number.
|
[
"Calculates",
"the",
"beginLine",
"of",
"a",
"violation",
"report",
"."
] |
49b9272b2a71aa1b480972ec6cb4cc347bb50959
|
https://github.com/jensgerdes/sonar-pmd/blob/49b9272b2a71aa1b480972ec6cb4cc347bb50959/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/TextRangeCalculator.java#L61-L64
|
157,776
|
algolia/instantsearch-android
|
ui/src/main/java/com/algolia/instantsearch/ui/utils/SearchViewFacade.java
|
SearchViewFacade.findViewById
|
@Nullable public View findViewById(int id) {
if (searchView != null) {
return searchView.findViewById(id);
} else if (supportView != null) {
return supportView.findViewById(id);
}
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
|
java
|
@Nullable public View findViewById(int id) {
if (searchView != null) {
return searchView.findViewById(id);
} else if (supportView != null) {
return supportView.findViewById(id);
}
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
|
[
"@",
"Nullable",
"public",
"View",
"findViewById",
"(",
"int",
"id",
")",
"{",
"if",
"(",
"searchView",
"!=",
"null",
")",
"{",
"return",
"searchView",
".",
"findViewById",
"(",
"id",
")",
";",
"}",
"else",
"if",
"(",
"supportView",
"!=",
"null",
")",
"{",
"return",
"supportView",
".",
"findViewById",
"(",
"id",
")",
";",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"ERROR_NO_SEARCHVIEW",
")",
";",
"}"
] |
Look for a child view with the given id. If this view has the given
id, return this view.
@param id The id to search for.
@return The view that has the given id in the hierarchy or null
|
[
"Look",
"for",
"a",
"child",
"view",
"with",
"the",
"given",
"id",
".",
"If",
"this",
"view",
"has",
"the",
"given",
"id",
"return",
"this",
"view",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/utils/SearchViewFacade.java#L88-L95
|
157,777
|
algolia/instantsearch-android
|
ui/src/main/java/com/algolia/instantsearch/ui/utils/SearchViewFacade.java
|
SearchViewFacade.getContext
|
@NonNull public Context getContext() {
if (searchView != null) {
return searchView.getContext();
} else if (supportView != null) {
return supportView.getContext();
}
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
|
java
|
@NonNull public Context getContext() {
if (searchView != null) {
return searchView.getContext();
} else if (supportView != null) {
return supportView.getContext();
}
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
|
[
"@",
"NonNull",
"public",
"Context",
"getContext",
"(",
")",
"{",
"if",
"(",
"searchView",
"!=",
"null",
")",
"{",
"return",
"searchView",
".",
"getContext",
"(",
")",
";",
"}",
"else",
"if",
"(",
"supportView",
"!=",
"null",
")",
"{",
"return",
"supportView",
".",
"getContext",
"(",
")",
";",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"ERROR_NO_SEARCHVIEW",
")",
";",
"}"
] |
Returns the context the view is running in, through which it can
access the current theme, resources, etc.
@return The view's Context.
|
[
"Returns",
"the",
"context",
"the",
"view",
"is",
"running",
"in",
"through",
"which",
"it",
"can",
"access",
"the",
"current",
"theme",
"resources",
"etc",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/utils/SearchViewFacade.java#L103-L110
|
157,778
|
algolia/instantsearch-android
|
ui/src/main/java/com/algolia/instantsearch/ui/utils/SearchViewFacade.java
|
SearchViewFacade.getQuery
|
@NonNull public CharSequence getQuery() {
if (searchView != null) {
return searchView.getQuery();
} else if (supportView != null) {
return supportView.getQuery();
}
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
|
java
|
@NonNull public CharSequence getQuery() {
if (searchView != null) {
return searchView.getQuery();
} else if (supportView != null) {
return supportView.getQuery();
}
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
|
[
"@",
"NonNull",
"public",
"CharSequence",
"getQuery",
"(",
")",
"{",
"if",
"(",
"searchView",
"!=",
"null",
")",
"{",
"return",
"searchView",
".",
"getQuery",
"(",
")",
";",
"}",
"else",
"if",
"(",
"supportView",
"!=",
"null",
")",
"{",
"return",
"supportView",
".",
"getQuery",
"(",
")",
";",
"}",
"throw",
"new",
"IllegalStateException",
"(",
"ERROR_NO_SEARCHVIEW",
")",
";",
"}"
] |
Returns the query string currently in the text field.
@return the query string
|
[
"Returns",
"the",
"query",
"string",
"currently",
"in",
"the",
"text",
"field",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/utils/SearchViewFacade.java#L117-L124
|
157,779
|
algolia/instantsearch-android
|
ui/src/main/java/com/algolia/instantsearch/ui/utils/SearchViewFacade.java
|
SearchViewFacade.setOnQueryTextListener
|
public void setOnQueryTextListener(@NonNull final SearchView.OnQueryTextListener listener) {
if (searchView != null) {
searchView.setOnQueryTextListener(listener);
} else if (supportView != null) {
supportView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {
@Override public boolean onQueryTextSubmit(String query) {
return listener.onQueryTextSubmit(query);
}
@Override public boolean onQueryTextChange(String newText) {
return listener.onQueryTextChange(newText);
}
});
} else {
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
}
|
java
|
public void setOnQueryTextListener(@NonNull final SearchView.OnQueryTextListener listener) {
if (searchView != null) {
searchView.setOnQueryTextListener(listener);
} else if (supportView != null) {
supportView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {
@Override public boolean onQueryTextSubmit(String query) {
return listener.onQueryTextSubmit(query);
}
@Override public boolean onQueryTextChange(String newText) {
return listener.onQueryTextChange(newText);
}
});
} else {
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
}
|
[
"public",
"void",
"setOnQueryTextListener",
"(",
"@",
"NonNull",
"final",
"SearchView",
".",
"OnQueryTextListener",
"listener",
")",
"{",
"if",
"(",
"searchView",
"!=",
"null",
")",
"{",
"searchView",
".",
"setOnQueryTextListener",
"(",
"listener",
")",
";",
"}",
"else",
"if",
"(",
"supportView",
"!=",
"null",
")",
"{",
"supportView",
".",
"setOnQueryTextListener",
"(",
"new",
"android",
".",
"support",
".",
"v7",
".",
"widget",
".",
"SearchView",
".",
"OnQueryTextListener",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"onQueryTextSubmit",
"(",
"String",
"query",
")",
"{",
"return",
"listener",
".",
"onQueryTextSubmit",
"(",
"query",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"onQueryTextChange",
"(",
"String",
"newText",
")",
"{",
"return",
"listener",
".",
"onQueryTextChange",
"(",
"newText",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"ERROR_NO_SEARCHVIEW",
")",
";",
"}",
"}"
] |
Sets a listener for user actions within the SearchView.
@param listener the listener object that receives callbacks when the user performs
actions in the SearchView such as clicking on buttons or typing a query.
|
[
"Sets",
"a",
"listener",
"for",
"user",
"actions",
"within",
"the",
"SearchView",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/utils/SearchViewFacade.java#L187-L203
|
157,780
|
algolia/instantsearch-android
|
ui/src/main/java/com/algolia/instantsearch/ui/utils/SearchViewFacade.java
|
SearchViewFacade.setOnCloseListener
|
public void setOnCloseListener(@NonNull final android.support.v7.widget.SearchView.OnCloseListener listener) {
if (searchView != null) {
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override public boolean onClose() {
return listener.onClose();
}
});
} else if (supportView != null) {
supportView.setOnCloseListener(listener);
} else {
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
}
|
java
|
public void setOnCloseListener(@NonNull final android.support.v7.widget.SearchView.OnCloseListener listener) {
if (searchView != null) {
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override public boolean onClose() {
return listener.onClose();
}
});
} else if (supportView != null) {
supportView.setOnCloseListener(listener);
} else {
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
}
|
[
"public",
"void",
"setOnCloseListener",
"(",
"@",
"NonNull",
"final",
"android",
".",
"support",
".",
"v7",
".",
"widget",
".",
"SearchView",
".",
"OnCloseListener",
"listener",
")",
"{",
"if",
"(",
"searchView",
"!=",
"null",
")",
"{",
"searchView",
".",
"setOnCloseListener",
"(",
"new",
"SearchView",
".",
"OnCloseListener",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"onClose",
"(",
")",
"{",
"return",
"listener",
".",
"onClose",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"if",
"(",
"supportView",
"!=",
"null",
")",
"{",
"supportView",
".",
"setOnCloseListener",
"(",
"listener",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"ERROR_NO_SEARCHVIEW",
")",
";",
"}",
"}"
] |
Sets a listener to inform when the user closes the SearchView.
@param listener the listener to call when the user closes the SearchView.
|
[
"Sets",
"a",
"listener",
"to",
"inform",
"when",
"the",
"user",
"closes",
"the",
"SearchView",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/utils/SearchViewFacade.java#L253-L265
|
157,781
|
algolia/instantsearch-android
|
core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java
|
Searcher.get
|
public static Searcher get(String variant) {
final Searcher searcher = instances.get(variant);
if (searcher == null) {
throw new IllegalStateException(Errors.SEARCHER_GET_BEFORE_CREATE);
}
return searcher;
}
|
java
|
public static Searcher get(String variant) {
final Searcher searcher = instances.get(variant);
if (searcher == null) {
throw new IllegalStateException(Errors.SEARCHER_GET_BEFORE_CREATE);
}
return searcher;
}
|
[
"public",
"static",
"Searcher",
"get",
"(",
"String",
"variant",
")",
"{",
"final",
"Searcher",
"searcher",
"=",
"instances",
".",
"get",
"(",
"variant",
")",
";",
"if",
"(",
"searcher",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"Errors",
".",
"SEARCHER_GET_BEFORE_CREATE",
")",
";",
"}",
"return",
"searcher",
";",
"}"
] |
Gets the Searcher for a given variant.
@param variant an identifier to differentiate this Searcher from eventual others.
@return the corresponding Searcher instance.
@throws IllegalStateException if no searcher was {@link #create(Searchable) created} before for this {@code variant}.
|
[
"Gets",
"the",
"Searcher",
"for",
"a",
"given",
"variant",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java#L166-L172
|
157,782
|
algolia/instantsearch-android
|
core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java
|
Searcher.reset
|
@NonNull
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher reset() {
lastResponsePage = 0;
lastRequestPage = 0;
lastResponseId = 0;
endReached = false;
clearFacetRefinements();
cancelPendingRequests();
numericRefinements.clear();
return this;
}
|
java
|
@NonNull
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher reset() {
lastResponsePage = 0;
lastRequestPage = 0;
lastResponseId = 0;
endReached = false;
clearFacetRefinements();
cancelPendingRequests();
numericRefinements.clear();
return this;
}
|
[
"@",
"NonNull",
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"public",
"Searcher",
"reset",
"(",
")",
"{",
"lastResponsePage",
"=",
"0",
";",
"lastRequestPage",
"=",
"0",
";",
"lastResponseId",
"=",
"0",
";",
"endReached",
"=",
"false",
";",
"clearFacetRefinements",
"(",
")",
";",
"cancelPendingRequests",
"(",
")",
";",
"numericRefinements",
".",
"clear",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
Resets the helper's state.
@return this {@link Searcher} for chaining.
|
[
"Resets",
"the",
"helper",
"s",
"state",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java#L463-L474
|
157,783
|
algolia/instantsearch-android
|
core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java
|
Searcher.cancelPendingRequests
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher cancelPendingRequests() {
if (pendingRequests.size() != 0) {
for (int i = 0; i < pendingRequests.size(); i++) {
int reqId = pendingRequests.keyAt(i);
Request r = pendingRequests.valueAt(i);
if (!r.isFinished() && !r.isCancelled()) {
cancelRequest(r, reqId);
}
}
}
return this;
}
|
java
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher cancelPendingRequests() {
if (pendingRequests.size() != 0) {
for (int i = 0; i < pendingRequests.size(); i++) {
int reqId = pendingRequests.keyAt(i);
Request r = pendingRequests.valueAt(i);
if (!r.isFinished() && !r.isCancelled()) {
cancelRequest(r, reqId);
}
}
}
return this;
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"public",
"Searcher",
"cancelPendingRequests",
"(",
")",
"{",
"if",
"(",
"pendingRequests",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"pendingRequests",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"int",
"reqId",
"=",
"pendingRequests",
".",
"keyAt",
"(",
"i",
")",
";",
"Request",
"r",
"=",
"pendingRequests",
".",
"valueAt",
"(",
"i",
")",
";",
"if",
"(",
"!",
"r",
".",
"isFinished",
"(",
")",
"&&",
"!",
"r",
".",
"isCancelled",
"(",
")",
")",
"{",
"cancelRequest",
"(",
"r",
",",
"reqId",
")",
";",
"}",
"}",
"}",
"return",
"this",
";",
"}"
] |
Cancels all requests still waiting for a response.
@return this {@link Searcher} for chaining.
|
[
"Cancels",
"all",
"requests",
"still",
"waiting",
"for",
"a",
"response",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java#L491-L503
|
157,784
|
algolia/instantsearch-android
|
core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java
|
Searcher.addBooleanFilter
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher addBooleanFilter(String attribute, Boolean value) {
booleanFilterMap.put(attribute, value);
rebuildQueryFacetFilters();
return this;
}
|
java
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher addBooleanFilter(String attribute, Boolean value) {
booleanFilterMap.put(attribute, value);
rebuildQueryFacetFilters();
return this;
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"public",
"Searcher",
"addBooleanFilter",
"(",
"String",
"attribute",
",",
"Boolean",
"value",
")",
"{",
"booleanFilterMap",
".",
"put",
"(",
"attribute",
",",
"value",
")",
";",
"rebuildQueryFacetFilters",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
Adds a boolean refinement for the next queries.
@param attribute the attribute to refine on.
@param value the value to refine with.
@return this {@link Searcher} for chaining.
|
[
"Adds",
"a",
"boolean",
"refinement",
"for",
"the",
"next",
"queries",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java#L768-L773
|
157,785
|
algolia/instantsearch-android
|
core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java
|
Searcher.addFacet
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher addFacet(String... attributes) {
for (String attribute : attributes) {
final Integer value = facetRequestCount.get(attribute);
facetRequestCount.put(attribute, value == null ? 1 : value + 1);
if (value == null || value == 0) {
facets.add(attribute);
}
}
rebuildQueryFacets();
return this;
}
|
java
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher addFacet(String... attributes) {
for (String attribute : attributes) {
final Integer value = facetRequestCount.get(attribute);
facetRequestCount.put(attribute, value == null ? 1 : value + 1);
if (value == null || value == 0) {
facets.add(attribute);
}
}
rebuildQueryFacets();
return this;
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"public",
"Searcher",
"addFacet",
"(",
"String",
"...",
"attributes",
")",
"{",
"for",
"(",
"String",
"attribute",
":",
"attributes",
")",
"{",
"final",
"Integer",
"value",
"=",
"facetRequestCount",
".",
"get",
"(",
"attribute",
")",
";",
"facetRequestCount",
".",
"put",
"(",
"attribute",
",",
"value",
"==",
"null",
"?",
"1",
":",
"value",
"+",
"1",
")",
";",
"if",
"(",
"value",
"==",
"null",
"||",
"value",
"==",
"0",
")",
"{",
"facets",
".",
"add",
"(",
"attribute",
")",
";",
"}",
"}",
"rebuildQueryFacets",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
Adds one or several attributes to facet on for the next queries.
@param attributes one or more attribute names.
@return this {@link Searcher} for chaining.
|
[
"Adds",
"one",
"or",
"several",
"attributes",
"to",
"facet",
"on",
"for",
"the",
"next",
"queries",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java#L809-L820
|
157,786
|
algolia/instantsearch-android
|
core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java
|
Searcher.deleteFacet
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher deleteFacet(String... attributes) {
for (String attribute : attributes) {
facetRequestCount.put(attribute, 0);
facets.remove(attribute);
}
rebuildQueryFacets();
return this;
}
|
java
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public Searcher deleteFacet(String... attributes) {
for (String attribute : attributes) {
facetRequestCount.put(attribute, 0);
facets.remove(attribute);
}
rebuildQueryFacets();
return this;
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"public",
"Searcher",
"deleteFacet",
"(",
"String",
"...",
"attributes",
")",
"{",
"for",
"(",
"String",
"attribute",
":",
"attributes",
")",
"{",
"facetRequestCount",
".",
"put",
"(",
"attribute",
",",
"0",
")",
";",
"facets",
".",
"remove",
"(",
"attribute",
")",
";",
"}",
"rebuildQueryFacets",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
Forces removal of one or several faceted attributes for the next queries.
@param attributes one or more attribute names.
@return this {@link Searcher} for chaining.
|
[
"Forces",
"removal",
"of",
"one",
"or",
"several",
"faceted",
"attributes",
"for",
"the",
"next",
"queries",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/helpers/Searcher.java#L852-L860
|
157,787
|
algolia/instantsearch-android
|
core/src/main/java/com/algolia/instantsearch/core/model/NumericRefinement.java
|
NumericRefinement.checkOperatorIsValid
|
public static void checkOperatorIsValid(int operatorCode) {
switch (operatorCode) {
case OPERATOR_LT:
case OPERATOR_LE:
case OPERATOR_EQ:
case OPERATOR_NE:
case OPERATOR_GE:
case OPERATOR_GT:
case OPERATOR_UNKNOWN:
return;
default:
throw new IllegalStateException(String.format(Locale.US, ERROR_INVALID_CODE, operatorCode));
}
}
|
java
|
public static void checkOperatorIsValid(int operatorCode) {
switch (operatorCode) {
case OPERATOR_LT:
case OPERATOR_LE:
case OPERATOR_EQ:
case OPERATOR_NE:
case OPERATOR_GE:
case OPERATOR_GT:
case OPERATOR_UNKNOWN:
return;
default:
throw new IllegalStateException(String.format(Locale.US, ERROR_INVALID_CODE, operatorCode));
}
}
|
[
"public",
"static",
"void",
"checkOperatorIsValid",
"(",
"int",
"operatorCode",
")",
"{",
"switch",
"(",
"operatorCode",
")",
"{",
"case",
"OPERATOR_LT",
":",
"case",
"OPERATOR_LE",
":",
"case",
"OPERATOR_EQ",
":",
"case",
"OPERATOR_NE",
":",
"case",
"OPERATOR_GE",
":",
"case",
"OPERATOR_GT",
":",
"case",
"OPERATOR_UNKNOWN",
":",
"return",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"Locale",
".",
"US",
",",
"ERROR_INVALID_CODE",
",",
"operatorCode",
")",
")",
";",
"}",
"}"
] |
Checks if the given operator code is a valid one.
@param operatorCode an operator code to evaluate
@throws IllegalStateException if operatorCode is not a known operator code.
|
[
"Checks",
"if",
"the",
"given",
"operator",
"code",
"is",
"a",
"valid",
"one",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/model/NumericRefinement.java#L81-L94
|
157,788
|
algolia/instantsearch-android
|
core/src/main/java/com/algolia/instantsearch/core/utils/JSONUtils.java
|
JSONUtils.getStringFromJSONPath
|
public static String getStringFromJSONPath(JSONObject record, String path) {
final Object object = getObjectFromJSONPath(record, path);
return object == null ? null : object.toString();
}
|
java
|
public static String getStringFromJSONPath(JSONObject record, String path) {
final Object object = getObjectFromJSONPath(record, path);
return object == null ? null : object.toString();
}
|
[
"public",
"static",
"String",
"getStringFromJSONPath",
"(",
"JSONObject",
"record",
",",
"String",
"path",
")",
"{",
"final",
"Object",
"object",
"=",
"getObjectFromJSONPath",
"(",
"record",
",",
"path",
")",
";",
"return",
"object",
"==",
"null",
"?",
"null",
":",
"object",
".",
"toString",
"(",
")",
";",
"}"
] |
Gets a string attribute from a json object given a path to traverse.
@param record a JSONObject to traverse.
@param path the json path to follow.
@return the attribute as a {@link String}, or null if it was not found.
|
[
"Gets",
"a",
"string",
"attribute",
"from",
"a",
"json",
"object",
"given",
"a",
"path",
"to",
"traverse",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/utils/JSONUtils.java#L21-L24
|
157,789
|
algolia/instantsearch-android
|
core/src/main/java/com/algolia/instantsearch/core/utils/JSONUtils.java
|
JSONUtils.getMapFromJSONPath
|
public static HashMap<String, String> getMapFromJSONPath(JSONObject record, String path) {
return getObjectFromJSONPath(record, path);
}
|
java
|
public static HashMap<String, String> getMapFromJSONPath(JSONObject record, String path) {
return getObjectFromJSONPath(record, path);
}
|
[
"public",
"static",
"HashMap",
"<",
"String",
",",
"String",
">",
"getMapFromJSONPath",
"(",
"JSONObject",
"record",
",",
"String",
"path",
")",
"{",
"return",
"getObjectFromJSONPath",
"(",
"record",
",",
"path",
")",
";",
"}"
] |
Gets a Map of attributes from a json object given a path to traverse.
@param record a JSONObject to traverse.
@param path the json path to follow.
@return the attributes as a {@link HashMap}, or null if it was not found.
|
[
"Gets",
"a",
"Map",
"of",
"attributes",
"from",
"a",
"json",
"object",
"given",
"a",
"path",
"to",
"traverse",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/core/src/main/java/com/algolia/instantsearch/core/utils/JSONUtils.java#L33-L35
|
157,790
|
algolia/instantsearch-android
|
ui/src/main/java/com/algolia/instantsearch/ui/views/Hits.java
|
Hits.enableKeyboardAutoHiding
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public void enableKeyboardAutoHiding() {
keyboardListener = new OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dx != 0 || dy != 0) {
imeManager.hideSoftInputFromWindow(
Hits.this.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
super.onScrolled(recyclerView, dx, dy);
}
};
addOnScrollListener(keyboardListener);
}
|
java
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public void enableKeyboardAutoHiding() {
keyboardListener = new OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dx != 0 || dy != 0) {
imeManager.hideSoftInputFromWindow(
Hits.this.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
super.onScrolled(recyclerView, dx, dy);
}
};
addOnScrollListener(keyboardListener);
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"public",
"void",
"enableKeyboardAutoHiding",
"(",
")",
"{",
"keyboardListener",
"=",
"new",
"OnScrollListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onScrolled",
"(",
"RecyclerView",
"recyclerView",
",",
"int",
"dx",
",",
"int",
"dy",
")",
"{",
"if",
"(",
"dx",
"!=",
"0",
"||",
"dy",
"!=",
"0",
")",
"{",
"imeManager",
".",
"hideSoftInputFromWindow",
"(",
"Hits",
".",
"this",
".",
"getWindowToken",
"(",
")",
",",
"InputMethodManager",
".",
"HIDE_NOT_ALWAYS",
")",
";",
"}",
"super",
".",
"onScrolled",
"(",
"recyclerView",
",",
"dx",
",",
"dy",
")",
";",
"}",
"}",
";",
"addOnScrollListener",
"(",
"keyboardListener",
")",
";",
"}"
] |
Starts closing the keyboard when the hits are scrolled.
|
[
"Starts",
"closing",
"the",
"keyboard",
"when",
"the",
"hits",
"are",
"scrolled",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/views/Hits.java#L210-L224
|
157,791
|
algolia/instantsearch-android
|
ui/src/main/java/com/algolia/instantsearch/ui/helpers/InstantSearch.java
|
InstantSearch.search
|
public void search(String query) {
final Query newQuery = searcher.getQuery().setQuery(query);
searcher.setQuery(newQuery).search();
}
|
java
|
public void search(String query) {
final Query newQuery = searcher.getQuery().setQuery(query);
searcher.setQuery(newQuery).search();
}
|
[
"public",
"void",
"search",
"(",
"String",
"query",
")",
"{",
"final",
"Query",
"newQuery",
"=",
"searcher",
".",
"getQuery",
"(",
")",
".",
"setQuery",
"(",
"query",
")",
";",
"searcher",
".",
"setQuery",
"(",
"newQuery",
")",
".",
"search",
"(",
")",
";",
"}"
] |
Triggers a new search with the given text.
@param query the text to search for.
|
[
"Triggers",
"a",
"new",
"search",
"with",
"the",
"given",
"text",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/helpers/InstantSearch.java#L176-L179
|
157,792
|
algolia/instantsearch-android
|
ui/src/main/java/com/algolia/instantsearch/ui/helpers/InstantSearch.java
|
InstantSearch.registerFilters
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public void registerFilters(List<AlgoliaFilter> filters) {
for (final AlgoliaFilter filter : filters) {
searcher.addFacet(filter.getAttribute());
}
}
|
java
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public void registerFilters(List<AlgoliaFilter> filters) {
for (final AlgoliaFilter filter : filters) {
searcher.addFacet(filter.getAttribute());
}
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"public",
"void",
"registerFilters",
"(",
"List",
"<",
"AlgoliaFilter",
">",
"filters",
")",
"{",
"for",
"(",
"final",
"AlgoliaFilter",
"filter",
":",
"filters",
")",
"{",
"searcher",
".",
"addFacet",
"(",
"filter",
".",
"getAttribute",
"(",
")",
")",
";",
"}",
"}"
] |
Registers your facet filters, adding them to this InstantSearch's widgets.
@param filters a List of facet filters.
|
[
"Registers",
"your",
"facet",
"filters",
"adding",
"them",
"to",
"this",
"InstantSearch",
"s",
"widgets",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/helpers/InstantSearch.java#L324-L329
|
157,793
|
algolia/instantsearch-android
|
ui/src/main/java/com/algolia/instantsearch/ui/helpers/InstantSearch.java
|
InstantSearch.registerWidget
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public void registerWidget(View widget) {
prepareWidget(widget);
if (widget instanceof AlgoliaResultsListener) {
AlgoliaResultsListener listener = (AlgoliaResultsListener) widget;
if (!this.resultListeners.contains(listener)) {
this.resultListeners.add(listener);
}
searcher.registerResultListener(listener);
}
if (widget instanceof AlgoliaErrorListener) {
AlgoliaErrorListener listener = (AlgoliaErrorListener) widget;
if (!this.errorListeners.contains(listener)) {
this.errorListeners.add(listener);
}
searcher.registerErrorListener(listener);
}
if (widget instanceof AlgoliaSearcherListener) {
AlgoliaSearcherListener listener = (AlgoliaSearcherListener) widget;
listener.initWithSearcher(searcher);
}
}
|
java
|
@SuppressWarnings({"WeakerAccess", "unused"}) // For library users
public void registerWidget(View widget) {
prepareWidget(widget);
if (widget instanceof AlgoliaResultsListener) {
AlgoliaResultsListener listener = (AlgoliaResultsListener) widget;
if (!this.resultListeners.contains(listener)) {
this.resultListeners.add(listener);
}
searcher.registerResultListener(listener);
}
if (widget instanceof AlgoliaErrorListener) {
AlgoliaErrorListener listener = (AlgoliaErrorListener) widget;
if (!this.errorListeners.contains(listener)) {
this.errorListeners.add(listener);
}
searcher.registerErrorListener(listener);
}
if (widget instanceof AlgoliaSearcherListener) {
AlgoliaSearcherListener listener = (AlgoliaSearcherListener) widget;
listener.initWithSearcher(searcher);
}
}
|
[
"@",
"SuppressWarnings",
"(",
"{",
"\"WeakerAccess\"",
",",
"\"unused\"",
"}",
")",
"// For library users",
"public",
"void",
"registerWidget",
"(",
"View",
"widget",
")",
"{",
"prepareWidget",
"(",
"widget",
")",
";",
"if",
"(",
"widget",
"instanceof",
"AlgoliaResultsListener",
")",
"{",
"AlgoliaResultsListener",
"listener",
"=",
"(",
"AlgoliaResultsListener",
")",
"widget",
";",
"if",
"(",
"!",
"this",
".",
"resultListeners",
".",
"contains",
"(",
"listener",
")",
")",
"{",
"this",
".",
"resultListeners",
".",
"add",
"(",
"listener",
")",
";",
"}",
"searcher",
".",
"registerResultListener",
"(",
"listener",
")",
";",
"}",
"if",
"(",
"widget",
"instanceof",
"AlgoliaErrorListener",
")",
"{",
"AlgoliaErrorListener",
"listener",
"=",
"(",
"AlgoliaErrorListener",
")",
"widget",
";",
"if",
"(",
"!",
"this",
".",
"errorListeners",
".",
"contains",
"(",
"listener",
")",
")",
"{",
"this",
".",
"errorListeners",
".",
"add",
"(",
"listener",
")",
";",
"}",
"searcher",
".",
"registerErrorListener",
"(",
"listener",
")",
";",
"}",
"if",
"(",
"widget",
"instanceof",
"AlgoliaSearcherListener",
")",
"{",
"AlgoliaSearcherListener",
"listener",
"=",
"(",
"AlgoliaSearcherListener",
")",
"widget",
";",
"listener",
".",
"initWithSearcher",
"(",
"searcher",
")",
";",
"}",
"}"
] |
Links the given widget to InstantSearch according to the interfaces it implements.
@param widget a widget implementing ({@link AlgoliaResultsListener} || {@link AlgoliaErrorListener} || {@link AlgoliaSearcherListener}).
|
[
"Links",
"the",
"given",
"widget",
"to",
"InstantSearch",
"according",
"to",
"the",
"interfaces",
"it",
"implements",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/helpers/InstantSearch.java#L365-L387
|
157,794
|
algolia/instantsearch-android
|
ui/src/main/java/com/algolia/instantsearch/ui/helpers/InstantSearch.java
|
InstantSearch.processAllListeners
|
private List<String> processAllListeners(View rootView) {
List<String> refinementAttributes = new ArrayList<>();
// Register any AlgoliaResultsListener (unless it has a different variant than searcher)
final List<AlgoliaResultsListener> resultListeners = LayoutViews.findByClass((ViewGroup) rootView, AlgoliaResultsListener.class);
if (resultListeners.isEmpty()) {
throw new IllegalStateException(Errors.LAYOUT_MISSING_RESULT_LISTENER);
}
for (AlgoliaResultsListener listener : resultListeners) {
if (!this.resultListeners.contains(listener)) {
final String variant = BindingHelper.getVariantForView((View) listener);
if (variant == null || searcher.variant.equals(variant)) {
this.resultListeners.add(listener);
searcher.registerResultListener(listener);
prepareWidget(listener, refinementAttributes);
}
}
}
// Register any AlgoliaErrorListener (unless it has a different variant than searcher)
final List<AlgoliaErrorListener> errorListeners = LayoutViews.findByClass((ViewGroup) rootView, AlgoliaErrorListener.class);
for (AlgoliaErrorListener listener : errorListeners) {
if (!this.errorListeners.contains(listener)) {
final String variant = BindingHelper.getVariantForView((View) listener);
if (variant == null || searcher.variant.equals(variant)) {
this.errorListeners.add(listener);
}
}
searcher.registerErrorListener(listener);
prepareWidget(listener, refinementAttributes);
}
// Register any AlgoliaSearcherListener (unless it has a different variant than searcher)
final List<AlgoliaSearcherListener> searcherListeners = LayoutViews.findByClass((ViewGroup) rootView, AlgoliaSearcherListener.class);
for (AlgoliaSearcherListener listener : searcherListeners) {
final String variant = BindingHelper.getVariantForView((View) listener);
if (variant == null || searcher.variant.equals(variant)) {
listener.initWithSearcher(searcher);
prepareWidget(listener, refinementAttributes);
}
}
return refinementAttributes;
}
|
java
|
private List<String> processAllListeners(View rootView) {
List<String> refinementAttributes = new ArrayList<>();
// Register any AlgoliaResultsListener (unless it has a different variant than searcher)
final List<AlgoliaResultsListener> resultListeners = LayoutViews.findByClass((ViewGroup) rootView, AlgoliaResultsListener.class);
if (resultListeners.isEmpty()) {
throw new IllegalStateException(Errors.LAYOUT_MISSING_RESULT_LISTENER);
}
for (AlgoliaResultsListener listener : resultListeners) {
if (!this.resultListeners.contains(listener)) {
final String variant = BindingHelper.getVariantForView((View) listener);
if (variant == null || searcher.variant.equals(variant)) {
this.resultListeners.add(listener);
searcher.registerResultListener(listener);
prepareWidget(listener, refinementAttributes);
}
}
}
// Register any AlgoliaErrorListener (unless it has a different variant than searcher)
final List<AlgoliaErrorListener> errorListeners = LayoutViews.findByClass((ViewGroup) rootView, AlgoliaErrorListener.class);
for (AlgoliaErrorListener listener : errorListeners) {
if (!this.errorListeners.contains(listener)) {
final String variant = BindingHelper.getVariantForView((View) listener);
if (variant == null || searcher.variant.equals(variant)) {
this.errorListeners.add(listener);
}
}
searcher.registerErrorListener(listener);
prepareWidget(listener, refinementAttributes);
}
// Register any AlgoliaSearcherListener (unless it has a different variant than searcher)
final List<AlgoliaSearcherListener> searcherListeners = LayoutViews.findByClass((ViewGroup) rootView, AlgoliaSearcherListener.class);
for (AlgoliaSearcherListener listener : searcherListeners) {
final String variant = BindingHelper.getVariantForView((View) listener);
if (variant == null || searcher.variant.equals(variant)) {
listener.initWithSearcher(searcher);
prepareWidget(listener, refinementAttributes);
}
}
return refinementAttributes;
}
|
[
"private",
"List",
"<",
"String",
">",
"processAllListeners",
"(",
"View",
"rootView",
")",
"{",
"List",
"<",
"String",
">",
"refinementAttributes",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// Register any AlgoliaResultsListener (unless it has a different variant than searcher)",
"final",
"List",
"<",
"AlgoliaResultsListener",
">",
"resultListeners",
"=",
"LayoutViews",
".",
"findByClass",
"(",
"(",
"ViewGroup",
")",
"rootView",
",",
"AlgoliaResultsListener",
".",
"class",
")",
";",
"if",
"(",
"resultListeners",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"Errors",
".",
"LAYOUT_MISSING_RESULT_LISTENER",
")",
";",
"}",
"for",
"(",
"AlgoliaResultsListener",
"listener",
":",
"resultListeners",
")",
"{",
"if",
"(",
"!",
"this",
".",
"resultListeners",
".",
"contains",
"(",
"listener",
")",
")",
"{",
"final",
"String",
"variant",
"=",
"BindingHelper",
".",
"getVariantForView",
"(",
"(",
"View",
")",
"listener",
")",
";",
"if",
"(",
"variant",
"==",
"null",
"||",
"searcher",
".",
"variant",
".",
"equals",
"(",
"variant",
")",
")",
"{",
"this",
".",
"resultListeners",
".",
"add",
"(",
"listener",
")",
";",
"searcher",
".",
"registerResultListener",
"(",
"listener",
")",
";",
"prepareWidget",
"(",
"listener",
",",
"refinementAttributes",
")",
";",
"}",
"}",
"}",
"// Register any AlgoliaErrorListener (unless it has a different variant than searcher)",
"final",
"List",
"<",
"AlgoliaErrorListener",
">",
"errorListeners",
"=",
"LayoutViews",
".",
"findByClass",
"(",
"(",
"ViewGroup",
")",
"rootView",
",",
"AlgoliaErrorListener",
".",
"class",
")",
";",
"for",
"(",
"AlgoliaErrorListener",
"listener",
":",
"errorListeners",
")",
"{",
"if",
"(",
"!",
"this",
".",
"errorListeners",
".",
"contains",
"(",
"listener",
")",
")",
"{",
"final",
"String",
"variant",
"=",
"BindingHelper",
".",
"getVariantForView",
"(",
"(",
"View",
")",
"listener",
")",
";",
"if",
"(",
"variant",
"==",
"null",
"||",
"searcher",
".",
"variant",
".",
"equals",
"(",
"variant",
")",
")",
"{",
"this",
".",
"errorListeners",
".",
"add",
"(",
"listener",
")",
";",
"}",
"}",
"searcher",
".",
"registerErrorListener",
"(",
"listener",
")",
";",
"prepareWidget",
"(",
"listener",
",",
"refinementAttributes",
")",
";",
"}",
"// Register any AlgoliaSearcherListener (unless it has a different variant than searcher)",
"final",
"List",
"<",
"AlgoliaSearcherListener",
">",
"searcherListeners",
"=",
"LayoutViews",
".",
"findByClass",
"(",
"(",
"ViewGroup",
")",
"rootView",
",",
"AlgoliaSearcherListener",
".",
"class",
")",
";",
"for",
"(",
"AlgoliaSearcherListener",
"listener",
":",
"searcherListeners",
")",
"{",
"final",
"String",
"variant",
"=",
"BindingHelper",
".",
"getVariantForView",
"(",
"(",
"View",
")",
"listener",
")",
";",
"if",
"(",
"variant",
"==",
"null",
"||",
"searcher",
".",
"variant",
".",
"equals",
"(",
"variant",
")",
")",
"{",
"listener",
".",
"initWithSearcher",
"(",
"searcher",
")",
";",
"prepareWidget",
"(",
"listener",
",",
"refinementAttributes",
")",
";",
"}",
"}",
"return",
"refinementAttributes",
";",
"}"
] |
Finds and sets up the Listeners in the given rootView.
@param rootView a View to traverse looking for listeners.
@return the list of refinement attributes found on listeners.
|
[
"Finds",
"and",
"sets",
"up",
"the",
"Listeners",
"in",
"the",
"given",
"rootView",
"."
] |
12092ec30140df9ffc2bf916339b433372034616
|
https://github.com/algolia/instantsearch-android/blob/12092ec30140df9ffc2bf916339b433372034616/ui/src/main/java/com/algolia/instantsearch/ui/helpers/InstantSearch.java#L395-L438
|
157,795
|
uwolfer/gerrit-rest-java-client
|
src/main/java/com/urswolfer/gerrit/client/rest/http/accounts/AccountsRestClient.java
|
AccountsRestClient.suggestAccounts
|
@Override
public SuggestAccountsRequest suggestAccounts() throws RestApiException {
return new SuggestAccountsRequest() {
@Override
public List<AccountInfo> get() throws RestApiException {
return AccountsRestClient.this.suggestAccounts(this);
}
};
}
|
java
|
@Override
public SuggestAccountsRequest suggestAccounts() throws RestApiException {
return new SuggestAccountsRequest() {
@Override
public List<AccountInfo> get() throws RestApiException {
return AccountsRestClient.this.suggestAccounts(this);
}
};
}
|
[
"@",
"Override",
"public",
"SuggestAccountsRequest",
"suggestAccounts",
"(",
")",
"throws",
"RestApiException",
"{",
"return",
"new",
"SuggestAccountsRequest",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"AccountInfo",
">",
"get",
"(",
")",
"throws",
"RestApiException",
"{",
"return",
"AccountsRestClient",
".",
"this",
".",
"suggestAccounts",
"(",
"this",
")",
";",
"}",
"}",
";",
"}"
] |
Added in Gerrit 2.11.
|
[
"Added",
"in",
"Gerrit",
"2",
".",
"11",
"."
] |
fa66cd76270cd12cff9e30e0d96826fe0253d209
|
https://github.com/uwolfer/gerrit-rest-java-client/blob/fa66cd76270cd12cff9e30e0d96826fe0253d209/src/main/java/com/urswolfer/gerrit/client/rest/http/accounts/AccountsRestClient.java#L60-L68
|
157,796
|
uwolfer/gerrit-rest-java-client
|
src/main/java/com/google/gerrit/extensions/restapi/Url.java
|
Url.encode
|
public static String encode(String component) {
if (component != null) {
try {
return URLEncoder.encode(component, UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("JVM must support UTF-8", e);
}
}
return null;
}
|
java
|
public static String encode(String component) {
if (component != null) {
try {
return URLEncoder.encode(component, UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("JVM must support UTF-8", e);
}
}
return null;
}
|
[
"public",
"static",
"String",
"encode",
"(",
"String",
"component",
")",
"{",
"if",
"(",
"component",
"!=",
"null",
")",
"{",
"try",
"{",
"return",
"URLEncoder",
".",
"encode",
"(",
"component",
",",
"UTF_8",
".",
"name",
"(",
")",
")",
";",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"JVM must support UTF-8\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Encode a path segment, escaping characters not valid for a URL.
<p>The following characters are not escaped:
<ul>
<li>{@code a..z, A..Z, 0..9}
<li>{@code . - * _}
</ul>
<p>' ' (space) is encoded as '+'.
<p>All other characters (including '/') are converted to the triplet "%xy" where "xy" is the
hex representation of the character in UTF-8.
@param component a string containing text to encode.
@return a string with all invalid URL characters escaped.
|
[
"Encode",
"a",
"path",
"segment",
"escaping",
"characters",
"not",
"valid",
"for",
"a",
"URL",
"."
] |
fa66cd76270cd12cff9e30e0d96826fe0253d209
|
https://github.com/uwolfer/gerrit-rest-java-client/blob/fa66cd76270cd12cff9e30e0d96826fe0253d209/src/main/java/com/google/gerrit/extensions/restapi/Url.java#L43-L52
|
157,797
|
uwolfer/gerrit-rest-java-client
|
src/main/java/com/urswolfer/gerrit/client/rest/http/GerritRestClient.java
|
GerritRestClient.getXsrfFromHtmlBody
|
private Optional<String> getXsrfFromHtmlBody(HttpResponse loginResponse) throws IOException {
Optional<Cookie> gerritAccountCookie = findGerritAccountCookie();
if (gerritAccountCookie.isPresent()) {
Matcher matcher = GERRIT_AUTH_PATTERN.matcher(EntityUtils.toString(loginResponse.getEntity(), Consts.UTF_8));
if (matcher.find()) {
return Optional.of(matcher.group(1));
}
}
return Optional.absent();
}
|
java
|
private Optional<String> getXsrfFromHtmlBody(HttpResponse loginResponse) throws IOException {
Optional<Cookie> gerritAccountCookie = findGerritAccountCookie();
if (gerritAccountCookie.isPresent()) {
Matcher matcher = GERRIT_AUTH_PATTERN.matcher(EntityUtils.toString(loginResponse.getEntity(), Consts.UTF_8));
if (matcher.find()) {
return Optional.of(matcher.group(1));
}
}
return Optional.absent();
}
|
[
"private",
"Optional",
"<",
"String",
">",
"getXsrfFromHtmlBody",
"(",
"HttpResponse",
"loginResponse",
")",
"throws",
"IOException",
"{",
"Optional",
"<",
"Cookie",
">",
"gerritAccountCookie",
"=",
"findGerritAccountCookie",
"(",
")",
";",
"if",
"(",
"gerritAccountCookie",
".",
"isPresent",
"(",
")",
")",
"{",
"Matcher",
"matcher",
"=",
"GERRIT_AUTH_PATTERN",
".",
"matcher",
"(",
"EntityUtils",
".",
"toString",
"(",
"loginResponse",
".",
"getEntity",
"(",
")",
",",
"Consts",
".",
"UTF_8",
")",
")",
";",
"if",
"(",
"matcher",
".",
"find",
"(",
")",
")",
"{",
"return",
"Optional",
".",
"of",
"(",
"matcher",
".",
"group",
"(",
"1",
")",
")",
";",
"}",
"}",
"return",
"Optional",
".",
"absent",
"(",
")",
";",
"}"
] |
In Gerrit < 2.12 the XSRF token was included in the start page HTML.
|
[
"In",
"Gerrit",
"<",
"2",
".",
"12",
"the",
"XSRF",
"token",
"was",
"included",
"in",
"the",
"start",
"page",
"HTML",
"."
] |
fa66cd76270cd12cff9e30e0d96826fe0253d209
|
https://github.com/uwolfer/gerrit-rest-java-client/blob/fa66cd76270cd12cff9e30e0d96826fe0253d209/src/main/java/com/urswolfer/gerrit/client/rest/http/GerritRestClient.java#L361-L370
|
157,798
|
uwolfer/gerrit-rest-java-client
|
src/main/java/com/urswolfer/gerrit/client/rest/http/GerritRestClient.java
|
GerritRestClient.getCredentialsProvider
|
private BasicCredentialsProvider getCredentialsProvider() {
return new BasicCredentialsProvider() {
private Set<AuthScope> authAlreadyTried = Sets.newHashSet();
@Override
public Credentials getCredentials(AuthScope authscope) {
if (authAlreadyTried.contains(authscope)) {
return null;
}
authAlreadyTried.add(authscope);
return super.getCredentials(authscope);
}
};
}
|
java
|
private BasicCredentialsProvider getCredentialsProvider() {
return new BasicCredentialsProvider() {
private Set<AuthScope> authAlreadyTried = Sets.newHashSet();
@Override
public Credentials getCredentials(AuthScope authscope) {
if (authAlreadyTried.contains(authscope)) {
return null;
}
authAlreadyTried.add(authscope);
return super.getCredentials(authscope);
}
};
}
|
[
"private",
"BasicCredentialsProvider",
"getCredentialsProvider",
"(",
")",
"{",
"return",
"new",
"BasicCredentialsProvider",
"(",
")",
"{",
"private",
"Set",
"<",
"AuthScope",
">",
"authAlreadyTried",
"=",
"Sets",
".",
"newHashSet",
"(",
")",
";",
"@",
"Override",
"public",
"Credentials",
"getCredentials",
"(",
"AuthScope",
"authscope",
")",
"{",
"if",
"(",
"authAlreadyTried",
".",
"contains",
"(",
"authscope",
")",
")",
"{",
"return",
"null",
";",
"}",
"authAlreadyTried",
".",
"add",
"(",
"authscope",
")",
";",
"return",
"super",
".",
"getCredentials",
"(",
"authscope",
")",
";",
"}",
"}",
";",
"}"
] |
With this impl, it only returns the same credentials once. Otherwise it's possible that a loop will occur.
When server returns status code 401, the HTTP client provides the same credentials forever.
Since we create a new HTTP client for every request, we can handle it this way.
|
[
"With",
"this",
"impl",
"it",
"only",
"returns",
"the",
"same",
"credentials",
"once",
".",
"Otherwise",
"it",
"s",
"possible",
"that",
"a",
"loop",
"will",
"occur",
".",
"When",
"server",
"returns",
"status",
"code",
"401",
"the",
"HTTP",
"client",
"provides",
"the",
"same",
"credentials",
"forever",
".",
"Since",
"we",
"create",
"a",
"new",
"HTTP",
"client",
"for",
"every",
"request",
"we",
"can",
"handle",
"it",
"this",
"way",
"."
] |
fa66cd76270cd12cff9e30e0d96826fe0253d209
|
https://github.com/uwolfer/gerrit-rest-java-client/blob/fa66cd76270cd12cff9e30e0d96826fe0253d209/src/main/java/com/urswolfer/gerrit/client/rest/http/GerritRestClient.java#L429-L442
|
157,799
|
uwolfer/gerrit-rest-java-client
|
src/main/java/com/google/gerrit/extensions/restapi/BinaryResult.java
|
BinaryResult.asString
|
public String asString() throws IOException {
long len = getContentLength();
ByteArrayOutputStream buf;
if (0 < len) {
buf = new ByteArrayOutputStream((int) len);
} else {
buf = new ByteArrayOutputStream();
}
writeTo(buf);
return decode(buf.toByteArray(), getCharacterEncoding());
}
|
java
|
public String asString() throws IOException {
long len = getContentLength();
ByteArrayOutputStream buf;
if (0 < len) {
buf = new ByteArrayOutputStream((int) len);
} else {
buf = new ByteArrayOutputStream();
}
writeTo(buf);
return decode(buf.toByteArray(), getCharacterEncoding());
}
|
[
"public",
"String",
"asString",
"(",
")",
"throws",
"IOException",
"{",
"long",
"len",
"=",
"getContentLength",
"(",
")",
";",
"ByteArrayOutputStream",
"buf",
";",
"if",
"(",
"0",
"<",
"len",
")",
"{",
"buf",
"=",
"new",
"ByteArrayOutputStream",
"(",
"(",
"int",
")",
"len",
")",
";",
"}",
"else",
"{",
"buf",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"}",
"writeTo",
"(",
"buf",
")",
";",
"return",
"decode",
"(",
"buf",
".",
"toByteArray",
"(",
")",
",",
"getCharacterEncoding",
"(",
")",
")",
";",
"}"
] |
Return a copy of the result as a String.
<p>The default version of this method copies the result into a temporary byte array and then
tries to decode it using the configured encoding.
@return string version of the result.
@throws IOException if the data cannot be produced or could not be decoded to a String.
|
[
"Return",
"a",
"copy",
"of",
"the",
"result",
"as",
"a",
"String",
"."
] |
fa66cd76270cd12cff9e30e0d96826fe0253d209
|
https://github.com/uwolfer/gerrit-rest-java-client/blob/fa66cd76270cd12cff9e30e0d96826fe0253d209/src/main/java/com/google/gerrit/extensions/restapi/BinaryResult.java#L154-L164
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.