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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
samskivert/samskivert | src/main/java/com/samskivert/util/MethodFinder.java | MethodFinder.findMethod | public Method findMethod (String methodName, Class<?>[] parameterTypes)
throws NoSuchMethodException
{
// make sure the constructor list is loaded
maybeLoadMethods();
List<Member> methodList = _methodMap.get(methodName);
if (methodList == null) {
throw new NoSuchMethodException(
"No method named " + _clazz.getName() + "." + methodName);
}
if (parameterTypes == null) {
parameterTypes = new Class<?>[0];
}
return (Method)findMemberIn(methodList, parameterTypes);
} | java | public Method findMethod (String methodName, Class<?>[] parameterTypes)
throws NoSuchMethodException
{
// make sure the constructor list is loaded
maybeLoadMethods();
List<Member> methodList = _methodMap.get(methodName);
if (methodList == null) {
throw new NoSuchMethodException(
"No method named " + _clazz.getName() + "." + methodName);
}
if (parameterTypes == null) {
parameterTypes = new Class<?>[0];
}
return (Method)findMemberIn(methodList, parameterTypes);
} | [
"public",
"Method",
"findMethod",
"(",
"String",
"methodName",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"parameterTypes",
")",
"throws",
"NoSuchMethodException",
"{",
"// make sure the constructor list is loaded",
"maybeLoadMethods",
"(",
")",
";",
"List",
"<",
"Membe... | Returns the most specific public method in my target class that has the given name and
accepts the number and type of parameters in the given Class array in a reflective
invocation.
<p> A null value or Void.TYPE in parameterTypes will match a corresponding Object or array
reference in a method's formal parameter list, but not a primitive formal parameter.
@param methodName name of the method to search for.
@param parameterTypes array representing the number and types of parameters to look for in
the method's signature. A null array is treated as a zero-length array.
@return Method object satisfying the conditions.
@exception NoSuchMethodException if no methods match the criteria, or if the reflective call
is ambiguous based on the parameter types, or if methodName is null. | [
"Returns",
"the",
"most",
"specific",
"public",
"method",
"in",
"my",
"target",
"class",
"that",
"has",
"the",
"given",
"name",
"and",
"accepts",
"the",
"number",
"and",
"type",
"of",
"parameters",
"in",
"the",
"given",
"Class",
"array",
"in",
"a",
"reflec... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/MethodFinder.java#L110-L127 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/MethodFinder.java | MethodFinder.maybeLoadConstructors | protected void maybeLoadConstructors ()
{
if (_ctorList == null) {
_ctorList = new ArrayList<Member>();
Constructor<?>[] ctors = _clazz.getConstructors();
for (int i = 0; i < ctors.length; ++i) {
_ctorList.add(ctors[i]);
_paramMap.put(ctors[i], ctors[i].getParameterTypes());
}
}
} | java | protected void maybeLoadConstructors ()
{
if (_ctorList == null) {
_ctorList = new ArrayList<Member>();
Constructor<?>[] ctors = _clazz.getConstructors();
for (int i = 0; i < ctors.length; ++i) {
_ctorList.add(ctors[i]);
_paramMap.put(ctors[i], ctors[i].getParameterTypes());
}
}
} | [
"protected",
"void",
"maybeLoadConstructors",
"(",
")",
"{",
"if",
"(",
"_ctorList",
"==",
"null",
")",
"{",
"_ctorList",
"=",
"new",
"ArrayList",
"<",
"Member",
">",
"(",
")",
";",
"Constructor",
"<",
"?",
">",
"[",
"]",
"ctors",
"=",
"_clazz",
".",
... | Loads up the data structures for my target class's constructors. | [
"Loads",
"up",
"the",
"data",
"structures",
"for",
"my",
"target",
"class",
"s",
"constructors",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/MethodFinder.java#L241-L251 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/MethodFinder.java | MethodFinder.maybeLoadMethods | protected void maybeLoadMethods ()
{
if (_methodMap == null) {
_methodMap = new HashMap<String,List<Member>>();
Method[] methods = _clazz.getMethods();
for (int i = 0; i < methods.length; ++i) {
Method m = methods[i];
String methodName = m.getName();
Class<?>[] paramTypes = m.getParameterTypes();
List<Member> list = _methodMap.get(methodName);
if (list == null) {
list = new ArrayList<Member>();
_methodMap.put(methodName, list);
}
if (!ClassUtil.classIsAccessible(_clazz)) {
m = ClassUtil.getAccessibleMethodFrom(_clazz, methodName, paramTypes );
}
if (m != null) {
list.add(m);
_paramMap.put(m, paramTypes);
}
}
}
} | java | protected void maybeLoadMethods ()
{
if (_methodMap == null) {
_methodMap = new HashMap<String,List<Member>>();
Method[] methods = _clazz.getMethods();
for (int i = 0; i < methods.length; ++i) {
Method m = methods[i];
String methodName = m.getName();
Class<?>[] paramTypes = m.getParameterTypes();
List<Member> list = _methodMap.get(methodName);
if (list == null) {
list = new ArrayList<Member>();
_methodMap.put(methodName, list);
}
if (!ClassUtil.classIsAccessible(_clazz)) {
m = ClassUtil.getAccessibleMethodFrom(_clazz, methodName, paramTypes );
}
if (m != null) {
list.add(m);
_paramMap.put(m, paramTypes);
}
}
}
} | [
"protected",
"void",
"maybeLoadMethods",
"(",
")",
"{",
"if",
"(",
"_methodMap",
"==",
"null",
")",
"{",
"_methodMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"List",
"<",
"Member",
">",
">",
"(",
")",
";",
"Method",
"[",
"]",
"methods",
"=",
"_cl... | Loads up the data structures for my target class's methods. | [
"Loads",
"up",
"the",
"data",
"structures",
"for",
"my",
"target",
"class",
"s",
"methods",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/MethodFinder.java#L256-L283 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Folds.java | Folds.foldLeft | public static <A, B> B foldLeft (F<B,A> func, B zero, Iterable<? extends A> values)
{
for (A value : values) {
zero = func.apply(zero, value);
}
return zero;
} | java | public static <A, B> B foldLeft (F<B,A> func, B zero, Iterable<? extends A> values)
{
for (A value : values) {
zero = func.apply(zero, value);
}
return zero;
} | [
"public",
"static",
"<",
"A",
",",
"B",
">",
"B",
"foldLeft",
"(",
"F",
"<",
"B",
",",
"A",
">",
"func",
",",
"B",
"zero",
",",
"Iterable",
"<",
"?",
"extends",
"A",
">",
"values",
")",
"{",
"for",
"(",
"A",
"value",
":",
"values",
")",
"{",
... | Left folds the supplied function over the supplied values using the supplied starting value. | [
"Left",
"folds",
"the",
"supplied",
"function",
"over",
"the",
"supplied",
"values",
"using",
"the",
"supplied",
"starting",
"value",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Folds.java#L30-L36 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Folds.java | Folds.reduceLeft | public static <A> A reduceLeft (F<A,A> func, Iterable<? extends A> values)
{
Iterator<? extends A> iter = values.iterator();
A zero = iter.next();
while (iter.hasNext()) {
zero = func.apply(zero, iter.next());
}
return zero;
} | java | public static <A> A reduceLeft (F<A,A> func, Iterable<? extends A> values)
{
Iterator<? extends A> iter = values.iterator();
A zero = iter.next();
while (iter.hasNext()) {
zero = func.apply(zero, iter.next());
}
return zero;
} | [
"public",
"static",
"<",
"A",
">",
"A",
"reduceLeft",
"(",
"F",
"<",
"A",
",",
"A",
">",
"func",
",",
"Iterable",
"<",
"?",
"extends",
"A",
">",
"values",
")",
"{",
"Iterator",
"<",
"?",
"extends",
"A",
">",
"iter",
"=",
"values",
".",
"iterator"... | Reduces the supplied values using the supplied function with a left fold.
@exception NoSuchElementException thrown if values does not contain at least one element. | [
"Reduces",
"the",
"supplied",
"values",
"using",
"the",
"supplied",
"function",
"with",
"a",
"left",
"fold",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Folds.java#L43-L51 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Folds.java | Folds.sum | public static int sum (int zero, Iterable<? extends Number> values)
{
for (Number value : values) {
zero += value.intValue();
}
return zero;
} | java | public static int sum (int zero, Iterable<? extends Number> values)
{
for (Number value : values) {
zero += value.intValue();
}
return zero;
} | [
"public",
"static",
"int",
"sum",
"(",
"int",
"zero",
",",
"Iterable",
"<",
"?",
"extends",
"Number",
">",
"values",
")",
"{",
"for",
"(",
"Number",
"value",
":",
"values",
")",
"{",
"zero",
"+=",
"value",
".",
"intValue",
"(",
")",
";",
"}",
"retu... | Sums the supplied collection of numbers to an int with a left to right fold. | [
"Sums",
"the",
"supplied",
"collection",
"of",
"numbers",
"to",
"an",
"int",
"with",
"a",
"left",
"to",
"right",
"fold",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Folds.java#L56-L62 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Folds.java | Folds.sum | public static long sum (long zero, Iterable<? extends Number> values)
{
for (Number value : values) {
zero += value.longValue();
}
return zero;
} | java | public static long sum (long zero, Iterable<? extends Number> values)
{
for (Number value : values) {
zero += value.longValue();
}
return zero;
} | [
"public",
"static",
"long",
"sum",
"(",
"long",
"zero",
",",
"Iterable",
"<",
"?",
"extends",
"Number",
">",
"values",
")",
"{",
"for",
"(",
"Number",
"value",
":",
"values",
")",
"{",
"zero",
"+=",
"value",
".",
"longValue",
"(",
")",
";",
"}",
"r... | Sums the supplied collection of numbers to a long with a left to right fold. | [
"Sums",
"the",
"supplied",
"collection",
"of",
"numbers",
"to",
"a",
"long",
"with",
"a",
"left",
"to",
"right",
"fold",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Folds.java#L67-L73 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Folds.java | Folds.sum | public static float sum (float zero, Iterable<? extends Number> values)
{
for (Number value : values) {
zero += value.floatValue();
}
return zero;
} | java | public static float sum (float zero, Iterable<? extends Number> values)
{
for (Number value : values) {
zero += value.floatValue();
}
return zero;
} | [
"public",
"static",
"float",
"sum",
"(",
"float",
"zero",
",",
"Iterable",
"<",
"?",
"extends",
"Number",
">",
"values",
")",
"{",
"for",
"(",
"Number",
"value",
":",
"values",
")",
"{",
"zero",
"+=",
"value",
".",
"floatValue",
"(",
")",
";",
"}",
... | Sums the supplied collection of numbers to a float with a left to right fold. | [
"Sums",
"the",
"supplied",
"collection",
"of",
"numbers",
"to",
"a",
"float",
"with",
"a",
"left",
"to",
"right",
"fold",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Folds.java#L78-L84 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Folds.java | Folds.sum | public static double sum (double zero, Iterable<? extends Number> values)
{
for (Number value : values) {
zero += value.doubleValue();
}
return zero;
} | java | public static double sum (double zero, Iterable<? extends Number> values)
{
for (Number value : values) {
zero += value.doubleValue();
}
return zero;
} | [
"public",
"static",
"double",
"sum",
"(",
"double",
"zero",
",",
"Iterable",
"<",
"?",
"extends",
"Number",
">",
"values",
")",
"{",
"for",
"(",
"Number",
"value",
":",
"values",
")",
"{",
"zero",
"+=",
"value",
".",
"doubleValue",
"(",
")",
";",
"}"... | Sums the supplied collection of numbers to a double with a left to right fold. | [
"Sums",
"the",
"supplied",
"collection",
"of",
"numbers",
"to",
"a",
"double",
"with",
"a",
"left",
"to",
"right",
"fold",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Folds.java#L89-L95 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Folds.java | Folds.sum | public static BigInteger sum (BigInteger zero, Iterable<? extends BigInteger> values)
{
for (BigInteger value : values) {
zero = zero.add(value);
}
return zero;
} | java | public static BigInteger sum (BigInteger zero, Iterable<? extends BigInteger> values)
{
for (BigInteger value : values) {
zero = zero.add(value);
}
return zero;
} | [
"public",
"static",
"BigInteger",
"sum",
"(",
"BigInteger",
"zero",
",",
"Iterable",
"<",
"?",
"extends",
"BigInteger",
">",
"values",
")",
"{",
"for",
"(",
"BigInteger",
"value",
":",
"values",
")",
"{",
"zero",
"=",
"zero",
".",
"add",
"(",
"value",
... | Sums the supplied collection of numbers to a bigint with a left to right fold. | [
"Sums",
"the",
"supplied",
"collection",
"of",
"numbers",
"to",
"a",
"bigint",
"with",
"a",
"left",
"to",
"right",
"fold",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Folds.java#L100-L106 | train |
samskivert/samskivert | src/main/java/com/samskivert/velocity/StringTool.java | StringTool.truncate | public static String truncate (String text, int length, String append)
{
return StringUtil.truncate(text, length, append);
} | java | public static String truncate (String text, int length, String append)
{
return StringUtil.truncate(text, length, append);
} | [
"public",
"static",
"String",
"truncate",
"(",
"String",
"text",
",",
"int",
"length",
",",
"String",
"append",
")",
"{",
"return",
"StringUtil",
".",
"truncate",
"(",
"text",
",",
"length",
",",
"append",
")",
";",
"}"
] | Truncates the supplied text at the specified length, appending the
specified "elipsis" indicator to the text if truncated. | [
"Truncates",
"the",
"supplied",
"text",
"at",
"the",
"specified",
"length",
"appending",
"the",
"specified",
"elipsis",
"indicator",
"to",
"the",
"text",
"if",
"truncated",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/StringTool.java#L97-L100 | train |
samskivert/samskivert | src/main/java/com/samskivert/velocity/StringTool.java | StringTool.join | public static String join (String[] values, String sep)
{
return StringUtil.join(values, sep);
} | java | public static String join (String[] values, String sep)
{
return StringUtil.join(values, sep);
} | [
"public",
"static",
"String",
"join",
"(",
"String",
"[",
"]",
"values",
",",
"String",
"sep",
")",
"{",
"return",
"StringUtil",
".",
"join",
"(",
"values",
",",
"sep",
")",
";",
"}"
] | Joins the supplied strings with the given separator. | [
"Joins",
"the",
"supplied",
"strings",
"with",
"the",
"given",
"separator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/StringTool.java#L113-L116 | train |
samskivert/samskivert | src/main/java/com/samskivert/velocity/StringTool.java | StringTool.copyright | public static String copyright (String holder, int startYear)
{
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
return "© " + holder + " " + startYear + "-" + year;
} | java | public static String copyright (String holder, int startYear)
{
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
return "© " + holder + " " + startYear + "-" + year;
} | [
"public",
"static",
"String",
"copyright",
"(",
"String",
"holder",
",",
"int",
"startYear",
")",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"int",
"year",
"=",
"cal",
".",
"get",
"(",
"Calendar",
".",
"YEAR",
")",
";",... | Generates a copyright string for the specified copyright holder from the
specified first year to the current year. | [
"Generates",
"a",
"copyright",
"string",
"for",
"the",
"specified",
"copyright",
"holder",
"from",
"the",
"specified",
"first",
"year",
"to",
"the",
"current",
"year",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/StringTool.java#L122-L127 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/RadialMenuItem.java | RadialMenuItem.render | public void render (Component host, RadialMenu menu, Graphics2D gfx, int x, int y)
{
paint(gfx, x, y, menu);
} | java | public void render (Component host, RadialMenu menu, Graphics2D gfx, int x, int y)
{
paint(gfx, x, y, menu);
} | [
"public",
"void",
"render",
"(",
"Component",
"host",
",",
"RadialMenu",
"menu",
",",
"Graphics2D",
"gfx",
",",
"int",
"x",
",",
"int",
"y",
")",
"{",
"paint",
"(",
"gfx",
",",
"x",
",",
"y",
",",
"menu",
")",
";",
"}"
] | Renders this menu item at the specified location. | [
"Renders",
"this",
"menu",
"item",
"at",
"the",
"specified",
"location",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/RadialMenuItem.java#L75-L78 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/util/ProximityTracker.java | ProximityTracker.addObject | public void addObject (int x, int y, Object object)
{
Record record = new Record(x, y, object);
// if this is the very first element, we have to insert it
// straight away because our binary search algorithm doesn't work
// on empty arrays
if (_size == 0) {
_records[_size++] = record;
return;
}
// figure out where to insert it
int ipoint = binarySearch(x);
// expand the records array if necessary
if (_size >= _records.length) {
int nsize = _size*2;
Record[] records = new Record[nsize];
System.arraycopy(_records, 0, records, 0, _size);
_records = records;
}
// shift everything down
if (ipoint < _size) {
System.arraycopy(_records, ipoint, _records, ipoint+1,
_size-ipoint);
}
// insert the record
_records[ipoint] = record;
_size++;
} | java | public void addObject (int x, int y, Object object)
{
Record record = new Record(x, y, object);
// if this is the very first element, we have to insert it
// straight away because our binary search algorithm doesn't work
// on empty arrays
if (_size == 0) {
_records[_size++] = record;
return;
}
// figure out where to insert it
int ipoint = binarySearch(x);
// expand the records array if necessary
if (_size >= _records.length) {
int nsize = _size*2;
Record[] records = new Record[nsize];
System.arraycopy(_records, 0, records, 0, _size);
_records = records;
}
// shift everything down
if (ipoint < _size) {
System.arraycopy(_records, ipoint, _records, ipoint+1,
_size-ipoint);
}
// insert the record
_records[ipoint] = record;
_size++;
} | [
"public",
"void",
"addObject",
"(",
"int",
"x",
",",
"int",
"y",
",",
"Object",
"object",
")",
"{",
"Record",
"record",
"=",
"new",
"Record",
"(",
"x",
",",
"y",
",",
"object",
")",
";",
"// if this is the very first element, we have to insert it",
"// straigh... | Adds an object to the tracker. | [
"Adds",
"an",
"object",
"to",
"the",
"tracker",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/ProximityTracker.java#L41-L73 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/util/ProximityTracker.java | ProximityTracker.distance | public static int distance (int x1, int y1, int x2, int y2)
{
int dx = x1-x2, dy = y1-y2;
return (int)Math.sqrt(dx*dx+dy*dy);
} | java | public static int distance (int x1, int y1, int x2, int y2)
{
int dx = x1-x2, dy = y1-y2;
return (int)Math.sqrt(dx*dx+dy*dy);
} | [
"public",
"static",
"int",
"distance",
"(",
"int",
"x1",
",",
"int",
"y1",
",",
"int",
"x2",
",",
"int",
"y2",
")",
"{",
"int",
"dx",
"=",
"x1",
"-",
"x2",
",",
"dy",
"=",
"y1",
"-",
"y2",
";",
"return",
"(",
"int",
")",
"Math",
".",
"sqrt",
... | Computes the geometric distance between the supplied two points. | [
"Computes",
"the",
"geometric",
"distance",
"between",
"the",
"supplied",
"two",
"points",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/ProximityTracker.java#L205-L209 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/util/ProximityTracker.java | ProximityTracker.binarySearch | protected int binarySearch (int x)
{
// copied from java.util.Arrays which I wouldn't have to have done had the provided a
// means by which to binarySearch in a subset of an array. alas.
int low = 0;
int high = _size-1;
while (low <= high) {
int mid = (low + high) >>> 1;
int cmp = (_records[mid].x - x);
if (cmp < 0) {
low = mid + 1;
} else if (cmp > 0) {
high = mid - 1;
} else {
return mid; // key found
}
}
return low; // key not found
} | java | protected int binarySearch (int x)
{
// copied from java.util.Arrays which I wouldn't have to have done had the provided a
// means by which to binarySearch in a subset of an array. alas.
int low = 0;
int high = _size-1;
while (low <= high) {
int mid = (low + high) >>> 1;
int cmp = (_records[mid].x - x);
if (cmp < 0) {
low = mid + 1;
} else if (cmp > 0) {
high = mid - 1;
} else {
return mid; // key found
}
}
return low; // key not found
} | [
"protected",
"int",
"binarySearch",
"(",
"int",
"x",
")",
"{",
"// copied from java.util.Arrays which I wouldn't have to have done had the provided a",
"// means by which to binarySearch in a subset of an array. alas.",
"int",
"low",
"=",
"0",
";",
"int",
"high",
"=",
"_size",
... | Returns the index of a record with the specified x coordinate, or a
value representing the index where such a record would be inserted
while preserving the sort order of the array. Doesn't work if the
records array contains zero elements. | [
"Returns",
"the",
"index",
"of",
"a",
"record",
"with",
"the",
"specified",
"x",
"coordinate",
"or",
"a",
"value",
"representing",
"the",
"index",
"where",
"such",
"a",
"record",
"would",
"be",
"inserted",
"while",
"preserving",
"the",
"sort",
"order",
"of",... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/ProximityTracker.java#L217-L238 | train |
samskivert/samskivert | src/main/java/com/samskivert/text/MessageUtil.java | MessageUtil.compose | public static String compose (String key, Object... args)
{
StringBuilder buf = new StringBuilder();
buf.append(key);
buf.append('|');
for (int i = 0; i < args.length; i++) {
if (i > 0) {
buf.append('|');
}
// escape the string while adding to the buffer
String arg = (args[i] == null) ? "" : String.valueOf(args[i]);
int alength = arg.length();
for (int p = 0; p < alength; p++) {
char ch = arg.charAt(p);
if (ch == '|') {
buf.append("\\!");
} else if (ch == '\\') {
buf.append("\\\\");
} else {
buf.append(ch);
}
}
}
return buf.toString();
} | java | public static String compose (String key, Object... args)
{
StringBuilder buf = new StringBuilder();
buf.append(key);
buf.append('|');
for (int i = 0; i < args.length; i++) {
if (i > 0) {
buf.append('|');
}
// escape the string while adding to the buffer
String arg = (args[i] == null) ? "" : String.valueOf(args[i]);
int alength = arg.length();
for (int p = 0; p < alength; p++) {
char ch = arg.charAt(p);
if (ch == '|') {
buf.append("\\!");
} else if (ch == '\\') {
buf.append("\\\\");
} else {
buf.append(ch);
}
}
}
return buf.toString();
} | [
"public",
"static",
"String",
"compose",
"(",
"String",
"key",
",",
"Object",
"...",
"args",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buf",
".",
"append",
"(",
"key",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'"... | Composes a message key with an array of arguments. The message can subsequently be
decomposed and translated without prior knowledge of how many arguments were provided. | [
"Composes",
"a",
"message",
"key",
"with",
"an",
"array",
"of",
"arguments",
".",
"The",
"message",
"can",
"subsequently",
"be",
"decomposed",
"and",
"translated",
"without",
"prior",
"knowledge",
"of",
"how",
"many",
"arguments",
"were",
"provided",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/text/MessageUtil.java#L52-L76 | train |
samskivert/samskivert | src/main/java/com/samskivert/text/MessageUtil.java | MessageUtil.unescape | public static String unescape (String value)
{
int bsidx = value.indexOf('\\');
if (bsidx == -1) {
return value;
}
StringBuilder buf = new StringBuilder();
int vlength = value.length();
for (int ii = 0; ii < vlength; ii++) {
char ch = value.charAt(ii);
if (ch != '\\' || ii == vlength-1) {
buf.append(ch);
} else {
// look at the next character
ch = value.charAt(++ii);
buf.append((ch == '!') ? '|' : ch);
}
}
return buf.toString();
} | java | public static String unescape (String value)
{
int bsidx = value.indexOf('\\');
if (bsidx == -1) {
return value;
}
StringBuilder buf = new StringBuilder();
int vlength = value.length();
for (int ii = 0; ii < vlength; ii++) {
char ch = value.charAt(ii);
if (ch != '\\' || ii == vlength-1) {
buf.append(ch);
} else {
// look at the next character
ch = value.charAt(++ii);
buf.append((ch == '!') ? '|' : ch);
}
}
return buf.toString();
} | [
"public",
"static",
"String",
"unescape",
"(",
"String",
"value",
")",
"{",
"int",
"bsidx",
"=",
"value",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"bsidx",
"==",
"-",
"1",
")",
"{",
"return",
"value",
";",
"}",
"StringBuilder",
"buf",
"=... | Unescapes characters that are escaped in a call to compose. | [
"Unescapes",
"characters",
"that",
"are",
"escaped",
"in",
"a",
"call",
"to",
"compose",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/text/MessageUtil.java#L102-L123 | train |
samskivert/samskivert | src/main/java/com/samskivert/text/MessageUtil.java | MessageUtil.decompose | public static String[] decompose (String compoundKey)
{
String[] args = compoundKey.split("\\|");
for (int ii = 0; ii < args.length; ii++) {
args[ii] = unescape(args[ii]);
}
return args;
} | java | public static String[] decompose (String compoundKey)
{
String[] args = compoundKey.split("\\|");
for (int ii = 0; ii < args.length; ii++) {
args[ii] = unescape(args[ii]);
}
return args;
} | [
"public",
"static",
"String",
"[",
"]",
"decompose",
"(",
"String",
"compoundKey",
")",
"{",
"String",
"[",
"]",
"args",
"=",
"compoundKey",
".",
"split",
"(",
"\"\\\\|\"",
")",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
"args",
".",
"... | Decomposes a compound key into its constituent parts. Arguments that were tainted during
composition will remain tainted. | [
"Decomposes",
"a",
"compound",
"key",
"into",
"its",
"constituent",
"parts",
".",
"Arguments",
"that",
"were",
"tainted",
"during",
"composition",
"will",
"remain",
"tainted",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/text/MessageUtil.java#L155-L162 | train |
samskivert/samskivert | src/main/java/com/samskivert/text/MessageUtil.java | MessageUtil.qualify | public static String qualify (String bundle, String key)
{
// sanity check
if (bundle.indexOf(QUAL_PREFIX) != -1 ||
bundle.indexOf(QUAL_SEP) != -1) {
String errmsg = "Message bundle may not contain '" + QUAL_PREFIX +
"' or '" + QUAL_SEP + "' [bundle=" + bundle +
", key=" + key + "]";
throw new IllegalArgumentException(errmsg);
}
return QUAL_PREFIX + bundle + QUAL_SEP + key;
} | java | public static String qualify (String bundle, String key)
{
// sanity check
if (bundle.indexOf(QUAL_PREFIX) != -1 ||
bundle.indexOf(QUAL_SEP) != -1) {
String errmsg = "Message bundle may not contain '" + QUAL_PREFIX +
"' or '" + QUAL_SEP + "' [bundle=" + bundle +
", key=" + key + "]";
throw new IllegalArgumentException(errmsg);
}
return QUAL_PREFIX + bundle + QUAL_SEP + key;
} | [
"public",
"static",
"String",
"qualify",
"(",
"String",
"bundle",
",",
"String",
"key",
")",
"{",
"// sanity check",
"if",
"(",
"bundle",
".",
"indexOf",
"(",
"QUAL_PREFIX",
")",
"!=",
"-",
"1",
"||",
"bundle",
".",
"indexOf",
"(",
"QUAL_SEP",
")",
"!=",... | Returns a fully qualified message key which, when translated by some other bundle, will know
to resolve and utilize the supplied bundle to translate this particular key. | [
"Returns",
"a",
"fully",
"qualified",
"message",
"key",
"which",
"when",
"translated",
"by",
"some",
"other",
"bundle",
"will",
"know",
"to",
"resolve",
"and",
"utilize",
"the",
"supplied",
"bundle",
"to",
"translate",
"this",
"particular",
"key",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/text/MessageUtil.java#L168-L179 | train |
samskivert/samskivert | src/main/java/com/samskivert/text/MessageUtil.java | MessageUtil.getBundle | public static String getBundle (String qualifiedKey)
{
if (!qualifiedKey.startsWith(QUAL_PREFIX)) {
throw new IllegalArgumentException(
qualifiedKey + " is not a fully qualified message key.");
}
int qsidx = qualifiedKey.indexOf(QUAL_SEP);
if (qsidx == -1) {
throw new IllegalArgumentException(
qualifiedKey + " is not a valid fully qualified key.");
}
return qualifiedKey.substring(QUAL_PREFIX.length(), qsidx);
} | java | public static String getBundle (String qualifiedKey)
{
if (!qualifiedKey.startsWith(QUAL_PREFIX)) {
throw new IllegalArgumentException(
qualifiedKey + " is not a fully qualified message key.");
}
int qsidx = qualifiedKey.indexOf(QUAL_SEP);
if (qsidx == -1) {
throw new IllegalArgumentException(
qualifiedKey + " is not a valid fully qualified key.");
}
return qualifiedKey.substring(QUAL_PREFIX.length(), qsidx);
} | [
"public",
"static",
"String",
"getBundle",
"(",
"String",
"qualifiedKey",
")",
"{",
"if",
"(",
"!",
"qualifiedKey",
".",
"startsWith",
"(",
"QUAL_PREFIX",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"qualifiedKey",
"+",
"\" is not a fully quali... | Returns the bundle name from a fully qualified message key.
@see #qualify | [
"Returns",
"the",
"bundle",
"name",
"from",
"a",
"fully",
"qualified",
"message",
"key",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/text/MessageUtil.java#L186-L200 | train |
samskivert/samskivert | src/main/java/com/samskivert/text/MessageUtil.java | MessageUtil.getUnqualifiedKey | public static String getUnqualifiedKey (String qualifiedKey)
{
if (!qualifiedKey.startsWith(QUAL_PREFIX)) {
throw new IllegalArgumentException(
qualifiedKey + " is not a fully qualified message key.");
}
int qsidx = qualifiedKey.indexOf(QUAL_SEP);
if (qsidx == -1) {
throw new IllegalArgumentException(
qualifiedKey + " is not a valid fully qualified key.");
}
return qualifiedKey.substring(qsidx+1);
} | java | public static String getUnqualifiedKey (String qualifiedKey)
{
if (!qualifiedKey.startsWith(QUAL_PREFIX)) {
throw new IllegalArgumentException(
qualifiedKey + " is not a fully qualified message key.");
}
int qsidx = qualifiedKey.indexOf(QUAL_SEP);
if (qsidx == -1) {
throw new IllegalArgumentException(
qualifiedKey + " is not a valid fully qualified key.");
}
return qualifiedKey.substring(qsidx+1);
} | [
"public",
"static",
"String",
"getUnqualifiedKey",
"(",
"String",
"qualifiedKey",
")",
"{",
"if",
"(",
"!",
"qualifiedKey",
".",
"startsWith",
"(",
"QUAL_PREFIX",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"qualifiedKey",
"+",
"\" is not a ful... | Returns the unqualified portion of the key from a fully qualified message key.
@see #qualify | [
"Returns",
"the",
"unqualified",
"portion",
"of",
"the",
"key",
"from",
"a",
"fully",
"qualified",
"message",
"key",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/text/MessageUtil.java#L207-L221 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.createUser | public int createUser (
Username username, Password password, String realname, String email, int siteId)
throws UserExistsException, PersistenceException
{
// create a new user object...
User user = new User();
user.setDirtyMask(_utable.getFieldMask());
// ...configure it...
populateUser(user, username, password, realname, email, siteId);
// ...and stick it into the database
return insertUser(user);
} | java | public int createUser (
Username username, Password password, String realname, String email, int siteId)
throws UserExistsException, PersistenceException
{
// create a new user object...
User user = new User();
user.setDirtyMask(_utable.getFieldMask());
// ...configure it...
populateUser(user, username, password, realname, email, siteId);
// ...and stick it into the database
return insertUser(user);
} | [
"public",
"int",
"createUser",
"(",
"Username",
"username",
",",
"Password",
"password",
",",
"String",
"realname",
",",
"String",
"email",
",",
"int",
"siteId",
")",
"throws",
"UserExistsException",
",",
"PersistenceException",
"{",
"// create a new user object...",
... | Requests that a new user be created in the repository.
@param username the username of the new user to create.
@param password the password for the new user.
@param realname the user's real name.
@param email the user's email address.
@param siteId the unique identifier of the site through which this account is being
created. The resulting user will be tracked as originating from this site for accounting
purposes ({@link SiteIdentifier#DEFAULT_SITE_ID} can be used by systems that don't desire to
perform site tracking.
@return The userid of the newly created user. | [
"Requests",
"that",
"a",
"new",
"user",
"be",
"created",
"in",
"the",
"repository",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L67-L79 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.loadUserBySession | public User loadUserBySession (String sessionKey)
throws PersistenceException
{
User user = load(_utable, "sessions", "where authcode = '" + sessionKey + "' " +
"AND sessions.userId = users.userId");
if (user != null) {
user.setDirtyMask(_utable.getFieldMask());
}
return user;
} | java | public User loadUserBySession (String sessionKey)
throws PersistenceException
{
User user = load(_utable, "sessions", "where authcode = '" + sessionKey + "' " +
"AND sessions.userId = users.userId");
if (user != null) {
user.setDirtyMask(_utable.getFieldMask());
}
return user;
} | [
"public",
"User",
"loadUserBySession",
"(",
"String",
"sessionKey",
")",
"throws",
"PersistenceException",
"{",
"User",
"user",
"=",
"load",
"(",
"_utable",
",",
"\"sessions\"",
",",
"\"where authcode = '\"",
"+",
"sessionKey",
"+",
"\"' \"",
"+",
"\"AND sessions.us... | Looks up a user by a session identifier.
@return the user associated with the specified session or null of no session exists with the
supplied identifier. | [
"Looks",
"up",
"a",
"user",
"by",
"a",
"session",
"identifier",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L109-L118 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.loadUsersFromId | public HashIntMap<User> loadUsersFromId (int[] userIds)
throws PersistenceException
{
HashIntMap<User> data = new HashIntMap<User>();
if (userIds.length > 0) {
String query = "where userId in (" + genIdString(userIds) + ")";
for (User user : loadAll(_utable, query)) {
user.setDirtyMask(_utable.getFieldMask());
data.put(user.userId, user);
}
}
return data;
} | java | public HashIntMap<User> loadUsersFromId (int[] userIds)
throws PersistenceException
{
HashIntMap<User> data = new HashIntMap<User>();
if (userIds.length > 0) {
String query = "where userId in (" + genIdString(userIds) + ")";
for (User user : loadAll(_utable, query)) {
user.setDirtyMask(_utable.getFieldMask());
data.put(user.userId, user);
}
}
return data;
} | [
"public",
"HashIntMap",
"<",
"User",
">",
"loadUsersFromId",
"(",
"int",
"[",
"]",
"userIds",
")",
"throws",
"PersistenceException",
"{",
"HashIntMap",
"<",
"User",
">",
"data",
"=",
"new",
"HashIntMap",
"<",
"User",
">",
"(",
")",
";",
"if",
"(",
"userI... | Looks up users by userid
@return the users whom have a user id in the userIds array. | [
"Looks",
"up",
"users",
"by",
"userid"
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L125-L137 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.lookupUsersByEmail | public ArrayList<User> lookupUsersByEmail (String email)
throws PersistenceException
{
return loadAll(_utable, "where email = " + JDBCUtil.escape(email));
} | java | public ArrayList<User> lookupUsersByEmail (String email)
throws PersistenceException
{
return loadAll(_utable, "where email = " + JDBCUtil.escape(email));
} | [
"public",
"ArrayList",
"<",
"User",
">",
"lookupUsersByEmail",
"(",
"String",
"email",
")",
"throws",
"PersistenceException",
"{",
"return",
"loadAll",
"(",
"_utable",
",",
"\"where email = \"",
"+",
"JDBCUtil",
".",
"escape",
"(",
"email",
")",
")",
";",
"}"
... | Lookup a user by email address, something that is not efficient and should really only be
done by site admins attempting to look up a user record.
@return the user with the specified user id or null if no user with that id exists. | [
"Lookup",
"a",
"user",
"by",
"email",
"address",
"something",
"that",
"is",
"not",
"efficient",
"and",
"should",
"really",
"only",
"be",
"done",
"by",
"site",
"admins",
"attempting",
"to",
"look",
"up",
"a",
"user",
"record",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L145-L149 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.lookupUsersWhere | public ArrayList<User> lookupUsersWhere (final String where)
throws PersistenceException
{
ArrayList<User> users = loadAll(_utable, where);
for (User user : users) {
// configure the user record with its field mask
user.setDirtyMask(_utable.getFieldMask());
}
return users;
} | java | public ArrayList<User> lookupUsersWhere (final String where)
throws PersistenceException
{
ArrayList<User> users = loadAll(_utable, where);
for (User user : users) {
// configure the user record with its field mask
user.setDirtyMask(_utable.getFieldMask());
}
return users;
} | [
"public",
"ArrayList",
"<",
"User",
">",
"lookupUsersWhere",
"(",
"final",
"String",
"where",
")",
"throws",
"PersistenceException",
"{",
"ArrayList",
"<",
"User",
">",
"users",
"=",
"loadAll",
"(",
"_utable",
",",
"where",
")",
";",
"for",
"(",
"User",
"u... | Looks up a list of users that match an arbitrary query. Care should be taken in constructing
these queries as the user table is likely to be large and a query that does not make use of
indices could be very slow.
@return the users matching the specified query or an empty list if there are no matches. | [
"Looks",
"up",
"a",
"list",
"of",
"users",
"that",
"match",
"an",
"arbitrary",
"query",
".",
"Care",
"should",
"be",
"taken",
"in",
"constructing",
"these",
"queries",
"as",
"the",
"user",
"table",
"is",
"likely",
"to",
"be",
"large",
"and",
"a",
"query"... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L158-L167 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.updateUser | public boolean updateUser (final User user)
throws PersistenceException
{
if (!user.getDirtyMask().isModified()) {
// nothing doing!
return false;
}
update(_utable, user, user.getDirtyMask());
return true;
} | java | public boolean updateUser (final User user)
throws PersistenceException
{
if (!user.getDirtyMask().isModified()) {
// nothing doing!
return false;
}
update(_utable, user, user.getDirtyMask());
return true;
} | [
"public",
"boolean",
"updateUser",
"(",
"final",
"User",
"user",
")",
"throws",
"PersistenceException",
"{",
"if",
"(",
"!",
"user",
".",
"getDirtyMask",
"(",
")",
".",
"isModified",
"(",
")",
")",
"{",
"// nothing doing!",
"return",
"false",
";",
"}",
"up... | Updates a user that was previously fetched from the repository. Only fields that have been
modified since it was loaded will be written to the database and those fields will
subsequently be marked clean once again.
@return true if the record was updated, false if the update was skipped because no fields in
the user record were modified. | [
"Updates",
"a",
"user",
"that",
"was",
"previously",
"fetched",
"from",
"the",
"repository",
".",
"Only",
"fields",
"that",
"have",
"been",
"modified",
"since",
"it",
"was",
"loaded",
"will",
"be",
"written",
"to",
"the",
"database",
"and",
"those",
"fields"... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L177-L186 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.deleteUser | public void deleteUser (final User user)
throws PersistenceException
{
if (user.isDeleted()) {
return;
}
executeUpdate(new Operation<Object>() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws PersistenceException, SQLException
{
// create our modified fields mask
FieldMask mask = _utable.getFieldMask();
mask.setModified("username");
mask.setModified("password");
mask.setModified("email");
// set the password to unusable
user.password = "";
// 'disable' their email address
String newEmail = user.email.replace('@','#');
user.email = newEmail;
String oldName = user.username;
for (int ii = 0; ii < 100; ii++) {
try {
user.username = StringUtil.truncate(ii + "=" + oldName, 24);
_utable.update(conn, user, mask);
return null; // nothing to return
} catch (SQLException se) {
if (!liaison.isDuplicateRowException(se)) {
throw se;
}
}
}
// ok we failed to rename the user, lets bust an error
throw new PersistenceException("Failed to 'delete' the user");
}
});
} | java | public void deleteUser (final User user)
throws PersistenceException
{
if (user.isDeleted()) {
return;
}
executeUpdate(new Operation<Object>() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws PersistenceException, SQLException
{
// create our modified fields mask
FieldMask mask = _utable.getFieldMask();
mask.setModified("username");
mask.setModified("password");
mask.setModified("email");
// set the password to unusable
user.password = "";
// 'disable' their email address
String newEmail = user.email.replace('@','#');
user.email = newEmail;
String oldName = user.username;
for (int ii = 0; ii < 100; ii++) {
try {
user.username = StringUtil.truncate(ii + "=" + oldName, 24);
_utable.update(conn, user, mask);
return null; // nothing to return
} catch (SQLException se) {
if (!liaison.isDuplicateRowException(se)) {
throw se;
}
}
}
// ok we failed to rename the user, lets bust an error
throw new PersistenceException("Failed to 'delete' the user");
}
});
} | [
"public",
"void",
"deleteUser",
"(",
"final",
"User",
"user",
")",
"throws",
"PersistenceException",
"{",
"if",
"(",
"user",
".",
"isDeleted",
"(",
")",
")",
"{",
"return",
";",
"}",
"executeUpdate",
"(",
"new",
"Operation",
"<",
"Object",
">",
"(",
")",... | 'Delete' the users account such that they can no longer access it, however we do not delete
the record from the db. The name is changed such that the original name has XX=FOO if the
name were FOO originally. If we have to lop off any of the name to get our prefix to fit we
use a minus sign instead of a equals side. The password field is set to be the empty string
so that no one can log in (since nothing hashes to the empty string. We also make sure
their email address no longer works, so in case we don't ignore 'deleted' users when we do
the sql to get emailaddresses for the mass mailings we still won't spam delete folk. We
leave the emailaddress intact exect for the @ sign which gets turned to a #, so that we can
see what their email was incase it was an accidently deletion and we have to verify through
email. | [
"Delete",
"the",
"users",
"account",
"such",
"that",
"they",
"can",
"no",
"longer",
"access",
"it",
"however",
"we",
"do",
"not",
"delete",
"the",
"record",
"from",
"the",
"db",
".",
"The",
"name",
"is",
"changed",
"such",
"that",
"the",
"original",
"nam... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L200-L241 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.registerSession | public String registerSession (User user, int expireDays)
throws PersistenceException
{
// look for an existing session for this user
final String query = "select authcode from sessions where userId = " + user.userId;
String authcode = execute(new Operation<String>() {
public String invoke (Connection conn, DatabaseLiaison liaison)
throws PersistenceException, SQLException
{
Statement stmt = conn.createStatement();
try {
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
return rs.getString(1);
}
return null;
} finally {
JDBCUtil.close(stmt);
}
}
});
// figure out when to expire the session
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, expireDays);
Date expires = new Date(cal.getTime().getTime());
// if we found one, update its expires time and reuse it
if (authcode != null) {
update("update sessions set expires = '" + expires + "' where " +
"authcode = '" + authcode + "'");
} else {
// otherwise create a new one and insert it into the table
authcode = UserUtil.genAuthCode(user);
update("insert into sessions (authcode, userId, expires) values('" + authcode + "', " +
user.userId + ", '" + expires + "')");
}
return authcode;
} | java | public String registerSession (User user, int expireDays)
throws PersistenceException
{
// look for an existing session for this user
final String query = "select authcode from sessions where userId = " + user.userId;
String authcode = execute(new Operation<String>() {
public String invoke (Connection conn, DatabaseLiaison liaison)
throws PersistenceException, SQLException
{
Statement stmt = conn.createStatement();
try {
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
return rs.getString(1);
}
return null;
} finally {
JDBCUtil.close(stmt);
}
}
});
// figure out when to expire the session
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, expireDays);
Date expires = new Date(cal.getTime().getTime());
// if we found one, update its expires time and reuse it
if (authcode != null) {
update("update sessions set expires = '" + expires + "' where " +
"authcode = '" + authcode + "'");
} else {
// otherwise create a new one and insert it into the table
authcode = UserUtil.genAuthCode(user);
update("insert into sessions (authcode, userId, expires) values('" + authcode + "', " +
user.userId + ", '" + expires + "')");
}
return authcode;
} | [
"public",
"String",
"registerSession",
"(",
"User",
"user",
",",
"int",
"expireDays",
")",
"throws",
"PersistenceException",
"{",
"// look for an existing session for this user",
"final",
"String",
"query",
"=",
"\"select authcode from sessions where userId = \"",
"+",
"user"... | Creates a new session for the specified user and returns the randomly generated session
identifier for that session. If a session entry already exists for the specified user it
will be reused.
@param expireDays the number of days in which the session token should expire. | [
"Creates",
"a",
"new",
"session",
"for",
"the",
"specified",
"user",
"and",
"returns",
"the",
"randomly",
"generated",
"session",
"identifier",
"for",
"that",
"session",
".",
"If",
"a",
"session",
"entry",
"already",
"exists",
"for",
"the",
"specified",
"user"... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L250-L289 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.refreshSession | public boolean refreshSession (String sessionKey, int expireDays)
throws PersistenceException
{
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, expireDays);
Date expires = new Date(cal.getTime().getTime());
// attempt to update an existing session row, returning true if we found and updated it
return (update("update sessions set expires = '" + expires + "' " +
"where authcode = " + JDBCUtil.escape(sessionKey)) == 1);
} | java | public boolean refreshSession (String sessionKey, int expireDays)
throws PersistenceException
{
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, expireDays);
Date expires = new Date(cal.getTime().getTime());
// attempt to update an existing session row, returning true if we found and updated it
return (update("update sessions set expires = '" + expires + "' " +
"where authcode = " + JDBCUtil.escape(sessionKey)) == 1);
} | [
"public",
"boolean",
"refreshSession",
"(",
"String",
"sessionKey",
",",
"int",
"expireDays",
")",
"throws",
"PersistenceException",
"{",
"Calendar",
"cal",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"cal",
".",
"add",
"(",
"Calendar",
".",
"DATE",
... | Validates that the supplied session key is still valid and if so, refreshes it for the
specified number of days.
@return true if the session was located and refreshed, false if it no longer exists. | [
"Validates",
"that",
"the",
"supplied",
"session",
"key",
"is",
"still",
"valid",
"and",
"if",
"so",
"refreshes",
"it",
"for",
"the",
"specified",
"number",
"of",
"days",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L297-L307 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.loadAllRealNames | public String[] loadAllRealNames ()
throws PersistenceException
{
final ArrayList<String> names = new ArrayList<String>();
// do the query
execute(new Operation<Object>() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws PersistenceException, SQLException
{
Statement stmt = conn.createStatement();
try {
String query = "select realname from users";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
names.add(rs.getString(1));
}
// nothing to return
return null;
} finally {
JDBCUtil.close(stmt);
}
}
});
// finally construct our result
return names.toArray(new String[names.size()]);
} | java | public String[] loadAllRealNames ()
throws PersistenceException
{
final ArrayList<String> names = new ArrayList<String>();
// do the query
execute(new Operation<Object>() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws PersistenceException, SQLException
{
Statement stmt = conn.createStatement();
try {
String query = "select realname from users";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
names.add(rs.getString(1));
}
// nothing to return
return null;
} finally {
JDBCUtil.close(stmt);
}
}
});
// finally construct our result
return names.toArray(new String[names.size()]);
} | [
"public",
"String",
"[",
"]",
"loadAllRealNames",
"(",
")",
"throws",
"PersistenceException",
"{",
"final",
"ArrayList",
"<",
"String",
">",
"names",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"// do the query",
"execute",
"(",
"new",
"Opera... | Returns an array with the real names of every user in the system. | [
"Returns",
"an",
"array",
"with",
"the",
"real",
"names",
"of",
"every",
"user",
"in",
"the",
"system",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L341-L370 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.populateUser | protected void populateUser (
User user, Username name, Password pass, String realname, String email, int siteId)
{
user.username = name.getUsername();
user.setPassword(pass);
user.setRealName(realname);
user.setEmail(email);
user.created = new Date(System.currentTimeMillis());
user.setSiteId(siteId);
} | java | protected void populateUser (
User user, Username name, Password pass, String realname, String email, int siteId)
{
user.username = name.getUsername();
user.setPassword(pass);
user.setRealName(realname);
user.setEmail(email);
user.created = new Date(System.currentTimeMillis());
user.setSiteId(siteId);
} | [
"protected",
"void",
"populateUser",
"(",
"User",
"user",
",",
"Username",
"name",
",",
"Password",
"pass",
",",
"String",
"realname",
",",
"String",
"email",
",",
"int",
"siteId",
")",
"{",
"user",
".",
"username",
"=",
"name",
".",
"getUsername",
"(",
... | Configures the supplied user record with the provided information in preparation for
inserting the record into the database for the first time. | [
"Configures",
"the",
"supplied",
"user",
"record",
"with",
"the",
"provided",
"information",
"in",
"preparation",
"for",
"inserting",
"the",
"record",
"into",
"the",
"database",
"for",
"the",
"first",
"time",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L376-L385 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.insertUser | protected int insertUser (final User user)
throws UserExistsException, PersistenceException
{
executeUpdate(new Operation<Object>() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws PersistenceException, SQLException
{
try {
_utable.insert(conn, user);
// update the userid now that it's known
user.userId = liaison.lastInsertedId(conn, null, _utable.getName(), "userId");
// nothing to return
return null;
} catch (SQLException sqe) {
if (liaison.isDuplicateRowException(sqe)) {
throw new UserExistsException("error.user_exists");
} else {
throw sqe;
}
}
}
});
return user.userId;
} | java | protected int insertUser (final User user)
throws UserExistsException, PersistenceException
{
executeUpdate(new Operation<Object>() {
public Object invoke (Connection conn, DatabaseLiaison liaison)
throws PersistenceException, SQLException
{
try {
_utable.insert(conn, user);
// update the userid now that it's known
user.userId = liaison.lastInsertedId(conn, null, _utable.getName(), "userId");
// nothing to return
return null;
} catch (SQLException sqe) {
if (liaison.isDuplicateRowException(sqe)) {
throw new UserExistsException("error.user_exists");
} else {
throw sqe;
}
}
}
});
return user.userId;
} | [
"protected",
"int",
"insertUser",
"(",
"final",
"User",
"user",
")",
"throws",
"UserExistsException",
",",
"PersistenceException",
"{",
"executeUpdate",
"(",
"new",
"Operation",
"<",
"Object",
">",
"(",
")",
"{",
"public",
"Object",
"invoke",
"(",
"Connection",
... | Inserts the supplied user record into the user database, assigning it a userid in the
process, which is returned. | [
"Inserts",
"the",
"supplied",
"user",
"record",
"into",
"the",
"user",
"database",
"assigning",
"it",
"a",
"userid",
"in",
"the",
"process",
"which",
"is",
"returned",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L391-L416 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserRepository.java | UserRepository.loadUserWhere | protected User loadUserWhere (String where)
throws PersistenceException
{
User user = load(_utable, where);
if (user != null) {
user.setDirtyMask(_utable.getFieldMask());
}
return user;
} | java | protected User loadUserWhere (String where)
throws PersistenceException
{
User user = load(_utable, where);
if (user != null) {
user.setDirtyMask(_utable.getFieldMask());
}
return user;
} | [
"protected",
"User",
"loadUserWhere",
"(",
"String",
"where",
")",
"throws",
"PersistenceException",
"{",
"User",
"user",
"=",
"load",
"(",
"_utable",
",",
"where",
")",
";",
"if",
"(",
"user",
"!=",
"null",
")",
"{",
"user",
".",
"setDirtyMask",
"(",
"_... | Loads up a user record that matches the specified where clause. Returns null if no record
matches. | [
"Loads",
"up",
"a",
"user",
"record",
"that",
"matches",
"the",
"specified",
"where",
"clause",
".",
"Returns",
"null",
"if",
"no",
"record",
"matches",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserRepository.java#L422-L430 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/util/ButtonUtil.java | ButtonUtil.setToggling | public static synchronized void setToggling (AbstractButton b)
{
if (_toggler == null) {
_toggler = new ActionListener () {
public void actionPerformed (ActionEvent event)
{
AbstractButton but = (AbstractButton) event.getSource();
but.setSelected(!but.isSelected());
}
};
}
b.addActionListener(_toggler);
} | java | public static synchronized void setToggling (AbstractButton b)
{
if (_toggler == null) {
_toggler = new ActionListener () {
public void actionPerformed (ActionEvent event)
{
AbstractButton but = (AbstractButton) event.getSource();
but.setSelected(!but.isSelected());
}
};
}
b.addActionListener(_toggler);
} | [
"public",
"static",
"synchronized",
"void",
"setToggling",
"(",
"AbstractButton",
"b",
")",
"{",
"if",
"(",
"_toggler",
"==",
"null",
")",
"{",
"_toggler",
"=",
"new",
"ActionListener",
"(",
")",
"{",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
... | Set the specified button such that it alternates between being selected and not whenever it
is pushed. | [
"Set",
"the",
"specified",
"button",
"such",
"that",
"it",
"alternates",
"between",
"being",
"selected",
"and",
"not",
"whenever",
"it",
"is",
"pushed",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/ButtonUtil.java#L33-L46 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/util/ButtonUtil.java | ButtonUtil.cycleToProperty | public static ActionListener cycleToProperty (
final String property, final PrefsConfig config, AbstractButton button,
final int[] values)
{
ActionListener al = new ActionListener() {
public void actionPerformed (ActionEvent event)
{
// get the current value and find out where it is in the list
int oldval = config.getValue(property, values[0]);
// if it's not even in the list, newidx will be 0
int newidx = (1 + IntListUtil.indexOf(values, oldval))
% values.length;
config.setValue(property, values[newidx]);
}
};
button.addActionListener(al);
return al;
} | java | public static ActionListener cycleToProperty (
final String property, final PrefsConfig config, AbstractButton button,
final int[] values)
{
ActionListener al = new ActionListener() {
public void actionPerformed (ActionEvent event)
{
// get the current value and find out where it is in the list
int oldval = config.getValue(property, values[0]);
// if it's not even in the list, newidx will be 0
int newidx = (1 + IntListUtil.indexOf(values, oldval))
% values.length;
config.setValue(property, values[newidx]);
}
};
button.addActionListener(al);
return al;
} | [
"public",
"static",
"ActionListener",
"cycleToProperty",
"(",
"final",
"String",
"property",
",",
"final",
"PrefsConfig",
"config",
",",
"AbstractButton",
"button",
",",
"final",
"int",
"[",
"]",
"values",
")",
"{",
"ActionListener",
"al",
"=",
"new",
"ActionLis... | Configure the specified button to cause the specified property to cycle through the
specified values whenever the button is pressed. | [
"Configure",
"the",
"specified",
"button",
"to",
"cause",
"the",
"specified",
"property",
"to",
"cycle",
"through",
"the",
"specified",
"values",
"whenever",
"the",
"button",
"is",
"pressed",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/ButtonUtil.java#L66-L83 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/HsqldbLiaison.java | HsqldbLiaison.createTableIfMissing | @Override // from DatabaseLiaison
public boolean createTableIfMissing (Connection conn, String table,
List<String> columns, List<ColumnDefinition> defns,
List<List<String>> uniqueColumns, List<String> pkColumns)
throws SQLException
{
if (columns.size() != defns.size()) {
throw new IllegalArgumentException("Column name and definition number mismatch");
}
// note the set of single column unique constraints already provided (see method comment)
Set<String> seenUniques = new HashSet<String>();
if (uniqueColumns != null) {
for (List<String> udef : uniqueColumns) {
if (udef.size() == 1) {
seenUniques.addAll(udef);
}
}
}
// primary key columns are also considered implicitly unique as of HSQL 2.2.4, and it will
// freak out if we also try to include them in the UNIQUE clause, so add those too
seenUniques.addAll(pkColumns);
// lazily create a copy of uniqueColumns, if needed
List<List<String>> newUniques = uniqueColumns;
// go through the columns and find any that are unique; these we replace with a non-unique
// variant, and instead add a new entry to the table unique constraint
List<ColumnDefinition> newDefns = new ArrayList<ColumnDefinition>(defns.size());
for (int ii = 0; ii < defns.size(); ii ++) {
ColumnDefinition def = defns.get(ii);
if (!def.unique) {
newDefns.add(def);
continue;
}
// let's be nice and not mutate the caller's object
newDefns.add(
new ColumnDefinition(def.type, def.nullable, false, def.defaultValue));
// if a uniqueness constraint for this column was not in the primaryKeys or
// uniqueColumns parameters, add the column to uniqueCsts
if (!seenUniques.contains(columns.get(ii))) {
if (newUniques == uniqueColumns) {
newUniques = new ArrayList<List<String>>(uniqueColumns);
}
newUniques.add(Collections.singletonList(columns.get(ii)));
}
}
// now call the real implementation with our modified data
return super.createTableIfMissing(conn, table, columns, newDefns, newUniques, pkColumns);
} | java | @Override // from DatabaseLiaison
public boolean createTableIfMissing (Connection conn, String table,
List<String> columns, List<ColumnDefinition> defns,
List<List<String>> uniqueColumns, List<String> pkColumns)
throws SQLException
{
if (columns.size() != defns.size()) {
throw new IllegalArgumentException("Column name and definition number mismatch");
}
// note the set of single column unique constraints already provided (see method comment)
Set<String> seenUniques = new HashSet<String>();
if (uniqueColumns != null) {
for (List<String> udef : uniqueColumns) {
if (udef.size() == 1) {
seenUniques.addAll(udef);
}
}
}
// primary key columns are also considered implicitly unique as of HSQL 2.2.4, and it will
// freak out if we also try to include them in the UNIQUE clause, so add those too
seenUniques.addAll(pkColumns);
// lazily create a copy of uniqueColumns, if needed
List<List<String>> newUniques = uniqueColumns;
// go through the columns and find any that are unique; these we replace with a non-unique
// variant, and instead add a new entry to the table unique constraint
List<ColumnDefinition> newDefns = new ArrayList<ColumnDefinition>(defns.size());
for (int ii = 0; ii < defns.size(); ii ++) {
ColumnDefinition def = defns.get(ii);
if (!def.unique) {
newDefns.add(def);
continue;
}
// let's be nice and not mutate the caller's object
newDefns.add(
new ColumnDefinition(def.type, def.nullable, false, def.defaultValue));
// if a uniqueness constraint for this column was not in the primaryKeys or
// uniqueColumns parameters, add the column to uniqueCsts
if (!seenUniques.contains(columns.get(ii))) {
if (newUniques == uniqueColumns) {
newUniques = new ArrayList<List<String>>(uniqueColumns);
}
newUniques.add(Collections.singletonList(columns.get(ii)));
}
}
// now call the real implementation with our modified data
return super.createTableIfMissing(conn, table, columns, newDefns, newUniques, pkColumns);
} | [
"@",
"Override",
"// from DatabaseLiaison",
"public",
"boolean",
"createTableIfMissing",
"(",
"Connection",
"conn",
",",
"String",
"table",
",",
"List",
"<",
"String",
">",
"columns",
",",
"List",
"<",
"ColumnDefinition",
">",
"defns",
",",
"List",
"<",
"List",
... | it may be that uniqueness should be removed from ColumnDefinition. | [
"it",
"may",
"be",
"that",
"uniqueness",
"should",
"be",
"removed",
"from",
"ColumnDefinition",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/HsqldbLiaison.java#L117-L168 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/querybuilder/sql/SelectQuery.java | SelectQuery.canAddTableToFromClause | private boolean canAddTableToFromClause(Table table, Map<Table, List<JoinCriteria>> destMap, List<Table> allTables) {
if ((table == null) || allTables.contains(table)) {
return false;
}
if ((destMap.get(table) != null) && (destMap.get(table).size() > 0)) {
List<JoinCriteria> list = destMap.get(table);
for (JoinCriteria jc : list) {
if (JoinType.isOuter(jc.getJoinType())) {
return false;
}
}
}
return true;
} | java | private boolean canAddTableToFromClause(Table table, Map<Table, List<JoinCriteria>> destMap, List<Table> allTables) {
if ((table == null) || allTables.contains(table)) {
return false;
}
if ((destMap.get(table) != null) && (destMap.get(table).size() > 0)) {
List<JoinCriteria> list = destMap.get(table);
for (JoinCriteria jc : list) {
if (JoinType.isOuter(jc.getJoinType())) {
return false;
}
}
}
return true;
} | [
"private",
"boolean",
"canAddTableToFromClause",
"(",
"Table",
"table",
",",
"Map",
"<",
"Table",
",",
"List",
"<",
"JoinCriteria",
">",
">",
"destMap",
",",
"List",
"<",
"Table",
">",
"allTables",
")",
"{",
"if",
"(",
"(",
"table",
"==",
"null",
")",
... | outer joins are written in Table class | [
"outer",
"joins",
"are",
"written",
"in",
"Table",
"class"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/querybuilder/sql/SelectQuery.java#L789-L802 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/QuickSort.java | QuickSort.sort | public static <T> void sort (T[] a, Comparator<? super T> comp)
{
sort(a, 0, a.length - 1, comp);
} | java | public static <T> void sort (T[] a, Comparator<? super T> comp)
{
sort(a, 0, a.length - 1, comp);
} | [
"public",
"static",
"<",
"T",
">",
"void",
"sort",
"(",
"T",
"[",
"]",
"a",
",",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comp",
")",
"{",
"sort",
"(",
"a",
",",
"0",
",",
"a",
".",
"length",
"-",
"1",
",",
"comp",
")",
";",
"}"
] | Sorts the supplied array of objects from least to greatest, using the supplied comparator. | [
"Sorts",
"the",
"supplied",
"array",
"of",
"objects",
"from",
"least",
"to",
"greatest",
"using",
"the",
"supplied",
"comparator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/QuickSort.java#L20-L23 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/QuickSort.java | QuickSort.sort | public static <T extends Comparable<? super T>> void sort (T[] a)
{
sort(a, 0, a.length - 1);
} | java | public static <T extends Comparable<? super T>> void sort (T[] a)
{
sort(a, 0, a.length - 1);
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"void",
"sort",
"(",
"T",
"[",
"]",
"a",
")",
"{",
"sort",
"(",
"a",
",",
"0",
",",
"a",
".",
"length",
"-",
"1",
")",
";",
"}"
] | Sorts the supplied array of comparable objects from least to greatest. | [
"Sorts",
"the",
"supplied",
"array",
"of",
"comparable",
"objects",
"from",
"least",
"to",
"greatest",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/QuickSort.java#L28-L31 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/QuickSort.java | QuickSort.rsort | public static <T> void rsort (T[] a, Comparator<? super T> comp)
{
rsort(a, 0, a.length - 1, comp);
} | java | public static <T> void rsort (T[] a, Comparator<? super T> comp)
{
rsort(a, 0, a.length - 1, comp);
} | [
"public",
"static",
"<",
"T",
">",
"void",
"rsort",
"(",
"T",
"[",
"]",
"a",
",",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comp",
")",
"{",
"rsort",
"(",
"a",
",",
"0",
",",
"a",
".",
"length",
"-",
"1",
",",
"comp",
")",
";",
"}"
] | Sorts the supplied array of objects from greatest to least, using the supplied comparator. | [
"Sorts",
"the",
"supplied",
"array",
"of",
"objects",
"from",
"greatest",
"to",
"least",
"using",
"the",
"supplied",
"comparator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/QuickSort.java#L36-L39 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/QuickSort.java | QuickSort.rsort | public static <T extends Comparable<? super T>> void rsort (T[] a)
{
rsort(a, 0, a.length - 1);
} | java | public static <T extends Comparable<? super T>> void rsort (T[] a)
{
rsort(a, 0, a.length - 1);
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"void",
"rsort",
"(",
"T",
"[",
"]",
"a",
")",
"{",
"rsort",
"(",
"a",
",",
"0",
",",
"a",
".",
"length",
"-",
"1",
")",
";",
"}"
] | Sorts the supplied array of comparable objects from greatest to least. | [
"Sorts",
"the",
"supplied",
"array",
"of",
"comparable",
"objects",
"from",
"greatest",
"to",
"least",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/QuickSort.java#L44-L47 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/QuickSort.java | QuickSort.sort | public static <T> void sort (T[] a, int lo0, int hi0, Comparator<? super T> comp)
{
// bail out if we're already done
if (hi0 <= lo0) {
return;
}
T t;
// if this is a two element file, do a simple sort on it
if (hi0 - lo0 == 1) {
// if they're not already sorted, swap them
if (comp.compare(a[hi0], a[lo0]) < 0) {
t = a[lo0]; a[lo0] = a[hi0]; a[hi0] = t;
}
return;
}
// the middle element in the array is our partitioning element
T mid = a[(lo0 + hi0) >>> 1];
// set up our partitioning boundaries
int lo = lo0-1, hi = hi0+1;
// loop through the array until indices cross
for (;;) {
// find the first element that is greater than or equal to the partition element
// starting from the left index
while (comp.compare(a[++lo], mid) < 0) { /* loop! */ }
// find an element that is smaller than or equal to the partition element starting from
// the right index
while (comp.compare(mid, a[--hi]) < 0) { /* loop! */ }
// swap the two elements or bail out of the loop
if (hi > lo) {
t = a[lo]; a[lo] = a[hi]; a[hi] = t;
} else {
break;
}
}
// if the right index has not reached the left side of array must now sort the left
// partition
if (lo0 < lo-1) {
sort(a, lo0, lo-1, comp);
}
// if the left index has not reached the right side of array must now sort the right
// partition
if (hi+1 < hi0) {
sort(a, hi+1, hi0, comp);
}
} | java | public static <T> void sort (T[] a, int lo0, int hi0, Comparator<? super T> comp)
{
// bail out if we're already done
if (hi0 <= lo0) {
return;
}
T t;
// if this is a two element file, do a simple sort on it
if (hi0 - lo0 == 1) {
// if they're not already sorted, swap them
if (comp.compare(a[hi0], a[lo0]) < 0) {
t = a[lo0]; a[lo0] = a[hi0]; a[hi0] = t;
}
return;
}
// the middle element in the array is our partitioning element
T mid = a[(lo0 + hi0) >>> 1];
// set up our partitioning boundaries
int lo = lo0-1, hi = hi0+1;
// loop through the array until indices cross
for (;;) {
// find the first element that is greater than or equal to the partition element
// starting from the left index
while (comp.compare(a[++lo], mid) < 0) { /* loop! */ }
// find an element that is smaller than or equal to the partition element starting from
// the right index
while (comp.compare(mid, a[--hi]) < 0) { /* loop! */ }
// swap the two elements or bail out of the loop
if (hi > lo) {
t = a[lo]; a[lo] = a[hi]; a[hi] = t;
} else {
break;
}
}
// if the right index has not reached the left side of array must now sort the left
// partition
if (lo0 < lo-1) {
sort(a, lo0, lo-1, comp);
}
// if the left index has not reached the right side of array must now sort the right
// partition
if (hi+1 < hi0) {
sort(a, hi+1, hi0, comp);
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"sort",
"(",
"T",
"[",
"]",
"a",
",",
"int",
"lo0",
",",
"int",
"hi0",
",",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comp",
")",
"{",
"// bail out if we're already done",
"if",
"(",
"hi0",
"<=",
"lo0",
... | Sorts the specified subset of the supplied array from least to greatest, using the supplied
comparator.
@param a the array of objects to be sorted.
@param lo0 the index of the lowest element to be included in the sort.
@param hi0 the index of the highest element to be included in the sort.
@param comp the comparator to use to establish ordering between elements. | [
"Sorts",
"the",
"specified",
"subset",
"of",
"the",
"supplied",
"array",
"from",
"least",
"to",
"greatest",
"using",
"the",
"supplied",
"comparator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/QuickSort.java#L58-L111 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/QuickSort.java | QuickSort.sort | public static <T extends Comparable<? super T>> void sort (T[] a, int lo0, int hi0)
{
// bail out if we're already done
if (hi0 <= lo0) {
return;
}
T t;
// if this is a two element file, do a simple sort on it
if (hi0 - lo0 == 1) {
// if they're not already sorted, swap them
if (a[lo0].compareTo(a[hi0]) > 0) {
t = a[lo0]; a[lo0] = a[hi0]; a[hi0] = t;
}
return;
}
// the middle element in the array is our partitioning element
T mid = a[(lo0 + hi0) >>> 1];
// set up our partitioning boundaries
int lo = lo0-1, hi = hi0+1;
// loop through the array until indices cross
for (;;) {
// find the first element that is greater than or equal to the partition element
// starting from the left Index.
while (mid.compareTo(a[++lo]) > 0) { /* loop! */ }
// find an element that is smaller than or equal to the partition element starting from
// the right Index.
while (mid.compareTo(a[--hi]) < 0) { /* loop! */ }
// swap the two elements or bail out of the loop
if (hi > lo) {
t = a[lo]; a[lo] = a[hi]; a[hi] = t;
} else {
break;
}
}
// if the right index has not reached the left side of array must now sort the left
// partition
if (lo0 < lo-1) {
sort(a, lo0, lo-1);
}
// if the left index has not reached the right side of array must now sort the right
// partition
if (hi+1 < hi0) {
sort(a, hi+1, hi0);
}
} | java | public static <T extends Comparable<? super T>> void sort (T[] a, int lo0, int hi0)
{
// bail out if we're already done
if (hi0 <= lo0) {
return;
}
T t;
// if this is a two element file, do a simple sort on it
if (hi0 - lo0 == 1) {
// if they're not already sorted, swap them
if (a[lo0].compareTo(a[hi0]) > 0) {
t = a[lo0]; a[lo0] = a[hi0]; a[hi0] = t;
}
return;
}
// the middle element in the array is our partitioning element
T mid = a[(lo0 + hi0) >>> 1];
// set up our partitioning boundaries
int lo = lo0-1, hi = hi0+1;
// loop through the array until indices cross
for (;;) {
// find the first element that is greater than or equal to the partition element
// starting from the left Index.
while (mid.compareTo(a[++lo]) > 0) { /* loop! */ }
// find an element that is smaller than or equal to the partition element starting from
// the right Index.
while (mid.compareTo(a[--hi]) < 0) { /* loop! */ }
// swap the two elements or bail out of the loop
if (hi > lo) {
t = a[lo]; a[lo] = a[hi]; a[hi] = t;
} else {
break;
}
}
// if the right index has not reached the left side of array must now sort the left
// partition
if (lo0 < lo-1) {
sort(a, lo0, lo-1);
}
// if the left index has not reached the right side of array must now sort the right
// partition
if (hi+1 < hi0) {
sort(a, hi+1, hi0);
}
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"void",
"sort",
"(",
"T",
"[",
"]",
"a",
",",
"int",
"lo0",
",",
"int",
"hi0",
")",
"{",
"// bail out if we're already done",
"if",
"(",
"hi0",
"<=",
"lo0",
")",... | Sorts the specified subset of the supplied array of comparables from least to greatest,
using the supplied comparator.
@param a the array of objects to be sorted.
@param lo0 the index of the lowest element to be included in the sort.
@param hi0 the index of the highest element to be included in the sort. | [
"Sorts",
"the",
"specified",
"subset",
"of",
"the",
"supplied",
"array",
"of",
"comparables",
"from",
"least",
"to",
"greatest",
"using",
"the",
"supplied",
"comparator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/QuickSort.java#L185-L238 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/QuickSort.java | QuickSort.sort | public static <T extends Comparable<? super T>> void sort (List<T> a)
{
sort(a, new Comparator<T>() {
public int compare (T o1, T o2) {
if (o1 == o2) { // catches null == null
return 0;
} else if (o1 == null) {
return 1;
} else if (o2 == null) {
return -1;
}
return o1.compareTo(o2); // null-free
}
});
} | java | public static <T extends Comparable<? super T>> void sort (List<T> a)
{
sort(a, new Comparator<T>() {
public int compare (T o1, T o2) {
if (o1 == o2) { // catches null == null
return 0;
} else if (o1 == null) {
return 1;
} else if (o2 == null) {
return -1;
}
return o1.compareTo(o2); // null-free
}
});
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"void",
"sort",
"(",
"List",
"<",
"T",
">",
"a",
")",
"{",
"sort",
"(",
"a",
",",
"new",
"Comparator",
"<",
"T",
">",
"(",
")",
"{",
"public",
"int",
"comp... | Sort the elements in the specified List according to their natural order. | [
"Sort",
"the",
"elements",
"in",
"the",
"specified",
"List",
"according",
"to",
"their",
"natural",
"order",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/QuickSort.java#L306-L320 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/QuickSort.java | QuickSort.sort | public static <T> void sort (List<T> a, Comparator<? super T> comp)
{
sort(a, 0, a.size() - 1, comp);
} | java | public static <T> void sort (List<T> a, Comparator<? super T> comp)
{
sort(a, 0, a.size() - 1, comp);
} | [
"public",
"static",
"<",
"T",
">",
"void",
"sort",
"(",
"List",
"<",
"T",
">",
"a",
",",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comp",
")",
"{",
"sort",
"(",
"a",
",",
"0",
",",
"a",
".",
"size",
"(",
")",
"-",
"1",
",",
"comp",
")",
... | Sort the elements in the specified List according to the ordering imposed by the specified
Comparator. | [
"Sort",
"the",
"elements",
"in",
"the",
"specified",
"List",
"according",
"to",
"the",
"ordering",
"imposed",
"by",
"the",
"specified",
"Comparator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/QuickSort.java#L326-L329 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/QuickSort.java | QuickSort.rsort | public static <T> void rsort (List<T> a, Comparator<? super T> comp)
{
sort(a, Collections.reverseOrder(comp));
} | java | public static <T> void rsort (List<T> a, Comparator<? super T> comp)
{
sort(a, Collections.reverseOrder(comp));
} | [
"public",
"static",
"<",
"T",
">",
"void",
"rsort",
"(",
"List",
"<",
"T",
">",
"a",
",",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comp",
")",
"{",
"sort",
"(",
"a",
",",
"Collections",
".",
"reverseOrder",
"(",
"comp",
")",
")",
";",
"}"
] | Sort the elements in the specified List according to the reverse ordering imposed by the
specified Comparator. | [
"Sort",
"the",
"elements",
"in",
"the",
"specified",
"List",
"according",
"to",
"the",
"reverse",
"ordering",
"imposed",
"by",
"the",
"specified",
"Comparator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/QuickSort.java#L354-L357 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/QuickSort.java | QuickSort.sort | public static <T> void sort (List<T> a, int lo0, int hi0, Comparator<? super T> comp)
{
// bail out if we're already done
if (hi0 <= lo0) {
return;
}
T e1, e2;
// if this is a two element file, do a simple sort on it
if (hi0 - lo0 == 1) {
// if they're not already sorted, swap them
e1 = a.get(lo0);
e2 = a.get(hi0);
if (comp.compare(e2, e1) < 0) {
a.set(hi0, e1);
a.set(lo0, e2);
}
return;
}
// the middle element in the array is our partitioning element
T mid = a.get((lo0 + hi0) >>> 1);
// set up our partitioning boundaries
int lo = lo0-1, hi = hi0+1;
// loop through the array until indices cross
for (;;) {
// find the first element that is greater than or equal to the partition element
// starting from the left index
do {
e1 = a.get(++lo);
} while (comp.compare(e1, mid) < 0);
// find an element that is smaller than or equal to the partition element starting from
// the right index
do {
e2 = a.get(--hi);
} while (comp.compare(mid, e2) < 0);
// swap the two elements or bail out of the loop
if (hi > lo) {
a.set(lo, e2);
a.set(hi, e1);
} else {
break;
}
}
// if the right index has not reached the left side of array must now sort the left
// partition
if (lo0 < lo-1) {
sort(a, lo0, lo-1, comp);
}
// if the left index has not reached the right side of array must now sort the right
// partition
if (hi+1 < hi0) {
sort(a, hi+1, hi0, comp);
}
} | java | public static <T> void sort (List<T> a, int lo0, int hi0, Comparator<? super T> comp)
{
// bail out if we're already done
if (hi0 <= lo0) {
return;
}
T e1, e2;
// if this is a two element file, do a simple sort on it
if (hi0 - lo0 == 1) {
// if they're not already sorted, swap them
e1 = a.get(lo0);
e2 = a.get(hi0);
if (comp.compare(e2, e1) < 0) {
a.set(hi0, e1);
a.set(lo0, e2);
}
return;
}
// the middle element in the array is our partitioning element
T mid = a.get((lo0 + hi0) >>> 1);
// set up our partitioning boundaries
int lo = lo0-1, hi = hi0+1;
// loop through the array until indices cross
for (;;) {
// find the first element that is greater than or equal to the partition element
// starting from the left index
do {
e1 = a.get(++lo);
} while (comp.compare(e1, mid) < 0);
// find an element that is smaller than or equal to the partition element starting from
// the right index
do {
e2 = a.get(--hi);
} while (comp.compare(mid, e2) < 0);
// swap the two elements or bail out of the loop
if (hi > lo) {
a.set(lo, e2);
a.set(hi, e1);
} else {
break;
}
}
// if the right index has not reached the left side of array must now sort the left
// partition
if (lo0 < lo-1) {
sort(a, lo0, lo-1, comp);
}
// if the left index has not reached the right side of array must now sort the right
// partition
if (hi+1 < hi0) {
sort(a, hi+1, hi0, comp);
}
} | [
"public",
"static",
"<",
"T",
">",
"void",
"sort",
"(",
"List",
"<",
"T",
">",
"a",
",",
"int",
"lo0",
",",
"int",
"hi0",
",",
"Comparator",
"<",
"?",
"super",
"T",
">",
"comp",
")",
"{",
"// bail out if we're already done",
"if",
"(",
"hi0",
"<=",
... | Sort a subset of the elements in the specified List according to the ordering imposed by the
specified Comparator. | [
"Sort",
"a",
"subset",
"of",
"the",
"elements",
"in",
"the",
"specified",
"List",
"according",
"to",
"the",
"ordering",
"imposed",
"by",
"the",
"specified",
"Comparator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/QuickSort.java#L363-L424 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Collections.java | Collections.getMetaIterator | @ReplacedBy("com.google.common.collect.Iterators#concat() or com.google.common.collect.Iterables#concat()")
public static <T> Iterator<T> getMetaIterator (Iterable<Iterator<T>> metaIterable)
{
return new MetaIterator<T>(metaIterable);
} | java | @ReplacedBy("com.google.common.collect.Iterators#concat() or com.google.common.collect.Iterables#concat()")
public static <T> Iterator<T> getMetaIterator (Iterable<Iterator<T>> metaIterable)
{
return new MetaIterator<T>(metaIterable);
} | [
"@",
"ReplacedBy",
"(",
"\"com.google.common.collect.Iterators#concat() or com.google.common.collect.Iterables#concat()\"",
")",
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"getMetaIterator",
"(",
"Iterable",
"<",
"Iterator",
"<",
"T",
">",
">",
"metaI... | Returns an Iterator that iterates over all the elements contained within the Iterators
within the specified Iterable.
@param metaIterable an iterable of Iterators. | [
"Returns",
"an",
"Iterator",
"that",
"iterates",
"over",
"all",
"the",
"elements",
"contained",
"within",
"the",
"Iterators",
"within",
"the",
"specified",
"Iterable",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Collections.java#L26-L30 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Collections.java | Collections.getSortedIterator | public static <T extends Comparable<? super T>> Iterator<T> getSortedIterator (Iterable<T> coll)
{
return getSortedIterator(coll.iterator(), new Comparator<T>() {
public int compare (T o1, T o2) {
if (o1 == o2) { // catches null == null
return 0;
} else if (o1 == null) {
return 1;
} else if (o2 == null) {
return -1;
}
return o1.compareTo(o2); // null-free
}
});
} | java | public static <T extends Comparable<? super T>> Iterator<T> getSortedIterator (Iterable<T> coll)
{
return getSortedIterator(coll.iterator(), new Comparator<T>() {
public int compare (T o1, T o2) {
if (o1 == o2) { // catches null == null
return 0;
} else if (o1 == null) {
return 1;
} else if (o2 == null) {
return -1;
}
return o1.compareTo(o2); // null-free
}
});
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"Iterator",
"<",
"T",
">",
"getSortedIterator",
"(",
"Iterable",
"<",
"T",
">",
"coll",
")",
"{",
"return",
"getSortedIterator",
"(",
"coll",
".",
"iterator",
"(",
... | Get an Iterator over the supplied Collection that returns the elements in their natural
order. | [
"Get",
"an",
"Iterator",
"over",
"the",
"supplied",
"Collection",
"that",
"returns",
"the",
"elements",
"in",
"their",
"natural",
"order",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Collections.java#L36-L50 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Collections.java | Collections.getSortedIterator | public static <T> Iterator<T> getSortedIterator (Iterable<T> coll, Comparator<T> comparator)
{
return getSortedIterator(coll.iterator(), comparator);
} | java | public static <T> Iterator<T> getSortedIterator (Iterable<T> coll, Comparator<T> comparator)
{
return getSortedIterator(coll.iterator(), comparator);
} | [
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"getSortedIterator",
"(",
"Iterable",
"<",
"T",
">",
"coll",
",",
"Comparator",
"<",
"T",
">",
"comparator",
")",
"{",
"return",
"getSortedIterator",
"(",
"coll",
".",
"iterator",
"(",
")",
... | Get an Iterator over the supplied Collection that returns the elements in the order dictated
by the supplied Comparator. | [
"Get",
"an",
"Iterator",
"over",
"the",
"supplied",
"Collection",
"that",
"returns",
"the",
"elements",
"in",
"the",
"order",
"dictated",
"by",
"the",
"supplied",
"Comparator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Collections.java#L56-L59 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Collections.java | Collections.getSortedIterator | public static <T extends Comparable<? super T>> Iterator<T> getSortedIterator (Iterator<T> itr)
{
return getSortedIterator(itr, new Comparator<T>() {
public int compare (T o1, T o2) {
if (o1 == o2) { // catches null == null
return 0;
} else if (o1 == null) {
return 1;
} else if (o2 == null) {
return -1;
}
return o1.compareTo(o2); // null-free
}
});
} | java | public static <T extends Comparable<? super T>> Iterator<T> getSortedIterator (Iterator<T> itr)
{
return getSortedIterator(itr, new Comparator<T>() {
public int compare (T o1, T o2) {
if (o1 == o2) { // catches null == null
return 0;
} else if (o1 == null) {
return 1;
} else if (o2 == null) {
return -1;
}
return o1.compareTo(o2); // null-free
}
});
} | [
"public",
"static",
"<",
"T",
"extends",
"Comparable",
"<",
"?",
"super",
"T",
">",
">",
"Iterator",
"<",
"T",
">",
"getSortedIterator",
"(",
"Iterator",
"<",
"T",
">",
"itr",
")",
"{",
"return",
"getSortedIterator",
"(",
"itr",
",",
"new",
"Comparator",... | Get an Iterator that returns the same elements returned by the supplied Iterator, but in
their natural order. | [
"Get",
"an",
"Iterator",
"that",
"returns",
"the",
"same",
"elements",
"returned",
"by",
"the",
"supplied",
"Iterator",
"but",
"in",
"their",
"natural",
"order",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Collections.java#L65-L79 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Collections.java | Collections.getSortedIterator | public static <T> Iterator<T> getSortedIterator (Iterator<T> itr, Comparator<T> comparator)
{
SortableArrayList<T> list = new SortableArrayList<T>();
CollectionUtil.addAll(list, itr);
list.sort(comparator);
return getUnmodifiableIterator(list);
} | java | public static <T> Iterator<T> getSortedIterator (Iterator<T> itr, Comparator<T> comparator)
{
SortableArrayList<T> list = new SortableArrayList<T>();
CollectionUtil.addAll(list, itr);
list.sort(comparator);
return getUnmodifiableIterator(list);
} | [
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"getSortedIterator",
"(",
"Iterator",
"<",
"T",
">",
"itr",
",",
"Comparator",
"<",
"T",
">",
"comparator",
")",
"{",
"SortableArrayList",
"<",
"T",
">",
"list",
"=",
"new",
"SortableArrayList... | Get an Iterator that returns the same elements returned by the supplied Iterator, but in the
order dictated by the supplied Comparator. | [
"Get",
"an",
"Iterator",
"that",
"returns",
"the",
"same",
"elements",
"returned",
"by",
"the",
"supplied",
"Iterator",
"but",
"in",
"the",
"order",
"dictated",
"by",
"the",
"supplied",
"Comparator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Collections.java#L85-L91 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Collections.java | Collections.getRandomIterator | public static <T> Iterator<T> getRandomIterator (Iterable<T> c)
{
return getRandomIterator(c.iterator());
} | java | public static <T> Iterator<T> getRandomIterator (Iterable<T> c)
{
return getRandomIterator(c.iterator());
} | [
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"getRandomIterator",
"(",
"Iterable",
"<",
"T",
">",
"c",
")",
"{",
"return",
"getRandomIterator",
"(",
"c",
".",
"iterator",
"(",
")",
")",
";",
"}"
] | Get an Iterator over the supplied Iterable that returns the elements in a completely random
order. Normally Iterators return elements in an undefined order, but it is usually the same
between different invocations as long as the underlying Iterable has not changed. This
method mixes things up. | [
"Get",
"an",
"Iterator",
"over",
"the",
"supplied",
"Iterable",
"that",
"returns",
"the",
"elements",
"in",
"a",
"completely",
"random",
"order",
".",
"Normally",
"Iterators",
"return",
"elements",
"in",
"an",
"undefined",
"order",
"but",
"it",
"is",
"usually"... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Collections.java#L99-L102 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Collections.java | Collections.getRandomIterator | public static <T> Iterator<T> getRandomIterator (Iterator<T> itr)
{
ArrayList<T> list = new ArrayList<T>();
CollectionUtil.addAll(list, itr);
java.util.Collections.shuffle(list);
return getUnmodifiableIterator(list);
} | java | public static <T> Iterator<T> getRandomIterator (Iterator<T> itr)
{
ArrayList<T> list = new ArrayList<T>();
CollectionUtil.addAll(list, itr);
java.util.Collections.shuffle(list);
return getUnmodifiableIterator(list);
} | [
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"getRandomIterator",
"(",
"Iterator",
"<",
"T",
">",
"itr",
")",
"{",
"ArrayList",
"<",
"T",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"CollectionUtil",
".",
"a... | Get an Iterator that returns the same elements returned by the supplied Iterator, but in a
completely random order. | [
"Get",
"an",
"Iterator",
"that",
"returns",
"the",
"same",
"elements",
"returned",
"by",
"the",
"supplied",
"Iterator",
"but",
"in",
"a",
"completely",
"random",
"order",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Collections.java#L108-L114 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Collections.java | Collections.getUnmodifiableIterator | public static <T> Iterator<T> getUnmodifiableIterator (Iterable<T> c)
{
return getUnmodifiableIterator(c.iterator());
} | java | public static <T> Iterator<T> getUnmodifiableIterator (Iterable<T> c)
{
return getUnmodifiableIterator(c.iterator());
} | [
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"getUnmodifiableIterator",
"(",
"Iterable",
"<",
"T",
">",
"c",
")",
"{",
"return",
"getUnmodifiableIterator",
"(",
"c",
".",
"iterator",
"(",
")",
")",
";",
"}"
] | Get an Iterator that returns the elements in the supplied Iterable but blocks removal. | [
"Get",
"an",
"Iterator",
"that",
"returns",
"the",
"elements",
"in",
"the",
"supplied",
"Iterable",
"but",
"blocks",
"removal",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Collections.java#L119-L122 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Collections.java | Collections.getUnmodifiableIterator | @ReplacedBy("com.google.common.collect.Iterators#unmodifiableIterator()")
public static <T> Iterator<T> getUnmodifiableIterator (final Iterator<T> itr)
{
return new Iterator<T>() {
public boolean hasNext () {
return itr.hasNext();
}
public T next () {
return itr.next();
}
public void remove () {
throw new UnsupportedOperationException(
"Cannot remove from an UnmodifiableIterator!");
}
};
} | java | @ReplacedBy("com.google.common.collect.Iterators#unmodifiableIterator()")
public static <T> Iterator<T> getUnmodifiableIterator (final Iterator<T> itr)
{
return new Iterator<T>() {
public boolean hasNext () {
return itr.hasNext();
}
public T next () {
return itr.next();
}
public void remove () {
throw new UnsupportedOperationException(
"Cannot remove from an UnmodifiableIterator!");
}
};
} | [
"@",
"ReplacedBy",
"(",
"\"com.google.common.collect.Iterators#unmodifiableIterator()\"",
")",
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"getUnmodifiableIterator",
"(",
"final",
"Iterator",
"<",
"T",
">",
"itr",
")",
"{",
"return",
"new",
"Iter... | Get an iterator that returns the same elements as the supplied iterator but blocks removal. | [
"Get",
"an",
"iterator",
"that",
"returns",
"the",
"same",
"elements",
"as",
"the",
"supplied",
"iterator",
"but",
"blocks",
"removal",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Collections.java#L127-L142 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/ValueMarshaller.java | ValueMarshaller.unmarshal | public static Object unmarshal (Class<?> type, String source)
throws Exception
{
if (type.isEnum()) {
// we need to use a dummy enum type here as there's no way to ask Enum.valueOf to
// execute on an existentially typed enum; it all works out under the hood
@SuppressWarnings("unchecked") Class<Dummy> etype = (Class<Dummy>)type;
return Enum.valueOf(etype, source); // may throw an exception
}
// look up an argument parser for the field type
Parser parser = _parsers.get(type);
if (parser == null) {
throw new Exception(
"Don't know how to convert strings into values of type '" + type + "'.");
}
return parser.parse(source);
} | java | public static Object unmarshal (Class<?> type, String source)
throws Exception
{
if (type.isEnum()) {
// we need to use a dummy enum type here as there's no way to ask Enum.valueOf to
// execute on an existentially typed enum; it all works out under the hood
@SuppressWarnings("unchecked") Class<Dummy> etype = (Class<Dummy>)type;
return Enum.valueOf(etype, source); // may throw an exception
}
// look up an argument parser for the field type
Parser parser = _parsers.get(type);
if (parser == null) {
throw new Exception(
"Don't know how to convert strings into values of type '" + type + "'.");
}
return parser.parse(source);
} | [
"public",
"static",
"Object",
"unmarshal",
"(",
"Class",
"<",
"?",
">",
"type",
",",
"String",
"source",
")",
"throws",
"Exception",
"{",
"if",
"(",
"type",
".",
"isEnum",
"(",
")",
")",
"{",
"// we need to use a dummy enum type here as there's no way to ask Enum.... | Attempts to convert the specified value to an instance of the
specified object type.
@exception Exception thrown if no field parser exists for the
target type or if an error occurs while parsing the value. | [
"Attempts",
"to",
"convert",
"the",
"specified",
"value",
"to",
"an",
"instance",
"of",
"the",
"specified",
"object",
"type",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ValueMarshaller.java#L27-L43 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/BaseArrayList.java | BaseArrayList.rangeCheck | protected final void rangeCheck (int index, boolean insert)
{
if ((index < 0) || (insert ? (index > _size) : (index >= _size))) {
throw new IndexOutOfBoundsException(
"Index: " + index + ", Size: " + _size);
}
} | java | protected final void rangeCheck (int index, boolean insert)
{
if ((index < 0) || (insert ? (index > _size) : (index >= _size))) {
throw new IndexOutOfBoundsException(
"Index: " + index + ", Size: " + _size);
}
} | [
"protected",
"final",
"void",
"rangeCheck",
"(",
"int",
"index",
",",
"boolean",
"insert",
")",
"{",
"if",
"(",
"(",
"index",
"<",
"0",
")",
"||",
"(",
"insert",
"?",
"(",
"index",
">",
"_size",
")",
":",
"(",
"index",
">=",
"_size",
")",
")",
")... | Check the range of a passed-in index to make sure it's valid.
@param insert if true, an index equal to our size is valid. | [
"Check",
"the",
"range",
"of",
"a",
"passed",
"-",
"in",
"index",
"to",
"make",
"sure",
"it",
"s",
"valid",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/BaseArrayList.java#L153-L159 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/queryexec/QueryParameter.java | QueryParameter.getValueClass | public Class getValueClass() {
if (valueClass == null) {
if (valueClassName != null) {
try {
valueClass = Class.forName(valueClassName);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}
return valueClass;
} | java | public Class getValueClass() {
if (valueClass == null) {
if (valueClassName != null) {
try {
valueClass = Class.forName(valueClassName);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}
return valueClass;
} | [
"public",
"Class",
"getValueClass",
"(",
")",
"{",
"if",
"(",
"valueClass",
"==",
"null",
")",
"{",
"if",
"(",
"valueClassName",
"!=",
"null",
")",
"{",
"try",
"{",
"valueClass",
"=",
"Class",
".",
"forName",
"(",
"valueClassName",
")",
";",
"}",
"catc... | Get java class object for the parameter value
@return java class object for the parameter value | [
"Get",
"java",
"class",
"object",
"for",
"the",
"parameter",
"value"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/queryexec/QueryParameter.java#L229-L241 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/queryexec/QueryParameter.java | QueryParameter.setPreviewValue | public void setPreviewValue(String previewValue) {
if (!isProcedureParameter && (previewValue != null)) {
throw new IllegalArgumentException("Parameter '" + name + "' is not a procedure parameter.");
}
this.previewValue = previewValue;
} | java | public void setPreviewValue(String previewValue) {
if (!isProcedureParameter && (previewValue != null)) {
throw new IllegalArgumentException("Parameter '" + name + "' is not a procedure parameter.");
}
this.previewValue = previewValue;
} | [
"public",
"void",
"setPreviewValue",
"(",
"String",
"previewValue",
")",
"{",
"if",
"(",
"!",
"isProcedureParameter",
"&&",
"(",
"previewValue",
"!=",
"null",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Parameter '\"",
"+",
"name",
"+",
... | Set preview value for procedure parameter Allows to set null for any type
@param previewValue
preview value for procedure parameter | [
"Set",
"preview",
"value",
"for",
"procedure",
"parameter",
"Allows",
"to",
"set",
"null",
"for",
"any",
"type"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/queryexec/QueryParameter.java#L470-L475 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Config.java | Config.getValue | public String getValue (String name, String defval)
{
return _props.getProperty(name, defval);
} | java | public String getValue (String name, String defval)
{
return _props.getProperty(name, defval);
} | [
"public",
"String",
"getValue",
"(",
"String",
"name",
",",
"String",
"defval",
")",
"{",
"return",
"_props",
".",
"getProperty",
"(",
"name",
",",
"defval",
")",
";",
"}"
] | Fetches and returns the value for the specified configuration property. If the value is not
specified in the associated properties file, the supplied default value is returned instead.
@param name the name of the property to be fetched.
@param defval the value to return if the property is not specified in the config file.
@return the value of the requested property. | [
"Fetches",
"and",
"returns",
"the",
"value",
"for",
"the",
"specified",
"configuration",
"property",
".",
"If",
"the",
"value",
"is",
"not",
"specified",
"in",
"the",
"associated",
"properties",
"file",
"the",
"supplied",
"default",
"value",
"is",
"returned",
... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Config.java#L202-L205 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Config.java | Config.instantiateValue | public Object instantiateValue (String name, String defcname)
throws Exception
{
return Class.forName(getValue(name, defcname)).newInstance();
} | java | public Object instantiateValue (String name, String defcname)
throws Exception
{
return Class.forName(getValue(name, defcname)).newInstance();
} | [
"public",
"Object",
"instantiateValue",
"(",
"String",
"name",
",",
"String",
"defcname",
")",
"throws",
"Exception",
"{",
"return",
"Class",
".",
"forName",
"(",
"getValue",
"(",
"name",
",",
"defcname",
")",
")",
".",
"newInstance",
"(",
")",
";",
"}"
] | Looks up the specified string-valued configuration entry, loads the class with that name and
instantiates a new instance of that class, which is returned.
@param name the name of the property to be fetched.
@param defcname the class name to use if the property is not specified in the config file.
@exception Exception thrown if any error occurs while loading or instantiating the class. | [
"Looks",
"up",
"the",
"specified",
"string",
"-",
"valued",
"configuration",
"entry",
"loads",
"the",
"class",
"with",
"that",
"name",
"and",
"instantiates",
"a",
"new",
"instance",
"of",
"that",
"class",
"which",
"is",
"returned",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Config.java#L336-L340 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Config.java | Config.keys | public Iterator<String> keys ()
{
HashSet<String> matches = new HashSet<String>();
enumerateKeys(matches);
return matches.iterator();
} | java | public Iterator<String> keys ()
{
HashSet<String> matches = new HashSet<String>();
enumerateKeys(matches);
return matches.iterator();
} | [
"public",
"Iterator",
"<",
"String",
">",
"keys",
"(",
")",
"{",
"HashSet",
"<",
"String",
">",
"matches",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"enumerateKeys",
"(",
"matches",
")",
";",
"return",
"matches",
".",
"iterator",
"(",
... | Returns an iterator that returns all of the configuration keys in this config object. | [
"Returns",
"an",
"iterator",
"that",
"returns",
"all",
"of",
"the",
"configuration",
"keys",
"in",
"this",
"config",
"object",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Config.java#L383-L388 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/exporter/TxtExporter.java | TxtExporter.put | private void put(PrintStream p, String s, int column, int colSpan, BandElement bandElement) {
if (s == null) {
// nl();
put(p, "", column, colSpan, bandElement);
return;
}
int size = 0;
if (colSpan > 1) {
for (int i=column; i<column+colSpan; i++) {
size += columnWidth[i];
}
} else {
size = columnWidth[column];
}
if ((bandElement != null) && bandElement.getHorizontalAlign() == BandElement.RIGHT) {
p.print(String.format("%" + size + "s", s));
} else {
p.print(String.format("%-" + size + "s", s));
}
} | java | private void put(PrintStream p, String s, int column, int colSpan, BandElement bandElement) {
if (s == null) {
// nl();
put(p, "", column, colSpan, bandElement);
return;
}
int size = 0;
if (colSpan > 1) {
for (int i=column; i<column+colSpan; i++) {
size += columnWidth[i];
}
} else {
size = columnWidth[column];
}
if ((bandElement != null) && bandElement.getHorizontalAlign() == BandElement.RIGHT) {
p.print(String.format("%" + size + "s", s));
} else {
p.print(String.format("%-" + size + "s", s));
}
} | [
"private",
"void",
"put",
"(",
"PrintStream",
"p",
",",
"String",
"s",
",",
"int",
"column",
",",
"int",
"colSpan",
",",
"BandElement",
"bandElement",
")",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"{",
"// nl();",
"put",
"(",
"p",
",",
"\"\"",
",",
... | Write one tsv field to the file, followed by a separator unless it is the
last field on the line. Lead and trailing blanks will be removed.
@param p print stream
@param s The string to write. Any additional quotes or embedded quotes
will be provided by put. Null means start a new line. | [
"Write",
"one",
"tsv",
"field",
"to",
"the",
"file",
"followed",
"by",
"a",
"separator",
"unless",
"it",
"is",
"the",
"last",
"field",
"on",
"the",
"line",
".",
"Lead",
"and",
"trailing",
"blanks",
"will",
"be",
"removed",
"."
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/exporter/TxtExporter.java#L159-L180 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/ConfigUtil.java | ConfigUtil.parseMetaData | protected static PropRecord parseMetaData (String path, URL sourceURL)
throws IOException
{
InputStream input = sourceURL.openStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(input));
try {
PropRecord record = new PropRecord(path, sourceURL);
boolean started = false;
String line;
while ((line = bin.readLine()) != null) {
if (line.startsWith(PACKAGE_KEY)) {
record._package = parseValue(line);
started = true;
} else if (line.startsWith(EXTENDS_KEY)) {
record._extends = parseValue(line);
started = true;
} else if (line.startsWith(OVERRIDES_KEY)) {
record._overrides = parseValues(line);
started = true;
} else if (started) {
break;
}
}
return record;
} finally {
StreamUtil.close(bin);
}
} | java | protected static PropRecord parseMetaData (String path, URL sourceURL)
throws IOException
{
InputStream input = sourceURL.openStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(input));
try {
PropRecord record = new PropRecord(path, sourceURL);
boolean started = false;
String line;
while ((line = bin.readLine()) != null) {
if (line.startsWith(PACKAGE_KEY)) {
record._package = parseValue(line);
started = true;
} else if (line.startsWith(EXTENDS_KEY)) {
record._extends = parseValue(line);
started = true;
} else if (line.startsWith(OVERRIDES_KEY)) {
record._overrides = parseValues(line);
started = true;
} else if (started) {
break;
}
}
return record;
} finally {
StreamUtil.close(bin);
}
} | [
"protected",
"static",
"PropRecord",
"parseMetaData",
"(",
"String",
"path",
",",
"URL",
"sourceURL",
")",
"throws",
"IOException",
"{",
"InputStream",
"input",
"=",
"sourceURL",
".",
"openStream",
"(",
")",
";",
"BufferedReader",
"bin",
"=",
"new",
"BufferedRea... | Performs simple processing of the supplied input stream to obtain inheritance metadata from
the properties file. | [
"Performs",
"simple",
"processing",
"of",
"the",
"supplied",
"input",
"stream",
"to",
"obtain",
"inheritance",
"metadata",
"from",
"the",
"properties",
"file",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ConfigUtil.java#L410-L437 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/ConfigUtil.java | ConfigUtil.getStream | public static InputStream getStream (String path, ClassLoader loader)
{
// first try the supplied class loader
InputStream in = getResourceAsStream(path, loader);
if (in != null) {
return in;
}
// if that didn't work, try the system class loader (but only if it's different from the
// class loader we just tried)
try {
ClassLoader sysloader = ClassLoader.getSystemClassLoader();
if (sysloader != loader) {
return getResourceAsStream(path, loader);
}
} catch (AccessControlException ace) {
// can't get the system loader, no problem!
}
return null;
} | java | public static InputStream getStream (String path, ClassLoader loader)
{
// first try the supplied class loader
InputStream in = getResourceAsStream(path, loader);
if (in != null) {
return in;
}
// if that didn't work, try the system class loader (but only if it's different from the
// class loader we just tried)
try {
ClassLoader sysloader = ClassLoader.getSystemClassLoader();
if (sysloader != loader) {
return getResourceAsStream(path, loader);
}
} catch (AccessControlException ace) {
// can't get the system loader, no problem!
}
return null;
} | [
"public",
"static",
"InputStream",
"getStream",
"(",
"String",
"path",
",",
"ClassLoader",
"loader",
")",
"{",
"// first try the supplied class loader",
"InputStream",
"in",
"=",
"getResourceAsStream",
"(",
"path",
",",
"loader",
")",
";",
"if",
"(",
"in",
"!=",
... | Returns an input stream referencing a file that exists somewhere in the classpath.
<p> The supplied classloader is searched first, followed by the system classloader.
@param path The path to the file, relative to the root of the classpath directory from which
it will be loaded (e.g. <code>com/foo/bar/foo.gif</code>). | [
"Returns",
"an",
"input",
"stream",
"referencing",
"a",
"file",
"that",
"exists",
"somewhere",
"in",
"the",
"classpath",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ConfigUtil.java#L484-L503 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/ServiceWaiter.java | ServiceWaiter.waitForResponse | public boolean waitForResponse ()
throws TimeoutException
{
if (_success == 0) {
synchronized (this) {
try {
// wait for the response, timing out after a while
if (_timeout == NO_TIMEOUT) {
wait();
} else {
wait(1000L * _timeout);
}
// if we get here without some sort of response, then we've timed out
if (_success == 0) {
throw new TimeoutException();
}
} catch (InterruptedException ie) {
throw (TimeoutException)
new TimeoutException().initCause(ie);
}
}
}
return (_success > 0);
} | java | public boolean waitForResponse ()
throws TimeoutException
{
if (_success == 0) {
synchronized (this) {
try {
// wait for the response, timing out after a while
if (_timeout == NO_TIMEOUT) {
wait();
} else {
wait(1000L * _timeout);
}
// if we get here without some sort of response, then we've timed out
if (_success == 0) {
throw new TimeoutException();
}
} catch (InterruptedException ie) {
throw (TimeoutException)
new TimeoutException().initCause(ie);
}
}
}
return (_success > 0);
} | [
"public",
"boolean",
"waitForResponse",
"(",
")",
"throws",
"TimeoutException",
"{",
"if",
"(",
"_success",
"==",
"0",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"try",
"{",
"// wait for the response, timing out after a while",
"if",
"(",
"_timeout",
"==",
... | Blocks waiting for the response.
@return true if a success response was posted, false if a failure response was posted. | [
"Blocks",
"waiting",
"for",
"the",
"response",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ServiceWaiter.java#L119-L145 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ObjectCloner.java | ObjectCloner.silenceDeepCopy | public static final <T> T silenceDeepCopy(T object) {
try {
return deepCopy(object);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} | java | public static final <T> T silenceDeepCopy(T object) {
try {
return deepCopy(object);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} | [
"public",
"static",
"final",
"<",
"T",
">",
"T",
"silenceDeepCopy",
"(",
"T",
"object",
")",
"{",
"try",
"{",
"return",
"deepCopy",
"(",
"object",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
... | Throws a RuntimeException if an exception occurs. | [
"Throws",
"a",
"RuntimeException",
"if",
"an",
"exception",
"occurs",
"."
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ObjectCloner.java#L71-L78 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/jora/FieldMask.java | FieldMask.isModified | public final boolean isModified ()
{
int mcount = _modified.length;
for (int ii = 0; ii < mcount; ii++) {
if (_modified[ii]) {
return true;
}
}
return false;
} | java | public final boolean isModified ()
{
int mcount = _modified.length;
for (int ii = 0; ii < mcount; ii++) {
if (_modified[ii]) {
return true;
}
}
return false;
} | [
"public",
"final",
"boolean",
"isModified",
"(",
")",
"{",
"int",
"mcount",
"=",
"_modified",
".",
"length",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
"mcount",
";",
"ii",
"++",
")",
"{",
"if",
"(",
"_modified",
"[",
"ii",
"]",
")",... | Returns true if any of the fields in this mask are modified. | [
"Returns",
"true",
"if",
"any",
"of",
"the",
"fields",
"in",
"this",
"mask",
"are",
"modified",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/FieldMask.java#L55-L64 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/jora/FieldMask.java | FieldMask.isModified | public final boolean isModified (String fieldName)
{
Integer index = _descripMap.get(fieldName);
if (index == null) {
throw new IllegalArgumentException("Field not in mask: " + fieldName);
}
return _modified[index.intValue()];
} | java | public final boolean isModified (String fieldName)
{
Integer index = _descripMap.get(fieldName);
if (index == null) {
throw new IllegalArgumentException("Field not in mask: " + fieldName);
}
return _modified[index.intValue()];
} | [
"public",
"final",
"boolean",
"isModified",
"(",
"String",
"fieldName",
")",
"{",
"Integer",
"index",
"=",
"_descripMap",
".",
"get",
"(",
"fieldName",
")",
";",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"... | Returns true if the field with the specified name is modifed. | [
"Returns",
"true",
"if",
"the",
"field",
"with",
"the",
"specified",
"name",
"is",
"modifed",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/FieldMask.java#L77-L84 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/jora/FieldMask.java | FieldMask.onlySubsetModified | public final boolean onlySubsetModified (Set<String> fieldSet)
{
for (String field : _descripMap.keySet()) {
if (isModified(field) && (!fieldSet.contains(field))) {
return false;
}
}
return true;
} | java | public final boolean onlySubsetModified (Set<String> fieldSet)
{
for (String field : _descripMap.keySet()) {
if (isModified(field) && (!fieldSet.contains(field))) {
return false;
}
}
return true;
} | [
"public",
"final",
"boolean",
"onlySubsetModified",
"(",
"Set",
"<",
"String",
">",
"fieldSet",
")",
"{",
"for",
"(",
"String",
"field",
":",
"_descripMap",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"isModified",
"(",
"field",
")",
"&&",
"(",
"!",
... | Returns true only if the set of modified fields is a subset of the
fields specified. | [
"Returns",
"true",
"only",
"if",
"the",
"set",
"of",
"modified",
"fields",
"is",
"a",
"subset",
"of",
"the",
"fields",
"specified",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/FieldMask.java#L90-L98 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/jora/FieldMask.java | FieldMask.setModified | public void setModified (String fieldName)
{
Integer index = _descripMap.get(fieldName);
if (index == null) {
throw new IllegalArgumentException("Field not in mask: " + fieldName);
}
_modified[index.intValue()] = true;
} | java | public void setModified (String fieldName)
{
Integer index = _descripMap.get(fieldName);
if (index == null) {
throw new IllegalArgumentException("Field not in mask: " + fieldName);
}
_modified[index.intValue()] = true;
} | [
"public",
"void",
"setModified",
"(",
"String",
"fieldName",
")",
"{",
"Integer",
"index",
"=",
"_descripMap",
".",
"get",
"(",
"fieldName",
")",
";",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Field not i... | Marks the specified field as modified. | [
"Marks",
"the",
"specified",
"field",
"as",
"modified",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/FieldMask.java#L103-L110 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Histogram.java | Histogram.addValue | public void addValue (int value)
{
if (value < _minValue) {
_buckets[0]++;
} else if (value >= _maxValue) {
_buckets[_buckets.length-1]++;
} else {
_buckets[(value-_minValue)/_bucketWidth]++;
}
_count++;
} | java | public void addValue (int value)
{
if (value < _minValue) {
_buckets[0]++;
} else if (value >= _maxValue) {
_buckets[_buckets.length-1]++;
} else {
_buckets[(value-_minValue)/_bucketWidth]++;
}
_count++;
} | [
"public",
"void",
"addValue",
"(",
"int",
"value",
")",
"{",
"if",
"(",
"value",
"<",
"_minValue",
")",
"{",
"_buckets",
"[",
"0",
"]",
"++",
";",
"}",
"else",
"if",
"(",
"value",
">=",
"_maxValue",
")",
"{",
"_buckets",
"[",
"_buckets",
".",
"leng... | Registers a value with this histogram. | [
"Registers",
"a",
"value",
"with",
"this",
"histogram",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Histogram.java#L32-L42 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Histogram.java | Histogram.summarize | public String summarize ()
{
StringBuilder buf = new StringBuilder();
buf.append(_count).append(":");
for (int ii = 0; ii < _buckets.length; ii++) {
if (ii > 0) {
buf.append(",");
}
buf.append(_buckets[ii]);
}
return buf.toString();
} | java | public String summarize ()
{
StringBuilder buf = new StringBuilder();
buf.append(_count).append(":");
for (int ii = 0; ii < _buckets.length; ii++) {
if (ii > 0) {
buf.append(",");
}
buf.append(_buckets[ii]);
}
return buf.toString();
} | [
"public",
"String",
"summarize",
"(",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buf",
".",
"append",
"(",
"_count",
")",
".",
"append",
"(",
"\":\"",
")",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
... | Generates a terse summary of the count and contents of the values in this histogram. | [
"Generates",
"a",
"terse",
"summary",
"of",
"the",
"count",
"and",
"contents",
"of",
"the",
"values",
"in",
"this",
"histogram",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Histogram.java#L74-L85 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Predicate.java | Predicate.filter | public <E extends T> Iterator<E> filter (final Iterator<E> input)
{
return new Iterator<E>() {
// from Iterator
public boolean hasNext ()
{
return _found || findNext();
}
// from Iterator
public E next ()
{
if (_found || findNext()) {
_found = false;
return _last;
} else {
throw new NoSuchElementException();
}
}
// from Iterator
public void remove ()
{
if (_removeable) {
_removeable = false;
input.remove();
} else {
throw new IllegalStateException();
}
}
private boolean findNext ()
{
boolean result = false;
while (input.hasNext()) {
E candidate = input.next();
if (isMatch(candidate)) {
_last = candidate;
result = true;
break;
}
}
_found = result;
_removeable = result;
return result;
}
private E _last;
private boolean _found; // because _last == null is a valid element
private boolean _removeable;
};
} | java | public <E extends T> Iterator<E> filter (final Iterator<E> input)
{
return new Iterator<E>() {
// from Iterator
public boolean hasNext ()
{
return _found || findNext();
}
// from Iterator
public E next ()
{
if (_found || findNext()) {
_found = false;
return _last;
} else {
throw new NoSuchElementException();
}
}
// from Iterator
public void remove ()
{
if (_removeable) {
_removeable = false;
input.remove();
} else {
throw new IllegalStateException();
}
}
private boolean findNext ()
{
boolean result = false;
while (input.hasNext()) {
E candidate = input.next();
if (isMatch(candidate)) {
_last = candidate;
result = true;
break;
}
}
_found = result;
_removeable = result;
return result;
}
private E _last;
private boolean _found; // because _last == null is a valid element
private boolean _removeable;
};
} | [
"public",
"<",
"E",
"extends",
"T",
">",
"Iterator",
"<",
"E",
">",
"filter",
"(",
"final",
"Iterator",
"<",
"E",
">",
"input",
")",
"{",
"return",
"new",
"Iterator",
"<",
"E",
">",
"(",
")",
"{",
"// from Iterator",
"public",
"boolean",
"hasNext",
"... | Return a new iterator that contains only matching elements from
the input iterator. | [
"Return",
"a",
"new",
"iterator",
"that",
"contains",
"only",
"matching",
"elements",
"from",
"the",
"input",
"iterator",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Predicate.java#L164-L218 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Predicate.java | Predicate.filter | public <E extends T> void filter (Collection<E> coll)
{
for (Iterator<E> itr = coll.iterator(); itr.hasNext(); ) {
if (!isMatch(itr.next())) {
itr.remove();
}
}
} | java | public <E extends T> void filter (Collection<E> coll)
{
for (Iterator<E> itr = coll.iterator(); itr.hasNext(); ) {
if (!isMatch(itr.next())) {
itr.remove();
}
}
} | [
"public",
"<",
"E",
"extends",
"T",
">",
"void",
"filter",
"(",
"Collection",
"<",
"E",
">",
"coll",
")",
"{",
"for",
"(",
"Iterator",
"<",
"E",
">",
"itr",
"=",
"coll",
".",
"iterator",
"(",
")",
";",
"itr",
".",
"hasNext",
"(",
")",
";",
")",... | Remove non-matching elements from the specified collection. | [
"Remove",
"non",
"-",
"matching",
"elements",
"from",
"the",
"specified",
"collection",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Predicate.java#L223-L230 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Predicate.java | Predicate.createView | public <E extends T> Iterable<E> createView (final Iterable<E> input)
{
return new Iterable<E>() {
public Iterator<E> iterator() {
return filter(input.iterator());
}
};
} | java | public <E extends T> Iterable<E> createView (final Iterable<E> input)
{
return new Iterable<E>() {
public Iterator<E> iterator() {
return filter(input.iterator());
}
};
} | [
"public",
"<",
"E",
"extends",
"T",
">",
"Iterable",
"<",
"E",
">",
"createView",
"(",
"final",
"Iterable",
"<",
"E",
">",
"input",
")",
"{",
"return",
"new",
"Iterable",
"<",
"E",
">",
"(",
")",
"{",
"public",
"Iterator",
"<",
"E",
">",
"iterator"... | Create an Iterable view of the specified Iterable that only contains
elements that match the predicate.
This Iterable can be iterated over at any time in the future to
view the current predicate-matching elements of the input Iterable. | [
"Create",
"an",
"Iterable",
"view",
"of",
"the",
"specified",
"Iterable",
"that",
"only",
"contains",
"elements",
"that",
"match",
"the",
"predicate",
".",
"This",
"Iterable",
"can",
"be",
"iterated",
"over",
"at",
"any",
"time",
"in",
"the",
"future",
"to",... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Predicate.java#L238-L245 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Predicate.java | Predicate.createView | public <E extends T> Collection<E> createView (final Collection<E> input)
{
// TODO: create a collection of the same type?
return new AbstractCollection<E>() {
@Override public int size ()
{
// oh god, oh god: we iterate and count
int size = 0;
for (Iterator<E> iter = iterator(); iter.hasNext(); ) {
iter.next();
size++;
}
return size;
}
@Override public boolean add (E element)
{
return input.add(element);
}
@Override public boolean remove (Object element)
{
return input.remove(element);
}
@Override public boolean contains (Object element)
{
try {
@SuppressWarnings("unchecked")
E elem = (E) element;
return isMatch(elem) && input.contains(elem);
} catch (ClassCastException cce) {
// since it's not an E, it can't be a member of our view
return false;
}
}
@Override public Iterator<E> iterator ()
{
return filter(input.iterator());
}
};
} | java | public <E extends T> Collection<E> createView (final Collection<E> input)
{
// TODO: create a collection of the same type?
return new AbstractCollection<E>() {
@Override public int size ()
{
// oh god, oh god: we iterate and count
int size = 0;
for (Iterator<E> iter = iterator(); iter.hasNext(); ) {
iter.next();
size++;
}
return size;
}
@Override public boolean add (E element)
{
return input.add(element);
}
@Override public boolean remove (Object element)
{
return input.remove(element);
}
@Override public boolean contains (Object element)
{
try {
@SuppressWarnings("unchecked")
E elem = (E) element;
return isMatch(elem) && input.contains(elem);
} catch (ClassCastException cce) {
// since it's not an E, it can't be a member of our view
return false;
}
}
@Override public Iterator<E> iterator ()
{
return filter(input.iterator());
}
};
} | [
"public",
"<",
"E",
"extends",
"T",
">",
"Collection",
"<",
"E",
">",
"createView",
"(",
"final",
"Collection",
"<",
"E",
">",
"input",
")",
"{",
"// TODO: create a collection of the same type?",
"return",
"new",
"AbstractCollection",
"<",
"E",
">",
"(",
")",
... | Create a view of the specified collection that only contains elements
that match the predicate.
This collection can be examined at any time in the future to view
the current predicate-matching elements of the input collection.
Note that the view is not modifiable and currently has poor
implementations of some methods. | [
"Create",
"a",
"view",
"of",
"the",
"specified",
"collection",
"that",
"only",
"contains",
"elements",
"that",
"match",
"the",
"predicate",
".",
"This",
"collection",
"can",
"be",
"examined",
"at",
"any",
"time",
"in",
"the",
"future",
"to",
"view",
"the",
... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Predicate.java#L256-L299 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Calendars.java | Calendars.at | public static Builder at (long millis)
{
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(millis);
return with(calendar);
} | java | public static Builder at (long millis)
{
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(millis);
return with(calendar);
} | [
"public",
"static",
"Builder",
"at",
"(",
"long",
"millis",
")",
"{",
"Calendar",
"calendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"calendar",
".",
"setTimeInMillis",
"(",
"millis",
")",
";",
"return",
"with",
"(",
"calendar",
")",
";",
"}... | Returns a fluent wrapper around a calendar configured with the specified time. | [
"Returns",
"a",
"fluent",
"wrapper",
"around",
"a",
"calendar",
"configured",
"with",
"the",
"specified",
"time",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Calendars.java#L184-L189 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Calendars.java | Calendars.at | public static Builder at (int year, int month, int day)
{
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, day);
return with(calendar).zeroTime();
} | java | public static Builder at (int year, int month, int day)
{
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, day);
return with(calendar).zeroTime();
} | [
"public",
"static",
"Builder",
"at",
"(",
"int",
"year",
",",
"int",
"month",
",",
"int",
"day",
")",
"{",
"Calendar",
"calendar",
"=",
"Calendar",
".",
"getInstance",
"(",
")",
";",
"calendar",
".",
"set",
"(",
"year",
",",
"month",
",",
"day",
")",... | Returns a fluent wrapper around a calendar configured to zero milliseconds after midnight on
the specified day in the specified month and year.
@param year a regular year value, like 1900
@param month a 0-based month value, like {@link Calendar#JANUARY}
@param day a regular day of the month value, like 31 | [
"Returns",
"a",
"fluent",
"wrapper",
"around",
"a",
"calendar",
"configured",
"to",
"zero",
"milliseconds",
"after",
"midnight",
"on",
"the",
"specified",
"day",
"in",
"the",
"specified",
"month",
"and",
"year",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Calendars.java#L199-L204 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Calendars.java | Calendars.in | public static Builder in (TimeZone zone, Locale locale)
{
return with(Calendar.getInstance(zone, locale));
} | java | public static Builder in (TimeZone zone, Locale locale)
{
return with(Calendar.getInstance(zone, locale));
} | [
"public",
"static",
"Builder",
"in",
"(",
"TimeZone",
"zone",
",",
"Locale",
"locale",
")",
"{",
"return",
"with",
"(",
"Calendar",
".",
"getInstance",
"(",
"zone",
",",
"locale",
")",
")",
";",
"}"
] | Returns a fluent wrapper around a calendar for the specifed time zone and locale. | [
"Returns",
"a",
"fluent",
"wrapper",
"around",
"a",
"calendar",
"for",
"the",
"specifed",
"time",
"zone",
"and",
"locale",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Calendars.java#L233-L236 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/RadialMenu.java | RadialMenu.addMenuItem | public RadialMenuItem addMenuItem (String command, String label, Image icon, Predicate predicate)
{
RadialMenuItem item = new RadialMenuItem(command, label, new ImageIcon(icon), predicate);
addMenuItem(item);
return item;
} | java | public RadialMenuItem addMenuItem (String command, String label, Image icon, Predicate predicate)
{
RadialMenuItem item = new RadialMenuItem(command, label, new ImageIcon(icon), predicate);
addMenuItem(item);
return item;
} | [
"public",
"RadialMenuItem",
"addMenuItem",
"(",
"String",
"command",
",",
"String",
"label",
",",
"Image",
"icon",
",",
"Predicate",
"predicate",
")",
"{",
"RadialMenuItem",
"item",
"=",
"new",
"RadialMenuItem",
"(",
"command",
",",
"label",
",",
"new",
"Image... | Adds a menu item to the menu. The menu should not currently be active.
@param command the command to be issued when the item is selected.
@param label the textual label to be displayed with the menu item.
@param icon the icon to display next to the menu text or null if no
icon is desired.
@param predicate a predicate that will be used to determine whether or not this menu item
should be included in the menu and enabled when it is shown.
@return the item that was added to the menu. It can be modified while the menu is not being
displayed. | [
"Adds",
"a",
"menu",
"item",
"to",
"the",
"menu",
".",
"The",
"menu",
"should",
"not",
"currently",
"be",
"active",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/RadialMenu.java#L123-L128 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/RadialMenu.java | RadialMenu.removeMenuItem | public boolean removeMenuItem (String command)
{
int icount = _items.size();
for (int i = 0; i < icount; i++) {
RadialMenuItem item = _items.get(i);
if (item.command.equals(command)) {
_items.remove(i);
return true;
}
}
return false;
} | java | public boolean removeMenuItem (String command)
{
int icount = _items.size();
for (int i = 0; i < icount; i++) {
RadialMenuItem item = _items.get(i);
if (item.command.equals(command)) {
_items.remove(i);
return true;
}
}
return false;
} | [
"public",
"boolean",
"removeMenuItem",
"(",
"String",
"command",
")",
"{",
"int",
"icount",
"=",
"_items",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"icount",
";",
"i",
"++",
")",
"{",
"RadialMenuItem",
"item",
"=... | Removes the first menu item that matches the specified command from this menu.
@return true if a matching menu item was removed, false if not. | [
"Removes",
"the",
"first",
"menu",
"item",
"that",
"matches",
"the",
"specified",
"command",
"from",
"this",
"menu",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/RadialMenu.java#L166-L178 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/RadialMenu.java | RadialMenu.deactivate | public void deactivate ()
{
if (_host != null) {
// unwire ourselves from the host component
Component comp = _host.getComponent();
comp.removeMouseListener(this);
comp.removeMouseMotionListener(this);
// reinstate the previous mouse listeners
if (_hijacker != null) {
_hijacker.release();
_hijacker = null;
}
// tell our host that we are no longer
_host.menuDeactivated(this);
// fire off a last repaint to clean up after ourselves
repaint();
}
// clear out our references
_host = null;
_tbounds = null;
_argument = null;
// clear out our action listeners
_actlist.clear();
} | java | public void deactivate ()
{
if (_host != null) {
// unwire ourselves from the host component
Component comp = _host.getComponent();
comp.removeMouseListener(this);
comp.removeMouseMotionListener(this);
// reinstate the previous mouse listeners
if (_hijacker != null) {
_hijacker.release();
_hijacker = null;
}
// tell our host that we are no longer
_host.menuDeactivated(this);
// fire off a last repaint to clean up after ourselves
repaint();
}
// clear out our references
_host = null;
_tbounds = null;
_argument = null;
// clear out our action listeners
_actlist.clear();
} | [
"public",
"void",
"deactivate",
"(",
")",
"{",
"if",
"(",
"_host",
"!=",
"null",
")",
"{",
"// unwire ourselves from the host component",
"Component",
"comp",
"=",
"_host",
".",
"getComponent",
"(",
")",
";",
"comp",
".",
"removeMouseListener",
"(",
"this",
")... | Deactivates the menu. | [
"Deactivates",
"the",
"menu",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/RadialMenu.java#L273-L301 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/RadialMenu.java | RadialMenu.render | public void render (Graphics2D gfx)
{
Component host = _host.getComponent();
int x = _bounds.x, y = _bounds.y;
if (_centerLabel != null) {
// render the centerpiece label
_centerLabel.paint(gfx, x + _centerLabel.closedBounds.x,
y + _centerLabel.closedBounds.y, this);
}
// render each of our items in turn
int icount = _items.size();
for (int i = 0; i < icount; i++) {
RadialMenuItem item = _items.get(i);
if (!item.isIncluded(this)) {
continue;
}
// we have to wait and render the active item last
if (item != _activeItem) {
item.render(host, this, gfx, x + item.closedBounds.x, y + item.closedBounds.y);
}
}
if (_activeItem != null) {
_activeItem.render(host, this, gfx, x + _activeItem.closedBounds.x,
y + _activeItem.closedBounds.y);
}
// render our bounds
// gfx.setColor(Color.green);
// gfx.draw(_bounds);
// gfx.setColor(Color.blue);
// gfx.draw(_tbounds);
} | java | public void render (Graphics2D gfx)
{
Component host = _host.getComponent();
int x = _bounds.x, y = _bounds.y;
if (_centerLabel != null) {
// render the centerpiece label
_centerLabel.paint(gfx, x + _centerLabel.closedBounds.x,
y + _centerLabel.closedBounds.y, this);
}
// render each of our items in turn
int icount = _items.size();
for (int i = 0; i < icount; i++) {
RadialMenuItem item = _items.get(i);
if (!item.isIncluded(this)) {
continue;
}
// we have to wait and render the active item last
if (item != _activeItem) {
item.render(host, this, gfx, x + item.closedBounds.x, y + item.closedBounds.y);
}
}
if (_activeItem != null) {
_activeItem.render(host, this, gfx, x + _activeItem.closedBounds.x,
y + _activeItem.closedBounds.y);
}
// render our bounds
// gfx.setColor(Color.green);
// gfx.draw(_bounds);
// gfx.setColor(Color.blue);
// gfx.draw(_tbounds);
} | [
"public",
"void",
"render",
"(",
"Graphics2D",
"gfx",
")",
"{",
"Component",
"host",
"=",
"_host",
".",
"getComponent",
"(",
")",
";",
"int",
"x",
"=",
"_bounds",
".",
"x",
",",
"y",
"=",
"_bounds",
".",
"y",
";",
"if",
"(",
"_centerLabel",
"!=",
"... | Renders the current configuration of this menu. | [
"Renders",
"the",
"current",
"configuration",
"of",
"this",
"menu",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/RadialMenu.java#L306-L341 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/RadialMenu.java | RadialMenu.repaint | protected void repaint ()
{
// only repaint the area that we overlap
_host.repaintRect(_bounds.x, _bounds.y, _bounds.width+1, _bounds.height+1);
} | java | protected void repaint ()
{
// only repaint the area that we overlap
_host.repaintRect(_bounds.x, _bounds.y, _bounds.width+1, _bounds.height+1);
} | [
"protected",
"void",
"repaint",
"(",
")",
"{",
"// only repaint the area that we overlap",
"_host",
".",
"repaintRect",
"(",
"_bounds",
".",
"x",
",",
"_bounds",
".",
"y",
",",
"_bounds",
".",
"width",
"+",
"1",
",",
"_bounds",
".",
"height",
"+",
"1",
")"... | Requests that our host component repaint the part of itself that we occupy. | [
"Requests",
"that",
"our",
"host",
"component",
"repaint",
"the",
"part",
"of",
"itself",
"that",
"we",
"occupy",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/RadialMenu.java#L576-L580 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/CurrencyUtil.java | CurrencyUtil.currency | public static String currency (double value, Locale locale)
{
return currency(value, NumberFormat.getCurrencyInstance(locale));
} | java | public static String currency (double value, Locale locale)
{
return currency(value, NumberFormat.getCurrencyInstance(locale));
} | [
"public",
"static",
"String",
"currency",
"(",
"double",
"value",
",",
"Locale",
"locale",
")",
"{",
"return",
"currency",
"(",
"value",
",",
"NumberFormat",
".",
"getCurrencyInstance",
"(",
"locale",
")",
")",
";",
"}"
] | Converts a number representing currency in the specified locale to a
displayable string. | [
"Converts",
"a",
"number",
"representing",
"currency",
"in",
"the",
"specified",
"locale",
"to",
"a",
"displayable",
"string",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/CurrencyUtil.java#L29-L32 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/JORARepository.java | JORARepository.update | protected <T> int update (final Table<T> table, final T object,
final FieldMask mask)
throws PersistenceException
{
return executeUpdate(new Operation<Integer>() {
public Integer invoke (Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
return table.update(conn, object, mask);
}
});
} | java | protected <T> int update (final Table<T> table, final T object,
final FieldMask mask)
throws PersistenceException
{
return executeUpdate(new Operation<Integer>() {
public Integer invoke (Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
return table.update(conn, object, mask);
}
});
} | [
"protected",
"<",
"T",
">",
"int",
"update",
"(",
"final",
"Table",
"<",
"T",
">",
"table",
",",
"final",
"T",
"object",
",",
"final",
"FieldMask",
"mask",
")",
"throws",
"PersistenceException",
"{",
"return",
"executeUpdate",
"(",
"new",
"Operation",
"<",... | Updates fields specified by the supplied field mask in the supplied
object in the specified table.
@return the number of rows modified by the update. | [
"Updates",
"fields",
"specified",
"by",
"the",
"supplied",
"field",
"mask",
"in",
"the",
"supplied",
"object",
"in",
"the",
"specified",
"table",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/JORARepository.java#L81-L92 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/JORARepository.java | JORARepository.loadAll | protected <T> ArrayList<T> loadAll (final Table<T> table,
final String query)
throws PersistenceException
{
return execute(new Operation<ArrayList<T>>() {
public ArrayList<T> invoke (
Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
return table.select(conn, query).toArrayList();
}
});
} | java | protected <T> ArrayList<T> loadAll (final Table<T> table,
final String query)
throws PersistenceException
{
return execute(new Operation<ArrayList<T>>() {
public ArrayList<T> invoke (
Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
return table.select(conn, query).toArrayList();
}
});
} | [
"protected",
"<",
"T",
">",
"ArrayList",
"<",
"T",
">",
"loadAll",
"(",
"final",
"Table",
"<",
"T",
">",
"table",
",",
"final",
"String",
"query",
")",
"throws",
"PersistenceException",
"{",
"return",
"execute",
"(",
"new",
"Operation",
"<",
"ArrayList",
... | Loads all objects from the specified table that match the supplied
query. | [
"Loads",
"all",
"objects",
"from",
"the",
"specified",
"table",
"that",
"match",
"the",
"supplied",
"query",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/JORARepository.java#L98-L110 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/JORARepository.java | JORARepository.loadAllByExample | protected <T> ArrayList<T> loadAllByExample (
final Table<T> table, final T example)
throws PersistenceException
{
return execute(new Operation<ArrayList<T>>() {
public ArrayList<T> invoke (
Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
return table.queryByExample(conn, example).toArrayList();
}
});
} | java | protected <T> ArrayList<T> loadAllByExample (
final Table<T> table, final T example)
throws PersistenceException
{
return execute(new Operation<ArrayList<T>>() {
public ArrayList<T> invoke (
Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
return table.queryByExample(conn, example).toArrayList();
}
});
} | [
"protected",
"<",
"T",
">",
"ArrayList",
"<",
"T",
">",
"loadAllByExample",
"(",
"final",
"Table",
"<",
"T",
">",
"table",
",",
"final",
"T",
"example",
")",
"throws",
"PersistenceException",
"{",
"return",
"execute",
"(",
"new",
"Operation",
"<",
"ArrayLi... | Loads all objects from the specified table that match the supplied
example. | [
"Loads",
"all",
"objects",
"from",
"the",
"specified",
"table",
"that",
"match",
"the",
"supplied",
"example",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/JORARepository.java#L134-L146 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/JORARepository.java | JORARepository.store | protected <T> int store (final Table<T> table, final T object)
throws PersistenceException
{
return executeUpdate(new Operation<Integer>() {
public Integer invoke (Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
if (table.update(conn, object) == 0) {
table.insert(conn, object);
return liaison.lastInsertedId(conn, null, table.getName(), "TODO");
}
return -1;
}
});
} | java | protected <T> int store (final Table<T> table, final T object)
throws PersistenceException
{
return executeUpdate(new Operation<Integer>() {
public Integer invoke (Connection conn, DatabaseLiaison liaison)
throws SQLException, PersistenceException
{
if (table.update(conn, object) == 0) {
table.insert(conn, object);
return liaison.lastInsertedId(conn, null, table.getName(), "TODO");
}
return -1;
}
});
} | [
"protected",
"<",
"T",
">",
"int",
"store",
"(",
"final",
"Table",
"<",
"T",
">",
"table",
",",
"final",
"T",
"object",
")",
"throws",
"PersistenceException",
"{",
"return",
"executeUpdate",
"(",
"new",
"Operation",
"<",
"Integer",
">",
"(",
")",
"{",
... | First attempts to update the supplied object and if that modifies
zero rows, inserts the object into the specified table. The table
must be configured to store items of the supplied type.
@return -1 if the object was updated, the last inserted id if it was
inserted. | [
"First",
"attempts",
"to",
"update",
"the",
"supplied",
"object",
"and",
"if",
"that",
"modifies",
"zero",
"rows",
"inserts",
"the",
"object",
"into",
"the",
"specified",
"table",
".",
"The",
"table",
"must",
"be",
"configured",
"to",
"store",
"items",
"of",... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/JORARepository.java#L244-L258 | train |
samskivert/samskivert | src/main/java/com/samskivert/velocity/FormTool.java | FormTool.fixedText | public String fixedText (String name, String extra, Object value)
{
return fixedInput("text", name, value, extra);
} | java | public String fixedText (String name, String extra, Object value)
{
return fixedInput("text", name, value, extra);
} | [
"public",
"String",
"fixedText",
"(",
"String",
"name",
",",
"String",
"extra",
",",
"Object",
"value",
")",
"{",
"return",
"fixedInput",
"(",
"\"text\"",
",",
"name",
",",
"value",
",",
"extra",
")",
";",
"}"
] | Creates a text input field with the specified name and the
specified extra arguments and the specified value. | [
"Creates",
"a",
"text",
"input",
"field",
"with",
"the",
"specified",
"name",
"and",
"the",
"specified",
"extra",
"arguments",
"and",
"the",
"specified",
"value",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/FormTool.java#L90-L93 | train |
samskivert/samskivert | src/main/java/com/samskivert/velocity/FormTool.java | FormTool.submitExtra | public String submitExtra (String name, String text, String extra)
{
return fixedInput("submit", name, text, extra);
} | java | public String submitExtra (String name, String text, String extra)
{
return fixedInput("submit", name, text, extra);
} | [
"public",
"String",
"submitExtra",
"(",
"String",
"name",
",",
"String",
"text",
",",
"String",
"extra",
")",
"{",
"return",
"fixedInput",
"(",
"\"submit\"",
",",
"name",
",",
"text",
",",
"extra",
")",
";",
"}"
] | Constructs a submit element with the specified parameter name and
the specified button text with the specified extra text. | [
"Constructs",
"a",
"submit",
"element",
"with",
"the",
"specified",
"parameter",
"name",
"and",
"the",
"specified",
"button",
"text",
"with",
"the",
"specified",
"extra",
"text",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/FormTool.java#L176-L179 | train |
samskivert/samskivert | src/main/java/com/samskivert/velocity/FormTool.java | FormTool.imageSubmit | public String imageSubmit (String name, String value, String imagePath)
{
return fixedInput("image", name, value, "src=\"" + imagePath + "\"");
} | java | public String imageSubmit (String name, String value, String imagePath)
{
return fixedInput("image", name, value, "src=\"" + imagePath + "\"");
} | [
"public",
"String",
"imageSubmit",
"(",
"String",
"name",
",",
"String",
"value",
",",
"String",
"imagePath",
")",
"{",
"return",
"fixedInput",
"(",
"\"image\"",
",",
"name",
",",
"value",
",",
"\"src=\\\"\"",
"+",
"imagePath",
"+",
"\"\\\"\"",
")",
";",
"... | Constructs a image submit element with the specified parameter name
and image path. | [
"Constructs",
"a",
"image",
"submit",
"element",
"with",
"the",
"specified",
"parameter",
"name",
"and",
"image",
"path",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/FormTool.java#L194-L197 | train |
samskivert/samskivert | src/main/java/com/samskivert/velocity/FormTool.java | FormTool.button | public String button (String name, String text, String extra)
{
return fixedInput("button", name, text, extra);
} | java | public String button (String name, String text, String extra)
{
return fixedInput("button", name, text, extra);
} | [
"public",
"String",
"button",
"(",
"String",
"name",
",",
"String",
"text",
",",
"String",
"extra",
")",
"{",
"return",
"fixedInput",
"(",
"\"button\"",
",",
"name",
",",
"text",
",",
"extra",
")",
";",
"}"
] | Constructs a button input element with the specified parameter name,
the specified button text, and the specified extra text. | [
"Constructs",
"a",
"button",
"input",
"element",
"with",
"the",
"specified",
"parameter",
"name",
"the",
"specified",
"button",
"text",
"and",
"the",
"specified",
"extra",
"text",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/FormTool.java#L214-L217 | train |
samskivert/samskivert | src/main/java/com/samskivert/velocity/FormTool.java | FormTool.hidden | public String hidden (String name, Object defaultValue)
{
return fixedHidden(name, getValue(name, defaultValue));
} | java | public String hidden (String name, Object defaultValue)
{
return fixedHidden(name, getValue(name, defaultValue));
} | [
"public",
"String",
"hidden",
"(",
"String",
"name",
",",
"Object",
"defaultValue",
")",
"{",
"return",
"fixedHidden",
"(",
"name",
",",
"getValue",
"(",
"name",
",",
"defaultValue",
")",
")",
";",
"}"
] | Constructs a hidden element with the specified parameter name where
the value is extracted from the appropriate request parameter
unless there is no value in which case the supplied default value
is used. | [
"Constructs",
"a",
"hidden",
"element",
"with",
"the",
"specified",
"parameter",
"name",
"where",
"the",
"value",
"is",
"extracted",
"from",
"the",
"appropriate",
"request",
"parameter",
"unless",
"there",
"is",
"no",
"value",
"in",
"which",
"case",
"the",
"su... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/FormTool.java#L234-L237 | train |
samskivert/samskivert | src/main/java/com/samskivert/velocity/FormTool.java | FormTool.checkbox | public String checkbox (String name, boolean defaultValue)
{
String value = getParameter(name);
return fixedCheckbox(
name, (value == null) ? defaultValue : !value.equals(""));
} | java | public String checkbox (String name, boolean defaultValue)
{
String value = getParameter(name);
return fixedCheckbox(
name, (value == null) ? defaultValue : !value.equals(""));
} | [
"public",
"String",
"checkbox",
"(",
"String",
"name",
",",
"boolean",
"defaultValue",
")",
"{",
"String",
"value",
"=",
"getParameter",
"(",
"name",
")",
";",
"return",
"fixedCheckbox",
"(",
"name",
",",
"(",
"value",
"==",
"null",
")",
"?",
"defaultValue... | Constructs a checkbox input field with the specified name and
default value. | [
"Constructs",
"a",
"checkbox",
"input",
"field",
"with",
"the",
"specified",
"name",
"and",
"default",
"value",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/FormTool.java#L264-L269 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.