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
partition
stringclasses
1 value
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", ".", "BASELIN...
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", "...
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1639-L1652
train
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_...
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", "ba...
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1691-L1704
train
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", "(", ...
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", "co...
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1841-L1855
train
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", ...
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",...
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L1875-L1891
train
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
train
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", "=", "getDur...
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
train
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
train
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", "=", "getDur...
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
train
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", "=", "ge...
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
train
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
train
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", ")", ",", "val...
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
train
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
train
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", "==",...
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
train
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
train
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
train
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
train
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", ...
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
train
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_...
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
train
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", "(", ")", ";...
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
train
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", ">", "prede...
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", "ti...
143ea0e195da59cd108f13b3b06328e9542337e8
https://github.com/joniles/mpxj/blob/143ea0e195da59cd108f13b3b06328e9542337e8/src/main/java/net/sf/mpxj/Task.java#L4589-L4635
train
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",...
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
train
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", ...
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
train
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", ",", ...
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
train
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", ")", ";", "}", ...
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
train
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", "(", ")", ")", ";", "retu...
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
train
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", ")", ...
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
train
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", "suppo...
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
train
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", "supp...
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
train
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", ")", ";", "}"...
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
train
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", ".", ...
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
train
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", "(",...
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
train
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", "=", ...
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
train
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", "(", "i...
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
train
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", "...
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
train
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", ...
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
train
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", ")", "{", "facetR...
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
train
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_G...
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
train
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",...
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
train
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
train
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", "...
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
train
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
train
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", ":", "fi...
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
train
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", "Algolia...
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
train
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 ...
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
train
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", ...
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
train
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", "(", ")", ")", ";", "}", "ca...
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
train
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", "(", "gerritAccount...
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
train
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",...
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", "provi...
fa66cd76270cd12cff9e30e0d96826fe0253d209
https://github.com/uwolfer/gerrit-rest-java-client/blob/fa66cd76270cd12cff9e30e0d96826fe0253d209/src/main/java/com/urswolfer/gerrit/client/rest/http/GerritRestClient.java#L429-L442
train
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", "(", "(", ...
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
train
uwolfer/gerrit-rest-java-client
src/main/java/com/urswolfer/gerrit/client/rest/http/PreemptiveAuthHttpRequestInterceptor.java
PreemptiveAuthHttpRequestInterceptor.isForGerritHost
private boolean isForGerritHost(HttpRequest request) { if (!(request instanceof HttpRequestWrapper)) return false; HttpRequest originalRequest = ((HttpRequestWrapper) request).getOriginal(); if (!(originalRequest instanceof HttpRequestBase)) return false; URI uri = ((HttpRequestBase) originalRequest).getURI(); URI authDataUri = URI.create(authData.getHost()); if (uri == null || uri.getHost() == null) return false; boolean hostEquals = uri.getHost().equals(authDataUri.getHost()); boolean portEquals = uri.getPort() == authDataUri.getPort(); return hostEquals && portEquals; }
java
private boolean isForGerritHost(HttpRequest request) { if (!(request instanceof HttpRequestWrapper)) return false; HttpRequest originalRequest = ((HttpRequestWrapper) request).getOriginal(); if (!(originalRequest instanceof HttpRequestBase)) return false; URI uri = ((HttpRequestBase) originalRequest).getURI(); URI authDataUri = URI.create(authData.getHost()); if (uri == null || uri.getHost() == null) return false; boolean hostEquals = uri.getHost().equals(authDataUri.getHost()); boolean portEquals = uri.getPort() == authDataUri.getPort(); return hostEquals && portEquals; }
[ "private", "boolean", "isForGerritHost", "(", "HttpRequest", "request", ")", "{", "if", "(", "!", "(", "request", "instanceof", "HttpRequestWrapper", ")", ")", "return", "false", ";", "HttpRequest", "originalRequest", "=", "(", "(", "HttpRequestWrapper", ")", "r...
Checks if request is intended for Gerrit host.
[ "Checks", "if", "request", "is", "intended", "for", "Gerrit", "host", "." ]
fa66cd76270cd12cff9e30e0d96826fe0253d209
https://github.com/uwolfer/gerrit-rest-java-client/blob/fa66cd76270cd12cff9e30e0d96826fe0253d209/src/main/java/com/urswolfer/gerrit/client/rest/http/PreemptiveAuthHttpRequestInterceptor.java#L54-L64
train
cloudfoundry/cf-java-client
cloudfoundry-util/src/main/java/org/cloudfoundry/util/FileUtils.java
FileUtils.getRelativePathName
public static String getRelativePathName(Path root, Path path) { Path relative = root.relativize(path); return Files.isDirectory(path) && !relative.toString().endsWith("/") ? String.format("%s/", relative.toString()) : relative.toString(); }
java
public static String getRelativePathName(Path root, Path path) { Path relative = root.relativize(path); return Files.isDirectory(path) && !relative.toString().endsWith("/") ? String.format("%s/", relative.toString()) : relative.toString(); }
[ "public", "static", "String", "getRelativePathName", "(", "Path", "root", ",", "Path", "path", ")", "{", "Path", "relative", "=", "root", ".", "relativize", "(", "path", ")", ";", "return", "Files", ".", "isDirectory", "(", "path", ")", "&&", "!", "relat...
Get the relative path of an application @param root the root to relativize against @param path the path to relativize @return the relative path
[ "Get", "the", "relative", "path", "of", "an", "application" ]
caa1cb889cfe8717614c071703d833a1540784df
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/FileUtils.java#L108-L111
train
cloudfoundry/cf-java-client
cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/_DefaultConnectionContext.java
_DefaultConnectionContext.dispose
@PreDestroy public final void dispose() { getConnectionPool().ifPresent(PoolResources::dispose); getThreadPool().dispose(); try { ObjectName name = getByteBufAllocatorObjectName(); if (ManagementFactory.getPlatformMBeanServer().isRegistered(name)) { ManagementFactory.getPlatformMBeanServer().unregisterMBean(name); } } catch (JMException e) { this.logger.error("Unable to register ByteBufAllocator MBean", e); } }
java
@PreDestroy public final void dispose() { getConnectionPool().ifPresent(PoolResources::dispose); getThreadPool().dispose(); try { ObjectName name = getByteBufAllocatorObjectName(); if (ManagementFactory.getPlatformMBeanServer().isRegistered(name)) { ManagementFactory.getPlatformMBeanServer().unregisterMBean(name); } } catch (JMException e) { this.logger.error("Unable to register ByteBufAllocator MBean", e); } }
[ "@", "PreDestroy", "public", "final", "void", "dispose", "(", ")", "{", "getConnectionPool", "(", ")", ".", "ifPresent", "(", "PoolResources", "::", "dispose", ")", ";", "getThreadPool", "(", ")", ".", "dispose", "(", ")", ";", "try", "{", "ObjectName", ...
Disposes resources created to service this connection context
[ "Disposes", "resources", "created", "to", "service", "this", "connection", "context" ]
caa1cb889cfe8717614c071703d833a1540784df
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/_DefaultConnectionContext.java#L70-L84
train
cloudfoundry/cf-java-client
cloudfoundry-util/src/main/java/org/cloudfoundry/util/ResourceUtils.java
ResourceUtils.getEntity
public static <T, R extends Resource<T>> T getEntity(R resource) { return resource.getEntity(); }
java
public static <T, R extends Resource<T>> T getEntity(R resource) { return resource.getEntity(); }
[ "public", "static", "<", "T", ",", "R", "extends", "Resource", "<", "T", ">", ">", "T", "getEntity", "(", "R", "resource", ")", "{", "return", "resource", ".", "getEntity", "(", ")", ";", "}" ]
Return the entity of a resource @param resource the resource @param <T> the type of the resource's entity @param <R> the resource type @return the resource's entity
[ "Return", "the", "entity", "of", "a", "resource" ]
caa1cb889cfe8717614c071703d833a1540784df
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/ResourceUtils.java#L39-L41
train
cloudfoundry/cf-java-client
cloudfoundry-util/src/main/java/org/cloudfoundry/util/ResourceUtils.java
ResourceUtils.getResources
public static <R extends Resource<?>, U extends PaginatedResponse<R>> Flux<R> getResources(U response) { return Flux.fromIterable(response.getResources()); }
java
public static <R extends Resource<?>, U extends PaginatedResponse<R>> Flux<R> getResources(U response) { return Flux.fromIterable(response.getResources()); }
[ "public", "static", "<", "R", "extends", "Resource", "<", "?", ">", ",", "U", "extends", "PaginatedResponse", "<", "R", ">", ">", "Flux", "<", "R", ">", "getResources", "(", "U", "response", ")", "{", "return", "Flux", ".", "fromIterable", "(", "respon...
Return a stream of resources from a response @param response the response @param <R> the resource type @param <U> the response type @return a stream of resources from the response
[ "Return", "a", "stream", "of", "resources", "from", "a", "response" ]
caa1cb889cfe8717614c071703d833a1540784df
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/ResourceUtils.java#L61-L63
train
cloudfoundry/cf-java-client
cloudfoundry-util/src/main/java/org/cloudfoundry/util/JobUtils.java
JobUtils.waitForCompletion
public static Mono<Void> waitForCompletion(CloudFoundryClient cloudFoundryClient, Duration completionTimeout, String jobId) { return requestJobV3(cloudFoundryClient, jobId) .filter(job -> JobState.PROCESSING != job.getState()) .repeatWhenEmpty(exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15), completionTimeout)) .filter(job -> JobState.FAILED == job.getState()) .flatMap(JobUtils::getError); }
java
public static Mono<Void> waitForCompletion(CloudFoundryClient cloudFoundryClient, Duration completionTimeout, String jobId) { return requestJobV3(cloudFoundryClient, jobId) .filter(job -> JobState.PROCESSING != job.getState()) .repeatWhenEmpty(exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15), completionTimeout)) .filter(job -> JobState.FAILED == job.getState()) .flatMap(JobUtils::getError); }
[ "public", "static", "Mono", "<", "Void", ">", "waitForCompletion", "(", "CloudFoundryClient", "cloudFoundryClient", ",", "Duration", "completionTimeout", ",", "String", "jobId", ")", "{", "return", "requestJobV3", "(", "cloudFoundryClient", ",", "jobId", ")", ".", ...
Waits for a job V3 to complete @param cloudFoundryClient the client to use to request job status @param completionTimeout the amount of time to wait for the job to complete. @param jobId the id of the job @return {@code onComplete} once job has completed
[ "Waits", "for", "a", "job", "V3", "to", "complete" ]
caa1cb889cfe8717614c071703d833a1540784df
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/JobUtils.java#L93-L99
train
cloudfoundry/cf-java-client
cloudfoundry-util/src/main/java/org/cloudfoundry/util/TimeUtils.java
TimeUtils.asTime
public static String asTime(long time) { if (time > HOUR) { return String.format("%.1f h", (time / HOUR)); } else if (time > MINUTE) { return String.format("%.1f m", (time / MINUTE)); } else if (time > SECOND) { return String.format("%.1f s", (time / SECOND)); } else { return String.format("%d ms", time); } }
java
public static String asTime(long time) { if (time > HOUR) { return String.format("%.1f h", (time / HOUR)); } else if (time > MINUTE) { return String.format("%.1f m", (time / MINUTE)); } else if (time > SECOND) { return String.format("%.1f s", (time / SECOND)); } else { return String.format("%d ms", time); } }
[ "public", "static", "String", "asTime", "(", "long", "time", ")", "{", "if", "(", "time", ">", "HOUR", ")", "{", "return", "String", ".", "format", "(", "\"%.1f h\"", ",", "(", "time", "/", "HOUR", ")", ")", ";", "}", "else", "if", "(", "time", "...
Renders a time period in human readable form @param time the time in milliseconds @return the time in human readable form
[ "Renders", "a", "time", "period", "in", "human", "readable", "form" ]
caa1cb889cfe8717614c071703d833a1540784df
https://github.com/cloudfoundry/cf-java-client/blob/caa1cb889cfe8717614c071703d833a1540784df/cloudfoundry-util/src/main/java/org/cloudfoundry/util/TimeUtils.java#L41-L51
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/View.java
View.buildMatcher
private ClassMatcher buildMatcher(String tagText) { // check there are at least @match <type> and a parameter String[] strings = StringUtil.tokenize(tagText); if (strings.length < 2) { System.err.println("Skipping uncomplete @match tag, type missing: " + tagText + " in view " + viewDoc); return null; } try { if (strings[0].equals("class")) { return new PatternMatcher(Pattern.compile(strings[1])); } else if (strings[0].equals("context")) { return new ContextMatcher(root, Pattern.compile(strings[1]), getGlobalOptions(), false); } else if (strings[0].equals("outgoingContext")) { return new ContextMatcher(root, Pattern.compile(strings[1]), getGlobalOptions(), false); } else if (strings[0].equals("interface")) { return new InterfaceMatcher(root, Pattern.compile(strings[1])); } else if (strings[0].equals("subclass")) { return new SubclassMatcher(root, Pattern.compile(strings[1])); } else { System.err.println("Skipping @match tag, unknown match type, in view " + viewDoc); } } catch (PatternSyntaxException pse) { System.err.println("Skipping @match tag due to invalid regular expression '" + tagText + "'" + " in view " + viewDoc); } catch (Exception e) { System.err.println("Skipping @match tag due to an internal error '" + tagText + "'" + " in view " + viewDoc); e.printStackTrace(); } return null; }
java
private ClassMatcher buildMatcher(String tagText) { // check there are at least @match <type> and a parameter String[] strings = StringUtil.tokenize(tagText); if (strings.length < 2) { System.err.println("Skipping uncomplete @match tag, type missing: " + tagText + " in view " + viewDoc); return null; } try { if (strings[0].equals("class")) { return new PatternMatcher(Pattern.compile(strings[1])); } else if (strings[0].equals("context")) { return new ContextMatcher(root, Pattern.compile(strings[1]), getGlobalOptions(), false); } else if (strings[0].equals("outgoingContext")) { return new ContextMatcher(root, Pattern.compile(strings[1]), getGlobalOptions(), false); } else if (strings[0].equals("interface")) { return new InterfaceMatcher(root, Pattern.compile(strings[1])); } else if (strings[0].equals("subclass")) { return new SubclassMatcher(root, Pattern.compile(strings[1])); } else { System.err.println("Skipping @match tag, unknown match type, in view " + viewDoc); } } catch (PatternSyntaxException pse) { System.err.println("Skipping @match tag due to invalid regular expression '" + tagText + "'" + " in view " + viewDoc); } catch (Exception e) { System.err.println("Skipping @match tag due to an internal error '" + tagText + "'" + " in view " + viewDoc); e.printStackTrace(); } return null; }
[ "private", "ClassMatcher", "buildMatcher", "(", "String", "tagText", ")", "{", "// check there are at least @match <type> and a parameter", "String", "[", "]", "strings", "=", "StringUtil", ".", "tokenize", "(", "tagText", ")", ";", "if", "(", "strings", ".", "lengt...
Factory method that builds the appropriate matcher for @match tags
[ "Factory", "method", "that", "builds", "the", "appropriate", "matcher", "for" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/View.java#L85-L118
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ContextMatcher.java
ContextMatcher.addToGraph
private void addToGraph(ClassDoc cd) { // avoid adding twice the same class, but don't rely on cg.getClassInfo // since there are other ways to add a classInfor than printing the class if (visited.contains(cd.toString())) return; visited.add(cd.toString()); cg.printClass(cd, false); cg.printRelations(cd); if (opt.inferRelationships) cg.printInferredRelations(cd); if (opt.inferDependencies) cg.printInferredDependencies(cd); }
java
private void addToGraph(ClassDoc cd) { // avoid adding twice the same class, but don't rely on cg.getClassInfo // since there are other ways to add a classInfor than printing the class if (visited.contains(cd.toString())) return; visited.add(cd.toString()); cg.printClass(cd, false); cg.printRelations(cd); if (opt.inferRelationships) cg.printInferredRelations(cd); if (opt.inferDependencies) cg.printInferredDependencies(cd); }
[ "private", "void", "addToGraph", "(", "ClassDoc", "cd", ")", "{", "// avoid adding twice the same class, but don't rely on cg.getClassInfo", "// since there are other ways to add a classInfor than printing the class", "if", "(", "visited", ".", "contains", "(", "cd", ".", "toStri...
Adds the specified class to the internal class graph along with its relations and dependencies, eventually inferring them, according to the Options specified for this matcher @param cd
[ "Adds", "the", "specified", "class", "to", "the", "internal", "class", "graph", "along", "with", "its", "relations", "and", "dependencies", "eventually", "inferring", "them", "according", "to", "the", "Options", "specified", "for", "this", "matcher" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ContextMatcher.java#L104-L117
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/UmlGraphDoc.java
UmlGraphDoc.optionLength
public static int optionLength(String option) { int result = Standard.optionLength(option); if (result != 0) return result; else return UmlGraph.optionLength(option); }
java
public static int optionLength(String option) { int result = Standard.optionLength(option); if (result != 0) return result; else return UmlGraph.optionLength(option); }
[ "public", "static", "int", "optionLength", "(", "String", "option", ")", "{", "int", "result", "=", "Standard", ".", "optionLength", "(", "option", ")", ";", "if", "(", "result", "!=", "0", ")", "return", "result", ";", "else", "return", "UmlGraph", ".",...
Option check, forwards options to the standard doclet, if that one refuses them, they are sent to UmlGraph
[ "Option", "check", "forwards", "options", "to", "the", "standard", "doclet", "if", "that", "one", "refuses", "them", "they", "are", "sent", "to", "UmlGraph" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L36-L42
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/UmlGraphDoc.java
UmlGraphDoc.start
public static boolean start(RootDoc root) { root.printNotice("UmlGraphDoc version " + Version.VERSION + ", running the standard doclet"); Standard.start(root); root.printNotice("UmlGraphDoc version " + Version.VERSION + ", altering javadocs"); try { String outputFolder = findOutputPath(root.options()); Options opt = UmlGraph.buildOptions(root); opt.setOptions(root.options()); // in javadoc enumerations are always printed opt.showEnumerations = true; opt.relativeLinksForSourcePackages = true; // enable strict matching for hide expressions opt.strictMatching = true; // root.printNotice(opt.toString()); generatePackageDiagrams(root, opt, outputFolder); generateContextDiagrams(root, opt, outputFolder); } catch(Throwable t) { root.printWarning("Error: " + t.toString()); t.printStackTrace(); return false; } return true; }
java
public static boolean start(RootDoc root) { root.printNotice("UmlGraphDoc version " + Version.VERSION + ", running the standard doclet"); Standard.start(root); root.printNotice("UmlGraphDoc version " + Version.VERSION + ", altering javadocs"); try { String outputFolder = findOutputPath(root.options()); Options opt = UmlGraph.buildOptions(root); opt.setOptions(root.options()); // in javadoc enumerations are always printed opt.showEnumerations = true; opt.relativeLinksForSourcePackages = true; // enable strict matching for hide expressions opt.strictMatching = true; // root.printNotice(opt.toString()); generatePackageDiagrams(root, opt, outputFolder); generateContextDiagrams(root, opt, outputFolder); } catch(Throwable t) { root.printWarning("Error: " + t.toString()); t.printStackTrace(); return false; } return true; }
[ "public", "static", "boolean", "start", "(", "RootDoc", "root", ")", "{", "root", ".", "printNotice", "(", "\"UmlGraphDoc version \"", "+", "Version", ".", "VERSION", "+", "\", running the standard doclet\"", ")", ";", "Standard", ".", "start", "(", "root", ")",...
Standard doclet entry point @param root @return
[ "Standard", "doclet", "entry", "point" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L49-L73
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/UmlGraphDoc.java
UmlGraphDoc.generateContextDiagrams
private static void generateContextDiagrams(RootDoc root, Options opt, String outputFolder) throws IOException { Set<ClassDoc> classDocs = new TreeSet<ClassDoc>(new Comparator<ClassDoc>() { public int compare(ClassDoc cd1, ClassDoc cd2) { return cd1.name().compareTo(cd2.name()); } }); for (ClassDoc classDoc : root.classes()) classDocs.add(classDoc); ContextView view = null; for (ClassDoc classDoc : classDocs) { try { if(view == null) view = new ContextView(outputFolder, classDoc, root, opt); else view.setContextCenter(classDoc); UmlGraph.buildGraph(root, view, classDoc); runGraphviz(opt.dotExecutable, outputFolder, classDoc.containingPackage().name(), classDoc.name(), root); alterHtmlDocs(opt, outputFolder, classDoc.containingPackage().name(), classDoc.name(), classDoc.name() + ".html", Pattern.compile(".*(Class|Interface|Enum) " + classDoc.name() + ".*") , root); } catch (Exception e) { throw new RuntimeException("Error generating " + classDoc.name(), e); } } }
java
private static void generateContextDiagrams(RootDoc root, Options opt, String outputFolder) throws IOException { Set<ClassDoc> classDocs = new TreeSet<ClassDoc>(new Comparator<ClassDoc>() { public int compare(ClassDoc cd1, ClassDoc cd2) { return cd1.name().compareTo(cd2.name()); } }); for (ClassDoc classDoc : root.classes()) classDocs.add(classDoc); ContextView view = null; for (ClassDoc classDoc : classDocs) { try { if(view == null) view = new ContextView(outputFolder, classDoc, root, opt); else view.setContextCenter(classDoc); UmlGraph.buildGraph(root, view, classDoc); runGraphviz(opt.dotExecutable, outputFolder, classDoc.containingPackage().name(), classDoc.name(), root); alterHtmlDocs(opt, outputFolder, classDoc.containingPackage().name(), classDoc.name(), classDoc.name() + ".html", Pattern.compile(".*(Class|Interface|Enum) " + classDoc.name() + ".*") , root); } catch (Exception e) { throw new RuntimeException("Error generating " + classDoc.name(), e); } } }
[ "private", "static", "void", "generateContextDiagrams", "(", "RootDoc", "root", ",", "Options", "opt", ",", "String", "outputFolder", ")", "throws", "IOException", "{", "Set", "<", "ClassDoc", ">", "classDocs", "=", "new", "TreeSet", "<", "ClassDoc", ">", "(",...
Generates the context diagram for a single class
[ "Generates", "the", "context", "diagram", "for", "a", "single", "class" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L106-L131
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/UmlGraphDoc.java
UmlGraphDoc.alterHtmlDocs
private static void alterHtmlDocs(Options opt, String outputFolder, String packageName, String className, String htmlFileName, Pattern insertPointPattern, RootDoc root) throws IOException { // setup files File output = new File(outputFolder, packageName.replace(".", "/")); File htmlFile = new File(output, htmlFileName); File alteredFile = new File(htmlFile.getAbsolutePath() + ".uml"); if (!htmlFile.exists()) { System.err.println("Expected file not found: " + htmlFile.getAbsolutePath()); return; } // parse & rewrite BufferedWriter writer = null; BufferedReader reader = null; boolean matched = false; try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(alteredFile), opt.outputEncoding)); reader = new BufferedReader(new InputStreamReader(new FileInputStream(htmlFile), opt.outputEncoding)); String line; while ((line = reader.readLine()) != null) { writer.write(line); writer.newLine(); if (!matched && insertPointPattern.matcher(line).matches()) { matched = true; String tag; if (opt.autoSize) tag = String.format(UML_AUTO_SIZED_DIV_TAG, className); else tag = String.format(UML_DIV_TAG, className); if (opt.collapsibleDiagrams) tag = String.format(EXPANDABLE_UML, tag, "Show UML class diagram", "Hide UML class diagram"); writer.write("<!-- UML diagram added by UMLGraph version " + Version.VERSION + " (http://www.spinellis.gr/umlgraph/) -->"); writer.newLine(); writer.write(tag); writer.newLine(); } } } finally { if (writer != null) writer.close(); if (reader != null) reader.close(); } // if altered, delete old file and rename new one to the old file name if (matched) { htmlFile.delete(); alteredFile.renameTo(htmlFile); } else { root.printNotice("Warning, could not find a line that matches the pattern '" + insertPointPattern.pattern() + "'.\n Class diagram reference not inserted"); alteredFile.delete(); } }
java
private static void alterHtmlDocs(Options opt, String outputFolder, String packageName, String className, String htmlFileName, Pattern insertPointPattern, RootDoc root) throws IOException { // setup files File output = new File(outputFolder, packageName.replace(".", "/")); File htmlFile = new File(output, htmlFileName); File alteredFile = new File(htmlFile.getAbsolutePath() + ".uml"); if (!htmlFile.exists()) { System.err.println("Expected file not found: " + htmlFile.getAbsolutePath()); return; } // parse & rewrite BufferedWriter writer = null; BufferedReader reader = null; boolean matched = false; try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(alteredFile), opt.outputEncoding)); reader = new BufferedReader(new InputStreamReader(new FileInputStream(htmlFile), opt.outputEncoding)); String line; while ((line = reader.readLine()) != null) { writer.write(line); writer.newLine(); if (!matched && insertPointPattern.matcher(line).matches()) { matched = true; String tag; if (opt.autoSize) tag = String.format(UML_AUTO_SIZED_DIV_TAG, className); else tag = String.format(UML_DIV_TAG, className); if (opt.collapsibleDiagrams) tag = String.format(EXPANDABLE_UML, tag, "Show UML class diagram", "Hide UML class diagram"); writer.write("<!-- UML diagram added by UMLGraph version " + Version.VERSION + " (http://www.spinellis.gr/umlgraph/) -->"); writer.newLine(); writer.write(tag); writer.newLine(); } } } finally { if (writer != null) writer.close(); if (reader != null) reader.close(); } // if altered, delete old file and rename new one to the old file name if (matched) { htmlFile.delete(); alteredFile.renameTo(htmlFile); } else { root.printNotice("Warning, could not find a line that matches the pattern '" + insertPointPattern.pattern() + "'.\n Class diagram reference not inserted"); alteredFile.delete(); } }
[ "private", "static", "void", "alterHtmlDocs", "(", "Options", "opt", ",", "String", "outputFolder", ",", "String", "packageName", ",", "String", "className", ",", "String", "htmlFileName", ",", "Pattern", "insertPointPattern", ",", "RootDoc", "root", ")", "throws"...
Takes an HTML file, looks for the first instance of the specified insertion point, and inserts the diagram image reference and a client side map in that point.
[ "Takes", "an", "HTML", "file", "looks", "for", "the", "first", "instance", "of", "the", "specified", "insertion", "point", "and", "inserts", "the", "diagram", "image", "reference", "and", "a", "client", "side", "map", "in", "that", "point", "." ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L199-L258
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/UmlGraphDoc.java
UmlGraphDoc.findOutputPath
private static String findOutputPath(String[][] options) { for (int i = 0; i < options.length; i++) { if (options[i][0].equals("-d")) return options[i][1]; } return "."; }
java
private static String findOutputPath(String[][] options) { for (int i = 0; i < options.length; i++) { if (options[i][0].equals("-d")) return options[i][1]; } return "."; }
[ "private", "static", "String", "findOutputPath", "(", "String", "[", "]", "[", "]", "options", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "options", ".", "length", ";", "i", "++", ")", "{", "if", "(", "options", "[", "i", "]", "...
Returns the output path specified on the javadoc options
[ "Returns", "the", "output", "path", "specified", "on", "the", "javadoc", "options" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/UmlGraphDoc.java#L263-L269
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/Options.java
Options.setAll
public void setAll() { showAttributes = true; showEnumerations = true; showEnumConstants = true; showOperations = true; showConstructors = true; showVisibility = true; showType = true; }
java
public void setAll() { showAttributes = true; showEnumerations = true; showEnumConstants = true; showOperations = true; showConstructors = true; showVisibility = true; showType = true; }
[ "public", "void", "setAll", "(", ")", "{", "showAttributes", "=", "true", ";", "showEnumerations", "=", "true", ";", "showEnumConstants", "=", "true", ";", "showOperations", "=", "true", ";", "showConstructors", "=", "true", ";", "showVisibility", "=", "true",...
Most complete output
[ "Most", "complete", "output" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/Options.java#L149-L157
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/Options.java
Options.optionLength
public static int optionLength(String option) { if(matchOption(option, "qualify", true) || matchOption(option, "qualifyGenerics", true) || matchOption(option, "hideGenerics", true) || matchOption(option, "horizontal", true) || matchOption(option, "all") || matchOption(option, "attributes", true) || matchOption(option, "enumconstants", true) || matchOption(option, "operations", true) || matchOption(option, "enumerations", true) || matchOption(option, "constructors", true) || matchOption(option, "visibility", true) || matchOption(option, "types", true) || matchOption(option, "autosize", true) || matchOption(option, "commentname", true) || matchOption(option, "nodefontabstractitalic", true) || matchOption(option, "postfixpackage", true) || matchOption(option, "noguillemot", true) || matchOption(option, "views", true) || matchOption(option, "inferrel", true) || matchOption(option, "useimports", true) || matchOption(option, "collapsible", true) || matchOption(option, "inferdep", true) || matchOption(option, "inferdepinpackage", true) || matchOption(option, "hideprivateinner", true) || matchOption(option, "compact", true)) return 1; else if(matchOption(option, "nodefillcolor") || matchOption(option, "nodefontcolor") || matchOption(option, "nodefontsize") || matchOption(option, "nodefontname") || matchOption(option, "nodefontclasssize") || matchOption(option, "nodefontclassname") || matchOption(option, "nodefonttagsize") || matchOption(option, "nodefonttagname") || matchOption(option, "nodefontpackagesize") || matchOption(option, "nodefontpackagename") || matchOption(option, "edgefontcolor") || matchOption(option, "edgecolor") || matchOption(option, "edgefontsize") || matchOption(option, "edgefontname") || matchOption(option, "shape") || matchOption(option, "output") || matchOption(option, "outputencoding") || matchOption(option, "bgcolor") || matchOption(option, "hide") || matchOption(option, "include") || matchOption(option, "apidocroot") || matchOption(option, "apidocmap") || matchOption(option, "d") || matchOption(option, "view") || matchOption(option, "inferreltype") || matchOption(option, "inferdepvis") || matchOption(option, "collpackages") || matchOption(option, "nodesep") || matchOption(option, "ranksep") || matchOption(option, "dotexecutable") || matchOption(option, "link")) return 2; else if(matchOption(option, "contextPattern") || matchOption(option, "linkoffline")) return 3; else return 0; }
java
public static int optionLength(String option) { if(matchOption(option, "qualify", true) || matchOption(option, "qualifyGenerics", true) || matchOption(option, "hideGenerics", true) || matchOption(option, "horizontal", true) || matchOption(option, "all") || matchOption(option, "attributes", true) || matchOption(option, "enumconstants", true) || matchOption(option, "operations", true) || matchOption(option, "enumerations", true) || matchOption(option, "constructors", true) || matchOption(option, "visibility", true) || matchOption(option, "types", true) || matchOption(option, "autosize", true) || matchOption(option, "commentname", true) || matchOption(option, "nodefontabstractitalic", true) || matchOption(option, "postfixpackage", true) || matchOption(option, "noguillemot", true) || matchOption(option, "views", true) || matchOption(option, "inferrel", true) || matchOption(option, "useimports", true) || matchOption(option, "collapsible", true) || matchOption(option, "inferdep", true) || matchOption(option, "inferdepinpackage", true) || matchOption(option, "hideprivateinner", true) || matchOption(option, "compact", true)) return 1; else if(matchOption(option, "nodefillcolor") || matchOption(option, "nodefontcolor") || matchOption(option, "nodefontsize") || matchOption(option, "nodefontname") || matchOption(option, "nodefontclasssize") || matchOption(option, "nodefontclassname") || matchOption(option, "nodefonttagsize") || matchOption(option, "nodefonttagname") || matchOption(option, "nodefontpackagesize") || matchOption(option, "nodefontpackagename") || matchOption(option, "edgefontcolor") || matchOption(option, "edgecolor") || matchOption(option, "edgefontsize") || matchOption(option, "edgefontname") || matchOption(option, "shape") || matchOption(option, "output") || matchOption(option, "outputencoding") || matchOption(option, "bgcolor") || matchOption(option, "hide") || matchOption(option, "include") || matchOption(option, "apidocroot") || matchOption(option, "apidocmap") || matchOption(option, "d") || matchOption(option, "view") || matchOption(option, "inferreltype") || matchOption(option, "inferdepvis") || matchOption(option, "collpackages") || matchOption(option, "nodesep") || matchOption(option, "ranksep") || matchOption(option, "dotexecutable") || matchOption(option, "link")) return 2; else if(matchOption(option, "contextPattern") || matchOption(option, "linkoffline")) return 3; else return 0; }
[ "public", "static", "int", "optionLength", "(", "String", "option", ")", "{", "if", "(", "matchOption", "(", "option", ",", "\"qualify\"", ",", "true", ")", "||", "matchOption", "(", "option", ",", "\"qualifyGenerics\"", ",", "true", ")", "||", "matchOption"...
Return the number of arguments associated with the specified option. The return value includes the actual option. Will return 0 if the option is not supported.
[ "Return", "the", "number", "of", "arguments", "associated", "with", "the", "specified", "option", ".", "The", "return", "value", "includes", "the", "actual", "option", ".", "Will", "return", "0", "if", "the", "option", "is", "not", "supported", "." ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/Options.java#L192-L257
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/Options.java
Options.addApiDocRoots
private void addApiDocRoots(String packageListUrl) { BufferedReader br = null; packageListUrl = fixApiDocRoot(packageListUrl); try { URL url = new URL(packageListUrl + "/package-list"); br = new BufferedReader(new InputStreamReader(url.openStream())); String line; while((line = br.readLine()) != null) { line = line + "."; Pattern pattern = Pattern.compile(line.replace(".", "\\.") + "[^\\.]*"); apiDocMap.put(pattern, packageListUrl); } } catch(IOException e) { System.err.println("Errors happened while accessing the package-list file at " + packageListUrl); } finally { if(br != null) try { br.close(); } catch (IOException e) {} } }
java
private void addApiDocRoots(String packageListUrl) { BufferedReader br = null; packageListUrl = fixApiDocRoot(packageListUrl); try { URL url = new URL(packageListUrl + "/package-list"); br = new BufferedReader(new InputStreamReader(url.openStream())); String line; while((line = br.readLine()) != null) { line = line + "."; Pattern pattern = Pattern.compile(line.replace(".", "\\.") + "[^\\.]*"); apiDocMap.put(pattern, packageListUrl); } } catch(IOException e) { System.err.println("Errors happened while accessing the package-list file at " + packageListUrl); } finally { if(br != null) try { br.close(); } catch (IOException e) {} } }
[ "private", "void", "addApiDocRoots", "(", "String", "packageListUrl", ")", "{", "BufferedReader", "br", "=", "null", ";", "packageListUrl", "=", "fixApiDocRoot", "(", "packageListUrl", ")", ";", "try", "{", "URL", "url", "=", "new", "URL", "(", "packageListUrl...
Adds api doc roots from a link. The folder reffered by the link should contain a package-list file that will be parsed in order to add api doc roots to this configuration @param packageListUrl
[ "Adds", "api", "doc", "roots", "from", "a", "link", ".", "The", "folder", "reffered", "by", "the", "link", "should", "contain", "a", "package", "-", "list", "file", "that", "will", "be", "parsed", "in", "order", "to", "add", "api", "doc", "roots", "to"...
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/Options.java#L459-L481
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/Options.java
Options.fixApiDocRoot
private String fixApiDocRoot(String str) { if (str == null) return null; String fixed = str.trim(); if (fixed.isEmpty()) return ""; if (File.separatorChar != '/') fixed = fixed.replace(File.separatorChar, '/'); if (!fixed.endsWith("/")) fixed = fixed + "/"; return fixed; }
java
private String fixApiDocRoot(String str) { if (str == null) return null; String fixed = str.trim(); if (fixed.isEmpty()) return ""; if (File.separatorChar != '/') fixed = fixed.replace(File.separatorChar, '/'); if (!fixed.endsWith("/")) fixed = fixed + "/"; return fixed; }
[ "private", "String", "fixApiDocRoot", "(", "String", "str", ")", "{", "if", "(", "str", "==", "null", ")", "return", "null", ";", "String", "fixed", "=", "str", ".", "trim", "(", ")", ";", "if", "(", "fixed", ".", "isEmpty", "(", ")", ")", "return"...
Trim and append a file separator to the string
[ "Trim", "and", "append", "a", "file", "separator", "to", "the", "string" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/Options.java#L564-L575
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/Options.java
Options.setOptions
public void setOptions(Doc p) { if (p == null) return; for (Tag tag : p.tags("opt")) setOption(StringUtil.tokenize(tag.text())); } /** * Check if the supplied string matches an entity specified * with the -hide parameter. * @return true if the string matches. */ public boolean matchesHideExpression(String s) { for (Pattern hidePattern : hidePatterns) { // micro-optimization because the "all pattern" is heavily used in UmlGraphDoc if(hidePattern == allPattern) return true; Matcher m = hidePattern.matcher(s); if (strictMatching ? m.matches() : m.find()) return true; } return false; } /** * Check if the supplied string matches an entity specified * with the -include parameter. * @return true if the string matches. */ public boolean matchesIncludeExpression(String s) { for (Pattern includePattern : includePatterns) { Matcher m = includePattern.matcher(s); if (strictMatching ? m.matches() : m.find()) return true; } return false; } /** * Check if the supplied string matches an entity specified * with the -collpackages parameter. * @return true if the string matches. */ public boolean matchesCollPackageExpression(String s) { for (Pattern collPattern : collPackages) { Matcher m = collPattern.matcher(s); if (strictMatching ? m.matches() : m.find()) return true; } return false; } // ---------------------------------------------------------------- // OptionProvider methods // ---------------------------------------------------------------- public Options getOptionsFor(ClassDoc cd) { Options localOpt = getGlobalOptions(); localOpt.setOptions(cd); return localOpt; } public Options getOptionsFor(String name) { return getGlobalOptions(); } public Options getGlobalOptions() { return (Options) clone(); } public void overrideForClass(Options opt, ClassDoc cd) { // nothing to do }
java
public void setOptions(Doc p) { if (p == null) return; for (Tag tag : p.tags("opt")) setOption(StringUtil.tokenize(tag.text())); } /** * Check if the supplied string matches an entity specified * with the -hide parameter. * @return true if the string matches. */ public boolean matchesHideExpression(String s) { for (Pattern hidePattern : hidePatterns) { // micro-optimization because the "all pattern" is heavily used in UmlGraphDoc if(hidePattern == allPattern) return true; Matcher m = hidePattern.matcher(s); if (strictMatching ? m.matches() : m.find()) return true; } return false; } /** * Check if the supplied string matches an entity specified * with the -include parameter. * @return true if the string matches. */ public boolean matchesIncludeExpression(String s) { for (Pattern includePattern : includePatterns) { Matcher m = includePattern.matcher(s); if (strictMatching ? m.matches() : m.find()) return true; } return false; } /** * Check if the supplied string matches an entity specified * with the -collpackages parameter. * @return true if the string matches. */ public boolean matchesCollPackageExpression(String s) { for (Pattern collPattern : collPackages) { Matcher m = collPattern.matcher(s); if (strictMatching ? m.matches() : m.find()) return true; } return false; } // ---------------------------------------------------------------- // OptionProvider methods // ---------------------------------------------------------------- public Options getOptionsFor(ClassDoc cd) { Options localOpt = getGlobalOptions(); localOpt.setOptions(cd); return localOpt; } public Options getOptionsFor(String name) { return getGlobalOptions(); } public Options getGlobalOptions() { return (Options) clone(); } public void overrideForClass(Options opt, ClassDoc cd) { // nothing to do }
[ "public", "void", "setOptions", "(", "Doc", "p", ")", "{", "if", "(", "p", "==", "null", ")", "return", ";", "for", "(", "Tag", "tag", ":", "p", ".", "tags", "(", "\"opt\"", ")", ")", "setOption", "(", "StringUtil", ".", "tokenize", "(", "tag", "...
Set the options based on the tag elements of the ClassDoc parameter
[ "Set", "the", "options", "based", "on", "the", "tag", "elements", "of", "the", "ClassDoc", "parameter" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/Options.java#L585-L659
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/RelationPattern.java
RelationPattern.addRelation
public void addRelation(RelationType relationType, RelationDirection direction) { int idx = relationType.ordinal(); directions[idx] = directions[idx].sum(direction); }
java
public void addRelation(RelationType relationType, RelationDirection direction) { int idx = relationType.ordinal(); directions[idx] = directions[idx].sum(direction); }
[ "public", "void", "addRelation", "(", "RelationType", "relationType", ",", "RelationDirection", "direction", ")", "{", "int", "idx", "=", "relationType", ".", "ordinal", "(", ")", ";", "directions", "[", "idx", "]", "=", "directions", "[", "idx", "]", ".", ...
Adds, eventually merging, a direction for the specified relation type @param relationType @param direction
[ "Adds", "eventually", "merging", "a", "direction", "for", "the", "specified", "relation", "type" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/RelationPattern.java#L30-L33
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.qualifiedName
private static String qualifiedName(Options opt, String r) { if (opt.hideGenerics) r = removeTemplate(r); // Fast path - nothing to do: if (opt.showQualified && (opt.showQualifiedGenerics || r.indexOf('<') < 0)) return r; StringBuilder buf = new StringBuilder(r.length()); qualifiedNameInner(opt, r, buf, 0, !opt.showQualified); return buf.toString(); }
java
private static String qualifiedName(Options opt, String r) { if (opt.hideGenerics) r = removeTemplate(r); // Fast path - nothing to do: if (opt.showQualified && (opt.showQualifiedGenerics || r.indexOf('<') < 0)) return r; StringBuilder buf = new StringBuilder(r.length()); qualifiedNameInner(opt, r, buf, 0, !opt.showQualified); return buf.toString(); }
[ "private", "static", "String", "qualifiedName", "(", "Options", "opt", ",", "String", "r", ")", "{", "if", "(", "opt", ".", "hideGenerics", ")", "r", "=", "removeTemplate", "(", "r", ")", ";", "// Fast path - nothing to do:", "if", "(", "opt", ".", "showQu...
Return the class's name, possibly by stripping the leading path
[ "Return", "the", "class", "s", "name", "possibly", "by", "stripping", "the", "leading", "path" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L136-L145
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.visibility
private String visibility(Options opt, ProgramElementDoc e) { return opt.showVisibility ? Visibility.get(e).symbol : " "; }
java
private String visibility(Options opt, ProgramElementDoc e) { return opt.showVisibility ? Visibility.get(e).symbol : " "; }
[ "private", "String", "visibility", "(", "Options", "opt", ",", "ProgramElementDoc", "e", ")", "{", "return", "opt", ".", "showVisibility", "?", "Visibility", ".", "get", "(", "e", ")", ".", "symbol", ":", "\" \"", ";", "}" ]
Print the visibility adornment of element e prefixed by any stereotypes
[ "Print", "the", "visibility", "adornment", "of", "element", "e", "prefixed", "by", "any", "stereotypes" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L177-L179
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.parameter
private String parameter(Options opt, Parameter p[]) { StringBuilder par = new StringBuilder(1000); for (int i = 0; i < p.length; i++) { par.append(p[i].name() + typeAnnotation(opt, p[i].type())); if (i + 1 < p.length) par.append(", "); } return par.toString(); }
java
private String parameter(Options opt, Parameter p[]) { StringBuilder par = new StringBuilder(1000); for (int i = 0; i < p.length; i++) { par.append(p[i].name() + typeAnnotation(opt, p[i].type())); if (i + 1 < p.length) par.append(", "); } return par.toString(); }
[ "private", "String", "parameter", "(", "Options", "opt", ",", "Parameter", "p", "[", "]", ")", "{", "StringBuilder", "par", "=", "new", "StringBuilder", "(", "1000", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ".", "length", ";"...
Print the method parameter p
[ "Print", "the", "method", "parameter", "p" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L182-L190
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.type
private String type(Options opt, Type t, boolean generics) { return ((generics ? opt.showQualifiedGenerics : opt.showQualified) ? // t.qualifiedTypeName() : t.typeName()) // + (opt.hideGenerics ? "" : typeParameters(opt, t.asParameterizedType())); }
java
private String type(Options opt, Type t, boolean generics) { return ((generics ? opt.showQualifiedGenerics : opt.showQualified) ? // t.qualifiedTypeName() : t.typeName()) // + (opt.hideGenerics ? "" : typeParameters(opt, t.asParameterizedType())); }
[ "private", "String", "type", "(", "Options", "opt", ",", "Type", "t", ",", "boolean", "generics", ")", "{", "return", "(", "(", "generics", "?", "opt", ".", "showQualifiedGenerics", ":", "opt", ".", "showQualified", ")", "?", "//", "t", ".", "qualifiedTy...
Print a a basic type t
[ "Print", "a", "a", "basic", "type", "t" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L193-L197
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.typeParameters
private String typeParameters(Options opt, ParameterizedType t) { if (t == null) return ""; StringBuffer tp = new StringBuffer(1000).append("&lt;"); Type args[] = t.typeArguments(); for (int i = 0; i < args.length; i++) { tp.append(type(opt, args[i], true)); if (i != args.length - 1) tp.append(", "); } return tp.append("&gt;").toString(); }
java
private String typeParameters(Options opt, ParameterizedType t) { if (t == null) return ""; StringBuffer tp = new StringBuffer(1000).append("&lt;"); Type args[] = t.typeArguments(); for (int i = 0; i < args.length; i++) { tp.append(type(opt, args[i], true)); if (i != args.length - 1) tp.append(", "); } return tp.append("&gt;").toString(); }
[ "private", "String", "typeParameters", "(", "Options", "opt", ",", "ParameterizedType", "t", ")", "{", "if", "(", "t", "==", "null", ")", "return", "\"\"", ";", "StringBuffer", "tp", "=", "new", "StringBuffer", "(", "1000", ")", ".", "append", "(", "\"&l...
Print the parameters of the parameterized type t
[ "Print", "the", "parameters", "of", "the", "parameterized", "type", "t" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L200-L211
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.attributes
private void attributes(Options opt, FieldDoc fd[]) { for (FieldDoc f : fd) { if (hidden(f)) continue; stereotype(opt, f, Align.LEFT); String att = visibility(opt, f) + f.name(); if (opt.showType) att += typeAnnotation(opt, f.type()); tableLine(Align.LEFT, att); tagvalue(opt, f); } }
java
private void attributes(Options opt, FieldDoc fd[]) { for (FieldDoc f : fd) { if (hidden(f)) continue; stereotype(opt, f, Align.LEFT); String att = visibility(opt, f) + f.name(); if (opt.showType) att += typeAnnotation(opt, f.type()); tableLine(Align.LEFT, att); tagvalue(opt, f); } }
[ "private", "void", "attributes", "(", "Options", "opt", ",", "FieldDoc", "fd", "[", "]", ")", "{", "for", "(", "FieldDoc", "f", ":", "fd", ")", "{", "if", "(", "hidden", "(", "f", ")", ")", "continue", ";", "stereotype", "(", "opt", ",", "f", ","...
Print the class's attributes fd
[ "Print", "the", "class", "s", "attributes", "fd" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L221-L232
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.operations
private boolean operations(Options opt, ConstructorDoc m[]) { boolean printed = false; for (ConstructorDoc cd : m) { if (hidden(cd)) continue; stereotype(opt, cd, Align.LEFT); String cs = visibility(opt, cd) + cd.name() // + (opt.showType ? "(" + parameter(opt, cd.parameters()) + ")" : "()"); tableLine(Align.LEFT, cs); tagvalue(opt, cd); printed = true; } return printed; }
java
private boolean operations(Options opt, ConstructorDoc m[]) { boolean printed = false; for (ConstructorDoc cd : m) { if (hidden(cd)) continue; stereotype(opt, cd, Align.LEFT); String cs = visibility(opt, cd) + cd.name() // + (opt.showType ? "(" + parameter(opt, cd.parameters()) + ")" : "()"); tableLine(Align.LEFT, cs); tagvalue(opt, cd); printed = true; } return printed; }
[ "private", "boolean", "operations", "(", "Options", "opt", ",", "ConstructorDoc", "m", "[", "]", ")", "{", "boolean", "printed", "=", "false", ";", "for", "(", "ConstructorDoc", "cd", ":", "m", ")", "{", "if", "(", "hidden", "(", "cd", ")", ")", "con...
Print the class's constructors m
[ "Print", "the", "class", "s", "constructors", "m" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L241-L254
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.operations
private boolean operations(Options opt, MethodDoc m[]) { boolean printed = false; for (MethodDoc md : m) { if (hidden(md)) continue; // Filter-out static initializer method if (md.name().equals("<clinit>") && md.isStatic() && md.isPackagePrivate()) continue; stereotype(opt, md, Align.LEFT); String op = visibility(opt, md) + md.name() + // (opt.showType ? "(" + parameter(opt, md.parameters()) + ")" + typeAnnotation(opt, md.returnType()) : "()"); tableLine(Align.LEFT, (md.isAbstract() ? Font.ABSTRACT : Font.NORMAL).wrap(opt, op)); printed = true; tagvalue(opt, md); } return printed; }
java
private boolean operations(Options opt, MethodDoc m[]) { boolean printed = false; for (MethodDoc md : m) { if (hidden(md)) continue; // Filter-out static initializer method if (md.name().equals("<clinit>") && md.isStatic() && md.isPackagePrivate()) continue; stereotype(opt, md, Align.LEFT); String op = visibility(opt, md) + md.name() + // (opt.showType ? "(" + parameter(opt, md.parameters()) + ")" + typeAnnotation(opt, md.returnType()) : "()"); tableLine(Align.LEFT, (md.isAbstract() ? Font.ABSTRACT : Font.NORMAL).wrap(opt, op)); printed = true; tagvalue(opt, md); } return printed; }
[ "private", "boolean", "operations", "(", "Options", "opt", ",", "MethodDoc", "m", "[", "]", ")", "{", "boolean", "printed", "=", "false", ";", "for", "(", "MethodDoc", "md", ":", "m", ")", "{", "if", "(", "hidden", "(", "md", ")", ")", "continue", ...
Print the class's operations m
[ "Print", "the", "class", "s", "operations", "m" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L257-L275
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.nodeProperties
private void nodeProperties(Options opt) { Options def = opt.getGlobalOptions(); if (opt.nodeFontName != def.nodeFontName) w.print(",fontname=\"" + opt.nodeFontName + "\""); if (opt.nodeFontColor != def.nodeFontColor) w.print(",fontcolor=\"" + opt.nodeFontColor + "\""); if (opt.nodeFontSize != def.nodeFontSize) w.print(",fontsize=" + fmt(opt.nodeFontSize)); w.print(opt.shape.style); w.println("];"); }
java
private void nodeProperties(Options opt) { Options def = opt.getGlobalOptions(); if (opt.nodeFontName != def.nodeFontName) w.print(",fontname=\"" + opt.nodeFontName + "\""); if (opt.nodeFontColor != def.nodeFontColor) w.print(",fontcolor=\"" + opt.nodeFontColor + "\""); if (opt.nodeFontSize != def.nodeFontSize) w.print(",fontsize=" + fmt(opt.nodeFontSize)); w.print(opt.shape.style); w.println("];"); }
[ "private", "void", "nodeProperties", "(", "Options", "opt", ")", "{", "Options", "def", "=", "opt", ".", "getGlobalOptions", "(", ")", ";", "if", "(", "opt", ".", "nodeFontName", "!=", "def", ".", "nodeFontName", ")", "w", ".", "print", "(", "\",fontname...
Print the common class node's properties
[ "Print", "the", "common", "class", "node", "s", "properties" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L278-L288
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.tagvalue
private void tagvalue(Options opt, Doc c) { Tag tags[] = c.tags("tagvalue"); if (tags.length == 0) return; for (Tag tag : tags) { String t[] = tokenize(tag.text()); if (t.length != 2) { System.err.println("@tagvalue expects two fields: " + tag.text()); continue; } tableLine(Align.RIGHT, Font.TAG.wrap(opt, "{" + t[0] + " = " + t[1] + "}")); } }
java
private void tagvalue(Options opt, Doc c) { Tag tags[] = c.tags("tagvalue"); if (tags.length == 0) return; for (Tag tag : tags) { String t[] = tokenize(tag.text()); if (t.length != 2) { System.err.println("@tagvalue expects two fields: " + tag.text()); continue; } tableLine(Align.RIGHT, Font.TAG.wrap(opt, "{" + t[0] + " = " + t[1] + "}")); } }
[ "private", "void", "tagvalue", "(", "Options", "opt", ",", "Doc", "c", ")", "{", "Tag", "tags", "[", "]", "=", "c", ".", "tags", "(", "\"tagvalue\"", ")", ";", "if", "(", "tags", ".", "length", "==", "0", ")", "return", ";", "for", "(", "Tag", ...
Return as a string the tagged values associated with c @param opt the Options used to guess font names @param c the Doc entry to look for @tagvalue @param prevterm the termination string for the previous element @param term the termination character for each tagged value
[ "Return", "as", "a", "string", "the", "tagged", "values", "associated", "with", "c" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L297-L310
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.stereotype
private void stereotype(Options opt, Doc c, Align align) { for (Tag tag : c.tags("stereotype")) { String t[] = tokenize(tag.text()); if (t.length != 1) { System.err.println("@stereotype expects one field: " + tag.text()); continue; } tableLine(align, guilWrap(opt, t[0])); } }
java
private void stereotype(Options opt, Doc c, Align align) { for (Tag tag : c.tags("stereotype")) { String t[] = tokenize(tag.text()); if (t.length != 1) { System.err.println("@stereotype expects one field: " + tag.text()); continue; } tableLine(align, guilWrap(opt, t[0])); } }
[ "private", "void", "stereotype", "(", "Options", "opt", ",", "Doc", "c", ",", "Align", "align", ")", "{", "for", "(", "Tag", "tag", ":", "c", ".", "tags", "(", "\"stereotype\"", ")", ")", "{", "String", "t", "[", "]", "=", "tokenize", "(", "tag", ...
Return as a string the stereotypes associated with c terminated by the escape character term
[ "Return", "as", "a", "string", "the", "stereotypes", "associated", "with", "c", "terminated", "by", "the", "escape", "character", "term" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L316-L325
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.hidden
private boolean hidden(ProgramElementDoc c) { if (c.tags("hidden").length > 0 || c.tags("view").length > 0) return true; Options opt = optionProvider.getOptionsFor(c instanceof ClassDoc ? (ClassDoc) c : c.containingClass()); return opt.matchesHideExpression(c.toString()) // || (opt.hidePrivateInner && c instanceof ClassDoc && c.isPrivate() && ((ClassDoc) c).containingClass() != null); }
java
private boolean hidden(ProgramElementDoc c) { if (c.tags("hidden").length > 0 || c.tags("view").length > 0) return true; Options opt = optionProvider.getOptionsFor(c instanceof ClassDoc ? (ClassDoc) c : c.containingClass()); return opt.matchesHideExpression(c.toString()) // || (opt.hidePrivateInner && c instanceof ClassDoc && c.isPrivate() && ((ClassDoc) c).containingClass() != null); }
[ "private", "boolean", "hidden", "(", "ProgramElementDoc", "c", ")", "{", "if", "(", "c", ".", "tags", "(", "\"hidden\"", ")", ".", "length", ">", "0", "||", "c", ".", "tags", "(", "\"view\"", ")", ".", "length", ">", "0", ")", "return", "true", ";"...
Return true if c has a @hidden tag associated with it
[ "Return", "true", "if", "c", "has", "a" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L328-L334
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.hidden
private boolean hidden(String className) { className = removeTemplate(className); ClassInfo ci = classnames.get(className); return ci != null ? ci.hidden : optionProvider.getOptionsFor(className).matchesHideExpression(className); }
java
private boolean hidden(String className) { className = removeTemplate(className); ClassInfo ci = classnames.get(className); return ci != null ? ci.hidden : optionProvider.getOptionsFor(className).matchesHideExpression(className); }
[ "private", "boolean", "hidden", "(", "String", "className", ")", "{", "className", "=", "removeTemplate", "(", "className", ")", ";", "ClassInfo", "ci", "=", "classnames", ".", "get", "(", "className", ")", ";", "return", "ci", "!=", "null", "?", "ci", "...
Return true if the class name is associated to an hidden class or matches a hide expression
[ "Return", "true", "if", "the", "class", "name", "is", "associated", "to", "an", "hidden", "class", "or", "matches", "a", "hide", "expression" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L356-L360
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.allRelation
private void allRelation(Options opt, RelationType rt, ClassDoc from) { String tagname = rt.lower; for (Tag tag : from.tags(tagname)) { String t[] = tokenize(tag.text()); // l-src label l-dst target t = t.length == 1 ? new String[] { "-", "-", "-", t[0] } : t; // Shorthand if (t.length != 4) { System.err.println("Error in " + from + "\n" + tagname + " expects four fields (l-src label l-dst target): " + tag.text()); return; } ClassDoc to = from.findClass(t[3]); if (to != null) { if(hidden(to)) continue; relation(opt, rt, from, to, t[0], t[1], t[2]); } else { if(hidden(t[3])) continue; relation(opt, rt, from, from.toString(), to, t[3], t[0], t[1], t[2]); } } }
java
private void allRelation(Options opt, RelationType rt, ClassDoc from) { String tagname = rt.lower; for (Tag tag : from.tags(tagname)) { String t[] = tokenize(tag.text()); // l-src label l-dst target t = t.length == 1 ? new String[] { "-", "-", "-", t[0] } : t; // Shorthand if (t.length != 4) { System.err.println("Error in " + from + "\n" + tagname + " expects four fields (l-src label l-dst target): " + tag.text()); return; } ClassDoc to = from.findClass(t[3]); if (to != null) { if(hidden(to)) continue; relation(opt, rt, from, to, t[0], t[1], t[2]); } else { if(hidden(t[3])) continue; relation(opt, rt, from, from.toString(), to, t[3], t[0], t[1], t[2]); } } }
[ "private", "void", "allRelation", "(", "Options", "opt", ",", "RelationType", "rt", ",", "ClassDoc", "from", ")", "{", "String", "tagname", "=", "rt", ".", "lower", ";", "for", "(", "Tag", "tag", ":", "from", ".", "tags", "(", "tagname", ")", ")", "{...
Print all relations for a given's class's tag @param tagname the tag containing the given relation @param from the source class @param edgetype the dot edge specification
[ "Print", "all", "relations", "for", "a", "given", "s", "class", "s", "tag" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L495-L515
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.printRelations
public void printRelations(ClassDoc c) { Options opt = optionProvider.getOptionsFor(c); if (hidden(c) || c.name().equals("")) // avoid phantom classes, they may pop up when the source uses annotations return; // Print generalization (through the Java superclass) Type s = c.superclassType(); ClassDoc sc = s != null && !s.qualifiedTypeName().equals(Object.class.getName()) ? s.asClassDoc() : null; if (sc != null && !c.isEnum() && !hidden(sc)) relation(opt, RelationType.EXTENDS, c, sc, null, null, null); // Print generalizations (through @extends tags) for (Tag tag : c.tags("extends")) if (!hidden(tag.text())) relation(opt, RelationType.EXTENDS, c, c.findClass(tag.text()), null, null, null); // Print realizations (Java interfaces) for (Type iface : c.interfaceTypes()) { ClassDoc ic = iface.asClassDoc(); if (!hidden(ic)) relation(opt, RelationType.IMPLEMENTS, c, ic, null, null, null); } // Print other associations allRelation(opt, RelationType.COMPOSED, c); allRelation(opt, RelationType.NAVCOMPOSED, c); allRelation(opt, RelationType.HAS, c); allRelation(opt, RelationType.NAVHAS, c); allRelation(opt, RelationType.ASSOC, c); allRelation(opt, RelationType.NAVASSOC, c); allRelation(opt, RelationType.DEPEND, c); }
java
public void printRelations(ClassDoc c) { Options opt = optionProvider.getOptionsFor(c); if (hidden(c) || c.name().equals("")) // avoid phantom classes, they may pop up when the source uses annotations return; // Print generalization (through the Java superclass) Type s = c.superclassType(); ClassDoc sc = s != null && !s.qualifiedTypeName().equals(Object.class.getName()) ? s.asClassDoc() : null; if (sc != null && !c.isEnum() && !hidden(sc)) relation(opt, RelationType.EXTENDS, c, sc, null, null, null); // Print generalizations (through @extends tags) for (Tag tag : c.tags("extends")) if (!hidden(tag.text())) relation(opt, RelationType.EXTENDS, c, c.findClass(tag.text()), null, null, null); // Print realizations (Java interfaces) for (Type iface : c.interfaceTypes()) { ClassDoc ic = iface.asClassDoc(); if (!hidden(ic)) relation(opt, RelationType.IMPLEMENTS, c, ic, null, null, null); } // Print other associations allRelation(opt, RelationType.COMPOSED, c); allRelation(opt, RelationType.NAVCOMPOSED, c); allRelation(opt, RelationType.HAS, c); allRelation(opt, RelationType.NAVHAS, c); allRelation(opt, RelationType.ASSOC, c); allRelation(opt, RelationType.NAVASSOC, c); allRelation(opt, RelationType.DEPEND, c); }
[ "public", "void", "printRelations", "(", "ClassDoc", "c", ")", "{", "Options", "opt", "=", "optionProvider", ".", "getOptionsFor", "(", "c", ")", ";", "if", "(", "hidden", "(", "c", ")", "||", "c", ".", "name", "(", ")", ".", "equals", "(", "\"\"", ...
Print a class's relations
[ "Print", "a", "class", "s", "relations" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L573-L600
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.printExtraClasses
public void printExtraClasses(RootDoc root) { Set<String> names = new HashSet<String>(classnames.keySet()); for(String className: names) { ClassInfo info = getClassInfo(className, true); if (info.nodePrinted) continue; ClassDoc c = root.classNamed(className); if(c != null) { printClass(c, false); continue; } // Handle missing classes: Options opt = optionProvider.getOptionsFor(className); if(opt.matchesHideExpression(className)) continue; w.println(linePrefix + "// " + className); w.print(linePrefix + info.name + "[label="); externalTableStart(opt, className, classToUrl(className)); innerTableStart(); String qualifiedName = qualifiedName(opt, className); int startTemplate = qualifiedName.indexOf('<'); int idx = qualifiedName.lastIndexOf('.', startTemplate < 0 ? qualifiedName.length() - 1 : startTemplate); if(opt.postfixPackage && idx > 0 && idx < (qualifiedName.length() - 1)) { String packageName = qualifiedName.substring(0, idx); String cn = qualifiedName.substring(idx + 1); tableLine(Align.CENTER, Font.CLASS.wrap(opt, escape(cn))); tableLine(Align.CENTER, Font.PACKAGE.wrap(opt, packageName)); } else { tableLine(Align.CENTER, Font.CLASS.wrap(opt, escape(qualifiedName))); } innerTableEnd(); externalTableEnd(); if (className == null || className.length() == 0) w.print(",URL=\"" + classToUrl(className) + "\""); nodeProperties(opt); } }
java
public void printExtraClasses(RootDoc root) { Set<String> names = new HashSet<String>(classnames.keySet()); for(String className: names) { ClassInfo info = getClassInfo(className, true); if (info.nodePrinted) continue; ClassDoc c = root.classNamed(className); if(c != null) { printClass(c, false); continue; } // Handle missing classes: Options opt = optionProvider.getOptionsFor(className); if(opt.matchesHideExpression(className)) continue; w.println(linePrefix + "// " + className); w.print(linePrefix + info.name + "[label="); externalTableStart(opt, className, classToUrl(className)); innerTableStart(); String qualifiedName = qualifiedName(opt, className); int startTemplate = qualifiedName.indexOf('<'); int idx = qualifiedName.lastIndexOf('.', startTemplate < 0 ? qualifiedName.length() - 1 : startTemplate); if(opt.postfixPackage && idx > 0 && idx < (qualifiedName.length() - 1)) { String packageName = qualifiedName.substring(0, idx); String cn = qualifiedName.substring(idx + 1); tableLine(Align.CENTER, Font.CLASS.wrap(opt, escape(cn))); tableLine(Align.CENTER, Font.PACKAGE.wrap(opt, packageName)); } else { tableLine(Align.CENTER, Font.CLASS.wrap(opt, escape(qualifiedName))); } innerTableEnd(); externalTableEnd(); if (className == null || className.length() == 0) w.print(",URL=\"" + classToUrl(className) + "\""); nodeProperties(opt); } }
[ "public", "void", "printExtraClasses", "(", "RootDoc", "root", ")", "{", "Set", "<", "String", ">", "names", "=", "new", "HashSet", "<", "String", ">", "(", "classnames", ".", "keySet", "(", ")", ")", ";", "for", "(", "String", "className", ":", "names...
Print classes that were parts of relationships, but not parsed by javadoc
[ "Print", "classes", "that", "were", "parts", "of", "relationships", "but", "not", "parsed", "by", "javadoc" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L603-L639
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.printInferredRelations
public void printInferredRelations(ClassDoc c) { // check if the source is excluded from inference if (hidden(c)) return; Options opt = optionProvider.getOptionsFor(c); for (FieldDoc field : c.fields(false)) { if(hidden(field)) continue; // skip statics if(field.isStatic()) continue; // skip primitives FieldRelationInfo fri = getFieldRelationInfo(field); if (fri == null) continue; // check if the destination is excluded from inference if (hidden(fri.cd)) continue; // if source and dest are not already linked, add a dependency RelationPattern rp = getClassInfo(c, true).getRelation(fri.cd.toString()); if (rp == null) { String destAdornment = fri.multiple ? "*" : ""; relation(opt, opt.inferRelationshipType, c, fri.cd, "", "", destAdornment); } } }
java
public void printInferredRelations(ClassDoc c) { // check if the source is excluded from inference if (hidden(c)) return; Options opt = optionProvider.getOptionsFor(c); for (FieldDoc field : c.fields(false)) { if(hidden(field)) continue; // skip statics if(field.isStatic()) continue; // skip primitives FieldRelationInfo fri = getFieldRelationInfo(field); if (fri == null) continue; // check if the destination is excluded from inference if (hidden(fri.cd)) continue; // if source and dest are not already linked, add a dependency RelationPattern rp = getClassInfo(c, true).getRelation(fri.cd.toString()); if (rp == null) { String destAdornment = fri.multiple ? "*" : ""; relation(opt, opt.inferRelationshipType, c, fri.cd, "", "", destAdornment); } } }
[ "public", "void", "printInferredRelations", "(", "ClassDoc", "c", ")", "{", "// check if the source is excluded from inference", "if", "(", "hidden", "(", "c", ")", ")", "return", ";", "Options", "opt", "=", "optionProvider", ".", "getOptionsFor", "(", "c", ")", ...
Prints associations recovered from the fields of a class. An association is inferred only if another relation between the two classes is not already in the graph. @param classes
[ "Prints", "associations", "recovered", "from", "the", "fields", "of", "a", "class", ".", "An", "association", "is", "inferred", "only", "if", "another", "relation", "between", "the", "two", "classes", "is", "not", "already", "in", "the", "graph", "." ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L646-L674
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.printInferredDependencies
public void printInferredDependencies(ClassDoc c) { if (hidden(c)) return; Options opt = optionProvider.getOptionsFor(c); Set<Type> types = new HashSet<Type>(); // harvest method return and parameter types for (MethodDoc method : filterByVisibility(c.methods(false), opt.inferDependencyVisibility)) { types.add(method.returnType()); for (Parameter parameter : method.parameters()) { types.add(parameter.type()); } } // and the field types if (!opt.inferRelationships) { for (FieldDoc field : filterByVisibility(c.fields(false), opt.inferDependencyVisibility)) { types.add(field.type()); } } // see if there are some type parameters if (c.asParameterizedType() != null) { ParameterizedType pt = c.asParameterizedType(); types.addAll(Arrays.asList(pt.typeArguments())); } // see if type parameters extend something for(TypeVariable tv: c.typeParameters()) { if(tv.bounds().length > 0 ) types.addAll(Arrays.asList(tv.bounds())); } // and finally check for explicitly imported classes (this // assumes there are no unused imports...) if (opt.useImports) types.addAll(Arrays.asList(importedClasses(c))); // compute dependencies for (Type type : types) { // skip primitives and type variables, as well as dependencies // on the source class if (type.isPrimitive() || type instanceof WildcardType || type instanceof TypeVariable || c.toString().equals(type.asClassDoc().toString())) continue; // check if the destination is excluded from inference ClassDoc fc = type.asClassDoc(); if (hidden(fc)) continue; // check if source and destination are in the same package and if we are allowed // to infer dependencies between classes in the same package if(!opt.inferDepInPackage && c.containingPackage().equals(fc.containingPackage())) continue; // if source and dest are not already linked, add a dependency RelationPattern rp = getClassInfo(c, true).getRelation(fc.toString()); if (rp == null || rp.matchesOne(new RelationPattern(RelationDirection.OUT))) { relation(opt, RelationType.DEPEND, c, fc, "", "", ""); } } }
java
public void printInferredDependencies(ClassDoc c) { if (hidden(c)) return; Options opt = optionProvider.getOptionsFor(c); Set<Type> types = new HashSet<Type>(); // harvest method return and parameter types for (MethodDoc method : filterByVisibility(c.methods(false), opt.inferDependencyVisibility)) { types.add(method.returnType()); for (Parameter parameter : method.parameters()) { types.add(parameter.type()); } } // and the field types if (!opt.inferRelationships) { for (FieldDoc field : filterByVisibility(c.fields(false), opt.inferDependencyVisibility)) { types.add(field.type()); } } // see if there are some type parameters if (c.asParameterizedType() != null) { ParameterizedType pt = c.asParameterizedType(); types.addAll(Arrays.asList(pt.typeArguments())); } // see if type parameters extend something for(TypeVariable tv: c.typeParameters()) { if(tv.bounds().length > 0 ) types.addAll(Arrays.asList(tv.bounds())); } // and finally check for explicitly imported classes (this // assumes there are no unused imports...) if (opt.useImports) types.addAll(Arrays.asList(importedClasses(c))); // compute dependencies for (Type type : types) { // skip primitives and type variables, as well as dependencies // on the source class if (type.isPrimitive() || type instanceof WildcardType || type instanceof TypeVariable || c.toString().equals(type.asClassDoc().toString())) continue; // check if the destination is excluded from inference ClassDoc fc = type.asClassDoc(); if (hidden(fc)) continue; // check if source and destination are in the same package and if we are allowed // to infer dependencies between classes in the same package if(!opt.inferDepInPackage && c.containingPackage().equals(fc.containingPackage())) continue; // if source and dest are not already linked, add a dependency RelationPattern rp = getClassInfo(c, true).getRelation(fc.toString()); if (rp == null || rp.matchesOne(new RelationPattern(RelationDirection.OUT))) { relation(opt, RelationType.DEPEND, c, fc, "", "", ""); } } }
[ "public", "void", "printInferredDependencies", "(", "ClassDoc", "c", ")", "{", "if", "(", "hidden", "(", "c", ")", ")", "return", ";", "Options", "opt", "=", "optionProvider", ".", "getOptionsFor", "(", "c", ")", ";", "Set", "<", "Type", ">", "types", ...
Prints dependencies recovered from the methods of a class. A dependency is inferred only if another relation between the two classes is not already in the graph. @param classes
[ "Prints", "dependencies", "recovered", "from", "the", "methods", "of", "a", "class", ".", "A", "dependency", "is", "inferred", "only", "if", "another", "relation", "between", "the", "two", "classes", "is", "not", "already", "in", "the", "graph", "." ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L691-L751
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.filterByVisibility
private <T extends ProgramElementDoc> List<T> filterByVisibility(T[] docs, Visibility visibility) { if (visibility == Visibility.PRIVATE) return Arrays.asList(docs); List<T> filtered = new ArrayList<T>(); for (T doc : docs) { if (Visibility.get(doc).compareTo(visibility) > 0) filtered.add(doc); } return filtered; }
java
private <T extends ProgramElementDoc> List<T> filterByVisibility(T[] docs, Visibility visibility) { if (visibility == Visibility.PRIVATE) return Arrays.asList(docs); List<T> filtered = new ArrayList<T>(); for (T doc : docs) { if (Visibility.get(doc).compareTo(visibility) > 0) filtered.add(doc); } return filtered; }
[ "private", "<", "T", "extends", "ProgramElementDoc", ">", "List", "<", "T", ">", "filterByVisibility", "(", "T", "[", "]", "docs", ",", "Visibility", "visibility", ")", "{", "if", "(", "visibility", "==", "Visibility", ".", "PRIVATE", ")", "return", "Array...
Returns all program element docs that have a visibility greater or equal than the specified level
[ "Returns", "all", "program", "element", "docs", "that", "have", "a", "visibility", "greater", "or", "equal", "than", "the", "specified", "level" ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L757-L767
train
dspinellis/UMLGraph
src/main/java/org/umlgraph/doclet/ClassGraph.java
ClassGraph.firstInnerTableStart
private void firstInnerTableStart(Options opt) { w.print(linePrefix + linePrefix + "<tr>" + opt.shape.extraColumn() + "<td><table border=\"0\" cellspacing=\"0\" " + "cellpadding=\"1\">" + linePostfix); }
java
private void firstInnerTableStart(Options opt) { w.print(linePrefix + linePrefix + "<tr>" + opt.shape.extraColumn() + "<td><table border=\"0\" cellspacing=\"0\" " + "cellpadding=\"1\">" + linePostfix); }
[ "private", "void", "firstInnerTableStart", "(", "Options", "opt", ")", "{", "w", ".", "print", "(", "linePrefix", "+", "linePrefix", "+", "\"<tr>\"", "+", "opt", ".", "shape", ".", "extraColumn", "(", ")", "+", "\"<td><table border=\\\"0\\\" cellspacing=\\\"0\\\" ...
Start the first inner table of a class.
[ "Start", "the", "first", "inner", "table", "of", "a", "class", "." ]
09576db5ae0ea63bfe30ef9fce88a513f9a8d843
https://github.com/dspinellis/UMLGraph/blob/09576db5ae0ea63bfe30ef9fce88a513f9a8d843/src/main/java/org/umlgraph/doclet/ClassGraph.java#L927-L931
train
twitter/scrooge
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
AbstractMavenScroogeMojo.extractThriftFile
private File extractThriftFile(String artifactId, String fileName, Set<File> thriftFiles) { for (File thriftFile : thriftFiles) { boolean fileFound = false; if (fileName.equals(thriftFile.getName())) { for (String pathComponent : thriftFile.getPath().split(File.separator)) { if (pathComponent.equals(artifactId)) { fileFound = true; } } } if (fileFound) { return thriftFile; } } return null; }
java
private File extractThriftFile(String artifactId, String fileName, Set<File> thriftFiles) { for (File thriftFile : thriftFiles) { boolean fileFound = false; if (fileName.equals(thriftFile.getName())) { for (String pathComponent : thriftFile.getPath().split(File.separator)) { if (pathComponent.equals(artifactId)) { fileFound = true; } } } if (fileFound) { return thriftFile; } } return null; }
[ "private", "File", "extractThriftFile", "(", "String", "artifactId", ",", "String", "fileName", ",", "Set", "<", "File", ">", "thriftFiles", ")", "{", "for", "(", "File", "thriftFile", ":", "thriftFiles", ")", "{", "boolean", "fileFound", "=", "false", ";", ...
Picks out a File from `thriftFiles` corresponding to a given artifact ID and file name. Returns null if `artifactId` and `fileName` do not map to a thrift file path. @parameter artifactId The artifact ID of which to look up the path @parameter fileName the name of the thrift file for which to extract a path @parameter thriftFiles The set of Thrift files in which to lookup the artifact ID. @return The path of the directory containing Thrift files for the given artifact ID. null if artifact ID not found.
[ "Picks", "out", "a", "File", "from", "thriftFiles", "corresponding", "to", "a", "given", "artifact", "ID", "and", "file", "name", ".", "Returns", "null", "if", "artifactId", "and", "fileName", "do", "not", "map", "to", "a", "thrift", "file", "path", "." ]
2aec9b19a610e12be9609cd97925d0b1284d48bc
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L228-L244
train
twitter/scrooge
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
AbstractMavenScroogeMojo.execute
public void execute() throws MojoExecutionException, MojoFailureException { try { Set<File> thriftFiles = findThriftFiles(); final File outputDirectory = getOutputDirectory(); ImmutableSet<File> outputFiles = findGeneratedFilesInDirectory(getOutputDirectory()); Set<String> compileRoots = new HashSet<String>(); compileRoots.add("scrooge"); if (thriftFiles.isEmpty()) { getLog().info("No thrift files to compile."); } else if (checkStaleness && ((lastModified(thriftFiles) + staleMillis) < lastModified(outputFiles))) { getLog().info("Generated thrift files up to date, skipping compile."); attachFiles(compileRoots); } else { outputDirectory.mkdirs(); // Quick fix to fix issues with two mvn installs in a row (ie no clean) cleanDirectory(outputDirectory); getLog().info(format("compiling thrift files %s with Scrooge", thriftFiles)); synchronized(lock) { ScroogeRunner runner = new ScroogeRunner(); Map<String, String> thriftNamespaceMap = new HashMap<String, String>(); for (ThriftNamespaceMapping mapping : thriftNamespaceMappings) { thriftNamespaceMap.put(mapping.getFrom(), mapping.getTo()); } // Include thrifts from resource as well. Set<File> includes = thriftIncludes; includes.add(getResourcesOutputDirectory()); // Include thrift root final File thriftSourceRoot = getThriftSourceRoot(); if (thriftSourceRoot != null && thriftSourceRoot.exists()) { includes.add(thriftSourceRoot); } runner.compile( getLog(), includeOutputDirectoryNamespace ? new File(outputDirectory, "scrooge") : outputDirectory, thriftFiles, includes, thriftNamespaceMap, language, thriftOpts); } attachFiles(compileRoots); } } catch (IOException e) { throw new MojoExecutionException("An IO error occurred", e); } }
java
public void execute() throws MojoExecutionException, MojoFailureException { try { Set<File> thriftFiles = findThriftFiles(); final File outputDirectory = getOutputDirectory(); ImmutableSet<File> outputFiles = findGeneratedFilesInDirectory(getOutputDirectory()); Set<String> compileRoots = new HashSet<String>(); compileRoots.add("scrooge"); if (thriftFiles.isEmpty()) { getLog().info("No thrift files to compile."); } else if (checkStaleness && ((lastModified(thriftFiles) + staleMillis) < lastModified(outputFiles))) { getLog().info("Generated thrift files up to date, skipping compile."); attachFiles(compileRoots); } else { outputDirectory.mkdirs(); // Quick fix to fix issues with two mvn installs in a row (ie no clean) cleanDirectory(outputDirectory); getLog().info(format("compiling thrift files %s with Scrooge", thriftFiles)); synchronized(lock) { ScroogeRunner runner = new ScroogeRunner(); Map<String, String> thriftNamespaceMap = new HashMap<String, String>(); for (ThriftNamespaceMapping mapping : thriftNamespaceMappings) { thriftNamespaceMap.put(mapping.getFrom(), mapping.getTo()); } // Include thrifts from resource as well. Set<File> includes = thriftIncludes; includes.add(getResourcesOutputDirectory()); // Include thrift root final File thriftSourceRoot = getThriftSourceRoot(); if (thriftSourceRoot != null && thriftSourceRoot.exists()) { includes.add(thriftSourceRoot); } runner.compile( getLog(), includeOutputDirectoryNamespace ? new File(outputDirectory, "scrooge") : outputDirectory, thriftFiles, includes, thriftNamespaceMap, language, thriftOpts); } attachFiles(compileRoots); } } catch (IOException e) { throw new MojoExecutionException("An IO error occurred", e); } }
[ "public", "void", "execute", "(", ")", "throws", "MojoExecutionException", ",", "MojoFailureException", "{", "try", "{", "Set", "<", "File", ">", "thriftFiles", "=", "findThriftFiles", "(", ")", ";", "final", "File", "outputDirectory", "=", "getOutputDirectory", ...
Executes the mojo.
[ "Executes", "the", "mojo", "." ]
2aec9b19a610e12be9609cd97925d0b1284d48bc
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L249-L302
train
twitter/scrooge
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
AbstractMavenScroogeMojo.lastModified
private long lastModified(Set<File> files) { long result = 0; for (File file : files) { if (file.lastModified() > result) result = file.lastModified(); } return result; }
java
private long lastModified(Set<File> files) { long result = 0; for (File file : files) { if (file.lastModified() > result) result = file.lastModified(); } return result; }
[ "private", "long", "lastModified", "(", "Set", "<", "File", ">", "files", ")", "{", "long", "result", "=", "0", ";", "for", "(", "File", "file", ":", "files", ")", "{", "if", "(", "file", ".", "lastModified", "(", ")", ">", "result", ")", "result",...
Get the last modified time for a set of files.
[ "Get", "the", "last", "modified", "time", "for", "a", "set", "of", "files", "." ]
2aec9b19a610e12be9609cd97925d0b1284d48bc
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L339-L346
train
twitter/scrooge
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
AbstractMavenScroogeMojo.findThriftFiles
private Set<File> findThriftFiles() throws IOException, MojoExecutionException { final File thriftSourceRoot = getThriftSourceRoot(); Set<File> thriftFiles = new HashSet<File>(); if (thriftSourceRoot != null && thriftSourceRoot.exists()) { thriftFiles.addAll(findThriftFilesInDirectory(thriftSourceRoot)); } getLog().info("finding thrift files in dependencies"); extractFilesFromDependencies(findThriftDependencies(), getResourcesOutputDirectory()); if (buildExtractedThrift && getResourcesOutputDirectory().exists()) { thriftFiles.addAll(findThriftFilesInDirectory(getResourcesOutputDirectory())); } getLog().info("finding thrift files in referenced (reactor) projects"); thriftFiles.addAll(getReferencedThriftFiles()); return thriftFiles; }
java
private Set<File> findThriftFiles() throws IOException, MojoExecutionException { final File thriftSourceRoot = getThriftSourceRoot(); Set<File> thriftFiles = new HashSet<File>(); if (thriftSourceRoot != null && thriftSourceRoot.exists()) { thriftFiles.addAll(findThriftFilesInDirectory(thriftSourceRoot)); } getLog().info("finding thrift files in dependencies"); extractFilesFromDependencies(findThriftDependencies(), getResourcesOutputDirectory()); if (buildExtractedThrift && getResourcesOutputDirectory().exists()) { thriftFiles.addAll(findThriftFilesInDirectory(getResourcesOutputDirectory())); } getLog().info("finding thrift files in referenced (reactor) projects"); thriftFiles.addAll(getReferencedThriftFiles()); return thriftFiles; }
[ "private", "Set", "<", "File", ">", "findThriftFiles", "(", ")", "throws", "IOException", ",", "MojoExecutionException", "{", "final", "File", "thriftSourceRoot", "=", "getThriftSourceRoot", "(", ")", ";", "Set", "<", "File", ">", "thriftFiles", "=", "new", "H...
build a complete set of local files, files from referenced projects, and dependencies.
[ "build", "a", "complete", "set", "of", "local", "files", "files", "from", "referenced", "projects", "and", "dependencies", "." ]
2aec9b19a610e12be9609cd97925d0b1284d48bc
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L351-L365
train
twitter/scrooge
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
AbstractMavenScroogeMojo.findThriftDependencies
private Set<Artifact> findThriftDependencies() throws IOException, MojoExecutionException { Set<Artifact> thriftDependencies = new HashSet<Artifact>(); Set<Artifact> deps = new HashSet<Artifact>(); deps.addAll(project.getArtifacts()); deps.addAll(project.getDependencyArtifacts()); Map<String, Artifact> depsMap = new HashMap<String, Artifact>(); for (Artifact dep : deps) { depsMap.put(dep.getId(), dep); } for (Artifact artifact : deps) { // This artifact has an idl classifier. if (isIdlCalssifier(artifact, classifier)) { thriftDependencies.add(artifact); } else { if (isDepOfIdlArtifact(artifact, depsMap)) { // Fetch idl artifact for dependency of an idl artifact. try { Artifact idlArtifact = MavenScroogeCompilerUtil.getIdlArtifact( artifact, artifactFactory, artifactResolver, localRepository, remoteArtifactRepositories, classifier); thriftDependencies.add(idlArtifact); } catch (MojoExecutionException e) { /* Do nothing as this artifact is not an idl artifact binary jars may have dependency on thrift lib etc. */ getLog().debug("Could not fetch idl jar for " + artifact); } } } } return thriftDependencies; }
java
private Set<Artifact> findThriftDependencies() throws IOException, MojoExecutionException { Set<Artifact> thriftDependencies = new HashSet<Artifact>(); Set<Artifact> deps = new HashSet<Artifact>(); deps.addAll(project.getArtifacts()); deps.addAll(project.getDependencyArtifacts()); Map<String, Artifact> depsMap = new HashMap<String, Artifact>(); for (Artifact dep : deps) { depsMap.put(dep.getId(), dep); } for (Artifact artifact : deps) { // This artifact has an idl classifier. if (isIdlCalssifier(artifact, classifier)) { thriftDependencies.add(artifact); } else { if (isDepOfIdlArtifact(artifact, depsMap)) { // Fetch idl artifact for dependency of an idl artifact. try { Artifact idlArtifact = MavenScroogeCompilerUtil.getIdlArtifact( artifact, artifactFactory, artifactResolver, localRepository, remoteArtifactRepositories, classifier); thriftDependencies.add(idlArtifact); } catch (MojoExecutionException e) { /* Do nothing as this artifact is not an idl artifact binary jars may have dependency on thrift lib etc. */ getLog().debug("Could not fetch idl jar for " + artifact); } } } } return thriftDependencies; }
[ "private", "Set", "<", "Artifact", ">", "findThriftDependencies", "(", ")", "throws", "IOException", ",", "MojoExecutionException", "{", "Set", "<", "Artifact", ">", "thriftDependencies", "=", "new", "HashSet", "<", "Artifact", ">", "(", ")", ";", "Set", "<", ...
Iterate through dependencies
[ "Iterate", "through", "dependencies" ]
2aec9b19a610e12be9609cd97925d0b1284d48bc
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L370-L408
train
twitter/scrooge
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
AbstractMavenScroogeMojo.getRecursiveThriftFiles
protected List<File> getRecursiveThriftFiles(MavenProject project, String outputDirectory) throws IOException { return getRecursiveThriftFiles(project, outputDirectory, new ArrayList<File>()); }
java
protected List<File> getRecursiveThriftFiles(MavenProject project, String outputDirectory) throws IOException { return getRecursiveThriftFiles(project, outputDirectory, new ArrayList<File>()); }
[ "protected", "List", "<", "File", ">", "getRecursiveThriftFiles", "(", "MavenProject", "project", ",", "String", "outputDirectory", ")", "throws", "IOException", "{", "return", "getRecursiveThriftFiles", "(", "project", ",", "outputDirectory", ",", "new", "ArrayList",...
Walk project references recursively, building up a list of thrift files they provide, starting with an empty file list.
[ "Walk", "project", "references", "recursively", "building", "up", "a", "list", "of", "thrift", "files", "they", "provide", "starting", "with", "an", "empty", "file", "list", "." ]
2aec9b19a610e12be9609cd97925d0b1284d48bc
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L488-L490
train
twitter/scrooge
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
AbstractMavenScroogeMojo.getRecursiveThriftFiles
List<File> getRecursiveThriftFiles(MavenProject project, String outputDirectory, List<File> files) throws IOException { HashFunction hashFun = Hashing.md5(); File dir = new File(new File(project.getFile().getParent(), "target"), outputDirectory); if (dir.exists()) { URI baseDir = getFileURI(dir); for (File f : findThriftFilesInDirectory(dir)) { URI fileURI = getFileURI(f); String relPath = baseDir.relativize(fileURI).getPath(); File destFolder = getResourcesOutputDirectory(); destFolder.mkdirs(); File destFile = new File(destFolder, relPath); if (!destFile.exists() || (destFile.isFile() && !Files.hash(f, hashFun).equals(Files.hash(destFile, hashFun)))) { getLog().info(format("copying %s to %s", f.getCanonicalPath(), destFile.getCanonicalPath())); copyFile(f, destFile); } files.add(destFile); } } Map<String, MavenProject> refs = project.getProjectReferences(); for (String name : refs.keySet()) { getRecursiveThriftFiles(refs.get(name), outputDirectory, files); } return files; }
java
List<File> getRecursiveThriftFiles(MavenProject project, String outputDirectory, List<File> files) throws IOException { HashFunction hashFun = Hashing.md5(); File dir = new File(new File(project.getFile().getParent(), "target"), outputDirectory); if (dir.exists()) { URI baseDir = getFileURI(dir); for (File f : findThriftFilesInDirectory(dir)) { URI fileURI = getFileURI(f); String relPath = baseDir.relativize(fileURI).getPath(); File destFolder = getResourcesOutputDirectory(); destFolder.mkdirs(); File destFile = new File(destFolder, relPath); if (!destFile.exists() || (destFile.isFile() && !Files.hash(f, hashFun).equals(Files.hash(destFile, hashFun)))) { getLog().info(format("copying %s to %s", f.getCanonicalPath(), destFile.getCanonicalPath())); copyFile(f, destFile); } files.add(destFile); } } Map<String, MavenProject> refs = project.getProjectReferences(); for (String name : refs.keySet()) { getRecursiveThriftFiles(refs.get(name), outputDirectory, files); } return files; }
[ "List", "<", "File", ">", "getRecursiveThriftFiles", "(", "MavenProject", "project", ",", "String", "outputDirectory", ",", "List", "<", "File", ">", "files", ")", "throws", "IOException", "{", "HashFunction", "hashFun", "=", "Hashing", ".", "md5", "(", ")", ...
Walk project references recursively, adding thrift files to the provided list.
[ "Walk", "project", "references", "recursively", "adding", "thrift", "files", "to", "the", "provided", "list", "." ]
2aec9b19a610e12be9609cd97925d0b1284d48bc
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L495-L518
train
twitter/scrooge
scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java
AbstractMavenScroogeMojo.isDepOfIdlArtifact
private boolean isDepOfIdlArtifact(Artifact artifact, Map<String, Artifact> depsMap) { List<String> depTrail = artifact.getDependencyTrail(); // depTrail can be null sometimes, which seems like a maven bug if (depTrail != null) { for (String name : depTrail) { Artifact dep = depsMap.get(name); if (dep != null && isIdlCalssifier(dep, classifier)) { return true; } } } return false; }
java
private boolean isDepOfIdlArtifact(Artifact artifact, Map<String, Artifact> depsMap) { List<String> depTrail = artifact.getDependencyTrail(); // depTrail can be null sometimes, which seems like a maven bug if (depTrail != null) { for (String name : depTrail) { Artifact dep = depsMap.get(name); if (dep != null && isIdlCalssifier(dep, classifier)) { return true; } } } return false; }
[ "private", "boolean", "isDepOfIdlArtifact", "(", "Artifact", "artifact", ",", "Map", "<", "String", ",", "Artifact", ">", "depsMap", ")", "{", "List", "<", "String", ">", "depTrail", "=", "artifact", ".", "getDependencyTrail", "(", ")", ";", "// depTrail can b...
Checks if the artifact is dependency of an dependent idl artifact @returns true if the artifact was a dependency of idl artifact
[ "Checks", "if", "the", "artifact", "is", "dependency", "of", "an", "dependent", "idl", "artifact" ]
2aec9b19a610e12be9609cd97925d0b1284d48bc
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/AbstractMavenScroogeMojo.java#L539-L551
train
twitter/scrooge
scrooge-maven-plugin/src/main/java/com/twitter/MavenScroogeCompilerUtil.java
MavenScroogeCompilerUtil.getIdlArtifact
public static Artifact getIdlArtifact(Artifact artifact, ArtifactFactory artifactFactory, ArtifactResolver artifactResolver, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepos, String classifier) throws MojoExecutionException { Artifact idlArtifact = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), "jar", classifier); try { artifactResolver.resolve(idlArtifact, remoteRepos, localRepository); return idlArtifact; } catch (final ArtifactResolutionException e) { throw new MojoExecutionException( "Failed to resolve one or more idl artifacts:\n\n" + e.getMessage(), e); } catch (final ArtifactNotFoundException e) { throw new MojoExecutionException( "Failed to resolve one or more idl artifacts:\n\n" + e.getMessage(), e); } }
java
public static Artifact getIdlArtifact(Artifact artifact, ArtifactFactory artifactFactory, ArtifactResolver artifactResolver, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepos, String classifier) throws MojoExecutionException { Artifact idlArtifact = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), "jar", classifier); try { artifactResolver.resolve(idlArtifact, remoteRepos, localRepository); return idlArtifact; } catch (final ArtifactResolutionException e) { throw new MojoExecutionException( "Failed to resolve one or more idl artifacts:\n\n" + e.getMessage(), e); } catch (final ArtifactNotFoundException e) { throw new MojoExecutionException( "Failed to resolve one or more idl artifacts:\n\n" + e.getMessage(), e); } }
[ "public", "static", "Artifact", "getIdlArtifact", "(", "Artifact", "artifact", ",", "ArtifactFactory", "artifactFactory", ",", "ArtifactResolver", "artifactResolver", ",", "ArtifactRepository", "localRepository", ",", "List", "<", "ArtifactRepository", ">", "remoteRepos", ...
Resolves an idl jar for the artifact. @return Returns idl artifact @throws MojoExecutionException is idl jar is not present for the artifact.
[ "Resolves", "an", "idl", "jar", "for", "the", "artifact", "." ]
2aec9b19a610e12be9609cd97925d0b1284d48bc
https://github.com/twitter/scrooge/blob/2aec9b19a610e12be9609cd97925d0b1284d48bc/scrooge-maven-plugin/src/main/java/com/twitter/MavenScroogeCompilerUtil.java#L20-L42
train
lift/framework
core/common/src/main/java/net/liftweb/common/Func.java
Func.lift
public static<Z> Function0<Z> lift(Func0<Z> f) { return bridge.lift(f); }
java
public static<Z> Function0<Z> lift(Func0<Z> f) { return bridge.lift(f); }
[ "public", "static", "<", "Z", ">", "Function0", "<", "Z", ">", "lift", "(", "Func0", "<", "Z", ">", "f", ")", "{", "return", "bridge", ".", "lift", "(", "f", ")", ";", "}" ]
Lift a Java Func0 to a Scala Function0 @param f the function to lift @returns the Scala function
[ "Lift", "a", "Java", "Func0", "to", "a", "Scala", "Function0" ]
975aa115e0a8e2450dd4905a17ebd19830ae97b2
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/common/src/main/java/net/liftweb/common/Func.java#L37-L39
train
lift/framework
core/common/src/main/java/net/liftweb/common/Func.java
Func.lift
public static<A, Z> Function1<A, Z> lift(Func1<A, Z> f) { return bridge.lift(f); }
java
public static<A, Z> Function1<A, Z> lift(Func1<A, Z> f) { return bridge.lift(f); }
[ "public", "static", "<", "A", ",", "Z", ">", "Function1", "<", "A", ",", "Z", ">", "lift", "(", "Func1", "<", "A", ",", "Z", ">", "f", ")", "{", "return", "bridge", ".", "lift", "(", "f", ")", ";", "}" ]
Lift a Java Func1 to a Scala Function1 @param f the function to lift @returns the Scala function
[ "Lift", "a", "Java", "Func1", "to", "a", "Scala", "Function1" ]
975aa115e0a8e2450dd4905a17ebd19830ae97b2
https://github.com/lift/framework/blob/975aa115e0a8e2450dd4905a17ebd19830ae97b2/core/common/src/main/java/net/liftweb/common/Func.java#L48-L50
train