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/IntSets.java | IntSets.difference | public static IntSet difference (IntSet set1, IntSet set2)
{
return and(set1, notView(set2));
} | java | public static IntSet difference (IntSet set1, IntSet set2)
{
return and(set1, notView(set2));
} | [
"public",
"static",
"IntSet",
"difference",
"(",
"IntSet",
"set1",
",",
"IntSet",
"set2",
")",
"{",
"return",
"and",
"(",
"set1",
",",
"notView",
"(",
"set2",
")",
")",
";",
"}"
] | Creates a new IntSet, initially populated with ints contained in set1 but not in set2.
Set2 may also contain elements not present in set1, these are ignored. | [
"Creates",
"a",
"new",
"IntSet",
"initially",
"populated",
"with",
"ints",
"contained",
"in",
"set1",
"but",
"not",
"in",
"set2",
".",
"Set2",
"may",
"also",
"contain",
"elements",
"not",
"present",
"in",
"set1",
"these",
"are",
"ignored",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/IntSets.java#L131-L134 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/IntSets.java | IntSets.checkNotNull | protected static void checkNotNull (Object[] array)
{
checkNotNull((Object)array);
for (Object o : array) {
checkNotNull(o);
}
} | java | protected static void checkNotNull (Object[] array)
{
checkNotNull((Object)array);
for (Object o : array) {
checkNotNull(o);
}
} | [
"protected",
"static",
"void",
"checkNotNull",
"(",
"Object",
"[",
"]",
"array",
")",
"{",
"checkNotNull",
"(",
"(",
"Object",
")",
"array",
")",
";",
"for",
"(",
"Object",
"o",
":",
"array",
")",
"{",
"checkNotNull",
"(",
"o",
")",
";",
"}",
"}"
] | Validate the specified arguments. | [
"Validate",
"the",
"specified",
"arguments",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/IntSets.java#L170-L176 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/HashIntSet.java | HashIntSet.setSentinel | public void setSentinel (int sentinel)
{
if (_sentinel == sentinel) {
return;
}
if (contains(sentinel)) {
throw new IllegalArgumentException("Set contains sentinel value " + sentinel);
}
// replace every instance of the old sentinel with the new
for (int ii = 0; ii < _buckets.length; ii++) {
if (_buckets[ii] == _sentinel) {
_buckets[ii] = sentinel;
}
}
_sentinel = sentinel;
} | java | public void setSentinel (int sentinel)
{
if (_sentinel == sentinel) {
return;
}
if (contains(sentinel)) {
throw new IllegalArgumentException("Set contains sentinel value " + sentinel);
}
// replace every instance of the old sentinel with the new
for (int ii = 0; ii < _buckets.length; ii++) {
if (_buckets[ii] == _sentinel) {
_buckets[ii] = sentinel;
}
}
_sentinel = sentinel;
} | [
"public",
"void",
"setSentinel",
"(",
"int",
"sentinel",
")",
"{",
"if",
"(",
"_sentinel",
"==",
"sentinel",
")",
"{",
"return",
";",
"}",
"if",
"(",
"contains",
"(",
"sentinel",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Set contai... | Sets the sentinel value, which cannot itself be stored in the set because it is used
internally to represent an unused location.
@exception IllegalArgumentException if the set currently contains the requested sentinel. | [
"Sets",
"the",
"sentinel",
"value",
"which",
"cannot",
"itself",
"be",
"stored",
"in",
"the",
"set",
"because",
"it",
"is",
"used",
"internally",
"to",
"represent",
"an",
"unused",
"location",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/HashIntSet.java#L80-L95 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/HashIntSet.java | HashIntSet.interator | public Interator interator ()
{
return new AbstractInterator() {
public boolean hasNext () {
checkConcurrentModification();
return _pos < _size;
}
public int nextInt () {
checkConcurrentModification();
if (_pos >= _size) {
throw new NoSuchElementException();
}
if (_idx == 0) {
// start after a sentinel. if we don't and instead start in the middle of a
// run of filled buckets, we risk returning values that will reappear at the
// end of the list after being shifted over to due to a removal
while (_buckets[_idx++] != _sentinel);
}
int mask = _buckets.length - 1;
for (; _pos < _size; _idx++) {
int value = _buckets[_idx & mask];
if (value != _sentinel) {
_pos++;
_idx++;
return value;
}
}
// we shouldn't get here
throw new RuntimeException("Ran out of elements getting next");
}
@Override public void remove () {
checkConcurrentModification();
if (_idx == 0) {
throw new IllegalStateException("Next method not yet called");
}
int pidx = (--_idx) & (_buckets.length - 1);
if (_buckets[pidx] == _sentinel) {
throw new IllegalStateException("No element to remove");
}
_buckets[pidx] = _sentinel;
_pos--;
_size--;
_omodcount = ++_modcount;
shift(pidx);
}
protected void checkConcurrentModification () {
if (_modcount != _omodcount) {
throw new ConcurrentModificationException();
}
}
protected int _pos, _idx;
protected int _omodcount = _modcount;
};
} | java | public Interator interator ()
{
return new AbstractInterator() {
public boolean hasNext () {
checkConcurrentModification();
return _pos < _size;
}
public int nextInt () {
checkConcurrentModification();
if (_pos >= _size) {
throw new NoSuchElementException();
}
if (_idx == 0) {
// start after a sentinel. if we don't and instead start in the middle of a
// run of filled buckets, we risk returning values that will reappear at the
// end of the list after being shifted over to due to a removal
while (_buckets[_idx++] != _sentinel);
}
int mask = _buckets.length - 1;
for (; _pos < _size; _idx++) {
int value = _buckets[_idx & mask];
if (value != _sentinel) {
_pos++;
_idx++;
return value;
}
}
// we shouldn't get here
throw new RuntimeException("Ran out of elements getting next");
}
@Override public void remove () {
checkConcurrentModification();
if (_idx == 0) {
throw new IllegalStateException("Next method not yet called");
}
int pidx = (--_idx) & (_buckets.length - 1);
if (_buckets[pidx] == _sentinel) {
throw new IllegalStateException("No element to remove");
}
_buckets[pidx] = _sentinel;
_pos--;
_size--;
_omodcount = ++_modcount;
shift(pidx);
}
protected void checkConcurrentModification () {
if (_modcount != _omodcount) {
throw new ConcurrentModificationException();
}
}
protected int _pos, _idx;
protected int _omodcount = _modcount;
};
} | [
"public",
"Interator",
"interator",
"(",
")",
"{",
"return",
"new",
"AbstractInterator",
"(",
")",
"{",
"public",
"boolean",
"hasNext",
"(",
")",
"{",
"checkConcurrentModification",
"(",
")",
";",
"return",
"_pos",
"<",
"_size",
";",
"}",
"public",
"int",
... | documentation inherited from interface IntSet | [
"documentation",
"inherited",
"from",
"interface",
"IntSet"
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/HashIntSet.java#L106-L159 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/HashIntSet.java | HashIntSet.rehash | protected void rehash (int ncount)
{
int[] obuckets = _buckets;
createBuckets(ncount);
for (int idx = 0, pos = 0; pos < _size; idx++) {
int value = obuckets[idx];
if (value != _sentinel) {
readd(value);
pos++;
}
}
} | java | protected void rehash (int ncount)
{
int[] obuckets = _buckets;
createBuckets(ncount);
for (int idx = 0, pos = 0; pos < _size; idx++) {
int value = obuckets[idx];
if (value != _sentinel) {
readd(value);
pos++;
}
}
} | [
"protected",
"void",
"rehash",
"(",
"int",
"ncount",
")",
"{",
"int",
"[",
"]",
"obuckets",
"=",
"_buckets",
";",
"createBuckets",
"(",
"ncount",
")",
";",
"for",
"(",
"int",
"idx",
"=",
"0",
",",
"pos",
"=",
"0",
";",
"pos",
"<",
"_size",
";",
"... | Recreates the bucket array with the specified new count. | [
"Recreates",
"the",
"bucket",
"array",
"with",
"the",
"specified",
"new",
"count",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/HashIntSet.java#L285-L297 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/HashIntSet.java | HashIntSet.readd | protected void readd (int value)
{
int mask = _buckets.length - 1;
int start = hash(value) & mask, idx = start;
do {
if (_buckets[idx] == _sentinel) {
_buckets[idx] = value;
return;
}
} while ((idx = idx + 1 & mask) != start);
// we shouldn't get here
throw new RuntimeException("Ran out of buckets readding value " + value);
} | java | protected void readd (int value)
{
int mask = _buckets.length - 1;
int start = hash(value) & mask, idx = start;
do {
if (_buckets[idx] == _sentinel) {
_buckets[idx] = value;
return;
}
} while ((idx = idx + 1 & mask) != start);
// we shouldn't get here
throw new RuntimeException("Ran out of buckets readding value " + value);
} | [
"protected",
"void",
"readd",
"(",
"int",
"value",
")",
"{",
"int",
"mask",
"=",
"_buckets",
".",
"length",
"-",
"1",
";",
"int",
"start",
"=",
"hash",
"(",
"value",
")",
"&",
"mask",
",",
"idx",
"=",
"start",
";",
"do",
"{",
"if",
"(",
"_buckets... | Adds a value that we know is neither equal to the sentinel nor already in the set. | [
"Adds",
"a",
"value",
"that",
"we",
"know",
"is",
"neither",
"equal",
"to",
"the",
"sentinel",
"nor",
"already",
"in",
"the",
"set",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/HashIntSet.java#L310-L323 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/HashIntSet.java | HashIntSet.writeObject | private void writeObject (ObjectOutputStream out)
throws IOException
{
out.defaultWriteObject();
for (int idx = 0, pos = 0; pos < _size; idx++) {
int value = _buckets[idx];
if (value != _sentinel) {
out.writeInt(value);
pos++;
}
}
} | java | private void writeObject (ObjectOutputStream out)
throws IOException
{
out.defaultWriteObject();
for (int idx = 0, pos = 0; pos < _size; idx++) {
int value = _buckets[idx];
if (value != _sentinel) {
out.writeInt(value);
pos++;
}
}
} | [
"private",
"void",
"writeObject",
"(",
"ObjectOutputStream",
"out",
")",
"throws",
"IOException",
"{",
"out",
".",
"defaultWriteObject",
"(",
")",
";",
"for",
"(",
"int",
"idx",
"=",
"0",
",",
"pos",
"=",
"0",
";",
"pos",
"<",
"_size",
";",
"idx",
"++"... | Custom serializer. | [
"Custom",
"serializer",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/HashIntSet.java#L364-L375 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/HashIntSet.java | HashIntSet.readObject | private void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
in.defaultReadObject();
createBuckets(getBucketCount(_size));
for (int ii = 0; ii < _size; ii++) {
readd(in.readInt());
}
} | java | private void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
in.defaultReadObject();
createBuckets(getBucketCount(_size));
for (int ii = 0; ii < _size; ii++) {
readd(in.readInt());
}
} | [
"private",
"void",
"readObject",
"(",
"ObjectInputStream",
"in",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"in",
".",
"defaultReadObject",
"(",
")",
";",
"createBuckets",
"(",
"getBucketCount",
"(",
"_size",
")",
")",
";",
"for",
"(",
"... | Custom deserializer. | [
"Custom",
"deserializer",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/HashIntSet.java#L380-L388 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/HashIntSet.java | HashIntSet.getBucketCount | protected static int getBucketCount (int capacity, float loadFactor)
{
int size = (int)(capacity / loadFactor);
int highest = Integer.highestOneBit(size);
return Math.max((size == highest) ? highest : (highest << 1), MIN_BUCKET_COUNT);
} | java | protected static int getBucketCount (int capacity, float loadFactor)
{
int size = (int)(capacity / loadFactor);
int highest = Integer.highestOneBit(size);
return Math.max((size == highest) ? highest : (highest << 1), MIN_BUCKET_COUNT);
} | [
"protected",
"static",
"int",
"getBucketCount",
"(",
"int",
"capacity",
",",
"float",
"loadFactor",
")",
"{",
"int",
"size",
"=",
"(",
"int",
")",
"(",
"capacity",
"/",
"loadFactor",
")",
";",
"int",
"highest",
"=",
"Integer",
".",
"highestOneBit",
"(",
... | Computes the number of buckets needed to provide the given capacity with the specified load
factor. | [
"Computes",
"the",
"number",
"of",
"buckets",
"needed",
"to",
"provide",
"the",
"given",
"capacity",
"with",
"the",
"specified",
"load",
"factor",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/HashIntSet.java#L414-L419 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/chart/JsonExporter.java | JsonExporter.setGridAxisColors | private void setGridAxisColors(ro.nextreports.jofc2.model.Chart flashChart, XAxis xAxis, YAxis yAxis) {
boolean isHorizontal = chart.getType().isHorizontal();
Color xGridColor = chart.getXGridColor();
Color yGridColor = chart.getYGridColor();
if (xGridColor != null) {
getXAxis(xAxis, yAxis, isHorizontal).setGridColour(getHexColor(xGridColor));
}
if ((chart.getXShowGrid() != null) && !chart.getXShowGrid()) {
if (flashChart.getBackgroundColour() == null) {
getXAxis(xAxis, yAxis, isHorizontal).setGridColour(getHexColor(DEFAULT_BACKGROUND));
} else {
getXAxis(xAxis, yAxis, isHorizontal).setGridColour(flashChart.getBackgroundColour());
}
}
if (yGridColor != null) {
getYAxis(xAxis, yAxis, isHorizontal).setGridColour(getHexColor(yGridColor));
}
if ((chart.getYShowGrid() != null) && !chart.getYShowGrid()) {
if (flashChart.getBackgroundColour() == null) {
getYAxis(xAxis, yAxis, isHorizontal).setGridColour(getHexColor(DEFAULT_BACKGROUND));
} else {
getYAxis(xAxis, yAxis, isHorizontal).setGridColour(flashChart.getBackgroundColour());
}
}
} | java | private void setGridAxisColors(ro.nextreports.jofc2.model.Chart flashChart, XAxis xAxis, YAxis yAxis) {
boolean isHorizontal = chart.getType().isHorizontal();
Color xGridColor = chart.getXGridColor();
Color yGridColor = chart.getYGridColor();
if (xGridColor != null) {
getXAxis(xAxis, yAxis, isHorizontal).setGridColour(getHexColor(xGridColor));
}
if ((chart.getXShowGrid() != null) && !chart.getXShowGrid()) {
if (flashChart.getBackgroundColour() == null) {
getXAxis(xAxis, yAxis, isHorizontal).setGridColour(getHexColor(DEFAULT_BACKGROUND));
} else {
getXAxis(xAxis, yAxis, isHorizontal).setGridColour(flashChart.getBackgroundColour());
}
}
if (yGridColor != null) {
getYAxis(xAxis, yAxis, isHorizontal).setGridColour(getHexColor(yGridColor));
}
if ((chart.getYShowGrid() != null) && !chart.getYShowGrid()) {
if (flashChart.getBackgroundColour() == null) {
getYAxis(xAxis, yAxis, isHorizontal).setGridColour(getHexColor(DEFAULT_BACKGROUND));
} else {
getYAxis(xAxis, yAxis, isHorizontal).setGridColour(flashChart.getBackgroundColour());
}
}
} | [
"private",
"void",
"setGridAxisColors",
"(",
"ro",
".",
"nextreports",
".",
"jofc2",
".",
"model",
".",
"Chart",
"flashChart",
",",
"XAxis",
"xAxis",
",",
"YAxis",
"yAxis",
")",
"{",
"boolean",
"isHorizontal",
"=",
"chart",
".",
"getType",
"(",
")",
".",
... | to hide a grid we set its color to chart background color | [
"to",
"hide",
"a",
"grid",
"we",
"set",
"its",
"color",
"to",
"chart",
"background",
"color"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/chart/JsonExporter.java#L653-L677 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/chart/JsonExporter.java | JsonExporter.setTicks | private void setTicks(XAxis xAxis, YAxis yAxis, boolean showXLabel, boolean showYLabel) {
boolean isHorizontal = chart.getType().isHorizontal();
if ((!showXLabel && !isHorizontal) || (!showYLabel && isHorizontal)) {
xAxis.setTickHeight(0);
}
if ((!showYLabel && !isHorizontal) || (!showXLabel && isHorizontal)) {
yAxis.setTickLength(0);
}
} | java | private void setTicks(XAxis xAxis, YAxis yAxis, boolean showXLabel, boolean showYLabel) {
boolean isHorizontal = chart.getType().isHorizontal();
if ((!showXLabel && !isHorizontal) || (!showYLabel && isHorizontal)) {
xAxis.setTickHeight(0);
}
if ((!showYLabel && !isHorizontal) || (!showXLabel && isHorizontal)) {
yAxis.setTickLength(0);
}
} | [
"private",
"void",
"setTicks",
"(",
"XAxis",
"xAxis",
",",
"YAxis",
"yAxis",
",",
"boolean",
"showXLabel",
",",
"boolean",
"showYLabel",
")",
"{",
"boolean",
"isHorizontal",
"=",
"chart",
".",
"getType",
"(",
")",
".",
"isHorizontal",
"(",
")",
";",
"if",
... | hide ticks if we do not show labels | [
"hide",
"ticks",
"if",
"we",
"do",
"not",
"show",
"labels"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/chart/JsonExporter.java#L696-L705 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/util/MouseHijacker.java | MouseHijacker.hijack | public void hijack ()
{
_mls = _comp.getMouseListeners();
for (int ii=0; ii < _mls.length; ii++) {
_comp.removeMouseListener(_mls[ii]);
}
_mmls = _comp.getMouseMotionListeners();
for (int ii=0; ii < _mmls.length; ii++) {
_comp.removeMouseMotionListener(_mmls[ii]);
}
_comp.addMouseMotionListener(_motionCatcher);
} | java | public void hijack ()
{
_mls = _comp.getMouseListeners();
for (int ii=0; ii < _mls.length; ii++) {
_comp.removeMouseListener(_mls[ii]);
}
_mmls = _comp.getMouseMotionListeners();
for (int ii=0; ii < _mmls.length; ii++) {
_comp.removeMouseMotionListener(_mmls[ii]);
}
_comp.addMouseMotionListener(_motionCatcher);
} | [
"public",
"void",
"hijack",
"(",
")",
"{",
"_mls",
"=",
"_comp",
".",
"getMouseListeners",
"(",
")",
";",
"for",
"(",
"int",
"ii",
"=",
"0",
";",
"ii",
"<",
"_mls",
".",
"length",
";",
"ii",
"++",
")",
"{",
"_comp",
".",
"removeMouseListener",
"(",... | Hijack the component's mouse listeners. | [
"Hijack",
"the",
"component",
"s",
"mouse",
"listeners",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/MouseHijacker.java#L60-L73 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/util/CookieUtil.java | CookieUtil.getCookie | public static Cookie getCookie (HttpServletRequest req, String name)
{
Cookie[] cookies = req.getCookies();
if (cookies != null) {
for (int ii=0, nn=cookies.length; ii < nn; ii++) {
if (cookies[ii].getName().equals(name)) {
return cookies[ii];
}
}
}
return null; // not found
} | java | public static Cookie getCookie (HttpServletRequest req, String name)
{
Cookie[] cookies = req.getCookies();
if (cookies != null) {
for (int ii=0, nn=cookies.length; ii < nn; ii++) {
if (cookies[ii].getName().equals(name)) {
return cookies[ii];
}
}
}
return null; // not found
} | [
"public",
"static",
"Cookie",
"getCookie",
"(",
"HttpServletRequest",
"req",
",",
"String",
"name",
")",
"{",
"Cookie",
"[",
"]",
"cookies",
"=",
"req",
".",
"getCookies",
"(",
")",
";",
"if",
"(",
"cookies",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
... | Get the cookie of the specified name, or null if not found. | [
"Get",
"the",
"cookie",
"of",
"the",
"specified",
"name",
"or",
"null",
"if",
"not",
"found",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/util/CookieUtil.java#L20-L32 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/util/CookieUtil.java | CookieUtil.getCookieValue | public static String getCookieValue (HttpServletRequest req, String name)
{
Cookie c = getCookie(req, name);
return (c == null) ? null : c.getValue();
} | java | public static String getCookieValue (HttpServletRequest req, String name)
{
Cookie c = getCookie(req, name);
return (c == null) ? null : c.getValue();
} | [
"public",
"static",
"String",
"getCookieValue",
"(",
"HttpServletRequest",
"req",
",",
"String",
"name",
")",
"{",
"Cookie",
"c",
"=",
"getCookie",
"(",
"req",
",",
"name",
")",
";",
"return",
"(",
"c",
"==",
"null",
")",
"?",
"null",
":",
"c",
".",
... | Get the value of the cookie for the cookie of the specified name, or null if not found. | [
"Get",
"the",
"value",
"of",
"the",
"cookie",
"for",
"the",
"cookie",
"of",
"the",
"specified",
"name",
"or",
"null",
"if",
"not",
"found",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/util/CookieUtil.java#L37-L41 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/util/CookieUtil.java | CookieUtil.clearCookie | public static void clearCookie (HttpServletResponse rsp, String name)
{
Cookie c = new Cookie(name, "x");
c.setPath("/");
c.setMaxAge(0);
rsp.addCookie(c);
} | java | public static void clearCookie (HttpServletResponse rsp, String name)
{
Cookie c = new Cookie(name, "x");
c.setPath("/");
c.setMaxAge(0);
rsp.addCookie(c);
} | [
"public",
"static",
"void",
"clearCookie",
"(",
"HttpServletResponse",
"rsp",
",",
"String",
"name",
")",
"{",
"Cookie",
"c",
"=",
"new",
"Cookie",
"(",
"name",
",",
"\"x\"",
")",
";",
"c",
".",
"setPath",
"(",
"\"/\"",
")",
";",
"c",
".",
"setMaxAge",... | Clear the cookie with the specified name. | [
"Clear",
"the",
"cookie",
"with",
"the",
"specified",
"name",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/util/CookieUtil.java#L46-L52 | train |
samskivert/samskivert | src/main/java/com/samskivert/velocity/Application.java | Application.translate | public final String translate (InvocationContext ctx, String msg)
{
return _msgmgr.getMessage(ctx.getRequest(), msg);
} | java | public final String translate (InvocationContext ctx, String msg)
{
return _msgmgr.getMessage(ctx.getRequest(), msg);
} | [
"public",
"final",
"String",
"translate",
"(",
"InvocationContext",
"ctx",
",",
"String",
"msg",
")",
"{",
"return",
"_msgmgr",
".",
"getMessage",
"(",
"ctx",
".",
"getRequest",
"(",
")",
",",
"msg",
")",
";",
"}"
] | A convenience function for translating messages. | [
"A",
"convenience",
"function",
"for",
"translating",
"messages",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/velocity/Application.java#L264-L267 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/exporter/RtfExporter.java | RtfExporter.addMetaData | private void addMetaData() {
document.addTitle(getDocumentTitle());
document.addAuthor(ReleaseInfoAdapter.getCompany());
document.addCreator("NextReports " + ReleaseInfoAdapter.getVersionNumber());
document.addSubject("Created by NextReports Designer" + ReleaseInfoAdapter.getVersionNumber());
document.addCreationDate();
document.addKeywords(ReleaseInfoAdapter.getHome());
} | java | private void addMetaData() {
document.addTitle(getDocumentTitle());
document.addAuthor(ReleaseInfoAdapter.getCompany());
document.addCreator("NextReports " + ReleaseInfoAdapter.getVersionNumber());
document.addSubject("Created by NextReports Designer" + ReleaseInfoAdapter.getVersionNumber());
document.addCreationDate();
document.addKeywords(ReleaseInfoAdapter.getHome());
} | [
"private",
"void",
"addMetaData",
"(",
")",
"{",
"document",
".",
"addTitle",
"(",
"getDocumentTitle",
"(",
")",
")",
";",
"document",
".",
"addAuthor",
"(",
"ReleaseInfoAdapter",
".",
"getCompany",
"(",
")",
")",
";",
"document",
".",
"addCreator",
"(",
"... | to opening the document | [
"to",
"opening",
"the",
"document"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/exporter/RtfExporter.java#L119-L126 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Throttle.java | Throttle.reinit | public void reinit (int operations, long period)
{
_period = period;
if (operations != _ops.length) {
long[] ops = new long[operations];
if (operations > _ops.length) {
// copy to a larger buffer, leaving zeroes at the beginning
int lastOp = _lastOp + operations - _ops.length;
System.arraycopy(_ops, 0, ops, 0, _lastOp);
System.arraycopy(_ops, _lastOp, ops, lastOp, _ops.length - _lastOp);
} else {
// if we're truncating, copy the first (oldest) stamps into ops[0..]
int endCount = Math.min(operations, _ops.length - _lastOp);
System.arraycopy(_ops, _lastOp, ops, 0, endCount);
System.arraycopy(_ops, 0, ops, endCount, operations - endCount);
_lastOp = 0;
}
_ops = ops;
}
} | java | public void reinit (int operations, long period)
{
_period = period;
if (operations != _ops.length) {
long[] ops = new long[operations];
if (operations > _ops.length) {
// copy to a larger buffer, leaving zeroes at the beginning
int lastOp = _lastOp + operations - _ops.length;
System.arraycopy(_ops, 0, ops, 0, _lastOp);
System.arraycopy(_ops, _lastOp, ops, lastOp, _ops.length - _lastOp);
} else {
// if we're truncating, copy the first (oldest) stamps into ops[0..]
int endCount = Math.min(operations, _ops.length - _lastOp);
System.arraycopy(_ops, _lastOp, ops, 0, endCount);
System.arraycopy(_ops, 0, ops, endCount, operations - endCount);
_lastOp = 0;
}
_ops = ops;
}
} | [
"public",
"void",
"reinit",
"(",
"int",
"operations",
",",
"long",
"period",
")",
"{",
"_period",
"=",
"period",
";",
"if",
"(",
"operations",
"!=",
"_ops",
".",
"length",
")",
"{",
"long",
"[",
"]",
"ops",
"=",
"new",
"long",
"[",
"operations",
"]",... | Updates the number of operations for this throttle to a new maximum, retaining the current
history of operations if the limit is being increased and truncating the oldest operations
if the limit is decreased.
@param operations the new maximum number of operations.
@param period the new period. | [
"Updates",
"the",
"number",
"of",
"operations",
"for",
"this",
"throttle",
"to",
"a",
"new",
"maximum",
"retaining",
"the",
"current",
"history",
"of",
"operations",
"if",
"the",
"limit",
"is",
"being",
"increased",
"and",
"truncating",
"the",
"oldest",
"opera... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Throttle.java#L59-L80 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/queryexec/util/StringUtil.java | StringUtil.stripBlankLines | public static String stripBlankLines(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
BufferedReader in = new BufferedReader(new StringReader(text));
boolean doneOneLine = false;
while (true) {
String line = in.readLine();
if (line == null) {
break;
}
if (line.trim().length() > 0) {
output.append(line);
output.append('\n');
doneOneLine = true;
}
}
if (!doneOneLine) {
output.append('\n');
}
return output.toString();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
} | java | public static String stripBlankLines(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
BufferedReader in = new BufferedReader(new StringReader(text));
boolean doneOneLine = false;
while (true) {
String line = in.readLine();
if (line == null) {
break;
}
if (line.trim().length() > 0) {
output.append(line);
output.append('\n');
doneOneLine = true;
}
}
if (!doneOneLine) {
output.append('\n');
}
return output.toString();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
} | [
"public",
"static",
"String",
"stripBlankLines",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"StringBuffer",
"output",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"BufferedReader",
"i... | Remove all blank lines from a string. A blank line is defined to be a
line where the only characters are whitespace. We always ensure that the
line contains a newline at the end.
@param text
The string to strip blank lines from
@return The blank line stripped reply | [
"Remove",
"all",
"blank",
"lines",
"from",
"a",
"string",
".",
"A",
"blank",
"line",
"is",
"defined",
"to",
"be",
"a",
"line",
"where",
"the",
"only",
"characters",
"are",
"whitespace",
".",
"We",
"always",
"ensure",
"that",
"the",
"line",
"contains",
"a... | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/queryexec/util/StringUtil.java#L42-L72 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/queryexec/util/StringUtil.java | StringUtil.stripMultiLineComments | public static String stripMultiLineComments(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
// Comment rules:
/*/ This is still a comment
/* /* */ // Comments do not nest
// /* */ This is in a comment
/* // */ // The second // is needed to make this a comment.
// First we strip multi line comments. I think this is important:
boolean inMultiLine = false;
BufferedReader in = new BufferedReader(new StringReader(text));
while (true) {
String line = in.readLine();
if (line == null) {
break;
}
if (!inMultiLine) {
// We are not in a multi-line comment, check for a start
int cstart = line.indexOf(COMMENT_MULTILINE_START);
if (cstart >= 0) {
// This could be a MLC on one line ...
int cend = line.indexOf(COMMENT_MULTILINE_END, cstart + COMMENT_MULTILINE_START.length());
if (cend >= 0) {
// A comment that starts and ends on one line
// BUG: you can have more than 1 multi-line comment on a line
line = line.substring(0, cstart) + SPACE + line.substring(cend + COMMENT_MULTILINE_END.length());
} else {
// A real multi-line comment
inMultiLine = true;
line = line.substring(0, cstart) + SPACE;
}
} else {
// We are not in a multi line comment and we havn't
// started one so we are going to ignore closing
// comments even if they exist.
}
} else {
// We are in a multi-line comment, check for the end
int cend = line.indexOf(COMMENT_MULTILINE_END);
if (cend >= 0) {
// End of comment
line = line.substring(cend + COMMENT_MULTILINE_END.length());
inMultiLine = false;
} else {
// The comment continues
line = SPACE;
}
}
output.append(line);
output.append('\n');
}
return output.toString();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
} | java | public static String stripMultiLineComments(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
// Comment rules:
/*/ This is still a comment
/* /* */ // Comments do not nest
// /* */ This is in a comment
/* // */ // The second // is needed to make this a comment.
// First we strip multi line comments. I think this is important:
boolean inMultiLine = false;
BufferedReader in = new BufferedReader(new StringReader(text));
while (true) {
String line = in.readLine();
if (line == null) {
break;
}
if (!inMultiLine) {
// We are not in a multi-line comment, check for a start
int cstart = line.indexOf(COMMENT_MULTILINE_START);
if (cstart >= 0) {
// This could be a MLC on one line ...
int cend = line.indexOf(COMMENT_MULTILINE_END, cstart + COMMENT_MULTILINE_START.length());
if (cend >= 0) {
// A comment that starts and ends on one line
// BUG: you can have more than 1 multi-line comment on a line
line = line.substring(0, cstart) + SPACE + line.substring(cend + COMMENT_MULTILINE_END.length());
} else {
// A real multi-line comment
inMultiLine = true;
line = line.substring(0, cstart) + SPACE;
}
} else {
// We are not in a multi line comment and we havn't
// started one so we are going to ignore closing
// comments even if they exist.
}
} else {
// We are in a multi-line comment, check for the end
int cend = line.indexOf(COMMENT_MULTILINE_END);
if (cend >= 0) {
// End of comment
line = line.substring(cend + COMMENT_MULTILINE_END.length());
inMultiLine = false;
} else {
// The comment continues
line = SPACE;
}
}
output.append(line);
output.append('\n');
}
return output.toString();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
} | [
"public",
"static",
"String",
"stripMultiLineComments",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"StringBuffer",
"output",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"// Comment rul... | Remove all the multi-line comments from a block of text
@param text The text to remove multi-line comments from
@return The multi-line comment free text | [
"Remove",
"all",
"the",
"multi",
"-",
"line",
"comments",
"from",
"a",
"block",
"of",
"text"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/queryexec/util/StringUtil.java#L112-L176 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/queryexec/util/StringUtil.java | StringUtil.stripSingleLineComments | public static String stripSingleLineComments(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
// First we strip multi line comments. I think this is important:
BufferedReader in = new BufferedReader(new StringReader(text));
while (true) {
String line = in.readLine();
if (line == null) {
break;
}
int cstart = line.indexOf(COMMENT_SINGLELINE_START);
if (cstart >= 0) {
line = line.substring(0, cstart);
}
output.append(line);
output.append('\n');
}
return output.toString();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
} | java | public static String stripSingleLineComments(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
// First we strip multi line comments. I think this is important:
BufferedReader in = new BufferedReader(new StringReader(text));
while (true) {
String line = in.readLine();
if (line == null) {
break;
}
int cstart = line.indexOf(COMMENT_SINGLELINE_START);
if (cstart >= 0) {
line = line.substring(0, cstart);
}
output.append(line);
output.append('\n');
}
return output.toString();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
} | [
"public",
"static",
"String",
"stripSingleLineComments",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"StringBuffer",
"output",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"// First we s... | Remove all the single-line comments from a block of text
@param text The text to remove single-line comments from
@return The single-line comment free text | [
"Remove",
"all",
"the",
"single",
"-",
"line",
"comments",
"from",
"a",
"block",
"of",
"text"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/queryexec/util/StringUtil.java#L183-L212 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/queryexec/util/StringUtil.java | StringUtil.trimLines | public static String trimLines(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
// First we strip multi line comments. I think this is important:
BufferedReader in = new BufferedReader(new StringReader(text));
while (true) {
String line = in.readLine();
if (line == null) {
break;
}
output.append(line.trim());
output.append('\n');
}
return output.toString();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
} | java | public static String trimLines(String text) {
if (text == null) {
return null;
}
try {
StringBuffer output = new StringBuffer();
// First we strip multi line comments. I think this is important:
BufferedReader in = new BufferedReader(new StringReader(text));
while (true) {
String line = in.readLine();
if (line == null) {
break;
}
output.append(line.trim());
output.append('\n');
}
return output.toString();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
} | [
"public",
"static",
"String",
"trimLines",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"text",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"StringBuffer",
"output",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"// First we strip multi lin... | Remove any leading or trailing spaces from a line of code.
This function could be improved by making it strip unnecessary double
spaces, but since we would need to leave double spaces inside strings
this is not simple and since the benefit is small, we'll leave it for now
@param text The javascript program to strip spaces from.
@return The stripped program | [
"Remove",
"any",
"leading",
"or",
"trailing",
"spaces",
"from",
"a",
"line",
"of",
"code",
".",
"This",
"function",
"could",
"be",
"improved",
"by",
"making",
"it",
"strip",
"unnecessary",
"double",
"spaces",
"but",
"since",
"we",
"would",
"need",
"to",
"l... | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/queryexec/util/StringUtil.java#L222-L246 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/queryexec/util/StringUtil.java | StringUtil.deleteExcededSpaces | public static String deleteExcededSpaces(String text) {
int size = text.length();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < size; i++) {
char ch = text.charAt(i);
if (ch == ' ') {
if (i > 0) {
char ch2 = text.charAt(i-1);
if ((ch2 != ' ') && (i < size-1) && (!text.substring(i+1).trim().equals(""))) {
sb.append(ch);
}
}
} else {
sb.append(ch);
}
}
return sb.toString();
} | java | public static String deleteExcededSpaces(String text) {
int size = text.length();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < size; i++) {
char ch = text.charAt(i);
if (ch == ' ') {
if (i > 0) {
char ch2 = text.charAt(i-1);
if ((ch2 != ' ') && (i < size-1) && (!text.substring(i+1).trim().equals(""))) {
sb.append(ch);
}
}
} else {
sb.append(ch);
}
}
return sb.toString();
} | [
"public",
"static",
"String",
"deleteExcededSpaces",
"(",
"String",
"text",
")",
"{",
"int",
"size",
"=",
"text",
".",
"length",
"(",
")",
";",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i... | Only one space between words. | [
"Only",
"one",
"space",
"between",
"words",
"."
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/queryexec/util/StringUtil.java#L269-L287 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserManager.java | UserManager.loadUser | public User loadUser (HttpServletRequest req)
throws PersistenceException
{
String authcook = CookieUtil.getCookieValue(req, _userAuthCookie);
if (USERMGR_DEBUG) {
log.info("Loading user by cookie", _userAuthCookie, authcook);
}
return loadUser(authcook);
} | java | public User loadUser (HttpServletRequest req)
throws PersistenceException
{
String authcook = CookieUtil.getCookieValue(req, _userAuthCookie);
if (USERMGR_DEBUG) {
log.info("Loading user by cookie", _userAuthCookie, authcook);
}
return loadUser(authcook);
} | [
"public",
"User",
"loadUser",
"(",
"HttpServletRequest",
"req",
")",
"throws",
"PersistenceException",
"{",
"String",
"authcook",
"=",
"CookieUtil",
".",
"getCookieValue",
"(",
"req",
",",
"_userAuthCookie",
")",
";",
"if",
"(",
"USERMGR_DEBUG",
")",
"{",
"log",... | Fetches the necessary authentication information from the http request and loads the user
identified by that information.
@return the user associated with the request or null if no user was associated with the
request or if the authentication information is bogus. | [
"Fetches",
"the",
"necessary",
"authentication",
"information",
"from",
"the",
"http",
"request",
"and",
"loads",
"the",
"user",
"identified",
"by",
"that",
"information",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserManager.java#L164-L172 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserManager.java | UserManager.loadUser | public User loadUser (String authcode)
throws PersistenceException
{
User user = (authcode == null) ? null : _repository.loadUserBySession(authcode);
if (USERMGR_DEBUG) {
log.info("Loaded user by authcode", "code", authcode, "user", user);
}
return user;
} | java | public User loadUser (String authcode)
throws PersistenceException
{
User user = (authcode == null) ? null : _repository.loadUserBySession(authcode);
if (USERMGR_DEBUG) {
log.info("Loaded user by authcode", "code", authcode, "user", user);
}
return user;
} | [
"public",
"User",
"loadUser",
"(",
"String",
"authcode",
")",
"throws",
"PersistenceException",
"{",
"User",
"user",
"=",
"(",
"authcode",
"==",
"null",
")",
"?",
"null",
":",
"_repository",
".",
"loadUserBySession",
"(",
"authcode",
")",
";",
"if",
"(",
"... | Loads up a user based on the supplied session authentication token. | [
"Loads",
"up",
"a",
"user",
"based",
"on",
"the",
"supplied",
"session",
"authentication",
"token",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserManager.java#L177-L185 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserManager.java | UserManager.login | public User login (String username, Password password, boolean persist,
HttpServletRequest req, HttpServletResponse rsp, Authenticator auth)
throws PersistenceException, AuthenticationFailedException
{
// load up the requested user
User user = _repository.loadUser(username);
if (user == null) {
throw new NoSuchUserException("error.no_such_user");
}
// run the user through the authentication gamut
auth.authenticateUser(user, username, password);
// give them the necessary cookies and business
effectLogin(user, persist ? PERSIST_EXPIRE_DAYS : NON_PERSIST_EXPIRE_DAYS, req, rsp);
return user;
} | java | public User login (String username, Password password, boolean persist,
HttpServletRequest req, HttpServletResponse rsp, Authenticator auth)
throws PersistenceException, AuthenticationFailedException
{
// load up the requested user
User user = _repository.loadUser(username);
if (user == null) {
throw new NoSuchUserException("error.no_such_user");
}
// run the user through the authentication gamut
auth.authenticateUser(user, username, password);
// give them the necessary cookies and business
effectLogin(user, persist ? PERSIST_EXPIRE_DAYS : NON_PERSIST_EXPIRE_DAYS, req, rsp);
return user;
} | [
"public",
"User",
"login",
"(",
"String",
"username",
",",
"Password",
"password",
",",
"boolean",
"persist",
",",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"rsp",
",",
"Authenticator",
"auth",
")",
"throws",
"PersistenceException",
",",
"Authenticati... | Attempts to authenticate the requester and initiate an authenticated session for them. An
authenticated session involves their receiving a cookie that proves them to be authenticated
and an entry in the session database being created that maps their information to their
userid. If this call completes, the session was established and the proper cookies were set
in the supplied response object. If invalid authentication information is provided or some
other error occurs, an exception will be thrown.
@param username The username supplied by the user.
@param password The password supplied by the user.
@param persist If true, the cookie will expire in one month, if false, the cookie will
expire at the end of the user's browser session.
@param req The request via which the login page was loaded.
@param rsp The response in which the cookie is to be set.
@param auth The authenticator used to check whether the user should be authenticated.
@return the user object of the authenticated user. | [
"Attempts",
"to",
"authenticate",
"the",
"requester",
"and",
"initiate",
"an",
"authenticated",
"session",
"for",
"them",
".",
"An",
"authenticated",
"session",
"involves",
"their",
"receiving",
"a",
"cookie",
"that",
"proves",
"them",
"to",
"be",
"authenticated",... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserManager.java#L230-L247 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/user/UserManager.java | UserManager.effectLogin | public void effectLogin (
User user, int expires, HttpServletRequest req, HttpServletResponse rsp)
throws PersistenceException
{
String authcode = _repository.registerSession(user, Math.max(expires, 1));
Cookie acookie = new Cookie(_userAuthCookie, authcode);
// strip the hostname from the server and use that as the domain unless configured not to
if (!"false".equalsIgnoreCase(_config.getProperty("auth_cookie.strip_hostname"))) {
CookieUtil.widenDomain(req, acookie);
}
acookie.setPath("/");
acookie.setMaxAge((expires > 0) ? (expires*24*60*60) : -1);
if (USERMGR_DEBUG) {
log.info("Setting cookie " + acookie + ".");
}
rsp.addCookie(acookie);
} | java | public void effectLogin (
User user, int expires, HttpServletRequest req, HttpServletResponse rsp)
throws PersistenceException
{
String authcode = _repository.registerSession(user, Math.max(expires, 1));
Cookie acookie = new Cookie(_userAuthCookie, authcode);
// strip the hostname from the server and use that as the domain unless configured not to
if (!"false".equalsIgnoreCase(_config.getProperty("auth_cookie.strip_hostname"))) {
CookieUtil.widenDomain(req, acookie);
}
acookie.setPath("/");
acookie.setMaxAge((expires > 0) ? (expires*24*60*60) : -1);
if (USERMGR_DEBUG) {
log.info("Setting cookie " + acookie + ".");
}
rsp.addCookie(acookie);
} | [
"public",
"void",
"effectLogin",
"(",
"User",
"user",
",",
"int",
"expires",
",",
"HttpServletRequest",
"req",
",",
"HttpServletResponse",
"rsp",
")",
"throws",
"PersistenceException",
"{",
"String",
"authcode",
"=",
"_repository",
".",
"registerSession",
"(",
"us... | If a user is already known to be authenticated for one reason or other, this method can be
used to give them the appropriate authentication cookies to effect their login.
@param expires the number of days in which to expire the session cookie, 0 means expire at
the end of the browser session. | [
"If",
"a",
"user",
"is",
"already",
"known",
"to",
"be",
"authenticated",
"for",
"one",
"reason",
"or",
"other",
"this",
"method",
"can",
"be",
"used",
"to",
"give",
"them",
"the",
"appropriate",
"authentication",
"cookies",
"to",
"effect",
"their",
"login",... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/user/UserManager.java#L290-L306 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/MessageManager.java | MessageManager.exists | public boolean exists (HttpServletRequest req, String path)
{
return (getMessage(req, path, false) != null);
} | java | public boolean exists (HttpServletRequest req, String path)
{
return (getMessage(req, path, false) != null);
} | [
"public",
"boolean",
"exists",
"(",
"HttpServletRequest",
"req",
",",
"String",
"path",
")",
"{",
"return",
"(",
"getMessage",
"(",
"req",
",",
"path",
",",
"false",
")",
"!=",
"null",
")",
";",
"}"
] | Return true if the specifed path exists in the resource bundle. | [
"Return",
"true",
"if",
"the",
"specifed",
"path",
"exists",
"in",
"the",
"resource",
"bundle",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/MessageManager.java#L63-L66 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/MessageManager.java | MessageManager.getMessage | public String getMessage (HttpServletRequest req, String path)
{
return getMessage(req, path, true);
} | java | public String getMessage (HttpServletRequest req, String path)
{
return getMessage(req, path, true);
} | [
"public",
"String",
"getMessage",
"(",
"HttpServletRequest",
"req",
",",
"String",
"path",
")",
"{",
"return",
"getMessage",
"(",
"req",
",",
"path",
",",
"true",
")",
";",
"}"
] | Looks up the message with the specified path in the resource bundle most appropriate for the
locales described as preferred by the request. Always reports missing paths. | [
"Looks",
"up",
"the",
"message",
"with",
"the",
"specified",
"path",
"in",
"the",
"resource",
"bundle",
"most",
"appropriate",
"for",
"the",
"locales",
"described",
"as",
"preferred",
"by",
"the",
"request",
".",
"Always",
"reports",
"missing",
"paths",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/MessageManager.java#L72-L75 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/MessageManager.java | MessageManager.resolveBundles | protected ResourceBundle[] resolveBundles (HttpServletRequest req)
{
// first look to see if we've cached the bundles for this request in the request object
ResourceBundle[] bundles = null;
if (req != null) {
bundles = (ResourceBundle[])req.getAttribute(getBundleCacheName());
}
if (bundles != null) {
return bundles;
}
ClassLoader siteLoader = null;
String siteString = null;
if (_siteIdent != null) {
int siteId = _siteIdent.identifySite(req);
siteString = _siteIdent.getSiteString(siteId);
// grab our site-specific class loader if we have one
if (_siteLoader != null) {
try {
siteLoader = _siteLoader.getSiteClassLoader(siteId);
} catch (IOException ioe) {
log.warning("Unable to fetch site-specific classloader", "siteId", siteId,
"error", ioe);
}
}
}
// try looking up the appropriate bundles
bundles = new ResourceBundle[2];
// first from the site-specific classloader
if (siteLoader != null) {
bundles[0] = resolveBundle(req, _siteBundlePath, siteLoader, false);
} else if (siteString != null) {
// or just try prefixing the site string to the normal bundle path and see if that
// turns something up
bundles[0] = resolveBundle(req, siteString + "_" + _bundlePath,
getClass().getClassLoader(), true);
}
// then from the default classloader
bundles[1] = resolveBundle(req, _bundlePath, getClass().getClassLoader(), false);
// if we found either or both bundles, cache 'em
if (bundles[0] != null || bundles[1] != null && req != null) {
req.setAttribute(getBundleCacheName(), bundles);
}
return bundles;
} | java | protected ResourceBundle[] resolveBundles (HttpServletRequest req)
{
// first look to see if we've cached the bundles for this request in the request object
ResourceBundle[] bundles = null;
if (req != null) {
bundles = (ResourceBundle[])req.getAttribute(getBundleCacheName());
}
if (bundles != null) {
return bundles;
}
ClassLoader siteLoader = null;
String siteString = null;
if (_siteIdent != null) {
int siteId = _siteIdent.identifySite(req);
siteString = _siteIdent.getSiteString(siteId);
// grab our site-specific class loader if we have one
if (_siteLoader != null) {
try {
siteLoader = _siteLoader.getSiteClassLoader(siteId);
} catch (IOException ioe) {
log.warning("Unable to fetch site-specific classloader", "siteId", siteId,
"error", ioe);
}
}
}
// try looking up the appropriate bundles
bundles = new ResourceBundle[2];
// first from the site-specific classloader
if (siteLoader != null) {
bundles[0] = resolveBundle(req, _siteBundlePath, siteLoader, false);
} else if (siteString != null) {
// or just try prefixing the site string to the normal bundle path and see if that
// turns something up
bundles[0] = resolveBundle(req, siteString + "_" + _bundlePath,
getClass().getClassLoader(), true);
}
// then from the default classloader
bundles[1] = resolveBundle(req, _bundlePath, getClass().getClassLoader(), false);
// if we found either or both bundles, cache 'em
if (bundles[0] != null || bundles[1] != null && req != null) {
req.setAttribute(getBundleCacheName(), bundles);
}
return bundles;
} | [
"protected",
"ResourceBundle",
"[",
"]",
"resolveBundles",
"(",
"HttpServletRequest",
"req",
")",
"{",
"// first look to see if we've cached the bundles for this request in the request object",
"ResourceBundle",
"[",
"]",
"bundles",
"=",
"null",
";",
"if",
"(",
"req",
"!=",... | Finds the closest matching resource bundle for the locales specified as preferred by the
client in the supplied http request. | [
"Finds",
"the",
"closest",
"matching",
"resource",
"bundle",
"for",
"the",
"locales",
"specified",
"as",
"preferred",
"by",
"the",
"client",
"in",
"the",
"supplied",
"http",
"request",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/MessageManager.java#L183-L233 | train |
samskivert/samskivert | src/main/java/com/samskivert/servlet/MessageManager.java | MessageManager.resolveBundle | protected ResourceBundle resolveBundle (HttpServletRequest req, String bundlePath,
ClassLoader loader, boolean silent)
{
ResourceBundle bundle = null;
if (req != null) {
Enumeration<?> locales = req.getLocales();
while (locales.hasMoreElements()) {
Locale locale = (Locale)locales.nextElement();
try {
// java caches resource bundles, so we don't need to reinvent the wheel here.
// however, java also falls back from a specific bundle to a more general one
// if it can't find a specific bundle. that's real nice of it, but we want
// first to see whether or not we have exact matches on any of the preferred
// locales specified by the client. if we don't, then we can rely on java's
// fallback mechanisms
bundle = ResourceBundle.getBundle(bundlePath, locale, loader);
// if it's an exact match, off we go
if (bundle.getLocale().equals(locale)) {
break;
}
} catch (MissingResourceException mre) {
// no need to freak out quite yet, see if we have something for one of the
// other preferred locales
}
}
}
// if we were unable to find an exact match for any of the user's preferred locales, take
// their most preferred and let java perform it's fallback logic on that one
if (bundle == null) {
Locale locale = (req == null) ? _deflocale : req.getLocale();
try {
bundle = ResourceBundle.getBundle(bundlePath, locale, loader);
} catch (MissingResourceException mre) {
if (!silent) {
// if we were unable even to find a default bundle, we may want to log a
// warning
log.warning("Unable to resolve any message bundle", "req", getURL(req),
"locale", locale, "bundlePath", bundlePath, "classLoader", loader,
"siteBundlePath", _siteBundlePath, "siteLoader", _siteLoader);
}
}
}
return bundle;
} | java | protected ResourceBundle resolveBundle (HttpServletRequest req, String bundlePath,
ClassLoader loader, boolean silent)
{
ResourceBundle bundle = null;
if (req != null) {
Enumeration<?> locales = req.getLocales();
while (locales.hasMoreElements()) {
Locale locale = (Locale)locales.nextElement();
try {
// java caches resource bundles, so we don't need to reinvent the wheel here.
// however, java also falls back from a specific bundle to a more general one
// if it can't find a specific bundle. that's real nice of it, but we want
// first to see whether or not we have exact matches on any of the preferred
// locales specified by the client. if we don't, then we can rely on java's
// fallback mechanisms
bundle = ResourceBundle.getBundle(bundlePath, locale, loader);
// if it's an exact match, off we go
if (bundle.getLocale().equals(locale)) {
break;
}
} catch (MissingResourceException mre) {
// no need to freak out quite yet, see if we have something for one of the
// other preferred locales
}
}
}
// if we were unable to find an exact match for any of the user's preferred locales, take
// their most preferred and let java perform it's fallback logic on that one
if (bundle == null) {
Locale locale = (req == null) ? _deflocale : req.getLocale();
try {
bundle = ResourceBundle.getBundle(bundlePath, locale, loader);
} catch (MissingResourceException mre) {
if (!silent) {
// if we were unable even to find a default bundle, we may want to log a
// warning
log.warning("Unable to resolve any message bundle", "req", getURL(req),
"locale", locale, "bundlePath", bundlePath, "classLoader", loader,
"siteBundlePath", _siteBundlePath, "siteLoader", _siteLoader);
}
}
}
return bundle;
} | [
"protected",
"ResourceBundle",
"resolveBundle",
"(",
"HttpServletRequest",
"req",
",",
"String",
"bundlePath",
",",
"ClassLoader",
"loader",
",",
"boolean",
"silent",
")",
"{",
"ResourceBundle",
"bundle",
"=",
"null",
";",
"if",
"(",
"req",
"!=",
"null",
")",
... | Resolves the default resource bundle based on the locale information provided in the
supplied http request object. | [
"Resolves",
"the",
"default",
"resource",
"bundle",
"based",
"on",
"the",
"locale",
"information",
"provided",
"in",
"the",
"supplied",
"http",
"request",
"object",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/servlet/MessageManager.java#L239-L288 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/FileUtil.java | FileUtil.unpackJar | public static boolean unpackJar (JarFile jar, File target)
{
boolean failure = false;
Enumeration<?> entries = jar.entries();
while (!failure && entries.hasMoreElements()) {
JarEntry entry = (JarEntry)entries.nextElement();
File efile = new File(target, entry.getName());
// if we're unpacking a normal jar file, it will have special path
// entries that allow us to create our directories first
if (entry.isDirectory()) {
if (!efile.exists() && !efile.mkdir()) {
log.warning("Failed to create jar entry path", "jar", jar, "entry", entry);
}
continue;
}
// but some do not, so we want to ensure that our directories exist
// prior to getting down and funky
File parent = new File(efile.getParent());
if (!parent.exists() && !parent.mkdirs()) {
log.warning("Failed to create jar entry parent", "jar", jar, "parent", parent);
continue;
}
BufferedOutputStream fout = null;
InputStream jin = null;
try {
fout = new BufferedOutputStream(new FileOutputStream(efile));
jin = jar.getInputStream(entry);
StreamUtil.copy(jin, fout);
} catch (Exception e) {
log.warning("Failure unpacking", "jar", jar, "entry", efile, "error", e);
failure = true;
} finally {
StreamUtil.close(jin);
StreamUtil.close(fout);
}
}
try {
jar.close();
} catch (Exception e) {
log.warning("Failed to close jar file", "jar", jar, "error", e);
}
return !failure;
} | java | public static boolean unpackJar (JarFile jar, File target)
{
boolean failure = false;
Enumeration<?> entries = jar.entries();
while (!failure && entries.hasMoreElements()) {
JarEntry entry = (JarEntry)entries.nextElement();
File efile = new File(target, entry.getName());
// if we're unpacking a normal jar file, it will have special path
// entries that allow us to create our directories first
if (entry.isDirectory()) {
if (!efile.exists() && !efile.mkdir()) {
log.warning("Failed to create jar entry path", "jar", jar, "entry", entry);
}
continue;
}
// but some do not, so we want to ensure that our directories exist
// prior to getting down and funky
File parent = new File(efile.getParent());
if (!parent.exists() && !parent.mkdirs()) {
log.warning("Failed to create jar entry parent", "jar", jar, "parent", parent);
continue;
}
BufferedOutputStream fout = null;
InputStream jin = null;
try {
fout = new BufferedOutputStream(new FileOutputStream(efile));
jin = jar.getInputStream(entry);
StreamUtil.copy(jin, fout);
} catch (Exception e) {
log.warning("Failure unpacking", "jar", jar, "entry", efile, "error", e);
failure = true;
} finally {
StreamUtil.close(jin);
StreamUtil.close(fout);
}
}
try {
jar.close();
} catch (Exception e) {
log.warning("Failed to close jar file", "jar", jar, "error", e);
}
return !failure;
} | [
"public",
"static",
"boolean",
"unpackJar",
"(",
"JarFile",
"jar",
",",
"File",
"target",
")",
"{",
"boolean",
"failure",
"=",
"false",
";",
"Enumeration",
"<",
"?",
">",
"entries",
"=",
"jar",
".",
"entries",
"(",
")",
";",
"while",
"(",
"!",
"failure... | Unpacks the specified jar file intto the specified target directory.
@return true if the jar file was successfully unpacked, false if an
error occurred that prevented the unpacking. The error will be logged. | [
"Unpacks",
"the",
"specified",
"jar",
"file",
"intto",
"the",
"specified",
"target",
"directory",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/FileUtil.java#L78-L125 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/Controller.java | Controller.setControlledPanel | public void setControlledPanel (final JComponent panel)
{
panel.addHierarchyListener(new HierarchyListener() {
public void hierarchyChanged (HierarchyEvent e) {
boolean nowShowing = panel.isDisplayable();
//System.err.println("Controller." + Controller.this +
// " nowShowing=" + nowShowing +
// ", wasShowing=" + _showing);
if (_showing != nowShowing) {
_showing = nowShowing;
if (_showing) {
wasAdded();
} else {
wasRemoved();
}
}
}
boolean _showing = false;
});
} | java | public void setControlledPanel (final JComponent panel)
{
panel.addHierarchyListener(new HierarchyListener() {
public void hierarchyChanged (HierarchyEvent e) {
boolean nowShowing = panel.isDisplayable();
//System.err.println("Controller." + Controller.this +
// " nowShowing=" + nowShowing +
// ", wasShowing=" + _showing);
if (_showing != nowShowing) {
_showing = nowShowing;
if (_showing) {
wasAdded();
} else {
wasRemoved();
}
}
}
boolean _showing = false;
});
} | [
"public",
"void",
"setControlledPanel",
"(",
"final",
"JComponent",
"panel",
")",
"{",
"panel",
".",
"addHierarchyListener",
"(",
"new",
"HierarchyListener",
"(",
")",
"{",
"public",
"void",
"hierarchyChanged",
"(",
"HierarchyEvent",
"e",
")",
"{",
"boolean",
"n... | Lets this controller know about the panel that it is controlling. | [
"Lets",
"this",
"controller",
"know",
"about",
"the",
"panel",
"that",
"it",
"is",
"controlling",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/Controller.java#L156-L176 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/Controller.java | Controller.handleAction | public boolean handleAction (ActionEvent action)
{
Object arg = null;
if (action instanceof CommandEvent) {
arg = ((CommandEvent)action).getArgument();
}
return handleAction(action.getSource(), action.getActionCommand(), arg);
} | java | public boolean handleAction (ActionEvent action)
{
Object arg = null;
if (action instanceof CommandEvent) {
arg = ((CommandEvent)action).getArgument();
}
return handleAction(action.getSource(), action.getActionCommand(), arg);
} | [
"public",
"boolean",
"handleAction",
"(",
"ActionEvent",
"action",
")",
"{",
"Object",
"arg",
"=",
"null",
";",
"if",
"(",
"action",
"instanceof",
"CommandEvent",
")",
"{",
"arg",
"=",
"(",
"(",
"CommandEvent",
")",
"action",
")",
".",
"getArgument",
"(",
... | Instructs this controller to process this action event. When an action
is posted by a user interface element, it will be posted to the
controller in closest scope for that element. If that controller handles
the event, it should return true from this method to indicate that
processing should stop. If it cannot handle the event, it can return
false to indicate that the event should be propagated to the next
controller up the chain.
<p> This method will be called on the AWT thread, so the controller can
safely manipulate user interface components while handling an action.
However, this means that action handling cannot block and should not
take an undue amount of time. If the controller needs to perform
complicated, lengthy processing it should do so with a separate thread,
for example via {@link com.samskivert.swing.util.TaskMaster}.
<p> The default implementation of this method will reflect on the
controller class, looking for a method that matches the name of the
action event. For example, if the action was "exit" a method named
"exit" would be sought. A handler method must provide one of three
signatures: one accepting no arguments, one including only a reference
to the source object, or one including the source object and an extra
argument (which can be used only if the action event is an instance of
{@link CommandEvent}). For example:
<pre>
public void cancelClicked (Object source);
public void textEntered (Object source, String text);
</pre>
The arguments to the method can be as specific or as generic as desired
and reflection will perform the appropriate conversions at runtime. For
example, a method could be declared like so:
<pre>
public void cancelClicked (JButton source);
</pre>
One would have to ensure that the only action events generated with the
action command string "cancelClicked" were generated by JButton
instances if such a signature were used.
@param action the action to be processed.
@return true if the action was processed, false if it should be
propagated up to the next controller in scope. | [
"Instructs",
"this",
"controller",
"to",
"process",
"this",
"action",
"event",
".",
"When",
"an",
"action",
"is",
"posted",
"by",
"a",
"user",
"interface",
"element",
"it",
"will",
"be",
"posted",
"to",
"the",
"controller",
"in",
"closest",
"scope",
"for",
... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/Controller.java#L247-L254 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/DefaultLogProvider.java | DefaultLogProvider.obtainTermSize | protected static void obtainTermSize ()
{
if (_tdimens == null) {
_tdimens = TermUtil.getTerminalSize();
// if we were unable to obtain our dimensions, use defaults
if (_tdimens == null) {
_tdimens = new Dimension(132, 24);
}
}
} | java | protected static void obtainTermSize ()
{
if (_tdimens == null) {
_tdimens = TermUtil.getTerminalSize();
// if we were unable to obtain our dimensions, use defaults
if (_tdimens == null) {
_tdimens = new Dimension(132, 24);
}
}
} | [
"protected",
"static",
"void",
"obtainTermSize",
"(",
")",
"{",
"if",
"(",
"_tdimens",
"==",
"null",
")",
"{",
"_tdimens",
"=",
"TermUtil",
".",
"getTerminalSize",
"(",
")",
";",
"// if we were unable to obtain our dimensions, use defaults",
"if",
"(",
"_tdimens",
... | Attempts to obtain the dimensions of the terminal window in which
we're running. This is extremely platform specific, but feel free
to add code to do the right thing for your platform. | [
"Attempts",
"to",
"obtain",
"the",
"dimensions",
"of",
"the",
"terminal",
"window",
"in",
"which",
"we",
"re",
"running",
".",
"This",
"is",
"extremely",
"platform",
"specific",
"but",
"feel",
"free",
"to",
"add",
"code",
"to",
"do",
"the",
"right",
"thing... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/DefaultLogProvider.java#L167-L177 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/exporter/CsvExporter.java | CsvExporter.put | private void put(PrintStream p, String s) {
if (s == null) {
// nl();
put(p, " ");
return;
}
if (wasPreviousField) {
p.print(separator);
}
if (trim) {
s = s.trim();
}
if (s.indexOf(quote) >= 0) {
/* worst case, needs surrounding quotes and internal quotes doubled */
p.print(quote);
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == quote) {
p.print(quote);
p.print(quote);
} else {
p.print(c);
}
}
p.print(quote);
} else if (quoteLevel == 2 || quoteLevel == 1 && s.indexOf(' ') >= 0
|| s.indexOf(separator) >= 0) {
/* need surrounding quotes */
p.print(quote);
p.print(s);
p.print(quote);
} else {
/* ordinary case, no surrounding quotes needed */
p.print(s);
}
/* make a note to print trailing comma later */
wasPreviousField = true;
} | java | private void put(PrintStream p, String s) {
if (s == null) {
// nl();
put(p, " ");
return;
}
if (wasPreviousField) {
p.print(separator);
}
if (trim) {
s = s.trim();
}
if (s.indexOf(quote) >= 0) {
/* worst case, needs surrounding quotes and internal quotes doubled */
p.print(quote);
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == quote) {
p.print(quote);
p.print(quote);
} else {
p.print(c);
}
}
p.print(quote);
} else if (quoteLevel == 2 || quoteLevel == 1 && s.indexOf(' ') >= 0
|| s.indexOf(separator) >= 0) {
/* need surrounding quotes */
p.print(quote);
p.print(s);
p.print(quote);
} else {
/* ordinary case, no surrounding quotes needed */
p.print(s);
}
/* make a note to print trailing comma later */
wasPreviousField = true;
} | [
"private",
"void",
"put",
"(",
"PrintStream",
"p",
",",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"{",
"// nl();",
"put",
"(",
"p",
",",
"\" \"",
")",
";",
"return",
";",
"}",
"if",
"(",
"wasPreviousField",
")",
"{",
"p",
".",
... | Write one csv 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",
"csv",
"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/CsvExporter.java#L157-L195 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/DebugChords.java | DebugChords.activate | public static void activate ()
{
// capture low-level keyboard events via the keyboard focus manager
if (_dispatcher == null) {
_dispatcher = new KeyEventDispatcher() {
public boolean dispatchKeyEvent (KeyEvent e) {
return DebugChords.dispatchKeyEvent(e);
}
};
KeyboardFocusManager keymgr =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
keymgr.addKeyEventDispatcher(_dispatcher);
}
} | java | public static void activate ()
{
// capture low-level keyboard events via the keyboard focus manager
if (_dispatcher == null) {
_dispatcher = new KeyEventDispatcher() {
public boolean dispatchKeyEvent (KeyEvent e) {
return DebugChords.dispatchKeyEvent(e);
}
};
KeyboardFocusManager keymgr =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
keymgr.addKeyEventDispatcher(_dispatcher);
}
} | [
"public",
"static",
"void",
"activate",
"(",
")",
"{",
"// capture low-level keyboard events via the keyboard focus manager",
"if",
"(",
"_dispatcher",
"==",
"null",
")",
"{",
"_dispatcher",
"=",
"new",
"KeyEventDispatcher",
"(",
")",
"{",
"public",
"boolean",
"dispat... | Initializes the debug chords services and wires up the key event
listener that will be used to invoke the bound code. | [
"Initializes",
"the",
"debug",
"chords",
"services",
"and",
"wires",
"up",
"the",
"key",
"event",
"listener",
"that",
"will",
"be",
"used",
"to",
"invoke",
"the",
"bound",
"code",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/DebugChords.java#L44-L58 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/DebugChords.java | DebugChords.registerHook | public static void registerHook (int modifierMask, int keyCode, Hook hook)
{
// store the hooks mapped by key code
ArrayList<Tuple<Integer,Hook>> list = _bindings.get(keyCode);
if (list == null) {
list = new ArrayList<Tuple<Integer,Hook>>();
_bindings.put(keyCode, list);
}
// append the hook and modifier mask to the list
list.add(new Tuple<Integer,Hook>(modifierMask, hook));
} | java | public static void registerHook (int modifierMask, int keyCode, Hook hook)
{
// store the hooks mapped by key code
ArrayList<Tuple<Integer,Hook>> list = _bindings.get(keyCode);
if (list == null) {
list = new ArrayList<Tuple<Integer,Hook>>();
_bindings.put(keyCode, list);
}
// append the hook and modifier mask to the list
list.add(new Tuple<Integer,Hook>(modifierMask, hook));
} | [
"public",
"static",
"void",
"registerHook",
"(",
"int",
"modifierMask",
",",
"int",
"keyCode",
",",
"Hook",
"hook",
")",
"{",
"// store the hooks mapped by key code",
"ArrayList",
"<",
"Tuple",
"<",
"Integer",
",",
"Hook",
">",
">",
"list",
"=",
"_bindings",
"... | Registers the supplied debug hook to be invoked when the specified
key combination is depressed.
@param modifierMask a mask with bits on for all modifiers that must
be present when the specified key code is received (e.g. {@link
KeyEvent#CTRL_DOWN_MASK}|{@link KeyEvent#ALT_DOWN_MASK}).
@param keyCode the code that identifies the normal key that must be
pressed to activate the hook (e.g. {@link KeyEvent#VK_E}).
@param hook the hook to be invoked when the specified key
combination is received. | [
"Registers",
"the",
"supplied",
"debug",
"hook",
"to",
"be",
"invoked",
"when",
"the",
"specified",
"key",
"combination",
"is",
"depressed",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/DebugChords.java#L72-L83 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/jora/Cursor.java | Cursor.next | public V next ()
throws SQLException
{
// if we closed everything up after the last call to next(),
// table will be null here and we should bail immediately
if (_table == null) {
return null;
}
if (_result == null) {
if (_qbeObject != null) {
PreparedStatement qbeStmt = _conn.prepareStatement(_query);
_table.bindQueryVariables(qbeStmt, _qbeObject, _qbeMask);
_result = qbeStmt.executeQuery();
_stmt = qbeStmt;
} else {
if (_stmt == null) {
_stmt = _conn.createStatement();
}
_result = _stmt.executeQuery(_query);
}
}
if (_result.next()) {
return _currObject = _table.load(_result);
}
_result.close();
_result = null;
_currObject = null;
_table = null;
if (_stmt != null) {
_stmt.close();
}
return null;
} | java | public V next ()
throws SQLException
{
// if we closed everything up after the last call to next(),
// table will be null here and we should bail immediately
if (_table == null) {
return null;
}
if (_result == null) {
if (_qbeObject != null) {
PreparedStatement qbeStmt = _conn.prepareStatement(_query);
_table.bindQueryVariables(qbeStmt, _qbeObject, _qbeMask);
_result = qbeStmt.executeQuery();
_stmt = qbeStmt;
} else {
if (_stmt == null) {
_stmt = _conn.createStatement();
}
_result = _stmt.executeQuery(_query);
}
}
if (_result.next()) {
return _currObject = _table.load(_result);
}
_result.close();
_result = null;
_currObject = null;
_table = null;
if (_stmt != null) {
_stmt.close();
}
return null;
} | [
"public",
"V",
"next",
"(",
")",
"throws",
"SQLException",
"{",
"// if we closed everything up after the last call to next(),",
"// table will be null here and we should bail immediately",
"if",
"(",
"_table",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",... | A cursor is initially positioned before its first row; the first call to
next makes the first row the current row; the second call makes the
second row the current row, etc.
<P> If an input stream from the previous row is open, it is implicitly
closed. The ResultSet's warning chain is cleared when a new row is read.
@return object constructed from fetched record or null if there are no
more rows | [
"A",
"cursor",
"is",
"initially",
"positioned",
"before",
"its",
"first",
"row",
";",
"the",
"first",
"call",
"to",
"next",
"makes",
"the",
"first",
"row",
"the",
"current",
"row",
";",
"the",
"second",
"call",
"makes",
"the",
"second",
"row",
"the",
"cu... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/Cursor.java#L32-L67 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/jora/Cursor.java | Cursor.get | public V get ()
throws SQLException
{
V result = next();
if (result != null) {
int spurious = 0;
while (next() != null) {
spurious++;
}
if (spurious > 0) {
log.warning("Cursor.get() quietly tossed " + spurious + " spurious additional " +
"records.", "query", _query);
}
}
return result;
} | java | public V get ()
throws SQLException
{
V result = next();
if (result != null) {
int spurious = 0;
while (next() != null) {
spurious++;
}
if (spurious > 0) {
log.warning("Cursor.get() quietly tossed " + spurious + " spurious additional " +
"records.", "query", _query);
}
}
return result;
} | [
"public",
"V",
"get",
"(",
")",
"throws",
"SQLException",
"{",
"V",
"result",
"=",
"next",
"(",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"int",
"spurious",
"=",
"0",
";",
"while",
"(",
"next",
"(",
")",
"!=",
"null",
")",
"{",
"sp... | Returns the first element matched by this cursor or null if no elements
were matched. Checks to ensure that no subsequent elements were matched
by the query, logs a warning if there were spurious additional matches. | [
"Returns",
"the",
"first",
"element",
"matched",
"by",
"this",
"cursor",
"or",
"null",
"if",
"no",
"elements",
"were",
"matched",
".",
"Checks",
"to",
"ensure",
"that",
"no",
"subsequent",
"elements",
"were",
"matched",
"by",
"the",
"query",
"logs",
"a",
"... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/Cursor.java#L74-L89 | train |
samskivert/samskivert | src/main/java/com/samskivert/jdbc/jora/Cursor.java | Cursor.close | public void close ()
throws SQLException
{
if (_result != null) {
_result.close();
_result = null;
}
if (_stmt != null) {
_stmt.close();
_stmt = null;
}
} | java | public void close ()
throws SQLException
{
if (_result != null) {
_result.close();
_result = null;
}
if (_stmt != null) {
_stmt.close();
_stmt = null;
}
} | [
"public",
"void",
"close",
"(",
")",
"throws",
"SQLException",
"{",
"if",
"(",
"_result",
"!=",
"null",
")",
"{",
"_result",
".",
"close",
"(",
")",
";",
"_result",
"=",
"null",
";",
"}",
"if",
"(",
"_stmt",
"!=",
"null",
")",
"{",
"_stmt",
".",
... | Close the Cursor, even if we haven't read all the possible objects. | [
"Close",
"the",
"Cursor",
"even",
"if",
"we",
"haven",
"t",
"read",
"all",
"the",
"possible",
"objects",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/jdbc/jora/Cursor.java#L141-L152 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/ReportRunner.java | ReportRunner.setReport | public void setReport(Report report) {
this.report = report;
if (this.report.getQuery() != null) {
this.report.getQuery().setDialect(dialect);
}
} | java | public void setReport(Report report) {
this.report = report;
if (this.report.getQuery() != null) {
this.report.getQuery().setDialect(dialect);
}
} | [
"public",
"void",
"setReport",
"(",
"Report",
"report",
")",
"{",
"this",
".",
"report",
"=",
"report",
";",
"if",
"(",
"this",
".",
"report",
".",
"getQuery",
"(",
")",
"!=",
"null",
")",
"{",
"this",
".",
"report",
".",
"getQuery",
"(",
")",
".",... | Set next report object
@param report
next report object | [
"Set",
"next",
"report",
"object"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/ReportRunner.java#L195-L200 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/ReportRunner.java | ReportRunner.setAlerts | public void setAlerts(List<Alert> alerts) {
if (format == null) {
throw new IllegalStateException(
"You have to use setFormat with a valid output format before using setAlert!");
}
if (!ALARM_FORMAT.equals(format) && !INDICATOR_FORMAT.equals(format) && !DISPLAY_FORMAT.equals(format)) {
throw new IllegalStateException(
"You can use setAlert only for ALARM, INDICATOR or DISPLAY output formats!");
}
this.alerts = alerts;
} | java | public void setAlerts(List<Alert> alerts) {
if (format == null) {
throw new IllegalStateException(
"You have to use setFormat with a valid output format before using setAlert!");
}
if (!ALARM_FORMAT.equals(format) && !INDICATOR_FORMAT.equals(format) && !DISPLAY_FORMAT.equals(format)) {
throw new IllegalStateException(
"You can use setAlert only for ALARM, INDICATOR or DISPLAY output formats!");
}
this.alerts = alerts;
} | [
"public",
"void",
"setAlerts",
"(",
"List",
"<",
"Alert",
">",
"alerts",
")",
"{",
"if",
"(",
"format",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"You have to use setFormat with a valid output format before using setAlert!\"",
")",
";",
... | Set a list of alert object for report of type alarm
@param alerts
list of alert object | [
"Set",
"a",
"list",
"of",
"alert",
"object",
"for",
"report",
"of",
"type",
"alarm"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/ReportRunner.java#L293-L303 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/ReportRunner.java | ReportRunner.executeQuery | public QueryResult executeQuery() throws ReportRunnerException, InterruptedException {
if (connection == null) {
throw new ReportRunnerException("Connection is null!");
}
if (report == null) {
throw new ReportRunnerException("Report is null!");
}
String sql = getSql();
// retrieves the report parameters
Map<String, QueryParameter> parameters = getReportParameters();
if (QueryUtil.restrictQueryExecution(sql)) {
throw new ReportRunnerException("You are not allowed to execute queries that modify the database!");
}
if (QueryUtil.isProcedureCall(sql)) {
if (!QueryUtil.isValidProcedureCall(sql, dialect)) {
throw new ReportRunnerException("Invalid procedure call! Must be of form 'call (${P1}, ?)'");
}
}
QueryResult queryResult = null;
try {
Query query = getQuery(sql);
QueryExecutor executor = new QueryExecutor(query, parameters, parameterValues, connection, count, true,
csv);
executor.setMaxRows(0);
executor.setTimeout(queryTimeout);
queryResult = executor.execute();
return queryResult;
} catch (Exception e) {
throw new ReportRunnerException(e);
}
} | java | public QueryResult executeQuery() throws ReportRunnerException, InterruptedException {
if (connection == null) {
throw new ReportRunnerException("Connection is null!");
}
if (report == null) {
throw new ReportRunnerException("Report is null!");
}
String sql = getSql();
// retrieves the report parameters
Map<String, QueryParameter> parameters = getReportParameters();
if (QueryUtil.restrictQueryExecution(sql)) {
throw new ReportRunnerException("You are not allowed to execute queries that modify the database!");
}
if (QueryUtil.isProcedureCall(sql)) {
if (!QueryUtil.isValidProcedureCall(sql, dialect)) {
throw new ReportRunnerException("Invalid procedure call! Must be of form 'call (${P1}, ?)'");
}
}
QueryResult queryResult = null;
try {
Query query = getQuery(sql);
QueryExecutor executor = new QueryExecutor(query, parameters, parameterValues, connection, count, true,
csv);
executor.setMaxRows(0);
executor.setTimeout(queryTimeout);
queryResult = executor.execute();
return queryResult;
} catch (Exception e) {
throw new ReportRunnerException(e);
}
} | [
"public",
"QueryResult",
"executeQuery",
"(",
")",
"throws",
"ReportRunnerException",
",",
"InterruptedException",
"{",
"if",
"(",
"connection",
"==",
"null",
")",
"{",
"throw",
"new",
"ReportRunnerException",
"(",
"\"Connection is null!\"",
")",
";",
"}",
"if",
"... | Execute query This method is useful in case you are not interested about
report layout, but only query and you want to make your own business.
@return QueryResult object
@throws ReportRunnerException
if Runner object is not correctly configured
@throws InterruptedException
if process was interrupted | [
"Execute",
"query",
"This",
"method",
"is",
"useful",
"in",
"case",
"you",
"are",
"not",
"interested",
"about",
"report",
"layout",
"but",
"only",
"query",
"and",
"you",
"want",
"to",
"make",
"your",
"own",
"business",
"."
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/ReportRunner.java#L331-L369 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/ReportRunner.java | ReportRunner.run | public boolean run(OutputStream stream) throws ReportRunnerException, NoDataFoundException {
if ((stream == null) && !TABLE_FORMAT.equals(format) && !ALARM_FORMAT.equals(format)
&& !INDICATOR_FORMAT.equals(format) && !DISPLAY_FORMAT.equals(format)) {
throw new ReportRunnerException("OutputStream cannot be null!");
}
if ((stream != null) && TABLE_FORMAT.equals(format)) {
throw new ReportRunnerException("TABLE FORMAT does not need an output stream. Use run() method instead.");
}
if ((stream != null) && ALARM_FORMAT.equals(format)) {
throw new ReportRunnerException("ALARM FORMAT does not need an output stream. Use run() method instead.");
}
if ((stream != null) && INDICATOR_FORMAT.equals(format)) {
throw new ReportRunnerException(
"INDICATOR FORMAT does not need an output stream. Use run() method instead.");
}
if ((stream != null) && DISPLAY_FORMAT.equals(format)) {
throw new ReportRunnerException("DISPLAY FORMAT does not need an output stream. Use run() method instead.");
}
if (!formatAllowed(format)) {
throw new ReportRunnerException("Unsupported format : " + format + " !");
}
QueryResult queryResult = null;
try {
queryResult = executeQuery();
String sql = getSql();
ParametersBean bean = new ParametersBean(getQuery(sql), getReportParameters(), parameterValues);
ReportLayout convertedLayout = ReportUtil.getDynamicReportLayout(connection, report.getLayout(), bean);
boolean isProcedure = QueryUtil.isProcedureCall(sql);
ExporterBean eb = new ExporterBean(connection, queryTimeout, queryResult, stream, convertedLayout, bean,
report.getBaseName(), false, alerts, isProcedure);
if (language != null) {
eb.setLanguage(language);
}
createExporter(eb);
return exporter.export();
} catch (NoDataFoundException e) {
throw e;
} catch (Exception e) {
throw new ReportRunnerException(e);
} finally {
if (queryResult != null) {
queryResult.close();
}
}
} | java | public boolean run(OutputStream stream) throws ReportRunnerException, NoDataFoundException {
if ((stream == null) && !TABLE_FORMAT.equals(format) && !ALARM_FORMAT.equals(format)
&& !INDICATOR_FORMAT.equals(format) && !DISPLAY_FORMAT.equals(format)) {
throw new ReportRunnerException("OutputStream cannot be null!");
}
if ((stream != null) && TABLE_FORMAT.equals(format)) {
throw new ReportRunnerException("TABLE FORMAT does not need an output stream. Use run() method instead.");
}
if ((stream != null) && ALARM_FORMAT.equals(format)) {
throw new ReportRunnerException("ALARM FORMAT does not need an output stream. Use run() method instead.");
}
if ((stream != null) && INDICATOR_FORMAT.equals(format)) {
throw new ReportRunnerException(
"INDICATOR FORMAT does not need an output stream. Use run() method instead.");
}
if ((stream != null) && DISPLAY_FORMAT.equals(format)) {
throw new ReportRunnerException("DISPLAY FORMAT does not need an output stream. Use run() method instead.");
}
if (!formatAllowed(format)) {
throw new ReportRunnerException("Unsupported format : " + format + " !");
}
QueryResult queryResult = null;
try {
queryResult = executeQuery();
String sql = getSql();
ParametersBean bean = new ParametersBean(getQuery(sql), getReportParameters(), parameterValues);
ReportLayout convertedLayout = ReportUtil.getDynamicReportLayout(connection, report.getLayout(), bean);
boolean isProcedure = QueryUtil.isProcedureCall(sql);
ExporterBean eb = new ExporterBean(connection, queryTimeout, queryResult, stream, convertedLayout, bean,
report.getBaseName(), false, alerts, isProcedure);
if (language != null) {
eb.setLanguage(language);
}
createExporter(eb);
return exporter.export();
} catch (NoDataFoundException e) {
throw e;
} catch (Exception e) {
throw new ReportRunnerException(e);
} finally {
if (queryResult != null) {
queryResult.close();
}
}
} | [
"public",
"boolean",
"run",
"(",
"OutputStream",
"stream",
")",
"throws",
"ReportRunnerException",
",",
"NoDataFoundException",
"{",
"if",
"(",
"(",
"stream",
"==",
"null",
")",
"&&",
"!",
"TABLE_FORMAT",
".",
"equals",
"(",
"format",
")",
"&&",
"!",
"ALARM_... | Export the current report to the specified output format
@param stream
output stream to write the exported report
@throws ReportRunnerException
if FluentReportRunner object is not correctly configured
@return true if export process finished, or false if export process was
stopped
@throws NoDataFoundException
if report has no data | [
"Export",
"the",
"current",
"report",
"to",
"the",
"specified",
"output",
"format"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/ReportRunner.java#L384-L441 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/ReportRunner.java | ReportRunner.removeExporterEventListener | public void removeExporterEventListener(ExporterEventListener listener) {
listenerList.remove(listener);
if (exporter != null) {
exporter.removeExporterEventListener(listener);
}
} | java | public void removeExporterEventListener(ExporterEventListener listener) {
listenerList.remove(listener);
if (exporter != null) {
exporter.removeExporterEventListener(listener);
}
} | [
"public",
"void",
"removeExporterEventListener",
"(",
"ExporterEventListener",
"listener",
")",
"{",
"listenerList",
".",
"remove",
"(",
"listener",
")",
";",
"if",
"(",
"exporter",
"!=",
"null",
")",
"{",
"exporter",
".",
"removeExporterEventListener",
"(",
"list... | Remove an exporter event listener
@param listener
exporter event listener | [
"Remove",
"an",
"exporter",
"event",
"listener"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/ReportRunner.java#L577-L582 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/ReportRunner.java | ReportRunner.getAlarmData | public AlarmData getAlarmData() {
if (ALARM_FORMAT.equals(format)) {
AlarmExporter alarmExporter = (AlarmExporter) exporter;
return alarmExporter.getData();
} else {
return new AlarmData();
}
} | java | public AlarmData getAlarmData() {
if (ALARM_FORMAT.equals(format)) {
AlarmExporter alarmExporter = (AlarmExporter) exporter;
return alarmExporter.getData();
} else {
return new AlarmData();
}
} | [
"public",
"AlarmData",
"getAlarmData",
"(",
")",
"{",
"if",
"(",
"ALARM_FORMAT",
".",
"equals",
"(",
"format",
")",
")",
"{",
"AlarmExporter",
"alarmExporter",
"=",
"(",
"AlarmExporter",
")",
"exporter",
";",
"return",
"alarmExporter",
".",
"getData",
"(",
"... | Get alarm data ALARM exporter
@return alarm data for ALARM exporter | [
"Get",
"alarm",
"data",
"ALARM",
"exporter"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/ReportRunner.java#L603-L610 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/ReportRunner.java | ReportRunner.getIndicatorData | public IndicatorData getIndicatorData() {
if (INDICATOR_FORMAT.equals(format)) {
IndicatorExporter ie = (IndicatorExporter) exporter;
return ie.getData();
} else {
return new IndicatorData();
}
} | java | public IndicatorData getIndicatorData() {
if (INDICATOR_FORMAT.equals(format)) {
IndicatorExporter ie = (IndicatorExporter) exporter;
return ie.getData();
} else {
return new IndicatorData();
}
} | [
"public",
"IndicatorData",
"getIndicatorData",
"(",
")",
"{",
"if",
"(",
"INDICATOR_FORMAT",
".",
"equals",
"(",
"format",
")",
")",
"{",
"IndicatorExporter",
"ie",
"=",
"(",
"IndicatorExporter",
")",
"exporter",
";",
"return",
"ie",
".",
"getData",
"(",
")"... | Get indicator data INDICATOR exporter
@return indicator data for INDICATOR exporter | [
"Get",
"indicator",
"data",
"INDICATOR",
"exporter"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/ReportRunner.java#L617-L624 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/ReportRunner.java | ReportRunner.getDisplayData | public DisplayData getDisplayData() {
if (DISPLAY_FORMAT.equals(format)) {
DisplayExporter de = (DisplayExporter) exporter;
return de.getData();
} else {
return new DisplayData();
}
} | java | public DisplayData getDisplayData() {
if (DISPLAY_FORMAT.equals(format)) {
DisplayExporter de = (DisplayExporter) exporter;
return de.getData();
} else {
return new DisplayData();
}
} | [
"public",
"DisplayData",
"getDisplayData",
"(",
")",
"{",
"if",
"(",
"DISPLAY_FORMAT",
".",
"equals",
"(",
"format",
")",
")",
"{",
"DisplayExporter",
"de",
"=",
"(",
"DisplayExporter",
")",
"exporter",
";",
"return",
"de",
".",
"getData",
"(",
")",
";",
... | Get display data DISPLAY exporter
@return display data for DISPLAY exporter | [
"Get",
"display",
"data",
"DISPLAY",
"exporter"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/ReportRunner.java#L631-L638 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/LRUHashMap.java | LRUHashMap.flush | protected void flush ()
{
if (!_canFlush) {
return;
}
// If we've exceeded our size, remove things until we're back
// under the required size.
if (_size > _maxSize) {
// This works because the entrySet iterator of a LinkedHashMap
// returns the entries in LRU order
Iterator<Map.Entry<K,V>> iter = _delegate.entrySet().iterator();
// don't remove the last entry, even if it's too big, because
// a cache with nothing in it sucks
for (int ii = size(); (ii > 1) && (_size > _maxSize); ii--) {
Map.Entry<K,V> entry = iter.next();
entryRemoved(entry.getValue());
iter.remove();
}
}
} | java | protected void flush ()
{
if (!_canFlush) {
return;
}
// If we've exceeded our size, remove things until we're back
// under the required size.
if (_size > _maxSize) {
// This works because the entrySet iterator of a LinkedHashMap
// returns the entries in LRU order
Iterator<Map.Entry<K,V>> iter = _delegate.entrySet().iterator();
// don't remove the last entry, even if it's too big, because
// a cache with nothing in it sucks
for (int ii = size(); (ii > 1) && (_size > _maxSize); ii--) {
Map.Entry<K,V> entry = iter.next();
entryRemoved(entry.getValue());
iter.remove();
}
}
} | [
"protected",
"void",
"flush",
"(",
")",
"{",
"if",
"(",
"!",
"_canFlush",
")",
"{",
"return",
";",
"}",
"// If we've exceeded our size, remove things until we're back",
"// under the required size.",
"if",
"(",
"_size",
">",
"_maxSize",
")",
"{",
"// This works becaus... | Flushes entries from the cache until we're back under our desired
cache size. | [
"Flushes",
"entries",
"from",
"the",
"cache",
"until",
"we",
"re",
"back",
"under",
"our",
"desired",
"cache",
"size",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/LRUHashMap.java#L228-L248 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/LRUHashMap.java | LRUHashMap.entryRemoved | protected void entryRemoved (V entry)
{
if (entry != null) {
_size -= _sizer.computeSize(entry);
if (_remobs != null) {
_remobs.removedFromMap(this, entry);
}
}
} | java | protected void entryRemoved (V entry)
{
if (entry != null) {
_size -= _sizer.computeSize(entry);
if (_remobs != null) {
_remobs.removedFromMap(this, entry);
}
}
} | [
"protected",
"void",
"entryRemoved",
"(",
"V",
"entry",
")",
"{",
"if",
"(",
"entry",
"!=",
"null",
")",
"{",
"_size",
"-=",
"_sizer",
".",
"computeSize",
"(",
"entry",
")",
";",
"if",
"(",
"_remobs",
"!=",
"null",
")",
"{",
"_remobs",
".",
"removedF... | Adjust our size to reflect the removal of the specified entry. | [
"Adjust",
"our",
"size",
"to",
"reflect",
"the",
"removal",
"of",
"the",
"specified",
"entry",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/LRUHashMap.java#L253-L261 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/ExpiringReference.java | ExpiringReference.create | public static <T> ExpiringReference<T> create (T value, long expireMillis)
{
return new ExpiringReference<T>(value, expireMillis);
} | java | public static <T> ExpiringReference<T> create (T value, long expireMillis)
{
return new ExpiringReference<T>(value, expireMillis);
} | [
"public",
"static",
"<",
"T",
">",
"ExpiringReference",
"<",
"T",
">",
"create",
"(",
"T",
"value",
",",
"long",
"expireMillis",
")",
"{",
"return",
"new",
"ExpiringReference",
"<",
"T",
">",
"(",
"value",
",",
"expireMillis",
")",
";",
"}"
] | Creates an expiring reference with the supplied value and expiration time. | [
"Creates",
"an",
"expiring",
"reference",
"with",
"the",
"supplied",
"value",
"and",
"expiration",
"time",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ExpiringReference.java#L23-L26 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/ExpiringReference.java | ExpiringReference.get | public static <T> T get (ExpiringReference<T> value)
{
return (value == null) ? null : value.getValue();
} | java | public static <T> T get (ExpiringReference<T> value)
{
return (value == null) ? null : value.getValue();
} | [
"public",
"static",
"<",
"T",
">",
"T",
"get",
"(",
"ExpiringReference",
"<",
"T",
">",
"value",
")",
"{",
"return",
"(",
"value",
"==",
"null",
")",
"?",
"null",
":",
"value",
".",
"getValue",
"(",
")",
";",
"}"
] | Gets the value from an expiring reference but returns null if the supplied reference
reference is null. | [
"Gets",
"the",
"value",
"from",
"an",
"expiring",
"reference",
"but",
"returns",
"null",
"if",
"the",
"supplied",
"reference",
"reference",
"is",
"null",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ExpiringReference.java#L32-L35 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/ExpiringReference.java | ExpiringReference.getValue | public T getValue ()
{
// if the value is still around and it's expired, clear it
if (_value != null && System.currentTimeMillis() >= _expires) {
_value = null;
}
// then return the value (which may be cleared to null by now)
return _value;
} | java | public T getValue ()
{
// if the value is still around and it's expired, clear it
if (_value != null && System.currentTimeMillis() >= _expires) {
_value = null;
}
// then return the value (which may be cleared to null by now)
return _value;
} | [
"public",
"T",
"getValue",
"(",
")",
"{",
"// if the value is still around and it's expired, clear it",
"if",
"(",
"_value",
"!=",
"null",
"&&",
"System",
".",
"currentTimeMillis",
"(",
")",
">=",
"_expires",
")",
"{",
"_value",
"=",
"null",
";",
"}",
"// then r... | Returns the value with which we were created or null if the value has
expired. | [
"Returns",
"the",
"value",
"with",
"which",
"we",
"were",
"created",
"or",
"null",
"if",
"the",
"value",
"has",
"expired",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/ExpiringReference.java#L51-L59 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/util/MenuUtil.java | MenuUtil.addMenuItem | public static JMenuItem addMenuItem (
ActionListener l, JMenu menu, String name)
{
return addMenuItem(l, menu, name, null, null);
} | java | public static JMenuItem addMenuItem (
ActionListener l, JMenu menu, String name)
{
return addMenuItem(l, menu, name, null, null);
} | [
"public",
"static",
"JMenuItem",
"addMenuItem",
"(",
"ActionListener",
"l",
",",
"JMenu",
"menu",
",",
"String",
"name",
")",
"{",
"return",
"addMenuItem",
"(",
"l",
",",
"menu",
",",
"name",
",",
"null",
",",
"null",
")",
";",
"}"
] | Adds a new menu item to the menu with the specified name.
@param l the action listener.
@param menu the menu to add the item to.
@param name the item name.
@return the new menu item. | [
"Adds",
"a",
"new",
"menu",
"item",
"to",
"the",
"menu",
"with",
"the",
"specified",
"name",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/MenuUtil.java#L99-L103 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/util/MenuUtil.java | MenuUtil.createItem | protected static JMenuItem createItem (String name, Integer mnem, KeyStroke accel)
{
JMenuItem item = new JMenuItem(name);
if (mnem != null) {
item.setMnemonic(mnem.intValue());
}
if (accel != null) {
item.setAccelerator(accel);
}
return item;
} | java | protected static JMenuItem createItem (String name, Integer mnem, KeyStroke accel)
{
JMenuItem item = new JMenuItem(name);
if (mnem != null) {
item.setMnemonic(mnem.intValue());
}
if (accel != null) {
item.setAccelerator(accel);
}
return item;
} | [
"protected",
"static",
"JMenuItem",
"createItem",
"(",
"String",
"name",
",",
"Integer",
"mnem",
",",
"KeyStroke",
"accel",
")",
"{",
"JMenuItem",
"item",
"=",
"new",
"JMenuItem",
"(",
"name",
")",
";",
"if",
"(",
"mnem",
"!=",
"null",
")",
"{",
"item",
... | Creates and configures a menu item. | [
"Creates",
"and",
"configures",
"a",
"menu",
"item",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/util/MenuUtil.java#L181-L191 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/MultiLineLabel.java | MultiLineLabel.setText | public void setText (String text)
{
if (_label.setText(text)) {
_dirty = true;
// clear out our constrained size where appropriate
if (_constrain == HORIZONTAL || _constrain == VERTICAL) {
_constrainedSize = 0;
_label.clearTargetDimens();
}
revalidate();
repaint();
}
} | java | public void setText (String text)
{
if (_label.setText(text)) {
_dirty = true;
// clear out our constrained size where appropriate
if (_constrain == HORIZONTAL || _constrain == VERTICAL) {
_constrainedSize = 0;
_label.clearTargetDimens();
}
revalidate();
repaint();
}
} | [
"public",
"void",
"setText",
"(",
"String",
"text",
")",
"{",
"if",
"(",
"_label",
".",
"setText",
"(",
"text",
")",
")",
"{",
"_dirty",
"=",
"true",
";",
"// clear out our constrained size where appropriate",
"if",
"(",
"_constrain",
"==",
"HORIZONTAL",
"||",... | Sets the text displayed by this label. | [
"Sets",
"the",
"text",
"displayed",
"by",
"this",
"label",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/MultiLineLabel.java#L137-L149 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/MultiLineLabel.java | MultiLineLabel.layoutLabel | protected void layoutLabel ()
{
Graphics2D gfx = (Graphics2D)getGraphics();
if (gfx != null) {
// re-layout the label
_label.layout(gfx);
gfx.dispose();
// note that we're no longer dirty
_dirty = false;
}
} | java | protected void layoutLabel ()
{
Graphics2D gfx = (Graphics2D)getGraphics();
if (gfx != null) {
// re-layout the label
_label.layout(gfx);
gfx.dispose();
// note that we're no longer dirty
_dirty = false;
}
} | [
"protected",
"void",
"layoutLabel",
"(",
")",
"{",
"Graphics2D",
"gfx",
"=",
"(",
"Graphics2D",
")",
"getGraphics",
"(",
")",
";",
"if",
"(",
"gfx",
"!=",
"null",
")",
"{",
"// re-layout the label",
"_label",
".",
"layout",
"(",
"gfx",
")",
";",
"gfx",
... | Called when the label has changed in some meaningful way and we'd accordingly like to
re-layout the label, update our component's size, and repaint everything to suit. | [
"Called",
"when",
"the",
"label",
"has",
"changed",
"in",
"some",
"meaningful",
"way",
"and",
"we",
"d",
"accordingly",
"like",
"to",
"re",
"-",
"layout",
"the",
"label",
"update",
"our",
"component",
"s",
"size",
"and",
"repaint",
"everything",
"to",
"sui... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/MultiLineLabel.java#L297-L308 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/querybuilder/sql/dialect/DialectFactory.java | DialectFactory.determineDialect | public static Dialect determineDialect(String databaseName, String databaseMajorVersion)
throws DialectException {
if (databaseName == null) {
throw new DialectException("Dialect must be explicitly set");
}
String dialectName;
// TODO workaround for firebird (databaseName='Firebird 2.0.LI-V2.0.3.12981 Firebird 2.0/tcp (decebal)/P10')
if (databaseName.startsWith(FIREBIRD)) {
dialectName = FirebirdDialect.class.getName();
} else if (databaseName.startsWith(MSACCESS)) {
dialectName = MSAccessDialect.class.getName();
} else {
DialectMapper mapper = MAPPERS.get(databaseName);
if (mapper == null) {
throw new DialectException( "Dialect must be explicitly set for database: " + databaseName );
}
dialectName = mapper.getDialectClass(databaseMajorVersion);
}
return buildDialect(dialectName);
} | java | public static Dialect determineDialect(String databaseName, String databaseMajorVersion)
throws DialectException {
if (databaseName == null) {
throw new DialectException("Dialect must be explicitly set");
}
String dialectName;
// TODO workaround for firebird (databaseName='Firebird 2.0.LI-V2.0.3.12981 Firebird 2.0/tcp (decebal)/P10')
if (databaseName.startsWith(FIREBIRD)) {
dialectName = FirebirdDialect.class.getName();
} else if (databaseName.startsWith(MSACCESS)) {
dialectName = MSAccessDialect.class.getName();
} else {
DialectMapper mapper = MAPPERS.get(databaseName);
if (mapper == null) {
throw new DialectException( "Dialect must be explicitly set for database: " + databaseName );
}
dialectName = mapper.getDialectClass(databaseMajorVersion);
}
return buildDialect(dialectName);
} | [
"public",
"static",
"Dialect",
"determineDialect",
"(",
"String",
"databaseName",
",",
"String",
"databaseMajorVersion",
")",
"throws",
"DialectException",
"{",
"if",
"(",
"databaseName",
"==",
"null",
")",
"{",
"throw",
"new",
"DialectException",
"(",
"\"Dialect mu... | Determine the appropriate Dialect to use given the database product name
and major version.
@param databaseName The name of the database product (obtained from metadata).
@param databaseMajorVersion The major version of the database product (obtained from metadata).
@return An appropriate dialect instance.
@throws DialectException | [
"Determine",
"the",
"appropriate",
"Dialect",
"to",
"use",
"given",
"the",
"database",
"product",
"name",
"and",
"major",
"version",
"."
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/querybuilder/sql/dialect/DialectFactory.java#L84-L105 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/querybuilder/sql/dialect/DialectFactory.java | DialectFactory.buildDialect | public static Dialect buildDialect(String dialectName) throws DialectException {
try {
return (Dialect) loadDialect(dialectName).newInstance();
} catch (ClassNotFoundException e) {
throw new DialectException("Dialect class not found: " + dialectName);
} catch (Exception e) {
throw new DialectException("Could not instantiate dialect class", e);
}
} | java | public static Dialect buildDialect(String dialectName) throws DialectException {
try {
return (Dialect) loadDialect(dialectName).newInstance();
} catch (ClassNotFoundException e) {
throw new DialectException("Dialect class not found: " + dialectName);
} catch (Exception e) {
throw new DialectException("Could not instantiate dialect class", e);
}
} | [
"public",
"static",
"Dialect",
"buildDialect",
"(",
"String",
"dialectName",
")",
"throws",
"DialectException",
"{",
"try",
"{",
"return",
"(",
"Dialect",
")",
"loadDialect",
"(",
"dialectName",
")",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"Cla... | Returns a dialect instance given the name of the class to use.
@param dialectName The name of the dialect class.
@return The dialect instance.
@throws DialectException | [
"Returns",
"a",
"dialect",
"instance",
"given",
"the",
"name",
"of",
"the",
"class",
"to",
"use",
"."
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/querybuilder/sql/dialect/DialectFactory.java#L115-L123 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Runnables.java | Runnables.asRunnable | public static Runnable asRunnable (Object instance, String methodName)
{
Class<?> clazz = instance.getClass();
Method method = findMethod(clazz, methodName);
if (Modifier.isStatic(method.getModifiers())) {
throw new IllegalArgumentException(
clazz.getName() + "." + methodName + "() must not be static");
}
return new MethodRunner(method, instance);
} | java | public static Runnable asRunnable (Object instance, String methodName)
{
Class<?> clazz = instance.getClass();
Method method = findMethod(clazz, methodName);
if (Modifier.isStatic(method.getModifiers())) {
throw new IllegalArgumentException(
clazz.getName() + "." + methodName + "() must not be static");
}
return new MethodRunner(method, instance);
} | [
"public",
"static",
"Runnable",
"asRunnable",
"(",
"Object",
"instance",
",",
"String",
"methodName",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"instance",
".",
"getClass",
"(",
")",
";",
"Method",
"method",
"=",
"findMethod",
"(",
"clazz",
",",
"m... | Creates a runnable that invokes the specified method on the specified instance via
reflection.
<p> NOTE: if you specify a protected or private method this method will call {@link
Method#setAccessible} to make the method accessible. If you're writing secure code or need
to run in a sandbox, don't use this functionality.
@throws IllegalArgumentException if the supplied method name does not correspond to a
non-static zero-argument method of the supplied instance's class. | [
"Creates",
"a",
"runnable",
"that",
"invokes",
"the",
"specified",
"method",
"on",
"the",
"specified",
"instance",
"via",
"reflection",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Runnables.java#L37-L46 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Runnables.java | Runnables.asRunnable | public static Runnable asRunnable (Class<?> clazz, String methodName)
{
Method method = findMethod(clazz, methodName);
if (!Modifier.isStatic(method.getModifiers())) {
throw new IllegalArgumentException(
clazz.getName() + "." + methodName + "() must be static");
}
return new MethodRunner(method, null);
} | java | public static Runnable asRunnable (Class<?> clazz, String methodName)
{
Method method = findMethod(clazz, methodName);
if (!Modifier.isStatic(method.getModifiers())) {
throw new IllegalArgumentException(
clazz.getName() + "." + methodName + "() must be static");
}
return new MethodRunner(method, null);
} | [
"public",
"static",
"Runnable",
"asRunnable",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"methodName",
")",
"{",
"Method",
"method",
"=",
"findMethod",
"(",
"clazz",
",",
"methodName",
")",
";",
"if",
"(",
"!",
"Modifier",
".",
"isStatic",
"(",... | Creates a runnable that invokes the specified static method via reflection.
<p> NOTE: if you specify a protected or private method this method will call {@link
Method#setAccessible} to make the method accessible. If you're writing secure code or need
to run in a sandbox, don't use this functionality.
@throws IllegalArgumentException if the supplied method name does not correspond to a static
zero-argument method of the supplied class. | [
"Creates",
"a",
"runnable",
"that",
"invokes",
"the",
"specified",
"static",
"method",
"via",
"reflection",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Runnables.java#L58-L66 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/chart/ChartRunner.java | ChartRunner.setConnection | public void setConnection(Connection connection, boolean csv) {
this.connection = connection;
this.csv = csv;
try {
dialect = DialectUtil.getDialect(connection);
} catch (Exception e) {
e.printStackTrace();
}
if (chart != null) {
if (chart.getReport().getQuery() != null) {
chart.getReport().getQuery().setDialect(dialect);
}
}
} | java | public void setConnection(Connection connection, boolean csv) {
this.connection = connection;
this.csv = csv;
try {
dialect = DialectUtil.getDialect(connection);
} catch (Exception e) {
e.printStackTrace();
}
if (chart != null) {
if (chart.getReport().getQuery() != null) {
chart.getReport().getQuery().setDialect(dialect);
}
}
} | [
"public",
"void",
"setConnection",
"(",
"Connection",
"connection",
",",
"boolean",
"csv",
")",
"{",
"this",
".",
"connection",
"=",
"connection",
";",
"this",
".",
"csv",
"=",
"csv",
";",
"try",
"{",
"dialect",
"=",
"DialectUtil",
".",
"getDialect",
"(",
... | Set database connection
@param connection database connection
@param csv true for a csv file connection | [
"Set",
"database",
"connection"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/chart/ChartRunner.java#L100-L113 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/chart/ChartRunner.java | ChartRunner.setChart | public void setChart(Chart chart) {
this.chart = chart;
if (this.chart.getReport().getQuery() != null) {
this.chart.getReport().getQuery().setDialect(dialect);
}
} | java | public void setChart(Chart chart) {
this.chart = chart;
if (this.chart.getReport().getQuery() != null) {
this.chart.getReport().getQuery().setDialect(dialect);
}
} | [
"public",
"void",
"setChart",
"(",
"Chart",
"chart",
")",
"{",
"this",
".",
"chart",
"=",
"chart",
";",
"if",
"(",
"this",
".",
"chart",
".",
"getReport",
"(",
")",
".",
"getQuery",
"(",
")",
"!=",
"null",
")",
"{",
"this",
".",
"chart",
".",
"ge... | Set next chart object
@param chart next chart object | [
"Set",
"next",
"chart",
"object"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/chart/ChartRunner.java#L129-L134 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/chart/ChartRunner.java | ChartRunner.run | public boolean run(OutputStream stream) throws ReportRunnerException,
NoDataFoundException, InterruptedException {
if ((stream == null) && GRAPHIC_FORMAT.equals(format)) {
throw new ReportRunnerException("OutputStream cannot be null!");
}
if ((stream != null) && TABLE_FORMAT.equals(format)) {
throw new ReportRunnerException("TABLE FORMAT does not need an output stream. Use run() method instead.");
}
if (connection == null) {
throw new ReportRunnerException("Connection is null!");
}
if (chart == null) {
throw new ReportRunnerException("Chart is null!");
}
Report report = chart.getReport();
String sql = report.getSql();
if (sql == null) {
// get sql from SelectQuery object (report built with next reporter
// !)
sql = report.getQuery().toString();
}
if (sql == null) {
throw new ReportRunnerException("Report sql expression not found");
}
try {
setDynamicColumns();
} catch (Exception e1) {
throw new ReportRunnerException(e1);
}
// retrieves the report parameters
Map<String, QueryParameter> parameters = new HashMap<String, QueryParameter>();
List<QueryParameter> parameterList = report.getParameters();
if (parameterList != null) {
for (QueryParameter param : parameterList) {
parameters.put(param.getName(), param);
}
}
if (QueryUtil.restrictQueryExecution(sql)) {
throw new ReportRunnerException(
"You are not allowed to execute queries that modify the database!");
}
if (QueryUtil.isProcedureCall(sql)) {
Dialect dialect = null;
try {
dialect = DialectUtil.getDialect(connection);
} catch (Exception e) {
e.printStackTrace();
}
if (!QueryUtil.isValidProcedureCall(sql, dialect)) {
throw new ReportRunnerException(
"Invalid procedure call! Must be of form 'call (${P1}, ?)'");
}
}
QueryExecutor executor = null;
try {
Query query = new Query(sql);
executor = new QueryExecutor(query, parameters, parameterValues, connection, true, true, csv);
executor.setMaxRows(0);
executor.setTimeout(queryTimeout);
QueryResult queryResult = executor.execute();
createExporter(query, parameters, parameterValues, queryResult, stream);
return exporter.export();
} catch (NoDataFoundException e) {
throw e;
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
e.printStackTrace();
throw new ReportRunnerException(e);
} finally {
resetStaticColumnsAfterRun();
if (executor != null) {
executor.close();
}
}
} | java | public boolean run(OutputStream stream) throws ReportRunnerException,
NoDataFoundException, InterruptedException {
if ((stream == null) && GRAPHIC_FORMAT.equals(format)) {
throw new ReportRunnerException("OutputStream cannot be null!");
}
if ((stream != null) && TABLE_FORMAT.equals(format)) {
throw new ReportRunnerException("TABLE FORMAT does not need an output stream. Use run() method instead.");
}
if (connection == null) {
throw new ReportRunnerException("Connection is null!");
}
if (chart == null) {
throw new ReportRunnerException("Chart is null!");
}
Report report = chart.getReport();
String sql = report.getSql();
if (sql == null) {
// get sql from SelectQuery object (report built with next reporter
// !)
sql = report.getQuery().toString();
}
if (sql == null) {
throw new ReportRunnerException("Report sql expression not found");
}
try {
setDynamicColumns();
} catch (Exception e1) {
throw new ReportRunnerException(e1);
}
// retrieves the report parameters
Map<String, QueryParameter> parameters = new HashMap<String, QueryParameter>();
List<QueryParameter> parameterList = report.getParameters();
if (parameterList != null) {
for (QueryParameter param : parameterList) {
parameters.put(param.getName(), param);
}
}
if (QueryUtil.restrictQueryExecution(sql)) {
throw new ReportRunnerException(
"You are not allowed to execute queries that modify the database!");
}
if (QueryUtil.isProcedureCall(sql)) {
Dialect dialect = null;
try {
dialect = DialectUtil.getDialect(connection);
} catch (Exception e) {
e.printStackTrace();
}
if (!QueryUtil.isValidProcedureCall(sql, dialect)) {
throw new ReportRunnerException(
"Invalid procedure call! Must be of form 'call (${P1}, ?)'");
}
}
QueryExecutor executor = null;
try {
Query query = new Query(sql);
executor = new QueryExecutor(query, parameters, parameterValues, connection, true, true, csv);
executor.setMaxRows(0);
executor.setTimeout(queryTimeout);
QueryResult queryResult = executor.execute();
createExporter(query, parameters, parameterValues, queryResult, stream);
return exporter.export();
} catch (NoDataFoundException e) {
throw e;
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
e.printStackTrace();
throw new ReportRunnerException(e);
} finally {
resetStaticColumnsAfterRun();
if (executor != null) {
executor.close();
}
}
} | [
"public",
"boolean",
"run",
"(",
"OutputStream",
"stream",
")",
"throws",
"ReportRunnerException",
",",
"NoDataFoundException",
",",
"InterruptedException",
"{",
"if",
"(",
"(",
"stream",
"==",
"null",
")",
"&&",
"GRAPHIC_FORMAT",
".",
"equals",
"(",
"format",
"... | Export the current chart to the specified output format
For IMAGE_FORMAT use withImagePath method.
@param stream output stream to write the exported chart
@throws ReportRunnerException if ChartRunner object is not correctly configured
@throws NoDataFoundException if chart has no data
@throws InterruptedException if process was interrupted
@return true if export process finished, or false if export process crashed | [
"Export",
"the",
"current",
"chart",
"to",
"the",
"specified",
"output",
"format",
"For",
"IMAGE_FORMAT",
"use",
"withImagePath",
"method",
"."
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/chart/ChartRunner.java#L299-L385 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/RepeatRecordFilter.java | RepeatRecordFilter.configureDefaultHandler | public static void configureDefaultHandler (int maxRepeat)
{
Logger logger = LogManager.getLogManager().getLogger("");
Handler[] handlers = logger.getHandlers();
RepeatRecordFilter filter = new RepeatRecordFilter(maxRepeat);
for (int ii = 0; ii < handlers.length; ii++) {
handlers[ii].setFilter(filter);
}
} | java | public static void configureDefaultHandler (int maxRepeat)
{
Logger logger = LogManager.getLogManager().getLogger("");
Handler[] handlers = logger.getHandlers();
RepeatRecordFilter filter = new RepeatRecordFilter(maxRepeat);
for (int ii = 0; ii < handlers.length; ii++) {
handlers[ii].setFilter(filter);
}
} | [
"public",
"static",
"void",
"configureDefaultHandler",
"(",
"int",
"maxRepeat",
")",
"{",
"Logger",
"logger",
"=",
"LogManager",
".",
"getLogManager",
"(",
")",
".",
"getLogger",
"(",
"\"\"",
")",
";",
"Handler",
"[",
"]",
"handlers",
"=",
"logger",
".",
"... | Configures the default logging handlers to use an instance of this
filter. | [
"Configures",
"the",
"default",
"logging",
"handlers",
"to",
"use",
"an",
"instance",
"of",
"this",
"filter",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/RepeatRecordFilter.java#L27-L35 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Log.java | Log.levelFromString | public static int levelFromString (String level)
{
if (level.equalsIgnoreCase("debug")) {
return DEBUG;
} else if (level.equalsIgnoreCase("info")) {
return INFO;
} else if (level.equalsIgnoreCase("warning")) {
return WARNING;
} else {
return -1;
}
} | java | public static int levelFromString (String level)
{
if (level.equalsIgnoreCase("debug")) {
return DEBUG;
} else if (level.equalsIgnoreCase("info")) {
return INFO;
} else if (level.equalsIgnoreCase("warning")) {
return WARNING;
} else {
return -1;
}
} | [
"public",
"static",
"int",
"levelFromString",
"(",
"String",
"level",
")",
"{",
"if",
"(",
"level",
".",
"equalsIgnoreCase",
"(",
"\"debug\"",
")",
")",
"{",
"return",
"DEBUG",
";",
"}",
"else",
"if",
"(",
"level",
".",
"equalsIgnoreCase",
"(",
"\"info\"",... | Returns the log level that matches the specified string or -1 if
the string could not be interpretted as a log level. | [
"Returns",
"the",
"log",
"level",
"that",
"matches",
"the",
"specified",
"string",
"or",
"-",
"1",
"if",
"the",
"string",
"could",
"not",
"be",
"interpretted",
"as",
"a",
"log",
"level",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Log.java#L162-L173 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/TermUtil.java | TermUtil.getSizeViaResize | protected static Dimension getSizeViaResize ()
{
BufferedReader bin = null;
try {
Process proc = Runtime.getRuntime().exec("resize");
InputStream in = proc.getInputStream();
bin = new BufferedReader(new InputStreamReader(in));
Pattern regex = Pattern.compile("([0-9]+)");
String line;
int columns = -1, lines = -1;
while ((line = bin.readLine()) != null) {
if (line.indexOf("COLUMNS") != -1) {
Matcher match = regex.matcher(line);
if (match.find()) {
columns = safeToInt(match.group());
}
} else if (line.indexOf("LINES") != -1) {
Matcher match = regex.matcher(line);
if (match.find()) {
lines = safeToInt(match.group());
}
}
}
if (columns != -1 && lines != -1) {
return new Dimension(columns, lines);
}
return null;
} catch (PatternSyntaxException pse) {
return null; // logging a warning here may be annoying
} catch (SecurityException se) {
return null; // logging a warning here may be annoying
} catch (IOException ioe) {
return null; // logging a warning here may be annoying
} finally {
StreamUtil.close(bin);
}
} | java | protected static Dimension getSizeViaResize ()
{
BufferedReader bin = null;
try {
Process proc = Runtime.getRuntime().exec("resize");
InputStream in = proc.getInputStream();
bin = new BufferedReader(new InputStreamReader(in));
Pattern regex = Pattern.compile("([0-9]+)");
String line;
int columns = -1, lines = -1;
while ((line = bin.readLine()) != null) {
if (line.indexOf("COLUMNS") != -1) {
Matcher match = regex.matcher(line);
if (match.find()) {
columns = safeToInt(match.group());
}
} else if (line.indexOf("LINES") != -1) {
Matcher match = regex.matcher(line);
if (match.find()) {
lines = safeToInt(match.group());
}
}
}
if (columns != -1 && lines != -1) {
return new Dimension(columns, lines);
}
return null;
} catch (PatternSyntaxException pse) {
return null; // logging a warning here may be annoying
} catch (SecurityException se) {
return null; // logging a warning here may be annoying
} catch (IOException ioe) {
return null; // logging a warning here may be annoying
} finally {
StreamUtil.close(bin);
}
} | [
"protected",
"static",
"Dimension",
"getSizeViaResize",
"(",
")",
"{",
"BufferedReader",
"bin",
"=",
"null",
";",
"try",
"{",
"Process",
"proc",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec",
"(",
"\"resize\"",
")",
";",
"InputStream",
"in",
"="... | Tries to obtain the terminal dimensions by running 'resize'. | [
"Tries",
"to",
"obtain",
"the",
"terminal",
"dimensions",
"by",
"running",
"resize",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/TermUtil.java#L88-L126 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/TermUtil.java | TermUtil.safeToInt | protected static int safeToInt (String intstr)
{
if (!StringUtil.isBlank(intstr)) {
try {
return Integer.parseInt(intstr);
} catch (NumberFormatException nfe) {
}
}
return -1;
} | java | protected static int safeToInt (String intstr)
{
if (!StringUtil.isBlank(intstr)) {
try {
return Integer.parseInt(intstr);
} catch (NumberFormatException nfe) {
}
}
return -1;
} | [
"protected",
"static",
"int",
"safeToInt",
"(",
"String",
"intstr",
")",
"{",
"if",
"(",
"!",
"StringUtil",
".",
"isBlank",
"(",
"intstr",
")",
")",
"{",
"try",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"intstr",
")",
";",
"}",
"catch",
"(",
"N... | Converts the string to an integer, returning -1 on any error. | [
"Converts",
"the",
"string",
"to",
"an",
"integer",
"returning",
"-",
"1",
"on",
"any",
"error",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/TermUtil.java#L129-L138 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Queue.java | Queue.append0 | protected void append0 (T item, boolean notify)
{
if (_count == _size) {
makeMoreRoom();
}
_items[_end] = item;
_end = (_end + 1) % _size;
_count++;
if (notify) {
notify();
}
} | java | protected void append0 (T item, boolean notify)
{
if (_count == _size) {
makeMoreRoom();
}
_items[_end] = item;
_end = (_end + 1) % _size;
_count++;
if (notify) {
notify();
}
} | [
"protected",
"void",
"append0",
"(",
"T",
"item",
",",
"boolean",
"notify",
")",
"{",
"if",
"(",
"_count",
"==",
"_size",
")",
"{",
"makeMoreRoom",
"(",
")",
";",
"}",
"_items",
"[",
"_end",
"]",
"=",
"item",
";",
"_end",
"=",
"(",
"_end",
"+",
"... | Internal append method. If subclassing queue, be sure to call
this method from inside a synchronized block. | [
"Internal",
"append",
"method",
".",
"If",
"subclassing",
"queue",
"be",
"sure",
"to",
"call",
"this",
"method",
"from",
"inside",
"a",
"synchronized",
"block",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Queue.java#L107-L119 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Queue.java | Queue.getNonBlocking | public synchronized T getNonBlocking ()
{
if (_count == 0) {
return null;
}
// pull the object off, and clear our reference to it
T retval = _items[_start];
_items[_start] = null;
_start = (_start + 1) % _size;
_count--;
return retval;
} | java | public synchronized T getNonBlocking ()
{
if (_count == 0) {
return null;
}
// pull the object off, and clear our reference to it
T retval = _items[_start];
_items[_start] = null;
_start = (_start + 1) % _size;
_count--;
return retval;
} | [
"public",
"synchronized",
"T",
"getNonBlocking",
"(",
")",
"{",
"if",
"(",
"_count",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"// pull the object off, and clear our reference to it",
"T",
"retval",
"=",
"_items",
"[",
"_start",
"]",
";",
"_items",
"[",... | Returns the next item on the queue or null if the queue is
empty. This method will not block waiting for an item to be added
to the queue. | [
"Returns",
"the",
"next",
"item",
"on",
"the",
"queue",
"or",
"null",
"if",
"the",
"queue",
"is",
"empty",
".",
"This",
"method",
"will",
"not",
"block",
"waiting",
"for",
"an",
"item",
"to",
"be",
"added",
"to",
"the",
"queue",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Queue.java#L126-L140 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Queue.java | Queue.get | public synchronized T get ()
{
while (_count == 0) {
try { wait(); } catch (InterruptedException e) {}
}
// pull the object off, and clear our reference to it
T retval = _items[_start];
_items[_start] = null;
_start = (_start + 1) % _size;
_count--;
// if we are only filling 1/8th of the space, shrink by half
if ((_size > MIN_SHRINK_SIZE) && (_size > _suggestedSize) &&
(_count < (_size >> 3))) shrink();
return retval;
} | java | public synchronized T get ()
{
while (_count == 0) {
try { wait(); } catch (InterruptedException e) {}
}
// pull the object off, and clear our reference to it
T retval = _items[_start];
_items[_start] = null;
_start = (_start + 1) % _size;
_count--;
// if we are only filling 1/8th of the space, shrink by half
if ((_size > MIN_SHRINK_SIZE) && (_size > _suggestedSize) &&
(_count < (_size >> 3))) shrink();
return retval;
} | [
"public",
"synchronized",
"T",
"get",
"(",
")",
"{",
"while",
"(",
"_count",
"==",
"0",
")",
"{",
"try",
"{",
"wait",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"}",
"}",
"// pull the object off, and clear our reference to it",
... | Gets the next item from the queue, blocking until an item is added
to the queue if the queue is empty at time of invocation. | [
"Gets",
"the",
"next",
"item",
"from",
"the",
"queue",
"blocking",
"until",
"an",
"item",
"is",
"added",
"to",
"the",
"queue",
"if",
"the",
"queue",
"is",
"empty",
"at",
"time",
"of",
"invocation",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Queue.java#L177-L195 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/Queue.java | Queue.shrink | private void shrink ()
{
T[] items = newArray(_size / 2);
if (_start > _end) {
// the data wraps around
System.arraycopy(_items, _start, items, 0, _size - _start);
System.arraycopy(_items, 0, items, _size - _start, _end + 1);
} else {
// the data does not wrap around
System.arraycopy(_items, _start, items, 0, _end - _start+1);
}
_size = _size / 2;
_start = 0;
_end = _count;
_items = items;
} | java | private void shrink ()
{
T[] items = newArray(_size / 2);
if (_start > _end) {
// the data wraps around
System.arraycopy(_items, _start, items, 0, _size - _start);
System.arraycopy(_items, 0, items, _size - _start, _end + 1);
} else {
// the data does not wrap around
System.arraycopy(_items, _start, items, 0, _end - _start+1);
}
_size = _size / 2;
_start = 0;
_end = _count;
_items = items;
} | [
"private",
"void",
"shrink",
"(",
")",
"{",
"T",
"[",
"]",
"items",
"=",
"newArray",
"(",
"_size",
"/",
"2",
")",
";",
"if",
"(",
"_start",
">",
"_end",
")",
"{",
"// the data wraps around",
"System",
".",
"arraycopy",
"(",
"_items",
",",
"_start",
"... | shrink by half | [
"shrink",
"by",
"half"
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/Queue.java#L209-L227 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/CollectionUtil.java | CollectionUtil.addAll | @ReplacedBy("com.google.common.collect.Iterators#addAll(Collection, com.google.common.collect.Iterators#forEnumeration(Enumeration))")
public static <T, C extends Collection<T>> C addAll (C col, Enumeration<? extends T> enm)
{
while (enm.hasMoreElements()) {
col.add(enm.nextElement());
}
return col;
} | java | @ReplacedBy("com.google.common.collect.Iterators#addAll(Collection, com.google.common.collect.Iterators#forEnumeration(Enumeration))")
public static <T, C extends Collection<T>> C addAll (C col, Enumeration<? extends T> enm)
{
while (enm.hasMoreElements()) {
col.add(enm.nextElement());
}
return col;
} | [
"@",
"ReplacedBy",
"(",
"\"com.google.common.collect.Iterators#addAll(Collection, com.google.common.collect.Iterators#forEnumeration(Enumeration))\"",
")",
"public",
"static",
"<",
"T",
",",
"C",
"extends",
"Collection",
"<",
"T",
">",
">",
"C",
"addAll",
"(",
"C",
"col",
... | Adds all items returned by the enumeration to the supplied collection
and returns the supplied collection. | [
"Adds",
"all",
"items",
"returned",
"by",
"the",
"enumeration",
"to",
"the",
"supplied",
"collection",
"and",
"returns",
"the",
"supplied",
"collection",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/CollectionUtil.java#L30-L37 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/CollectionUtil.java | CollectionUtil.addAll | @ReplacedBy("com.google.common.collect.Iterators#addAll()")
public static <T, C extends Collection<T>> C addAll (C col, Iterator<? extends T> iter)
{
while (iter.hasNext()) {
col.add(iter.next());
}
return col;
} | java | @ReplacedBy("com.google.common.collect.Iterators#addAll()")
public static <T, C extends Collection<T>> C addAll (C col, Iterator<? extends T> iter)
{
while (iter.hasNext()) {
col.add(iter.next());
}
return col;
} | [
"@",
"ReplacedBy",
"(",
"\"com.google.common.collect.Iterators#addAll()\"",
")",
"public",
"static",
"<",
"T",
",",
"C",
"extends",
"Collection",
"<",
"T",
">",
">",
"C",
"addAll",
"(",
"C",
"col",
",",
"Iterator",
"<",
"?",
"extends",
"T",
">",
"iter",
")... | Adds all items returned by the iterator to the supplied collection and
returns the supplied collection. | [
"Adds",
"all",
"items",
"returned",
"by",
"the",
"iterator",
"to",
"the",
"supplied",
"collection",
"and",
"returns",
"the",
"supplied",
"collection",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/CollectionUtil.java#L43-L50 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/CollectionUtil.java | CollectionUtil.addAll | @ReplacedBy("java.util.Collections#addAll()")
public static <T, E extends T, C extends Collection<T>> C addAll (C col, E[] values)
{
if (values != null) {
for (E value : values) {
col.add(value);
}
}
return col;
} | java | @ReplacedBy("java.util.Collections#addAll()")
public static <T, E extends T, C extends Collection<T>> C addAll (C col, E[] values)
{
if (values != null) {
for (E value : values) {
col.add(value);
}
}
return col;
} | [
"@",
"ReplacedBy",
"(",
"\"java.util.Collections#addAll()\"",
")",
"public",
"static",
"<",
"T",
",",
"E",
"extends",
"T",
",",
"C",
"extends",
"Collection",
"<",
"T",
">",
">",
"C",
"addAll",
"(",
"C",
"col",
",",
"E",
"[",
"]",
"values",
")",
"{",
... | Adds all items in the given object array to the supplied collection and
returns the supplied collection. If the supplied array is null, nothing
is added to the collection. | [
"Adds",
"all",
"items",
"in",
"the",
"given",
"object",
"array",
"to",
"the",
"supplied",
"collection",
"and",
"returns",
"the",
"supplied",
"collection",
".",
"If",
"the",
"supplied",
"array",
"is",
"null",
"nothing",
"is",
"added",
"to",
"the",
"collection... | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/CollectionUtil.java#L57-L66 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/CollectionUtil.java | CollectionUtil.addAll | public static <T, C extends Collection<T>> C addAll (
C col, Iterable<? extends Collection<? extends T>> values)
{
for (Collection<? extends T> val : values) {
col.addAll(val);
}
return col;
} | java | public static <T, C extends Collection<T>> C addAll (
C col, Iterable<? extends Collection<? extends T>> values)
{
for (Collection<? extends T> val : values) {
col.addAll(val);
}
return col;
} | [
"public",
"static",
"<",
"T",
",",
"C",
"extends",
"Collection",
"<",
"T",
">",
">",
"C",
"addAll",
"(",
"C",
"col",
",",
"Iterable",
"<",
"?",
"extends",
"Collection",
"<",
"?",
"extends",
"T",
">",
">",
"values",
")",
"{",
"for",
"(",
"Collection... | Folds all the specified values into the supplied collection and returns it. | [
"Folds",
"all",
"the",
"specified",
"values",
"into",
"the",
"supplied",
"collection",
"and",
"returns",
"it",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/CollectionUtil.java#L71-L78 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/CollectionUtil.java | CollectionUtil.putAll | public static <K, V, M extends Map<K, V>> M putAll (
M map, Iterable<? extends Map<? extends K, ? extends V>> values)
{
for (Map<? extends K, ? extends V> val : values) {
map.putAll(val);
}
return map;
} | java | public static <K, V, M extends Map<K, V>> M putAll (
M map, Iterable<? extends Map<? extends K, ? extends V>> values)
{
for (Map<? extends K, ? extends V> val : values) {
map.putAll(val);
}
return map;
} | [
"public",
"static",
"<",
"K",
",",
"V",
",",
"M",
"extends",
"Map",
"<",
"K",
",",
"V",
">",
">",
"M",
"putAll",
"(",
"M",
"map",
",",
"Iterable",
"<",
"?",
"extends",
"Map",
"<",
"?",
"extends",
"K",
",",
"?",
"extends",
"V",
">",
">",
"valu... | Folds all the specified values into the supplied map and returns it. | [
"Folds",
"all",
"the",
"specified",
"values",
"into",
"the",
"supplied",
"map",
"and",
"returns",
"it",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/CollectionUtil.java#L83-L90 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.parametersAreDefined | public void parametersAreDefined(Report report) throws ParameterNotFoundException {
String[] paramNames;
String sql = report.getSql();
if (sql == null) {
sql = report.getQuery().toString();
}
Query query = new Query(sql);
paramNames = query.getParameterNames();
List<QueryParameter> parameters = report.getParameters();
for (String paramName : paramNames) {
QueryParameter param = null;
for (QueryParameter p : parameters) {
if (paramName.equals(p.getName())) {
param = p;
}
}
if (param == null) {
throw new ParameterNotFoundException(paramName);
}
}
} | java | public void parametersAreDefined(Report report) throws ParameterNotFoundException {
String[] paramNames;
String sql = report.getSql();
if (sql == null) {
sql = report.getQuery().toString();
}
Query query = new Query(sql);
paramNames = query.getParameterNames();
List<QueryParameter> parameters = report.getParameters();
for (String paramName : paramNames) {
QueryParameter param = null;
for (QueryParameter p : parameters) {
if (paramName.equals(p.getName())) {
param = p;
}
}
if (param == null) {
throw new ParameterNotFoundException(paramName);
}
}
} | [
"public",
"void",
"parametersAreDefined",
"(",
"Report",
"report",
")",
"throws",
"ParameterNotFoundException",
"{",
"String",
"[",
"]",
"paramNames",
";",
"String",
"sql",
"=",
"report",
".",
"getSql",
"(",
")",
";",
"if",
"(",
"sql",
"==",
"null",
")",
"... | Test if all parameters used in the report are defined
@param report report object
@throws ParameterNotFoundException if a parameter used in the report is not defined | [
"Test",
"if",
"all",
"parameters",
"used",
"in",
"the",
"report",
"are",
"defined"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L81-L103 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.getRuntimeParameterValues | public static List<IdName> getRuntimeParameterValues(Connection con, QueryParameter qp, Map<String, QueryParameter> map,
Map<String, Object> vals) throws Exception {
List<IdName> values = new ArrayList<IdName>();
if (qp.isManualSource()) {
QueryExecutor executor = null;
try {
Query query = new Query(qp.getSource());
executor = new QueryExecutor(query, map, vals, con, false, false, false);
executor.setTimeout(10000);
executor.setMaxRows(0);
QueryResult qr = executor.execute();
// int count = qr.getRowCount();
// one or two columns in manual select source
// for (int i = 0; i < count; i++) {
while (qr.hasNext()) {
IdName in = new IdName();
in.setId((Serializable) qr.nextValue(0));
if (qr.getColumnCount() == 1) {
in.setName((Serializable) qr.nextValue(0));
} else {
in.setName((Serializable) qr.nextValue(1));
}
values.add(in);
}
} catch (Exception ex) {
ex.printStackTrace();
throw new Exception(ex);
} finally {
if (executor != null) {
executor.close();
}
}
} else {
String source = qp.getSource();
int index = source.indexOf(".");
int index2 = source.lastIndexOf(".");
String tableName = source.substring(0, index);
String columnName;
String shownColumnName = null;
if (index == index2) {
columnName = source.substring(index + 1);
} else {
columnName = source.substring(index + 1, index2);
shownColumnName = source.substring(index2 + 1);
}
values = getColumnValues(con, qp.getSchema(), tableName, columnName, shownColumnName, qp.getOrderBy());
}
return values;
} | java | public static List<IdName> getRuntimeParameterValues(Connection con, QueryParameter qp, Map<String, QueryParameter> map,
Map<String, Object> vals) throws Exception {
List<IdName> values = new ArrayList<IdName>();
if (qp.isManualSource()) {
QueryExecutor executor = null;
try {
Query query = new Query(qp.getSource());
executor = new QueryExecutor(query, map, vals, con, false, false, false);
executor.setTimeout(10000);
executor.setMaxRows(0);
QueryResult qr = executor.execute();
// int count = qr.getRowCount();
// one or two columns in manual select source
// for (int i = 0; i < count; i++) {
while (qr.hasNext()) {
IdName in = new IdName();
in.setId((Serializable) qr.nextValue(0));
if (qr.getColumnCount() == 1) {
in.setName((Serializable) qr.nextValue(0));
} else {
in.setName((Serializable) qr.nextValue(1));
}
values.add(in);
}
} catch (Exception ex) {
ex.printStackTrace();
throw new Exception(ex);
} finally {
if (executor != null) {
executor.close();
}
}
} else {
String source = qp.getSource();
int index = source.indexOf(".");
int index2 = source.lastIndexOf(".");
String tableName = source.substring(0, index);
String columnName;
String shownColumnName = null;
if (index == index2) {
columnName = source.substring(index + 1);
} else {
columnName = source.substring(index + 1, index2);
shownColumnName = source.substring(index2 + 1);
}
values = getColumnValues(con, qp.getSchema(), tableName, columnName, shownColumnName, qp.getOrderBy());
}
return values;
} | [
"public",
"static",
"List",
"<",
"IdName",
">",
"getRuntimeParameterValues",
"(",
"Connection",
"con",
",",
"QueryParameter",
"qp",
",",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"map",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"vals",
")",
"t... | Get values for a parameter sql at runtime
All parent parameters must have the values in the map.
@param con database connection
@param qp parameter
@param map report map of parameters
@param vals map of parameter values
@return values for parameter with sql source
@throws Exception if an exception occurs | [
"Get",
"values",
"for",
"a",
"parameter",
"sql",
"at",
"runtime",
"All",
"parent",
"parameters",
"must",
"have",
"the",
"values",
"in",
"the",
"map",
"."
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L353-L404 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.getParameterValues | public static List<IdName> getParameterValues(Connection con, QueryParameter qp, Map<String, QueryParameter> map,
Map<String, Serializable> vals) throws Exception {
Map<String, Object> objVals = new HashMap<String, Object>();
for (String key : vals.keySet()) {
Serializable s = vals.get(key);
if (s instanceof Serializable[]) {
Serializable[] array = (Serializable[]) s;
Object[] objArray = new Object[array.length];
for (int i = 0, size = array.length; i < size; i++) {
objArray[i] = array[i];
}
s = objArray;
}
objVals.put(key, s);
}
QueryExecutor executor = null;
try {
List<IdName> values = new ArrayList<IdName>();
Query query = new Query(qp.getSource());
executor = new QueryExecutor(query, map, objVals, con, false, false, false);
executor.setTimeout(10000);
executor.setMaxRows(0);
QueryResult qr = executor.execute();
//int count = qr.getRowCount();
// one or two columns in manual select source
//for (int i = 0; i < count; i++) {
while (qr.hasNext()) {
IdName in = new IdName();
in.setId((Serializable) qr.nextValue(0));
if (qr.getColumnCount() == 1) {
in.setName((Serializable) qr.nextValue(0));
} else {
in.setName((Serializable) qr.nextValue(1));
}
values.add(in);
}
return values;
} catch (Exception ex) {
ex.printStackTrace();
throw new Exception(ex);
} finally {
if (executor != null) {
executor.close();
}
}
} | java | public static List<IdName> getParameterValues(Connection con, QueryParameter qp, Map<String, QueryParameter> map,
Map<String, Serializable> vals) throws Exception {
Map<String, Object> objVals = new HashMap<String, Object>();
for (String key : vals.keySet()) {
Serializable s = vals.get(key);
if (s instanceof Serializable[]) {
Serializable[] array = (Serializable[]) s;
Object[] objArray = new Object[array.length];
for (int i = 0, size = array.length; i < size; i++) {
objArray[i] = array[i];
}
s = objArray;
}
objVals.put(key, s);
}
QueryExecutor executor = null;
try {
List<IdName> values = new ArrayList<IdName>();
Query query = new Query(qp.getSource());
executor = new QueryExecutor(query, map, objVals, con, false, false, false);
executor.setTimeout(10000);
executor.setMaxRows(0);
QueryResult qr = executor.execute();
//int count = qr.getRowCount();
// one or two columns in manual select source
//for (int i = 0; i < count; i++) {
while (qr.hasNext()) {
IdName in = new IdName();
in.setId((Serializable) qr.nextValue(0));
if (qr.getColumnCount() == 1) {
in.setName((Serializable) qr.nextValue(0));
} else {
in.setName((Serializable) qr.nextValue(1));
}
values.add(in);
}
return values;
} catch (Exception ex) {
ex.printStackTrace();
throw new Exception(ex);
} finally {
if (executor != null) {
executor.close();
}
}
} | [
"public",
"static",
"List",
"<",
"IdName",
">",
"getParameterValues",
"(",
"Connection",
"con",
",",
"QueryParameter",
"qp",
",",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"map",
",",
"Map",
"<",
"String",
",",
"Serializable",
">",
"vals",
")",
"th... | Get values for a dependent parameter sql
All parent parameters must have the values in the map.
@param con database connection
@param qp parameter
@param map report map of parameters
@param vals map of parameter values
@return values for parameter with sql source
@throws Exception if an exception occurs | [
"Get",
"values",
"for",
"a",
"dependent",
"parameter",
"sql",
"All",
"parent",
"parameters",
"must",
"have",
"the",
"values",
"in",
"the",
"map",
"."
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L418-L467 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.getDefaultSourceValues | public static ArrayList<Serializable> getDefaultSourceValues(Connection con, QueryParameter qp) throws Exception {
ArrayList<Serializable> result = new ArrayList<Serializable>();
List<IdName> list = getSelectValues(con, qp.getDefaultSource(), false, QueryParameter.NO_ORDER);
if (QueryParameter.SINGLE_SELECTION.equals(qp.getSelection())) {
for (IdName in : list) {
result.add(in.getId());
}
} else {
for (IdName in : list) {
result.add(in);
}
}
return result;
} | java | public static ArrayList<Serializable> getDefaultSourceValues(Connection con, QueryParameter qp) throws Exception {
ArrayList<Serializable> result = new ArrayList<Serializable>();
List<IdName> list = getSelectValues(con, qp.getDefaultSource(), false, QueryParameter.NO_ORDER);
if (QueryParameter.SINGLE_SELECTION.equals(qp.getSelection())) {
for (IdName in : list) {
result.add(in.getId());
}
} else {
for (IdName in : list) {
result.add(in);
}
}
return result;
} | [
"public",
"static",
"ArrayList",
"<",
"Serializable",
">",
"getDefaultSourceValues",
"(",
"Connection",
"con",
",",
"QueryParameter",
"qp",
")",
"throws",
"Exception",
"{",
"ArrayList",
"<",
"Serializable",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"Serializabl... | Get values for a default source
@param con connection
@param qp parameter
@return a list of default values
@throws Exception if select failes | [
"Get",
"values",
"for",
"a",
"default",
"source"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L477-L490 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.getUsedNotHiddenParametersMap | public static Map<String, QueryParameter> getUsedNotHiddenParametersMap(Report report) {
return getUsedParametersMap(report, false, false);
} | java | public static Map<String, QueryParameter> getUsedNotHiddenParametersMap(Report report) {
return getUsedParametersMap(report, false, false);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"getUsedNotHiddenParametersMap",
"(",
"Report",
"report",
")",
"{",
"return",
"getUsedParametersMap",
"(",
"report",
",",
"false",
",",
"false",
")",
";",
"}"
] | Get used parameters map where the key is the parameter name and the value is the parameter
Not all the report parameters have to be used, some may only be defined for further usage.
The result will not contain the hidden parameters.
@param report next report object
@return used not-hidden parameters map | [
"Get",
"used",
"parameters",
"map",
"where",
"the",
"key",
"is",
"the",
"parameter",
"name",
"and",
"the",
"value",
"is",
"the",
"parameter",
"Not",
"all",
"the",
"report",
"parameters",
"have",
"to",
"be",
"used",
"some",
"may",
"only",
"be",
"defined",
... | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L655-L657 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.getUsedHiddenParametersMap | public static Map<String, QueryParameter> getUsedHiddenParametersMap(Report report) {
return getUsedParametersMap(report, false, true);
} | java | public static Map<String, QueryParameter> getUsedHiddenParametersMap(Report report) {
return getUsedParametersMap(report, false, true);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"getUsedHiddenParametersMap",
"(",
"Report",
"report",
")",
"{",
"return",
"getUsedParametersMap",
"(",
"report",
",",
"false",
",",
"true",
")",
";",
"}"
] | Get used hidden parameters map where the key is the parameter name and the value is the parameter
Not all the report parameters have to be used, some may only be defined for further usage.
The result will contain only the hidden parameters.
@param report next report object
@return used hidden parameters map | [
"Get",
"used",
"hidden",
"parameters",
"map",
"where",
"the",
"key",
"is",
"the",
"parameter",
"name",
"and",
"the",
"value",
"is",
"the",
"parameter",
"Not",
"all",
"the",
"report",
"parameters",
"have",
"to",
"be",
"used",
"some",
"may",
"only",
"be",
... | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L667-L669 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.getUsedParametersMap | public static Map<String, QueryParameter> getUsedParametersMap(Query query, Map<String, QueryParameter> allParameters) {
Set<String> paramNames = new HashSet<String>(Arrays.asList(query.getParameterNames()));
for (QueryParameter p : allParameters.values()) {
paramNames.addAll(p.getDependentParameterNames());
}
LinkedHashMap<String, QueryParameter> params = new LinkedHashMap<String, QueryParameter>();
for (String name : allParameters.keySet()) {
boolean found = false;
for (String pName : paramNames) {
if (pName.equals(name)) {
found = true;
break;
}
}
QueryParameter qp = allParameters.get(name);
if (found || qp.isHidden()) {
params.put(name, qp);
}
}
return params;
} | java | public static Map<String, QueryParameter> getUsedParametersMap(Query query, Map<String, QueryParameter> allParameters) {
Set<String> paramNames = new HashSet<String>(Arrays.asList(query.getParameterNames()));
for (QueryParameter p : allParameters.values()) {
paramNames.addAll(p.getDependentParameterNames());
}
LinkedHashMap<String, QueryParameter> params = new LinkedHashMap<String, QueryParameter>();
for (String name : allParameters.keySet()) {
boolean found = false;
for (String pName : paramNames) {
if (pName.equals(name)) {
found = true;
break;
}
}
QueryParameter qp = allParameters.get(name);
if (found || qp.isHidden()) {
params.put(name, qp);
}
}
return params;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"getUsedParametersMap",
"(",
"Query",
"query",
",",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"allParameters",
")",
"{",
"Set",
"<",
"String",
">",
"paramNames",
"=",
"new",
"HashS... | Get used parameters map where the key is the parameter name and the value is the parameter
Not all the report parameters have to be used, some may only be defined for further usage.
The result will contain also the hidden parameters and all parameters used just inside other parameters.
@param query query object
@param allParameters parameters map
@return used parameters map | [
"Get",
"used",
"parameters",
"map",
"where",
"the",
"key",
"is",
"the",
"parameter",
"name",
"and",
"the",
"value",
"is",
"the",
"parameter",
"Not",
"all",
"the",
"report",
"parameters",
"have",
"to",
"be",
"used",
"some",
"may",
"only",
"be",
"defined",
... | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L729-L749 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.getUsedParametersMap | public static Map<String, QueryParameter> getUsedParametersMap(String sql, Map<String, QueryParameter> allParameters) {
Query query = new Query(sql);
return getUsedParametersMap(query, allParameters);
} | java | public static Map<String, QueryParameter> getUsedParametersMap(String sql, Map<String, QueryParameter> allParameters) {
Query query = new Query(sql);
return getUsedParametersMap(query, allParameters);
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"getUsedParametersMap",
"(",
"String",
"sql",
",",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"allParameters",
")",
"{",
"Query",
"query",
"=",
"new",
"Query",
"(",
"sql",
")",
";... | Get used parameters map where the key is the parameter name and the value is the parameter
Not all the report parameters have to be used, some may only be defined for further usage.
The result will contain also the hidden parameters.
@param sql sql
@param allParameters parameters map
@return used parameters map | [
"Get",
"used",
"parameters",
"map",
"where",
"the",
"key",
"is",
"the",
"parameter",
"name",
"and",
"the",
"value",
"is",
"the",
"parameter",
"Not",
"all",
"the",
"report",
"parameters",
"have",
"to",
"be",
"used",
"some",
"may",
"only",
"be",
"defined",
... | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L789-L792 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.allParametersAreHidden | public static boolean allParametersAreHidden(Map<String, QueryParameter> map) {
for (QueryParameter qp : map.values()) {
if (!qp.isHidden()) {
return false;
}
}
return true;
} | java | public static boolean allParametersAreHidden(Map<String, QueryParameter> map) {
for (QueryParameter qp : map.values()) {
if (!qp.isHidden()) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"allParametersAreHidden",
"(",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"map",
")",
"{",
"for",
"(",
"QueryParameter",
"qp",
":",
"map",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"!",
"qp",
".",
"isHidden",
"... | See if all parameters are hidden
@param map map of parameters
@return true if all parameters are hidden | [
"See",
"if",
"all",
"parameters",
"are",
"hidden"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L801-L808 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.allParametersHaveDefaults | public static boolean allParametersHaveDefaults(Map<String, QueryParameter> map) {
for (QueryParameter qp : map.values()) {
if ((qp.getDefaultValues() == null) || (qp.getDefaultValues().size() == 0)) {
if ((qp.getDefaultSource() == null) || "".equals(qp.getDefaultSource().trim())) {
return false;
}
}
}
return true;
} | java | public static boolean allParametersHaveDefaults(Map<String, QueryParameter> map) {
for (QueryParameter qp : map.values()) {
if ((qp.getDefaultValues() == null) || (qp.getDefaultValues().size() == 0)) {
if ((qp.getDefaultSource() == null) || "".equals(qp.getDefaultSource().trim())) {
return false;
}
}
}
return true;
} | [
"public",
"static",
"boolean",
"allParametersHaveDefaults",
"(",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"map",
")",
"{",
"for",
"(",
"QueryParameter",
"qp",
":",
"map",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"(",
"qp",
".",
"getDefaultV... | See if all parameters have default values
@param map map of parameters
@return true if all parameters have default values | [
"See",
"if",
"all",
"parameters",
"have",
"default",
"values"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L816-L825 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.initAllRuntimeParameterValues | public static void initAllRuntimeParameterValues(QueryParameter param,
List<IdName> values, Map<String, Object> parameterValues) throws QueryException {
if (param.getSelection().equals(QueryParameter.SINGLE_SELECTION)) {
parameterValues.put(param.getName(), values.get(0));
} else {
Object[] val = new Object[values.size()];
for (int k = 0, size = values.size(); k < size; k++) {
val[k] = values.get(k);
}
parameterValues.put(param.getName(), val);
}
} | java | public static void initAllRuntimeParameterValues(QueryParameter param,
List<IdName> values, Map<String, Object> parameterValues) throws QueryException {
if (param.getSelection().equals(QueryParameter.SINGLE_SELECTION)) {
parameterValues.put(param.getName(), values.get(0));
} else {
Object[] val = new Object[values.size()];
for (int k = 0, size = values.size(); k < size; k++) {
val[k] = values.get(k);
}
parameterValues.put(param.getName(), val);
}
} | [
"public",
"static",
"void",
"initAllRuntimeParameterValues",
"(",
"QueryParameter",
"param",
",",
"List",
"<",
"IdName",
">",
"values",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"parameterValues",
")",
"throws",
"QueryException",
"{",
"if",
"(",
"param",
... | Init parameter values map with all the values
@param param parameter
@param values all parameter values
@param parameterValues map of parameter values
@throws QueryException if could not get parameter values | [
"Init",
"parameter",
"values",
"map",
"with",
"all",
"the",
"values"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L835-L847 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.initDefaultParameterValues | public static void initDefaultParameterValues(QueryParameter param,
List<Serializable> defValues, Map<String, Object> parameterValues) throws QueryException {
if (param.getSelection().equals(QueryParameter.SINGLE_SELECTION)) {
parameterValues.put(param.getName(), defValues.get(0));
} else {
Object[] val = new Object[defValues.size()];
for (int k = 0, size = defValues.size(); k < size; k++) {
val[k] = defValues.get(k);
}
parameterValues.put(param.getName(), val);
}
} | java | public static void initDefaultParameterValues(QueryParameter param,
List<Serializable> defValues, Map<String, Object> parameterValues) throws QueryException {
if (param.getSelection().equals(QueryParameter.SINGLE_SELECTION)) {
parameterValues.put(param.getName(), defValues.get(0));
} else {
Object[] val = new Object[defValues.size()];
for (int k = 0, size = defValues.size(); k < size; k++) {
val[k] = defValues.get(k);
}
parameterValues.put(param.getName(), val);
}
} | [
"public",
"static",
"void",
"initDefaultParameterValues",
"(",
"QueryParameter",
"param",
",",
"List",
"<",
"Serializable",
">",
"defValues",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"parameterValues",
")",
"throws",
"QueryException",
"{",
"if",
"(",
"para... | Init parameter values map with the default values
@param param parameter
@param defValues default values
@param parameterValues map of parameter values
@throws QueryException if could not get default parameter values | [
"Init",
"parameter",
"values",
"map",
"with",
"the",
"default",
"values"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L857-L869 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.initStaticDefaultParameterValues | public static void initStaticDefaultParameterValues(QueryParameter param,
Map<String, Object> parameterValues) throws QueryException {
List<Serializable> defValues;
if ((param.getDefaultValues() != null) && (param.getDefaultValues().size() > 0)) {
defValues = param.getDefaultValues();
} else {
throw new QueryException(
"Invalid use of method initStaticDefaultParameterValues : no static values for parameter "
+ param.getName());
}
initDefaultParameterValues(param, defValues, parameterValues);
} | java | public static void initStaticDefaultParameterValues(QueryParameter param,
Map<String, Object> parameterValues) throws QueryException {
List<Serializable> defValues;
if ((param.getDefaultValues() != null) && (param.getDefaultValues().size() > 0)) {
defValues = param.getDefaultValues();
} else {
throw new QueryException(
"Invalid use of method initStaticDefaultParameterValues : no static values for parameter "
+ param.getName());
}
initDefaultParameterValues(param, defValues, parameterValues);
} | [
"public",
"static",
"void",
"initStaticDefaultParameterValues",
"(",
"QueryParameter",
"param",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"parameterValues",
")",
"throws",
"QueryException",
"{",
"List",
"<",
"Serializable",
">",
"defValues",
";",
"if",
"(",
... | Init parameter values map with the static default values of a parameter
@param param parameter
@param parameterValues map of parameter values
@throws QueryException if could not get default parameter values | [
"Init",
"parameter",
"values",
"map",
"with",
"the",
"static",
"default",
"values",
"of",
"a",
"parameter"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L900-L911 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.initAllRuntimeParameterValues | public static void initAllRuntimeParameterValues(Connection conn, QueryParameter param, Map<String,QueryParameter> map,
Map<String, Object> parameterValues) throws QueryException {
List<IdName> allValues = new ArrayList<IdName>();
if ((param.getSource() != null) && (!param.getSource().trim().equals(""))) {
try {
allValues = ParameterUtil.getRuntimeParameterValues(conn, param, map, parameterValues);
} catch (Exception e) {
throw new QueryException(e);
}
}
initAllRuntimeParameterValues(param, allValues, parameterValues);
} | java | public static void initAllRuntimeParameterValues(Connection conn, QueryParameter param, Map<String,QueryParameter> map,
Map<String, Object> parameterValues) throws QueryException {
List<IdName> allValues = new ArrayList<IdName>();
if ((param.getSource() != null) && (!param.getSource().trim().equals(""))) {
try {
allValues = ParameterUtil.getRuntimeParameterValues(conn, param, map, parameterValues);
} catch (Exception e) {
throw new QueryException(e);
}
}
initAllRuntimeParameterValues(param, allValues, parameterValues);
} | [
"public",
"static",
"void",
"initAllRuntimeParameterValues",
"(",
"Connection",
"conn",
",",
"QueryParameter",
"param",
",",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"map",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"parameterValues",
")",
"throws",... | Init parameter values map with all the values from select source of a parameter at runtime
@param conn database connection
@param param parameter
@param map report map of parameters
@param parameterValues map of parameter values
@throws QueryException if could not get parameter values | [
"Init",
"parameter",
"values",
"map",
"with",
"all",
"the",
"values",
"from",
"select",
"source",
"of",
"a",
"parameter",
"at",
"runtime"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L945-L957 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.initStaticNotHiddenDefaultParameterValues | public static void initStaticNotHiddenDefaultParameterValues(Report report,
Map<String, Object> parameterValues) throws QueryException {
Map<String, QueryParameter> params = getUsedParametersMap(report);
for (QueryParameter qp : params.values()) {
if (!qp.isHidden()) {
initStaticDefaultParameterValues(qp, parameterValues);
}
}
} | java | public static void initStaticNotHiddenDefaultParameterValues(Report report,
Map<String, Object> parameterValues) throws QueryException {
Map<String, QueryParameter> params = getUsedParametersMap(report);
for (QueryParameter qp : params.values()) {
if (!qp.isHidden()) {
initStaticDefaultParameterValues(qp, parameterValues);
}
}
} | [
"public",
"static",
"void",
"initStaticNotHiddenDefaultParameterValues",
"(",
"Report",
"report",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"parameterValues",
")",
"throws",
"QueryException",
"{",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"params",
"=... | Init parameter values map with the static default values for all not-hidden parameters of a report
@param report report
@param parameterValues map of parameter values
@throws QueryException if could not get default parameter values | [
"Init",
"parameter",
"values",
"map",
"with",
"the",
"static",
"default",
"values",
"for",
"all",
"not",
"-",
"hidden",
"parameters",
"of",
"a",
"report"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L989-L997 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.toMap | public static Map<String, QueryParameter> toMap(List<QueryParameter> parameters) {
Map<String, QueryParameter> map = new HashMap<String, QueryParameter>();
for (QueryParameter qp : parameters) {
map.put(qp.getName(), qp);
}
return map;
} | java | public static Map<String, QueryParameter> toMap(List<QueryParameter> parameters) {
Map<String, QueryParameter> map = new HashMap<String, QueryParameter>();
for (QueryParameter qp : parameters) {
map.put(qp.getName(), qp);
}
return map;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"toMap",
"(",
"List",
"<",
"QueryParameter",
">",
"parameters",
")",
"{",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"QueryParame... | Convert a list of QueryParameter object to a map where the key is the parameter name
and the value is the parameter
@param parameters list of parameters
@return map of parameters | [
"Convert",
"a",
"list",
"of",
"QueryParameter",
"object",
"to",
"a",
"map",
"where",
"the",
"key",
"is",
"the",
"parameter",
"name",
"and",
"the",
"value",
"is",
"the",
"parameter"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L1040-L1046 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.getParameterValueFromStringWithPattern | public static Object getParameterValueFromStringWithPattern(String parameterClass, String value, String pattern) throws Exception {
if (pattern == null) {
return getParameterValueFromString(parameterClass, value);
} else {
if (QueryParameter.DATE_VALUE.equals(parameterClass) ||
QueryParameter.TIME_VALUE.equals(parameterClass) ||
QueryParameter.TIMESTAMP_VALUE.equals(parameterClass)) {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return getParameterValueFromString(parameterClass, value, sdf);
} else {
return getParameterValueFromString(parameterClass, value);
}
}
} | java | public static Object getParameterValueFromStringWithPattern(String parameterClass, String value, String pattern) throws Exception {
if (pattern == null) {
return getParameterValueFromString(parameterClass, value);
} else {
if (QueryParameter.DATE_VALUE.equals(parameterClass) ||
QueryParameter.TIME_VALUE.equals(parameterClass) ||
QueryParameter.TIMESTAMP_VALUE.equals(parameterClass)) {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return getParameterValueFromString(parameterClass, value, sdf);
} else {
return getParameterValueFromString(parameterClass, value);
}
}
} | [
"public",
"static",
"Object",
"getParameterValueFromStringWithPattern",
"(",
"String",
"parameterClass",
",",
"String",
"value",
",",
"String",
"pattern",
")",
"throws",
"Exception",
"{",
"if",
"(",
"pattern",
"==",
"null",
")",
"{",
"return",
"getParameterValueFrom... | Get parameter value from a string represenation using a pattern
@param parameterClass parameter class
@param value string value representation
@param pattern value pattern
@return parameter value from string representation using pattern
@throws Exception if string value cannot be parse | [
"Get",
"parameter",
"value",
"from",
"a",
"string",
"represenation",
"using",
"a",
"pattern"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L1067-L1081 | train |
nextreports/nextreports-engine | src/ro/nextreports/engine/util/ParameterUtil.java | ParameterUtil.intersectParametersMap | public static Map<String, QueryParameter> intersectParametersMap(List<Report> reports) {
Map<String, QueryParameter> map = new LinkedHashMap<String, QueryParameter>();
if ((reports == null) || (reports.size() == 0)) {
return map;
}
if (reports.size() == 1) {
return getUsedParametersMap(reports.get(0), false, false);
}
Map<String, QueryParameter> firstParamMap = getUsedParametersMap(reports.get(0), false, false);
Map<String, QueryParameter> secondParamMap = getUsedParametersMap(reports.get(1), false, false);
map = intersectParametersMap(firstParamMap, secondParamMap);
for (int i=2, n=reports.size(); i<n; i++) {
Map<String, QueryParameter> paramMap = getUsedParametersMap(reports.get(i), false, false);
map = intersectParametersMap(map, paramMap);
if (map.size() == 0) {
break;
}
}
return map;
} | java | public static Map<String, QueryParameter> intersectParametersMap(List<Report> reports) {
Map<String, QueryParameter> map = new LinkedHashMap<String, QueryParameter>();
if ((reports == null) || (reports.size() == 0)) {
return map;
}
if (reports.size() == 1) {
return getUsedParametersMap(reports.get(0), false, false);
}
Map<String, QueryParameter> firstParamMap = getUsedParametersMap(reports.get(0), false, false);
Map<String, QueryParameter> secondParamMap = getUsedParametersMap(reports.get(1), false, false);
map = intersectParametersMap(firstParamMap, secondParamMap);
for (int i=2, n=reports.size(); i<n; i++) {
Map<String, QueryParameter> paramMap = getUsedParametersMap(reports.get(i), false, false);
map = intersectParametersMap(map, paramMap);
if (map.size() == 0) {
break;
}
}
return map;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"intersectParametersMap",
"(",
"List",
"<",
"Report",
">",
"reports",
")",
"{",
"Map",
"<",
"String",
",",
"QueryParameter",
">",
"map",
"=",
"new",
"LinkedHashMap",
"<",
"String",
",",
... | Get a map with all the identical parameters for a list of reports
@param reports list of reports
@return a map with all the identical parameters for a list of reports
see QueryParameter.compare(Object o) | [
"Get",
"a",
"map",
"with",
"all",
"the",
"identical",
"parameters",
"for",
"a",
"list",
"of",
"reports"
] | a847575a9298b5fce63b88961190c5b83ddccc44 | https://github.com/nextreports/nextreports-engine/blob/a847575a9298b5fce63b88961190c5b83ddccc44/src/ro/nextreports/engine/util/ParameterUtil.java#L1158-L1178 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/CollapsibleList.java | CollapsibleList.addSection | public int addSection (String label, ListModel model)
{
add(new JLabel(label));
add(new JList(model));
return getSectionCount()-1;
} | java | public int addSection (String label, ListModel model)
{
add(new JLabel(label));
add(new JList(model));
return getSectionCount()-1;
} | [
"public",
"int",
"addSection",
"(",
"String",
"label",
",",
"ListModel",
"model",
")",
"{",
"add",
"(",
"new",
"JLabel",
"(",
"label",
")",
")",
";",
"add",
"(",
"new",
"JList",
"(",
"model",
")",
")",
";",
"return",
"getSectionCount",
"(",
")",
"-",... | Adds a section to this collapsible list.
@param label the title of the section.
@param model the list model to use for the new section.
@return the index of the newly added section. | [
"Adds",
"a",
"section",
"to",
"this",
"collapsible",
"list",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/CollapsibleList.java#L64-L69 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/CollapsibleList.java | CollapsibleList.getSectionList | public JList getSectionList (int index)
{
@SuppressWarnings("unchecked") JList list = (JList)getComponent(index*2+1);
return list;
} | java | public JList getSectionList (int index)
{
@SuppressWarnings("unchecked") JList list = (JList)getComponent(index*2+1);
return list;
} | [
"public",
"JList",
"getSectionList",
"(",
"int",
"index",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"JList",
"list",
"=",
"(",
"JList",
")",
"getComponent",
"(",
"index",
"*",
"2",
"+",
"1",
")",
";",
"return",
"list",
";",
"}"
] | Returns the list object associated with the specified section. | [
"Returns",
"the",
"list",
"object",
"associated",
"with",
"the",
"specified",
"section",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/CollapsibleList.java#L83-L87 | train |
samskivert/samskivert | src/main/java/com/samskivert/swing/CollapsibleList.java | CollapsibleList.toggleCollapsed | public void toggleCollapsed (int index)
{
JList list = getSectionList(index);
list.setVisible(!list.isVisible());
} | java | public void toggleCollapsed (int index)
{
JList list = getSectionList(index);
list.setVisible(!list.isVisible());
} | [
"public",
"void",
"toggleCollapsed",
"(",
"int",
"index",
")",
"{",
"JList",
"list",
"=",
"getSectionList",
"(",
"index",
")",
";",
"list",
".",
"setVisible",
"(",
"!",
"list",
".",
"isVisible",
"(",
")",
")",
";",
"}"
] | Toggles the collapsed state of the specified section. | [
"Toggles",
"the",
"collapsed",
"state",
"of",
"the",
"specified",
"section",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/swing/CollapsibleList.java#L92-L96 | train |
samskivert/samskivert | src/main/java/com/samskivert/util/MethodFinder.java | MethodFinder.findConstructor | public Constructor<?> findConstructor (Class<?>[] parameterTypes)
throws NoSuchMethodException
{
// make sure the constructor list is loaded
maybeLoadConstructors();
if (parameterTypes == null) {
parameterTypes = new Class<?>[0];
}
return (Constructor<?>)findMemberIn(_ctorList, parameterTypes);
} | java | public Constructor<?> findConstructor (Class<?>[] parameterTypes)
throws NoSuchMethodException
{
// make sure the constructor list is loaded
maybeLoadConstructors();
if (parameterTypes == null) {
parameterTypes = new Class<?>[0];
}
return (Constructor<?>)findMemberIn(_ctorList, parameterTypes);
} | [
"public",
"Constructor",
"<",
"?",
">",
"findConstructor",
"(",
"Class",
"<",
"?",
">",
"[",
"]",
"parameterTypes",
")",
"throws",
"NoSuchMethodException",
"{",
"// make sure the constructor list is loaded",
"maybeLoadConstructors",
"(",
")",
";",
"if",
"(",
"parame... | Returns the most specific public constructor in my target class that accepts the number and
type of parameters in the given Class array in a reflective invocation.
<p> A null value or Void.TYPE parameterTypes matches a corresponding Object or array
reference in a constructor's formal parameter list, but not a primitive formal parameter.
@param parameterTypes array representing the number and types of parameters to look for in
the constructor's signature. A null array is treated as a zero-length array.
@return Constructor object satisfying the conditions.
@exception NoSuchMethodException if no constructors match the criteria, or if the reflective
call is ambiguous based on the parameter types. | [
"Returns",
"the",
"most",
"specific",
"public",
"constructor",
"in",
"my",
"target",
"class",
"that",
"accepts",
"the",
"number",
"and",
"type",
"of",
"parameters",
"in",
"the",
"given",
"Class",
"array",
"in",
"a",
"reflective",
"invocation",
"."
] | a64d9ef42b69819bdb2c66bddac6a64caef928b6 | https://github.com/samskivert/samskivert/blob/a64d9ef42b69819bdb2c66bddac6a64caef928b6/src/main/java/com/samskivert/util/MethodFinder.java#L80-L91 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.