code stringlengths 23 201k | docstring stringlengths 17 96.2k | func_name stringlengths 0 235 | language stringclasses 1
value | repo stringlengths 8 72 | path stringlengths 11 317 | url stringlengths 57 377 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
private boolean stateRelease(int index) {
int pos = index;
while ((pos < input.length)
&& ((input[pos] >= '0' && input[pos] <= '9')
|| (input[pos] >= 'a' && input[pos] <= 'z')
|| (input[pos] >= 'A' && input[pos] <= 'Z') || input[pos] == '-')) {
pos++; // match [0..9a-zA-Z-]+
}
if (pos == inde... | Convenience method to check if this is a stable version.
@return true if the major version number is greater than zero and there are
no pre release tags. | stateRelease | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/SemanticVersion.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java | MIT |
private boolean stateMeta(int index) {
int pos = index;
while ((pos < input.length)
&& ((input[pos] >= '0' && input[pos] <= '9')
|| (input[pos] >= 'a' && input[pos] <= 'z')
|| (input[pos] >= 'A' && input[pos] <= 'Z') || input[pos] == '-')) {
pos++; // match [0..9a-zA-Z-]+
}
if (pos == index) ... | Convenience method to check if this is a stable version.
@return true if the major version number is greater than zero and there are
no pre release tags. | stateMeta | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/SemanticVersion.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/SemanticVersion.java | MIT |
public void report(String name) {
if (Constants.CHARSET_WINDOWS_1252.equals(name)) {
if (hint != null) {
// Use the encoding hint when available
name = hint;
} else if (statistics.count('\r') == 0) {
// If there are no CR(LF)s, then the enc... | Helper class used by {@link UniversalEncodingDetector} to access the
<code>juniversalchardet</code> detection logic. | report | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/UniversalEncodingListener.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/UniversalEncodingListener.java | MIT |
public boolean isDone() {
return detector.isDone();
} | Helper class used by {@link UniversalEncodingDetector} to access the
<code>juniversalchardet</code> detection logic. | isDone | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/UniversalEncodingListener.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/UniversalEncodingListener.java | MIT |
public void handleData(byte[] buf, int offset, int length) {
statistics.addData(buf, offset, length);
detector.handleData(buf, offset, length);
} | Helper class used by {@link UniversalEncodingDetector} to access the
<code>juniversalchardet</code> detection logic. | handleData | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/UniversalEncodingListener.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/UniversalEncodingListener.java | MIT |
public Charset dataEnd() {
detector.dataEnd();
if (charset == null && statistics.isMostlyAscii()) {
report(Constants.CHARSET_WINDOWS_1252);
}
return charset;
} | Helper class used by {@link UniversalEncodingDetector} to access the
<code>juniversalchardet</code> detection logic. | dataEnd | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/UniversalEncodingListener.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/UniversalEncodingListener.java | MIT |
public int getMajor() {
return major;
} | A version composed of major, minor, patch, qualifier and build. All fields except
major is optional, and optional fields are denoted using negative value (in case
of integer type or empty string in case of string type).
@author robin | getMajor | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/Version.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/Version.java | MIT |
public int getMinor() {
return minor;
} | A version composed of major, minor, patch, qualifier and build. All fields except
major is optional, and optional fields are denoted using negative value (in case
of integer type or empty string in case of string type).
@author robin | getMinor | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/Version.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/Version.java | MIT |
public int getPatch() {
return patch;
} | A version composed of major, minor, patch, qualifier and build. All fields except
major is optional, and optional fields are denoted using negative value (in case
of integer type or empty string in case of string type).
@author robin | getPatch | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/Version.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/Version.java | MIT |
public String getQualifier() {
return qualifier;
} | A version composed of major, minor, patch, qualifier and build. All fields except
major is optional, and optional fields are denoted using negative value (in case
of integer type or empty string in case of string type).
@author robin | getQualifier | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/Version.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/Version.java | MIT |
public int getBuild() {
return build;
} | A version composed of major, minor, patch, qualifier and build. All fields except
major is optional, and optional fields are denoted using negative value (in case
of integer type or empty string in case of string type).
@author robin | getBuild | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/Version.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/Version.java | MIT |
public boolean isCompatible(Version version) {
return major == version.getMajor() && (minor<0?0:minor) == (version.getMinor()<0?0:version.getMinor());
} | A version composed of major, minor, patch, qualifier and build. All fields except
major is optional, and optional fields are denoted using negative value (in case
of integer type or empty string in case of string type).
@author robin | isCompatible | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/Version.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/Version.java | MIT |
@Override
public int compareTo(Version version) {
if (major < version.getMajor())
return -1;
else if (major > version.getMajor())
return 1;
else if ((minor<0?0:minor) < (version.getMinor()<0?0:version.getMinor()))
return -1;
else if ((minor<0?0:minor) > (version.getMinor()<0?0:version.getMinor())) ... | A version composed of major, minor, patch, qualifier and build. All fields except
major is optional, and optional fields are denoted using negative value (in case
of integer type or empty string in case of string type).
@author robin | compareTo | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/Version.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/Version.java | MIT |
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append(major);
if (minor >= 0) {
buffer.append(".").append(minor);
if (patch >= 0)
buffer.append(".").append(patch);
}
if (qualifier.length() != 0) {
buffer.append("-").append(qualifier);
if (build >= 0)
... | A version composed of major, minor, patch, qualifier and build. All fields except
major is optional, and optional fields are denoted using negative value (in case
of integer type or empty string in case of string type).
@author robin | toString | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/Version.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/Version.java | MIT |
public LinkedList<Diff> diff_main(String text1, String text2) {
return diff_main(text1, text2, true);
} | Find the differences between two texts. Run a faster, slightly less
optimal diff. This method allows the 'checklines' of diff_main() to be
optional. Most of the time checklines is wanted, so default to true.
@param text1 Old string to be diffed.
@param text2 New string to be diffed.
@return Linked List of Diff objects... | diff_main | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public LinkedList<Diff> diff_main(String text1, String text2, boolean checklines) {
// Set a deadline by which time the diff must be complete.
long deadline;
if (Diff_Timeout <= 0) {
deadline = Long.MAX_VALUE;
} else {
deadline = System.currentTimeMillis() + (long) (Diff_Timeout * 1000);
}
return diff... | Find the differences between two texts.
@param text1 Old string to be diffed.
@param text2 New string to be diffed.
@param checklines Speedup flag. If false, then don't run a line-level
diff first to identify the changed areas. If true, then run a
faster slightly less optimal diff.
@return Linked List of... | diff_main | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
private LinkedList<Diff> diff_main(String text1, String text2, boolean checklines, long deadline) {
// Check for null inputs.
if (text1 == null || text2 == null) {
throw new IllegalArgumentException("Null inputs. (diff_main)");
}
// Check for equality (speedup).
LinkedList<Diff> diffs;
if (text1.equals(... | Find the differences between two texts. Simplifies the problem by
stripping any common prefix or suffix off the texts before diffing.
@param text1 Old string to be diffed.
@param text2 New string to be diffed.
@param checklines Speedup flag. If false, then don't run a line-level
diff first to identify the chang... | diff_main | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
private LinkedList<Diff> diff_compute(String text1, String text2, boolean checklines,
long deadline) {
LinkedList<Diff> diffs = new LinkedList<Diff>();
if (text1.length() == 0) {
// Just add some text (speedup).
diffs.add(new Diff(Operation.INSERT, text2));
return diffs;
}
if (text2.length() == 0)... | Find the differences between two texts. Assumes that the texts do not
have any common prefix or suffix.
@param text1 Old string to be diffed.
@param text2 New string to be diffed.
@param checklines Speedup flag. If false, then don't run a line-level
diff first to identify the changed areas. If true, then run a
... | diff_compute | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
private LinkedList<Diff> diff_lineMode(String text1, String text2, long deadline) {
// Scan the text on a line-by-line basis first.
LinesToCharsResult b = diff_linesToChars(text1, text2);
text1 = b.chars1;
text2 = b.chars2;
List<String> linearray = b.lineArray;
LinkedList<Diff> diffs = diff_main(text1, tex... | Do a quick line-level diff on both strings, then rediff the parts for
greater accuracy. This speedup can produce non-minimal diffs.
@param text1 Old string to be diffed.
@param text2 New string to be diffed.
@param deadline Time when the diff should be complete by.
@return Linked List of Diff objects. | diff_lineMode | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
protected LinkedList<Diff> diff_bisect(String text1, String text2, long deadline) {
// Cache the text lengths to prevent multiple calls.
int text1_length = text1.length();
int text2_length = text2.length();
int max_d = (text1_length + text2_length + 1) / 2;
int v_offset = max_d;
int v_length = 2 * max_d;
... | Find the 'middle snake' of a diff, split the problem in two and return
the recursively constructed diff. See Myers 1986 paper: An O(ND)
Difference Algorithm and Its Variations.
@param text1 Old string to be diffed.
@param text2 New string to be diffed.
@param deadline Time at which to bail if not yet complete.
@return... | diff_bisect | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
private LinkedList<Diff> diff_bisectSplit(String text1, String text2, int x, int y,
long deadline) {
String text1a = text1.substring(0, x);
String text2a = text2.substring(0, y);
String text1b = text1.substring(x);
String text2b = text2.substring(y);
// Compute both diffs serially.
LinkedList<Diff> diff... | Given the location of the 'middle snake', split the diff in two parts and
recurse.
@param text1 Old string to be diffed.
@param text2 New string to be diffed.
@param x Index of split point in text1.
@param y Index of split point in text2.
@param deadline Time at which to bail if not yet complete.
@return LinkedList of... | diff_bisectSplit | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
protected LinesToCharsResult diff_linesToChars(String text1, String text2) {
List<String> lineArray = new ArrayList<String>();
Map<String, Integer> lineHash = new HashMap<String, Integer>();
// e.g. linearray[4] == "Hello\n"
// e.g. linehash.get("Hello\n") == 4
// "\x00" is a valid character, but various deb... | Split two texts into a list of strings. Reduce the texts to a string of
hashes where each Unicode character represents one line.
@param text1 First string.
@param text2 Second string.
@return An object containing the encoded text1, the encoded text2 and the
List of unique strings. The zeroth element of the Lis... | diff_linesToChars | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
private String diff_linesToCharsMunge(String text, List<String> lineArray,
Map<String, Integer> lineHash) {
int lineStart = 0;
int lineEnd = -1;
String line;
StringBuilder chars = new StringBuilder();
// Walk the text, pulling out a substring for each line.
// text.split('\n') would would temporarily dou... | Split a text into a list of strings. Reduce the texts to a string of
hashes where each Unicode character represents one line.
@param text String to encode.
@param lineArray List of unique strings.
@param lineHash Map of strings to indices.
@return Encoded string. | diff_linesToCharsMunge | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
protected void diff_charsToLines(LinkedList<Diff> diffs, List<String> lineArray) {
StringBuilder text;
for (Diff diff : diffs) {
text = new StringBuilder();
for (int y = 0; y < diff.text.length(); y++) {
text.append(lineArray.get(diff.text.charAt(y)));
}
diff.text = text.toString();
}
} | Rehydrate the text in a diff from a string of line hashes to real lines
of text.
@param diffs LinkedList of Diff objects.
@param lineArray List of unique strings. | diff_charsToLines | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public int diff_commonPrefix(String text1, String text2) {
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
int n = Math.min(text1.length(), text2.length());
for (int i = 0; i < n; i++) {
if (text1.charAt(i) != text2.charAt(i)) {
return i;
}
}
return n;
} | Determine the common prefix of two strings
@param text1 First string.
@param text2 Second string.
@return The number of characters common to the start of each string. | diff_commonPrefix | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public int diff_commonSuffix(String text1, String text2) {
// Performance analysis: http://neil.fraser.name/news/2007/10/09/
int text1_length = text1.length();
int text2_length = text2.length();
int n = Math.min(text1_length, text2_length);
for (int i = 1; i <= n; i++) {
if (text1.charAt(text1_length - i) ... | Determine the common suffix of two strings
@param text1 First string.
@param text2 Second string.
@return The number of characters common to the end of each string. | diff_commonSuffix | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
protected int diff_commonOverlap(String text1, String text2) {
// Cache the text lengths to prevent multiple calls.
int text1_length = text1.length();
int text2_length = text2.length();
// Eliminate the null case.
if (text1_length == 0 || text2_length == 0) {
return 0;
}
// Truncate the longer string.
... | Determine if the suffix of one string is the prefix of another.
@param text1 First string.
@param text2 Second string.
@return The number of characters common to the end of the first string
and the start of the second string. | diff_commonOverlap | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
protected String[] diff_halfMatch(String text1, String text2) {
if (Diff_Timeout <= 0) {
// Don't risk returning a non-optimal diff if we have unlimited
// time.
return null;
}
String longtext = text1.length() > text2.length() ? text1 : text2;
String shorttext = text1.length() > text2.length() ? text2 ... | Do the two texts share a substring which is at least half the length of
the longer text? This speedup can produce non-minimal diffs.
@param text1 First string.
@param text2 Second string.
@return Five element String array, containing the prefix of text1, the
suffix of text1, the prefix of text2, the suffix of ... | diff_halfMatch | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
private String[] diff_halfMatchI(String longtext, String shorttext, int i) {
// Start with a 1/4 length substring at position i as a seed.
String seed = longtext.substring(i, i + longtext.length() / 4);
int j = -1;
String best_common = "";
String best_longtext_a = "", best_longtext_b = "";
String best_short... | Does a substring of shorttext exist within longtext such that the
substring is at least half the length of longtext?
@param longtext Longer string.
@param shorttext Shorter string.
@param i Start index of quarter length substring within longtext.
@return Five element String array, containing the prefix of longtext, th... | diff_halfMatchI | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public void diff_cleanupSemantic(LinkedList<Diff> diffs) {
if (diffs.isEmpty()) {
return;
}
boolean changes = false;
Stack<Diff> equalities = new Stack<Diff>(); // Stack of qualities.
String lastequality = null; // Always equal to
// equalities.lastElement().text
ListIterator<Diff> pointer = dif... | Reduce the number of edits by eliminating semantically trivial
equalities.
@param diffs LinkedList of Diff objects. | diff_cleanupSemantic | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public void diff_cleanupSemanticLossless(LinkedList<Diff> diffs) {
String equality1, edit, equality2;
String commonString;
int commonOffset;
int score, bestScore;
String bestEquality1, bestEdit, bestEquality2;
// Create a new iterator at the start.
ListIterator<Diff> pointer = diffs.listIterator();
Diff... | Look for single edits surrounded on both sides by equalities which can be
shifted sideways to align the edit to a word boundary. e.g: The c<ins>at
c</ins>ame. -> The <ins>cat </ins>came.
@param diffs LinkedList of Diff objects. | diff_cleanupSemanticLossless | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
private int diff_cleanupSemanticScore(String one, String two) {
if (one.length() == 0 || two.length() == 0) {
// Edges are the best.
return 6;
}
// Each port of this function behaves slightly differently due to
// subtle differences in each language's definition of things like
// 'whitespace'. Since th... | Given two strings, compute a score representing whether the internal
boundary falls on logical boundaries. Scores range from 6 (best) to 0
(worst).
@param one First string.
@param two Second string.
@return The score. | diff_cleanupSemanticScore | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public void diff_cleanupEfficiency(LinkedList<Diff> diffs) {
if (diffs.isEmpty()) {
return;
}
boolean changes = false;
Stack<Diff> equalities = new Stack<Diff>(); // Stack of equalities.
String lastequality = null; // Always equal to
// equalities.lastElement().text
ListIterator<Diff> pointer = ... | Reduce the number of edits by eliminating operationally trivial
equalities.
@param diffs LinkedList of Diff objects. | diff_cleanupEfficiency | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public void diff_cleanupMerge(LinkedList<Diff> diffs) {
diffs.add(new Diff(Operation.EQUAL, "")); // Add a dummy entry at the
// end.
ListIterator<Diff> pointer = diffs.listIterator();
int count_delete = 0;
int count_insert = 0;
String text_delete = "";
String text_insert = "";
Diff thisDiff ... | Reorder and merge like edit sections. Merge equalities. Any edit section
can move as long as it doesn't cross an equality.
@param diffs LinkedList of Diff objects. | diff_cleanupMerge | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public int diff_xIndex(LinkedList<Diff> diffs, int loc) {
int chars1 = 0;
int chars2 = 0;
int last_chars1 = 0;
int last_chars2 = 0;
Diff lastDiff = null;
for (Diff aDiff : diffs) {
if (aDiff.operation != Operation.INSERT) {
// Equality or deletion.
chars1 += aDiff.text.length();
}
if (aDiff... | loc is a location in text1, compute and return the equivalent location in
text2. e.g. "The cat" vs "The big cat", 1->1, 5->8
@param diffs LinkedList of Diff objects.
@param loc Location within text1.
@return Location within text2. | diff_xIndex | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public String diff_prettyHtml(LinkedList<Diff> diffs) {
StringBuilder html = new StringBuilder();
for (Diff aDiff : diffs) {
String text =
aDiff.text.replace("&", "&").replace("<", "<").replace(">", ">")
.replace("\n", "¶<br>");
switch (aDiff.operation) {
case INSERT:
html.... | Convert a Diff list into a pretty HTML report.
@param diffs LinkedList of Diff objects.
@return HTML representation. | diff_prettyHtml | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public String diff_text1(LinkedList<Diff> diffs) {
StringBuilder text = new StringBuilder();
for (Diff aDiff : diffs) {
if (aDiff.operation != Operation.INSERT) {
text.append(aDiff.text);
}
}
return text.toString();
} | Compute and return the source text (all equalities and deletions).
@param diffs LinkedList of Diff objects.
@return Source text. | diff_text1 | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public String diff_text2(LinkedList<Diff> diffs) {
StringBuilder text = new StringBuilder();
for (Diff aDiff : diffs) {
if (aDiff.operation != Operation.DELETE) {
text.append(aDiff.text);
}
}
return text.toString();
} | Compute and return the destination text (all equalities and insertions).
@param diffs LinkedList of Diff objects.
@return Destination text. | diff_text2 | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public int diff_levenshtein(LinkedList<Diff> diffs) {
int levenshtein = 0;
int insertions = 0;
int deletions = 0;
for (Diff aDiff : diffs) {
switch (aDiff.operation) {
case INSERT:
insertions += aDiff.text.length();
break;
case DELETE:
deletions += aDiff.text.length();
break;
... | Compute the Levenshtein distance; the number of inserted, deleted or
substituted characters.
@param diffs LinkedList of Diff objects.
@return Number of changes. | diff_levenshtein | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public String diff_toDelta(LinkedList<Diff> diffs) {
StringBuilder text = new StringBuilder();
for (Diff aDiff : diffs) {
switch (aDiff.operation) {
case INSERT:
try {
text.append("+")
.append(URLEncoder.encode(aDiff.text, "UTF-8").replace('+', ' '))
.append("\t");
} catch (Un... | Crush the diff into an encoded string which describes the operations
required to transform text1 into text2. E.g. =3\t-2\t+ing -> Keep 3
chars, delete 2 chars, insert 'ing'. Operations are tab-separated.
Inserted text is escaped using %xx notation.
@param diffs Array of Diff objects.
@return Delta text. | diff_toDelta | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public LinkedList<Diff> diff_fromDelta(String text1, String delta)
throws IllegalArgumentException {
LinkedList<Diff> diffs = new LinkedList<Diff>();
int pointer = 0; // Cursor in text1
String[] tokens = delta.split("\t");
for (String token : tokens) {
if (token.length() == 0) {
// Blank tokens are ok... | Given the original text1, and an encoded string which describes the
operations required to transform text1 into text2, compute the full diff.
@param text1 Source string for the diff.
@param delta Delta text.
@return Array of Diff objects or null if invalid.
@throws IllegalArgumentException If invalid input. | diff_fromDelta | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public int match_main(String text, String pattern, int loc) {
// Check for null inputs.
if (text == null || pattern == null) {
throw new IllegalArgumentException("Null inputs. (match_main)");
}
loc = Math.max(0, Math.min(loc, text.length()));
if (text.equals(pattern)) {
// Shortcut (potentially not gua... | Locate the best instance of 'pattern' in 'text' near 'loc'. Returns -1 if
no match found.
@param text The text to search.
@param pattern The pattern to search for.
@param loc The location to search around.
@return Best match index or -1. | match_main | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
protected int match_bitap(String text, String pattern, int loc) {
assert (Match_MaxBits == 0 || pattern.length() <= Match_MaxBits) : "Pattern too long for this application.";
// Initialise the alphabet.
Map<Character, Integer> s = match_alphabet(pattern);
// Highest score beyond which we give up.
double sco... | Locate the best instance of 'pattern' in 'text' near 'loc' using the
Bitap algorithm. Returns -1 if no match found.
@param text The text to search.
@param pattern The pattern to search for.
@param loc The location to search around.
@return Best match index or -1. | match_bitap | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
private double match_bitapScore(int e, int x, int loc, String pattern) {
float accuracy = (float) e / pattern.length();
int proximity = Math.abs(loc - x);
if (Match_Distance == 0) {
// Dodge divide by zero error.
return proximity == 0 ? accuracy : 1.0;
}
return accuracy + (proximity / (float) Match_Dist... | Compute and return the score for a match with e errors and x location.
@param e Number of errors in match.
@param x Location of match.
@param loc Expected location of match.
@param pattern Pattern being sought.
@return Overall score for match (0.0 = good, 1.0 = bad). | match_bitapScore | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
protected Map<Character, Integer> match_alphabet(String pattern) {
Map<Character, Integer> s = new HashMap<Character, Integer>();
char[] char_pattern = pattern.toCharArray();
for (char c : char_pattern) {
s.put(c, 0);
}
int i = 0;
for (char c : char_pattern) {
s.put(c, s.get(c) | (1 << (pattern.length... | Initialise the alphabet for the Bitap algorithm.
@param pattern The text to encode.
@return Hash of character locations. | match_alphabet | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
protected void patch_addContext(Patch patch, String text) {
if (text.length() == 0) {
return;
}
String pattern = text.substring(patch.start2, patch.start2 + patch.length1);
int padding = 0;
// Look for the first and last matches of pattern in text. If two
// different
// matches are found, increase th... | Increase the context until it is unique, but don't let the pattern expand
beyond Match_MaxBits.
@param patch The patch to grow.
@param text Source text. | patch_addContext | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public LinkedList<Patch> patch_make(String text1, String text2) {
if (text1 == null || text2 == null) {
throw new IllegalArgumentException("Null inputs. (patch_make)");
}
// No diffs provided, compute our own.
LinkedList<Diff> diffs = diff_main(text1, text2, true);
if (diffs.size() > 2) {
diff_cleanupSe... | Compute a list of patches to turn text1 into text2. A set of diffs will
be computed.
@param text1 Old text.
@param text2 New text.
@return LinkedList of Patch objects. | patch_make | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public LinkedList<Patch> patch_make(LinkedList<Diff> diffs) {
if (diffs == null) {
throw new IllegalArgumentException("Null inputs. (patch_make)");
}
// No origin string provided, compute our own.
String text1 = diff_text1(diffs);
return patch_make(text1, diffs);
} | Compute a list of patches to turn text1 into text2. text1 will be derived
from the provided diffs.
@param diffs Array of Diff objects for text1 to text2.
@return LinkedList of Patch objects. | patch_make | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public LinkedList<Patch> patch_make(String text1, String text2, LinkedList<Diff> diffs) {
return patch_make(text1, diffs);
} | Compute a list of patches to turn text1 into text2. text2 is ignored,
diffs are the delta between text1 and text2.
@param text1 Old text
@param text2 Ignored.
@param diffs Array of Diff objects for text1 to text2.
@return LinkedList of Patch objects.
@deprecated Prefer patch_make(String text1, LinkedList<Diff> diffs). | patch_make | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public LinkedList<Patch> patch_make(String text1, LinkedList<Diff> diffs) {
if (text1 == null || diffs == null) {
throw new IllegalArgumentException("Null inputs. (patch_make)");
}
LinkedList<Patch> patches = new LinkedList<Patch>();
if (diffs.isEmpty()) {
return patches; // Get rid of the null case.
}... | Compute a list of patches to turn text1 into text2. text2 is not
provided, diffs are the delta between text1 and text2.
@param text1 Old text.
@param diffs Array of Diff objects for text1 to text2.
@return LinkedList of Patch objects. | patch_make | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public LinkedList<Patch> patch_deepCopy(LinkedList<Patch> patches) {
LinkedList<Patch> patchesCopy = new LinkedList<Patch>();
for (Patch aPatch : patches) {
Patch patchCopy = new Patch();
for (Diff aDiff : aPatch.diffs) {
Diff diffCopy = new Diff(aDiff.operation, aDiff.text);
patchCopy.diffs.add(diffC... | Given an array of patches, return another array that is identical.
@param patches Array of Patch objects.
@return Array of Patch objects. | patch_deepCopy | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public Object[] patch_apply(LinkedList<Patch> patches, String text) {
if (patches.isEmpty()) {
return new Object[] {text, new boolean[0]};
}
// Deep copy the patches so that no changes are made to originals.
patches = patch_deepCopy(patches);
String nullPadding = patch_addPadding(patches);
text = nullP... | Merge a set of patches onto the text. Return a patched text, as well as
an array of true/false values indicating which patches were applied.
@param patches Array of Patch objects
@param text Old text.
@return Two element Object array, containing the new text and an array of
boolean values. | patch_apply | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public String patch_addPadding(LinkedList<Patch> patches) {
short paddingLength = this.Patch_Margin;
String nullPadding = "";
for (short x = 1; x <= paddingLength; x++) {
nullPadding += String.valueOf((char) x);
}
// Bump all the patches forward.
for (Patch aPatch : patches) {
aPatch.start1 += paddin... | Add some padding on text start and end so that edges can match something.
Intended to be called only from within patch_apply.
@param patches Array of Patch objects.
@return The padding string added to each side. | patch_addPadding | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public String patch_toText(List<Patch> patches) {
StringBuilder text = new StringBuilder();
for (Patch aPatch : patches) {
text.append(aPatch);
}
return text.toString();
} | Take a list of patches and return a textual representation.
@param patches List of Patch objects.
@return Text representation of patches. | patch_toText | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public List<Patch> patch_fromText(String textline) throws IllegalArgumentException {
List<Patch> patches = new LinkedList<Patch>();
if (textline.length() == 0) {
return patches;
}
List<String> textList = Arrays.asList(textline.split("\n"));
LinkedList<String> text = new LinkedList<String>(textList);
Patc... | Parse a textual representation of patches and return a List of Patch
objects.
@param textline Text representation of patches.
@return List of Patch objects.
@throws IllegalArgumentException If invalid input. | patch_fromText | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public String toString() {
String prettyText = this.text.replace('\n', '\u00b6');
return "Diff(" + this.operation + ",\"" + prettyText + "\")";
} | Display a human-readable version of this Diff.
@return text version. | toString | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
@Override
public int hashCode() {
final int prime = 31;
int result = (operation == null) ? 0 : operation.hashCode();
result += prime * ((text == null) ? 0 : text.hashCode());
return result;
} | Create a numeric hash value for a Diff. This function is not used by
DMP.
@return Hash value. | hashCode | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Diff other = (Diff) obj;
if (operation != other.operation) {
return false;
}
if (text == null) {
if (... | Is this Diff equivalent to another Diff?
@param obj Another Diff to compare against.
@return true or false. | equals | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
public String toString() {
String coords1, coords2;
if (this.length1 == 0) {
coords1 = this.start1 + ",0";
} else if (this.length1 == 1) {
coords1 = Integer.toString(this.start1 + 1);
} else {
coords1 = (this.start1 + 1) + "," + this.length1;
}
if (this.length2 == 0) {
coords2 = this.s... | Emmulate GNU diff's format. Header: @@ -382,8 +481,9 @@ Indicies are
printed as 1-based, not 0-based.
@return The GNU diff string. | toString | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
private static String unescapeForEncodeUriCompatability(String str) {
return str.replace("%21", "!").replace("%7E", "~").replace("%27", "'").replace("%28", "(")
.replace("%29", ")").replace("%3B", ";").replace("%2F", "/").replace("%3F", "?")
.replace("%3A", ":").replace("%40", "@").replace("%26", "&").replace... | Unescape selected chars for compatability with JavaScript's encodeURI. In
speed critical applications this could be dropped since the receiving
application will certainly decode these fine. Note that this function is
case-sensitive. Thus "%3f" would not be unescaped. But this is ok because
it is only called with the ou... | unescapeForEncodeUriCompatability | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java | MIT |
@Override
public boolean isEmpty(HibernateProxy value) {
return (value == null) || (findProxied(value) == null);
} | Serializer to use for values proxied using {@link HibernateProxy}.
<p>
TODO: should try to make this work more like Jackson
<code>BeanPropertyWriter</code>, possibly sub-classing it -- it handles much
of functionality we need, and has access to more information than value
serializers (like this one) have. | isEmpty | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/jackson/hibernate/HibernateProxySerializer.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/jackson/hibernate/HibernateProxySerializer.java | MIT |
@Override
public void serialize(HibernateProxy value, JsonGenerator jgen,
SerializerProvider provider) throws IOException,
JsonProcessingException {
Object proxiedValue = findProxied(value);
// TODO: figure out how to suppress nulls, if necessary? (too late for
// that here)
if (proxiedValue == null) {
... | Serializer to use for values proxied using {@link HibernateProxy}.
<p>
TODO: should try to make this work more like Jackson
<code>BeanPropertyWriter</code>, possibly sub-classing it -- it handles much
of functionality we need, and has access to more information than value
serializers (like this one) have. | serialize | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/jackson/hibernate/HibernateProxySerializer.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/jackson/hibernate/HibernateProxySerializer.java | MIT |
@Override
public void serializeWithType(HibernateProxy value, JsonGenerator jgen,
SerializerProvider provider, TypeSerializer typeSer)
throws IOException, JsonProcessingException {
Object proxiedValue = findProxied(value);
if (proxiedValue == null) {
provider.defaultSerializeNull(jgen);
return;
}
/... | Serializer to use for values proxied using {@link HibernateProxy}.
<p>
TODO: should try to make this work more like Jackson
<code>BeanPropertyWriter</code>, possibly sub-classing it -- it handles much
of functionality we need, and has access to more information than value
serializers (like this one) have. | serializeWithType | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/jackson/hibernate/HibernateProxySerializer.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/jackson/hibernate/HibernateProxySerializer.java | MIT |
protected Object findProxied(HibernateProxy proxy) {
return proxy.getHibernateLazyInitializer().getImplementation();
} | Helper method for finding value being proxied, if it is available or if
it is to be forced to be loaded. | findProxied | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/util/jackson/hibernate/HibernateProxySerializer.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/util/jackson/hibernate/HibernateProxySerializer.java | MIT |
public String getEmail() {
return this.email;
} | Get the email associated with this Gravatar.
@return the email associated with this Gravatar | getEmail | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public void setSize(int size) {
if (size >= 0 && size < 512) {
this.size = size;
}
} | Set the image size of this Gravatar in pixels.
@param size
size of image in pixels [1-512], 0 for default size | setSize | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public int getSize() {
return this.size;
} | Get the size set for this Gravatar.
@return the size set for this Gravatar [1-512], 0 for default size | getSize | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public void setDefault(int dflt) {
if (dflt >= DFLT_DEFAULT && dflt <= DFLT_BLANK) {
// blank out the custom if one was set
this.customDefault = null;
this.dflt = dflt;
}
} | Set the image returned if there is no Gravatar for the email.
@param dflt
must be one of the DFLT_XXX constants | setDefault | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public int getDefault() {
return this.dflt;
} | Get the default image setting of this Gravatar.
@return the default image setting of this Gravatar | getDefault | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public void setForceDefault(boolean forceDefault) {
this.forceDefault = forceDefault;
} | Sets whether the default Gravatar should always be returned.
@param forceDefault
true if the default Gravatar should always be returned | setForceDefault | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public boolean getForceDefault() {
return this.forceDefault;
} | Get whether this Gravatar is set to always return the default image.
@return true if this Gravatar is set to always return the default image | getForceDefault | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public void setCustomDefault(String url) {
try {
if (url != null) {
// UTF-8 should always be supported
this.customDefault = URLEncoder.encode(url, "UTF-8");
this.dflt = DFLT_DEFAULT;
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} | Set the URL of a custom default image to use.
@param url
the URL of the custom default image to use | setCustomDefault | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public String getCustomDefault() {
try {
// UTF-8 should always be supported
return this.customDefault == null ? null : URLDecoder.decode(
this.customDefault, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
} | Get the URL of the custom default image set for this Gravatar.
@return the URL of the custom default image set, null if not set | getCustomDefault | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public void setRating(int rating) {
if (rating >= RTNG_NONE && rating <= RTNG_X) {
this.rating = rating;
}
} | Set the maximum allowed rating of the image to return.
@param rating
must be one of the RTNG_XXX constants | setRating | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public int getRating() {
return this.rating;
} | Get the maximum allowed rating of image set for this Gravatar.
@return the rating set for this Gravatar | getRating | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public String getURL() {
var str = new StringBuilder();
var url = OneDev.getInstance(SettingManager.class).getSystemSetting().getAvatarServiceUrl();
str.append(StringUtils.stripEnd(url, "/\\")).append("/");
str.append(this.hash);
str.append(this.getOptions());
return str.toString();
} | Get the URL for this Gravatar, HTTPS if specified.
true if HTTPS is desired
@return URL for this Gravatar | getURL | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
private String getOptions() {
StringBuilder opts = new StringBuilder();
opts.append("?");
// size
if (this.size != 0) {
opts.append("s=");
opts.append(this.size);
}
// default
if (this.dflt >= 0) {
// check if we just added an option
opts.append(opts.length() > 1 ? "&" : "");
opts.append("d... | Build the options string to append to the URL.
@return the options portion of the URL | getOptions | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public static String getURL(String email) {
return AvatarService.getURL(email, 0, DFLT_DEFAULT, false, RTNG_NONE);
} | Get the optionally HTTPS Gravatar URL for a particular email.
@param email
the email for this Gravatar
@return the URL of the Gravatar | getURL | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public static String getURL(String email, int size) {
return AvatarService.getURL(email, size, DFLT_DEFAULT);
} | Get the Gravatar URL for an email and with a specified size
@param email
the email for this Gravatar
@param size
the desired size for this Gravatar [1-512]
@return the URL of the Gravatar | getURL | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public static String getURL(String email, int size, int dflt) {
return AvatarService.getURL(email, size, dflt, RTNG_NONE);
} | Get the Gravatar for an email with a specified size and default image.
@param email
the email for this Gravatar
@param size
the desired size for this Gravatar [1-512]
@param dflt
must be one of the DFLT_XXX constants
@return the URL of the Gravatar | getURL | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public static String getURL(String email, int size, int dflt, int rating) {
return AvatarService.getURL(email, size, dflt, false, rating);
} | Get the Gravatar for an email with a specified size, default image, and
maximum rating.
@param email
the email for this Gravatar
@param size
the desired size for this Gravatar [1-512]
@param dflt
must be one of the DFLT_XXX constants
@param rating
must be one of the RTNG_XXX... | getURL | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public static String getURL(String email, int size, int dflt,
boolean forceDefault, int rating) {
AvatarService g = new AvatarService(email);
g.setSize(size);
g.setDefault(dflt);
g.setForceDefault(forceDefault);
g.setRating(rating);
return g.getURL();
} | Get the Gravatar for an email with a specified size, custom default,
maximum rating, and specified force default option, and HTTPS preference.
@param email
the email for this Gravatar
@param size
the desired size for this Gravatar [1-512]
@param forceDefault
true if the default should ... | getURL | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
public static String getURL(String email, int size, String customDefault,
boolean forceDefault, int rating) {
AvatarService g = new AvatarService(email);
g.setSize(size);
g.setCustomDefault(customDefault);
g.setForceDefault(forceDefault);
g.setRating(rating);
return g.getURL();
} | Get the Gravatar for an email with a specified size, custom default,
maximum rating, specified force default option, and HTTPS preference.
@param email
the email for this Gravatar
@param size
the desired size for this Gravatar [1-512]
@param customDefault
URL of custom default image
@p... | getURL | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
private static String toHexString(byte[] buf) {
BigInteger bi = new BigInteger(1, buf);
return String.format("%0" + (buf.length << 1) + "X", bi);
} | Convert an array of bytes to a Hex String
@param buf
the bytes to convert
@return the Hex String of the bytes | toHexString | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/avatar/AvatarService.java | MIT |
@Nullable
protected Optional<String> describe(ParseExpect parseExpect, String suggestedLiteral) {
if (StringUtils.isNotBlank(suggestedLiteral))
return Optional.absent();
else
return Optional.of(_T("space"));
} | Describe suggested literal
@param suggestedLiteral
suggested literal
@return
an optional containing description of the literal, or <tt>null</tt> to suppress the suggestion | describe | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/behavior/inputassist/ANTLRAssistBehavior.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/behavior/inputassist/ANTLRAssistBehavior.java | MIT |
protected boolean isFuzzySuggestion(InputCompletion suggestion) {
return false;
} | Given an input content, anchor is index of the char at which place to display left side
of the suggestion window. This makes it possible to make the suggestion window moves
as one types, instead of always staying at a fixed place
@param inputContent
@return | isFuzzySuggestion | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/behavior/inputassist/InputAssistBehavior.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/behavior/inputassist/InputAssistBehavior.java | MIT |
public CodeComment getComment() {
return OneDev.getInstance(CodeCommentManager.class).load(commentId);
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | getComment | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
private WebMarkupContainer newCommentOrReplyContainer() {
WebMarkupContainer viewFragment = new Fragment("comment", "commentOrReplyViewFrag", this);
viewFragment.setOutputMarkupId(true);
viewFragment.add(AttributeAppender.append("class", new LoadableDetachableModel<String>() {
@Override
protected String... | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | newCommentOrReplyContainer | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
protected String load() {
var comment = getComment();
if (!comment.getUser().equals(SecurityUtils.getAuthUser()) && !comment.isVisitedAfter(getComment().getCreateDate()))
return "new";
else
return "";
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | load | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
protected void onComponentTag(ComponentTag tag) {
super.onComponentTag(tag);
tag.put("data-tippy-content", _T("Current context is different from the context when this comment is added, click to show the comment context"));
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | onComponentTag | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
public String getObject() {
return getComment().getContent();
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | getObject | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
public void detach() {
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | detach | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
public void setObject(String object) {
CodeComment comment = getComment();
comment.setContent(object);
OneDev.getInstance(CodeCommentManager.class).update(comment);
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | setObject | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
protected SuggestionSupport getSuggestionSupport() {
return CodeCommentPanel.this.getSuggestionSupport();
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | getSuggestionSupport | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
public void onClick(AjaxRequestTarget target) {
Fragment editFragment = new Fragment(viewFragment.getId(), "commentOrReplyEditFrag", CodeCommentPanel.this);
Form<?> form = new Form<Void>("form");
form.setOutputMarkupId(true);
CommentInput contentInput = new CommentInput("content",... | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | onClick | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
protected AttachmentSupport getAttachmentSupport() {
return new ProjectAttachmentSupport(getComment().getProject(), getComment().getUUID(),
SecurityUtils.canManageCodeComments(getProject()));
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | getAttachmentSupport | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
protected String getAutosaveKey() {
return "code-comment:" + getComment().getId() + ":content";
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | getAutosaveKey | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
protected SuggestionSupport getSuggestionSupport() {
return CodeCommentPanel.this.getSuggestionSupport();
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | getSuggestionSupport | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
protected Project getProject() {
return getComment().getProject();
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | getProject | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
@Override
protected List<User> getParticipants() {
return getComment().getParticipants();
} | We pass comment id instead of comment model as we want to make sure that
comment is always loaded upon usage as this panel is involved in websocket
update and websocket update does not detach models at end of request which
may result in Hibernate lazy load exception when the comment is used again
in next request
@p... | getParticipants | java | theonedev/onedev | server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | https://github.com/theonedev/onedev/blob/master/server-core/src/main/java/io/onedev/server/web/component/codecomment/CodeCommentPanel.java | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.