id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
1,200 | alrocar/POIProxy | es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java | CsvReader.get | public String get(int columnIndex) throws IOException {
checkClosed();
if (columnIndex > -1 && columnIndex < columnsCount) {
return values[columnIndex];
} else {
return "";
}
} | java | public String get(int columnIndex) throws IOException {
checkClosed();
if (columnIndex > -1 && columnIndex < columnsCount) {
return values[columnIndex];
} else {
return "";
}
} | [
"public",
"String",
"get",
"(",
"int",
"columnIndex",
")",
"throws",
"IOException",
"{",
"checkClosed",
"(",
")",
";",
"if",
"(",
"columnIndex",
">",
"-",
"1",
"&&",
"columnIndex",
"<",
"columnsCount",
")",
"{",
"return",
"values",
"[",
"columnIndex",
"]",
";",
"}",
"else",
"{",
"return",
"\"\"",
";",
"}",
"}"
] | Returns the current column value for a given column index.
@param columnIndex
The index of the column.
@return The current column value.
@exception IOException
Thrown if this object has already been closed. | [
"Returns",
"the",
"current",
"column",
"value",
"for",
"a",
"given",
"column",
"index",
"."
] | e1dabe738a862478b2580e90d5fc4209a2997868 | https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java#L535-L543 |
1,201 | alrocar/POIProxy | es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java | CsvReader.readHeaders | public boolean readHeaders() throws IOException {
boolean result = readRecord();
// copy the header data from the column array
// to the header string array
headersHolder.Length = columnsCount;
headersHolder.Headers = new String[columnsCount];
for (int i = 0; i < headersHolder.Length; i++) {
String columnValue = get(i);
headersHolder.Headers[i] = columnValue;
// if there are duplicate header names, we will save the last one
headersHolder.IndexByName.put(columnValue, new Integer(i));
}
if (result) {
currentRecord--;
}
columnsCount = 0;
return result;
} | java | public boolean readHeaders() throws IOException {
boolean result = readRecord();
// copy the header data from the column array
// to the header string array
headersHolder.Length = columnsCount;
headersHolder.Headers = new String[columnsCount];
for (int i = 0; i < headersHolder.Length; i++) {
String columnValue = get(i);
headersHolder.Headers[i] = columnValue;
// if there are duplicate header names, we will save the last one
headersHolder.IndexByName.put(columnValue, new Integer(i));
}
if (result) {
currentRecord--;
}
columnsCount = 0;
return result;
} | [
"public",
"boolean",
"readHeaders",
"(",
")",
"throws",
"IOException",
"{",
"boolean",
"result",
"=",
"readRecord",
"(",
")",
";",
"// copy the header data from the column array",
"// to the header string array",
"headersHolder",
".",
"Length",
"=",
"columnsCount",
";",
"headersHolder",
".",
"Headers",
"=",
"new",
"String",
"[",
"columnsCount",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"headersHolder",
".",
"Length",
";",
"i",
"++",
")",
"{",
"String",
"columnValue",
"=",
"get",
"(",
"i",
")",
";",
"headersHolder",
".",
"Headers",
"[",
"i",
"]",
"=",
"columnValue",
";",
"// if there are duplicate header names, we will save the last one",
"headersHolder",
".",
"IndexByName",
".",
"put",
"(",
"columnValue",
",",
"new",
"Integer",
"(",
"i",
")",
")",
";",
"}",
"if",
"(",
"result",
")",
"{",
"currentRecord",
"--",
";",
"}",
"columnsCount",
"=",
"0",
";",
"return",
"result",
";",
"}"
] | Read the first record of data as column headers.
@return Whether the header record was successfully read or not.
@exception IOException
Thrown if an error occurs while reading data from the
source stream. | [
"Read",
"the",
"first",
"record",
"of",
"data",
"as",
"column",
"headers",
"."
] | e1dabe738a862478b2580e90d5fc4209a2997868 | https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java#L1223-L1249 |
1,202 | alrocar/POIProxy | es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java | CsvReader.getHeader | public String getHeader(int columnIndex) throws IOException {
checkClosed();
// check to see if we have read the header record yet
// check to see if the column index is within the bounds
// of our header array
if (columnIndex > -1 && columnIndex < headersHolder.Length) {
// return the processed header data for this column
return headersHolder.Headers[columnIndex];
} else {
return "";
}
} | java | public String getHeader(int columnIndex) throws IOException {
checkClosed();
// check to see if we have read the header record yet
// check to see if the column index is within the bounds
// of our header array
if (columnIndex > -1 && columnIndex < headersHolder.Length) {
// return the processed header data for this column
return headersHolder.Headers[columnIndex];
} else {
return "";
}
} | [
"public",
"String",
"getHeader",
"(",
"int",
"columnIndex",
")",
"throws",
"IOException",
"{",
"checkClosed",
"(",
")",
";",
"// check to see if we have read the header record yet",
"// check to see if the column index is within the bounds",
"// of our header array",
"if",
"(",
"columnIndex",
">",
"-",
"1",
"&&",
"columnIndex",
"<",
"headersHolder",
".",
"Length",
")",
"{",
"// return the processed header data for this column",
"return",
"headersHolder",
".",
"Headers",
"[",
"columnIndex",
"]",
";",
"}",
"else",
"{",
"return",
"\"\"",
";",
"}",
"}"
] | Returns the column header value for a given column index.
@param columnIndex
The index of the header column being requested.
@return The value of the column header at the given column index.
@exception IOException
Thrown if this object has already been closed. | [
"Returns",
"the",
"column",
"header",
"value",
"for",
"a",
"given",
"column",
"index",
"."
] | e1dabe738a862478b2580e90d5fc4209a2997868 | https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java#L1260-L1275 |
1,203 | alrocar/POIProxy | es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java | CsvReader.getIndex | public int getIndex(String headerName) throws IOException {
checkClosed();
Object indexValue = headersHolder.IndexByName.get(headerName);
if (indexValue != null) {
return ((Integer) indexValue).intValue();
} else {
return -1;
}
} | java | public int getIndex(String headerName) throws IOException {
checkClosed();
Object indexValue = headersHolder.IndexByName.get(headerName);
if (indexValue != null) {
return ((Integer) indexValue).intValue();
} else {
return -1;
}
} | [
"public",
"int",
"getIndex",
"(",
"String",
"headerName",
")",
"throws",
"IOException",
"{",
"checkClosed",
"(",
")",
";",
"Object",
"indexValue",
"=",
"headersHolder",
".",
"IndexByName",
".",
"get",
"(",
"headerName",
")",
";",
"if",
"(",
"indexValue",
"!=",
"null",
")",
"{",
"return",
"(",
"(",
"Integer",
")",
"indexValue",
")",
".",
"intValue",
"(",
")",
";",
"}",
"else",
"{",
"return",
"-",
"1",
";",
"}",
"}"
] | Gets the corresponding column index for a given column header name.
@param headerName
The header name of the column.
@return The column index for the given column header name. Returns
-1 if not found.
@exception IOException
Thrown if this object has already been closed. | [
"Gets",
"the",
"corresponding",
"column",
"index",
"for",
"a",
"given",
"column",
"header",
"name",
"."
] | e1dabe738a862478b2580e90d5fc4209a2997868 | https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java#L1443-L1453 |
1,204 | alrocar/POIProxy | es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java | CsvReader.skipLine | public boolean skipLine() throws IOException {
checkClosed();
// clear public column values for current line
columnsCount = 0;
boolean skippedLine = false;
if (hasMoreData) {
boolean foundEol = false;
do {
if (dataBuffer.Position == dataBuffer.Count) {
checkDataLength();
} else {
skippedLine = true;
// grab the current letter as a char
char currentLetter = dataBuffer.Buffer[dataBuffer.Position];
if (currentLetter == Letters.CR
|| currentLetter == Letters.LF) {
foundEol = true;
}
// keep track of the last letter because we need
// it for several key decisions
lastLetter = currentLetter;
if (!foundEol) {
dataBuffer.Position++;
}
} // end else
} while (hasMoreData && !foundEol);
columnBuffer.Position = 0;
dataBuffer.LineStart = dataBuffer.Position + 1;
}
rawBuffer.Position = 0;
rawRecord = "";
return skippedLine;
} | java | public boolean skipLine() throws IOException {
checkClosed();
// clear public column values for current line
columnsCount = 0;
boolean skippedLine = false;
if (hasMoreData) {
boolean foundEol = false;
do {
if (dataBuffer.Position == dataBuffer.Count) {
checkDataLength();
} else {
skippedLine = true;
// grab the current letter as a char
char currentLetter = dataBuffer.Buffer[dataBuffer.Position];
if (currentLetter == Letters.CR
|| currentLetter == Letters.LF) {
foundEol = true;
}
// keep track of the last letter because we need
// it for several key decisions
lastLetter = currentLetter;
if (!foundEol) {
dataBuffer.Position++;
}
} // end else
} while (hasMoreData && !foundEol);
columnBuffer.Position = 0;
dataBuffer.LineStart = dataBuffer.Position + 1;
}
rawBuffer.Position = 0;
rawRecord = "";
return skippedLine;
} | [
"public",
"boolean",
"skipLine",
"(",
")",
"throws",
"IOException",
"{",
"checkClosed",
"(",
")",
";",
"// clear public column values for current line",
"columnsCount",
"=",
"0",
";",
"boolean",
"skippedLine",
"=",
"false",
";",
"if",
"(",
"hasMoreData",
")",
"{",
"boolean",
"foundEol",
"=",
"false",
";",
"do",
"{",
"if",
"(",
"dataBuffer",
".",
"Position",
"==",
"dataBuffer",
".",
"Count",
")",
"{",
"checkDataLength",
"(",
")",
";",
"}",
"else",
"{",
"skippedLine",
"=",
"true",
";",
"// grab the current letter as a char",
"char",
"currentLetter",
"=",
"dataBuffer",
".",
"Buffer",
"[",
"dataBuffer",
".",
"Position",
"]",
";",
"if",
"(",
"currentLetter",
"==",
"Letters",
".",
"CR",
"||",
"currentLetter",
"==",
"Letters",
".",
"LF",
")",
"{",
"foundEol",
"=",
"true",
";",
"}",
"// keep track of the last letter because we need",
"// it for several key decisions",
"lastLetter",
"=",
"currentLetter",
";",
"if",
"(",
"!",
"foundEol",
")",
"{",
"dataBuffer",
".",
"Position",
"++",
";",
"}",
"}",
"// end else",
"}",
"while",
"(",
"hasMoreData",
"&&",
"!",
"foundEol",
")",
";",
"columnBuffer",
".",
"Position",
"=",
"0",
";",
"dataBuffer",
".",
"LineStart",
"=",
"dataBuffer",
".",
"Position",
"+",
"1",
";",
"}",
"rawBuffer",
".",
"Position",
"=",
"0",
";",
"rawRecord",
"=",
"\"\"",
";",
"return",
"skippedLine",
";",
"}"
] | Skips the next line of data using the standard end of line characters and
does not do any column delimited parsing.
@return Whether a line was successfully skipped or not.
@exception IOException
Thrown if an error occurs while reading data from the
source stream. | [
"Skips",
"the",
"next",
"line",
"of",
"data",
"using",
"the",
"standard",
"end",
"of",
"line",
"characters",
"and",
"does",
"not",
"do",
"any",
"column",
"delimited",
"parsing",
"."
] | e1dabe738a862478b2580e90d5fc4209a2997868 | https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/csv/CsvReader.java#L1490-L1538 |
1,205 | alrocar/POIProxy | es.alrocar.poiproxy/src/main/java/es/alrocar/jpe/parser/JPEParser.java | JPEParser.transform | public double[] transform(String from, String to, double[] xy) {
return GeotoolsUtils.transform(from, to, xy);
} | java | public double[] transform(String from, String to, double[] xy) {
return GeotoolsUtils.transform(from, to, xy);
} | [
"public",
"double",
"[",
"]",
"transform",
"(",
"String",
"from",
",",
"String",
"to",
",",
"double",
"[",
"]",
"xy",
")",
"{",
"return",
"GeotoolsUtils",
".",
"transform",
"(",
"from",
",",
"to",
",",
"xy",
")",
";",
"}"
] | Transform a pair of coordinates from a SRS to another expressed as EPSG
codes
@param from
The EPSG code of the source SRS
@param to
The EPSG code of the destination SRS
@param xy
The pair of coordinates (x,y) or (lon,lat)
@return | [
"Transform",
"a",
"pair",
"of",
"coordinates",
"from",
"a",
"SRS",
"to",
"another",
"expressed",
"as",
"EPSG",
"codes"
] | e1dabe738a862478b2580e90d5fc4209a2997868 | https://github.com/alrocar/POIProxy/blob/e1dabe738a862478b2580e90d5fc4209a2997868/es.alrocar.poiproxy/src/main/java/es/alrocar/jpe/parser/JPEParser.java#L105-L107 |
1,206 | maddingo/sojo | src/main/java/net/sf/sojo/core/reflect/ReflectionFieldHelper.java | ReflectionFieldHelper.getAllFieldsByClassIntern | private static Map<Object, Object> getAllFieldsByClassIntern (Class<?> pvClass, Map<Object, Object> pvFieldsMap) {
putAllFieldsIntern( pvClass.getFields(), pvFieldsMap) ;
putAllFieldsIntern( pvClass.getDeclaredFields(), pvFieldsMap);
if (!(pvClass.getSuperclass().equals(Object.class))) {
getAllFieldsByClassIntern(pvClass.getSuperclass(), pvFieldsMap);
}
return pvFieldsMap;
} | java | private static Map<Object, Object> getAllFieldsByClassIntern (Class<?> pvClass, Map<Object, Object> pvFieldsMap) {
putAllFieldsIntern( pvClass.getFields(), pvFieldsMap) ;
putAllFieldsIntern( pvClass.getDeclaredFields(), pvFieldsMap);
if (!(pvClass.getSuperclass().equals(Object.class))) {
getAllFieldsByClassIntern(pvClass.getSuperclass(), pvFieldsMap);
}
return pvFieldsMap;
} | [
"private",
"static",
"Map",
"<",
"Object",
",",
"Object",
">",
"getAllFieldsByClassIntern",
"(",
"Class",
"<",
"?",
">",
"pvClass",
",",
"Map",
"<",
"Object",
",",
"Object",
">",
"pvFieldsMap",
")",
"{",
"putAllFieldsIntern",
"(",
"pvClass",
".",
"getFields",
"(",
")",
",",
"pvFieldsMap",
")",
";",
"putAllFieldsIntern",
"(",
"pvClass",
".",
"getDeclaredFields",
"(",
")",
",",
"pvFieldsMap",
")",
";",
"if",
"(",
"!",
"(",
"pvClass",
".",
"getSuperclass",
"(",
")",
".",
"equals",
"(",
"Object",
".",
"class",
")",
")",
")",
"{",
"getAllFieldsByClassIntern",
"(",
"pvClass",
".",
"getSuperclass",
"(",
")",
",",
"pvFieldsMap",
")",
";",
"}",
"return",
"pvFieldsMap",
";",
"}"
] | Recursive search all methods from the Class in the Class Hierarchy to Object class.
@param pvClass Search class.
@param pvFieldsMap Method map (key=property name, value=method).
@return All fields found. | [
"Recursive",
"search",
"all",
"methods",
"from",
"the",
"Class",
"in",
"the",
"Class",
"Hierarchy",
"to",
"Object",
"class",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/core/reflect/ReflectionFieldHelper.java#L82-L90 |
1,207 | maddingo/sojo | src/main/java/net/sf/sojo/common/ObjectUtil.java | ObjectUtil.copy | public Object copy(final Object pvRootObject) {
Object lvSimple = makeSimple(pvRootObject);
Object lvComplex = makeComplex(lvSimple);
return lvComplex;
} | java | public Object copy(final Object pvRootObject) {
Object lvSimple = makeSimple(pvRootObject);
Object lvComplex = makeComplex(lvSimple);
return lvComplex;
} | [
"public",
"Object",
"copy",
"(",
"final",
"Object",
"pvRootObject",
")",
"{",
"Object",
"lvSimple",
"=",
"makeSimple",
"(",
"pvRootObject",
")",
";",
"Object",
"lvComplex",
"=",
"makeComplex",
"(",
"lvSimple",
")",
";",
"return",
"lvComplex",
";",
"}"
] | Copy of all values of the root object.
@param pvRootObject Source object, that will be copy.
@return The copy of the source object. | [
"Copy",
"of",
"all",
"values",
"of",
"the",
"root",
"object",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/common/ObjectUtil.java#L202-L206 |
1,208 | maddingo/sojo | src/main/java/net/sf/sojo/common/ObjectUtil.java | ObjectUtil.compare | public CompareResult compare(final Object pvObject1, final Object pvObject2) {
CompareResult[] lvCompareResults = null;
lvCompareResults = compareIntern(pvObject1, pvObject2, true);
CompareResult lvResult = (lvCompareResults == null ? null : lvCompareResults[0]);
return lvResult;
} | java | public CompareResult compare(final Object pvObject1, final Object pvObject2) {
CompareResult[] lvCompareResults = null;
lvCompareResults = compareIntern(pvObject1, pvObject2, true);
CompareResult lvResult = (lvCompareResults == null ? null : lvCompareResults[0]);
return lvResult;
} | [
"public",
"CompareResult",
"compare",
"(",
"final",
"Object",
"pvObject1",
",",
"final",
"Object",
"pvObject2",
")",
"{",
"CompareResult",
"[",
"]",
"lvCompareResults",
"=",
"null",
";",
"lvCompareResults",
"=",
"compareIntern",
"(",
"pvObject1",
",",
"pvObject2",
",",
"true",
")",
";",
"CompareResult",
"lvResult",
"=",
"(",
"lvCompareResults",
"==",
"null",
"?",
"null",
":",
"lvCompareResults",
"[",
"0",
"]",
")",
";",
"return",
"lvResult",
";",
"}"
] | Compare and is stopped by find the first different value.
@param pvObject1 To comparing first value.
@param pvObject2 To comparing second value.
@return The different betwenn Object1 and Object2, or <code>null</code> if equals. | [
"Compare",
"and",
"is",
"stopped",
"by",
"find",
"the",
"first",
"different",
"value",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/common/ObjectUtil.java#L252-L257 |
1,209 | svenkubiak/mangooio-mongodb-extension | src/main/java/de/svenkubiak/mangooio/mongodb/MongoDB.java | MongoDB.findById | public <T extends Object> T findById(Object id, Class<T> clazz) {
Preconditions.checkNotNull(clazz, "Tryed to find an object by id, but given class is null");
Preconditions.checkNotNull(id, "Tryed to find an object by id, but given id is null");
return this.datastore.get(clazz, (id instanceof ObjectId) ? id : new ObjectId(String.valueOf(id)));
} | java | public <T extends Object> T findById(Object id, Class<T> clazz) {
Preconditions.checkNotNull(clazz, "Tryed to find an object by id, but given class is null");
Preconditions.checkNotNull(id, "Tryed to find an object by id, but given id is null");
return this.datastore.get(clazz, (id instanceof ObjectId) ? id : new ObjectId(String.valueOf(id)));
} | [
"public",
"<",
"T",
"extends",
"Object",
">",
"T",
"findById",
"(",
"Object",
"id",
",",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"clazz",
",",
"\"Tryed to find an object by id, but given class is null\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"id",
",",
"\"Tryed to find an object by id, but given id is null\"",
")",
";",
"return",
"this",
".",
"datastore",
".",
"get",
"(",
"clazz",
",",
"(",
"id",
"instanceof",
"ObjectId",
")",
"?",
"id",
":",
"new",
"ObjectId",
"(",
"String",
".",
"valueOf",
"(",
"id",
")",
")",
")",
";",
"}"
] | Retrieves a mapped Morphia object from MongoDB. If the id is not of
type ObjectId, it will be converted to ObjectId
@param id The id of the object
@param clazz The mapped Morphia class
@param <T> JavaDoc requires this - please ignore
@return The requested class from MongoDB or null if none found | [
"Retrieves",
"a",
"mapped",
"Morphia",
"object",
"from",
"MongoDB",
".",
"If",
"the",
"id",
"is",
"not",
"of",
"type",
"ObjectId",
"it",
"will",
"be",
"converted",
"to",
"ObjectId"
] | 4a281b63c20cdbb4b82c4c0d100726ec464bfa12 | https://github.com/svenkubiak/mangooio-mongodb-extension/blob/4a281b63c20cdbb4b82c4c0d100726ec464bfa12/src/main/java/de/svenkubiak/mangooio/mongodb/MongoDB.java#L128-L133 |
1,210 | svenkubiak/mangooio-mongodb-extension | src/main/java/de/svenkubiak/mangooio/mongodb/MongoDB.java | MongoDB.findAll | public <T extends Object> List<T> findAll(Class<T> clazz) {
Preconditions.checkNotNull(clazz, "Tryed to get all morphia objects of a given object, but given object is null");
return this.datastore.find(clazz).asList();
} | java | public <T extends Object> List<T> findAll(Class<T> clazz) {
Preconditions.checkNotNull(clazz, "Tryed to get all morphia objects of a given object, but given object is null");
return this.datastore.find(clazz).asList();
} | [
"public",
"<",
"T",
"extends",
"Object",
">",
"List",
"<",
"T",
">",
"findAll",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"clazz",
",",
"\"Tryed to get all morphia objects of a given object, but given object is null\"",
")",
";",
"return",
"this",
".",
"datastore",
".",
"find",
"(",
"clazz",
")",
".",
"asList",
"(",
")",
";",
"}"
] | Retrieves a list of mapped Morphia objects from MongoDB
@param clazz The mapped Morphia class
@param <T> JavaDoc requires this - please ignore
@return A list of mapped Morphia objects or an empty list if none found | [
"Retrieves",
"a",
"list",
"of",
"mapped",
"Morphia",
"objects",
"from",
"MongoDB"
] | 4a281b63c20cdbb4b82c4c0d100726ec464bfa12 | https://github.com/svenkubiak/mangooio-mongodb-extension/blob/4a281b63c20cdbb4b82c4c0d100726ec464bfa12/src/main/java/de/svenkubiak/mangooio/mongodb/MongoDB.java#L143-L147 |
1,211 | svenkubiak/mangooio-mongodb-extension | src/main/java/de/svenkubiak/mangooio/mongodb/MongoDB.java | MongoDB.countAll | public <T extends Object> long countAll(Class<T> clazz) {
Preconditions.checkNotNull(clazz, "Tryed to count all a morphia objects of a given object, but given object is null");
return this.datastore.find(clazz).count();
} | java | public <T extends Object> long countAll(Class<T> clazz) {
Preconditions.checkNotNull(clazz, "Tryed to count all a morphia objects of a given object, but given object is null");
return this.datastore.find(clazz).count();
} | [
"public",
"<",
"T",
"extends",
"Object",
">",
"long",
"countAll",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"clazz",
",",
"\"Tryed to count all a morphia objects of a given object, but given object is null\"",
")",
";",
"return",
"this",
".",
"datastore",
".",
"find",
"(",
"clazz",
")",
".",
"count",
"(",
")",
";",
"}"
] | Counts all objected of a mapped Morphia class
@param clazz The mapped Morphia class
@param <T> JavaDoc requires this - please ignore
@return The number of objects in MongoDB | [
"Counts",
"all",
"objected",
"of",
"a",
"mapped",
"Morphia",
"class"
] | 4a281b63c20cdbb4b82c4c0d100726ec464bfa12 | https://github.com/svenkubiak/mangooio-mongodb-extension/blob/4a281b63c20cdbb4b82c4c0d100726ec464bfa12/src/main/java/de/svenkubiak/mangooio/mongodb/MongoDB.java#L157-L161 |
1,212 | svenkubiak/mangooio-mongodb-extension | src/main/java/de/svenkubiak/mangooio/mongodb/MongoDB.java | MongoDB.deleteAll | public <T extends Object> void deleteAll(Class<T> clazz) {
Preconditions.checkNotNull(clazz, "Tryed to delete list of mapped morphia objects, but given class is null");
this.datastore.delete(this.datastore.createQuery(clazz));
} | java | public <T extends Object> void deleteAll(Class<T> clazz) {
Preconditions.checkNotNull(clazz, "Tryed to delete list of mapped morphia objects, but given class is null");
this.datastore.delete(this.datastore.createQuery(clazz));
} | [
"public",
"<",
"T",
"extends",
"Object",
">",
"void",
"deleteAll",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"clazz",
",",
"\"Tryed to delete list of mapped morphia objects, but given class is null\"",
")",
";",
"this",
".",
"datastore",
".",
"delete",
"(",
"this",
".",
"datastore",
".",
"createQuery",
"(",
"clazz",
")",
")",
";",
"}"
] | Deletes all mapped Morphia objects of a given class
@param <T> JavaDoc requires this - please ignore
@param clazz The mapped Morphia class | [
"Deletes",
"all",
"mapped",
"Morphia",
"objects",
"of",
"a",
"given",
"class"
] | 4a281b63c20cdbb4b82c4c0d100726ec464bfa12 | https://github.com/svenkubiak/mangooio-mongodb-extension/blob/4a281b63c20cdbb4b82c4c0d100726ec464bfa12/src/main/java/de/svenkubiak/mangooio/mongodb/MongoDB.java#L191-L195 |
1,213 | maddingo/sojo | src/main/java/net/sf/sojo/core/reflect/ReflectionMethodHelper.java | ReflectionMethodHelper.getAllNotEqualsGetterAndSetterAndRemoveThisProperties | public static Map<Object, Object> getAllNotEqualsGetterAndSetterAndRemoveThisProperties(Map<Object, Object> pvGetterMap, Map<Object, Object> pvSetterMap) {
Map<Object, Object> lvMap = new TreeMap<Object, Object>();
Iterator<Object> it = new ArrayList<Object>(pvGetterMap.keySet()).iterator();
lvMap.put(Util.getKeyWordClass(), pvGetterMap.get(Util.getKeyWordClass()));
while (it.hasNext()) {
Object lvGetterProp = it.next();
if (pvSetterMap.containsKey(lvGetterProp)) {
lvMap.put(lvGetterProp, pvGetterMap.get(lvGetterProp));
}
}
return Collections.unmodifiableMap(lvMap);
} | java | public static Map<Object, Object> getAllNotEqualsGetterAndSetterAndRemoveThisProperties(Map<Object, Object> pvGetterMap, Map<Object, Object> pvSetterMap) {
Map<Object, Object> lvMap = new TreeMap<Object, Object>();
Iterator<Object> it = new ArrayList<Object>(pvGetterMap.keySet()).iterator();
lvMap.put(Util.getKeyWordClass(), pvGetterMap.get(Util.getKeyWordClass()));
while (it.hasNext()) {
Object lvGetterProp = it.next();
if (pvSetterMap.containsKey(lvGetterProp)) {
lvMap.put(lvGetterProp, pvGetterMap.get(lvGetterProp));
}
}
return Collections.unmodifiableMap(lvMap);
} | [
"public",
"static",
"Map",
"<",
"Object",
",",
"Object",
">",
"getAllNotEqualsGetterAndSetterAndRemoveThisProperties",
"(",
"Map",
"<",
"Object",
",",
"Object",
">",
"pvGetterMap",
",",
"Map",
"<",
"Object",
",",
"Object",
">",
"pvSetterMap",
")",
"{",
"Map",
"<",
"Object",
",",
"Object",
">",
"lvMap",
"=",
"new",
"TreeMap",
"<",
"Object",
",",
"Object",
">",
"(",
")",
";",
"Iterator",
"<",
"Object",
">",
"it",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
"pvGetterMap",
".",
"keySet",
"(",
")",
")",
".",
"iterator",
"(",
")",
";",
"lvMap",
".",
"put",
"(",
"Util",
".",
"getKeyWordClass",
"(",
")",
",",
"pvGetterMap",
".",
"get",
"(",
"Util",
".",
"getKeyWordClass",
"(",
")",
")",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"Object",
"lvGetterProp",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"pvSetterMap",
".",
"containsKey",
"(",
"lvGetterProp",
")",
")",
"{",
"lvMap",
".",
"put",
"(",
"lvGetterProp",
",",
"pvGetterMap",
".",
"get",
"(",
"lvGetterProp",
")",
")",
";",
"}",
"}",
"return",
"Collections",
".",
"unmodifiableMap",
"(",
"lvMap",
")",
";",
"}"
] | Remove all getter-method where no setter-method exist.
If more setter-method as getter-method, they wasn't removed. | [
"Remove",
"all",
"getter",
"-",
"method",
"where",
"no",
"setter",
"-",
"method",
"exist",
".",
"If",
"more",
"setter",
"-",
"method",
"as",
"getter",
"-",
"method",
"they",
"wasn",
"t",
"removed",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/core/reflect/ReflectionMethodHelper.java#L77-L88 |
1,214 | maddingo/sojo | src/main/java/net/sf/sojo/core/reflect/ReflectionMethodHelper.java | ReflectionMethodHelper.getAllGetterMethodWithCache | public static Map<Object, Object> getAllGetterMethodWithCache(Class<?> pvClass, String pvFilter[]) {
Map<Object, Object> lvGetterMap = classPropertiesCacheGetter.getClassPropertiesMapByClass(pvClass);
if (lvGetterMap == null) {
lvGetterMap = getAllGetterMethod(pvClass);
Map<Object, Object> lvSetterMap = getAllSetterMethodWithCache(pvClass, pvFilter);
lvGetterMap = getAllNotEqualsGetterAndSetterAndRemoveThisProperties (lvGetterMap, lvSetterMap);
classPropertiesCacheGetter.addClassPropertiesMap(pvClass, lvGetterMap);
}
return lvGetterMap;
} | java | public static Map<Object, Object> getAllGetterMethodWithCache(Class<?> pvClass, String pvFilter[]) {
Map<Object, Object> lvGetterMap = classPropertiesCacheGetter.getClassPropertiesMapByClass(pvClass);
if (lvGetterMap == null) {
lvGetterMap = getAllGetterMethod(pvClass);
Map<Object, Object> lvSetterMap = getAllSetterMethodWithCache(pvClass, pvFilter);
lvGetterMap = getAllNotEqualsGetterAndSetterAndRemoveThisProperties (lvGetterMap, lvSetterMap);
classPropertiesCacheGetter.addClassPropertiesMap(pvClass, lvGetterMap);
}
return lvGetterMap;
} | [
"public",
"static",
"Map",
"<",
"Object",
",",
"Object",
">",
"getAllGetterMethodWithCache",
"(",
"Class",
"<",
"?",
">",
"pvClass",
",",
"String",
"pvFilter",
"[",
"]",
")",
"{",
"Map",
"<",
"Object",
",",
"Object",
">",
"lvGetterMap",
"=",
"classPropertiesCacheGetter",
".",
"getClassPropertiesMapByClass",
"(",
"pvClass",
")",
";",
"if",
"(",
"lvGetterMap",
"==",
"null",
")",
"{",
"lvGetterMap",
"=",
"getAllGetterMethod",
"(",
"pvClass",
")",
";",
"Map",
"<",
"Object",
",",
"Object",
">",
"lvSetterMap",
"=",
"getAllSetterMethodWithCache",
"(",
"pvClass",
",",
"pvFilter",
")",
";",
"lvGetterMap",
"=",
"getAllNotEqualsGetterAndSetterAndRemoveThisProperties",
"(",
"lvGetterMap",
",",
"lvSetterMap",
")",
";",
"classPropertiesCacheGetter",
".",
"addClassPropertiesMap",
"(",
"pvClass",
",",
"lvGetterMap",
")",
";",
"}",
"return",
"lvGetterMap",
";",
"}"
] | Find all getter-method from a Class and remove all getter-method where no setter-method exist.
@param pvClass Class to anaylse.
@return Map from getter-method (key=property name, value=method). | [
"Find",
"all",
"getter",
"-",
"method",
"from",
"a",
"Class",
"and",
"remove",
"all",
"getter",
"-",
"method",
"where",
"no",
"setter",
"-",
"method",
"exist",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/core/reflect/ReflectionMethodHelper.java#L95-L104 |
1,215 | maddingo/sojo | src/main/java/net/sf/sojo/core/reflect/ReflectionMethodHelper.java | ReflectionMethodHelper.getAllSetterMethodWithCache | public static Map<Object, Object> getAllSetterMethodWithCache(Class<?> pvClass, String pvFilter[]) {
Map<Object, Object> lvMap = classPropertiesCacheSetter.getClassPropertiesMapByClass(pvClass);
if (lvMap == null) {
lvMap = getAllSetterMethod(pvClass);
classPropertiesCacheSetter.addClassPropertiesMap(pvClass, lvMap);
}
lvMap = Util.filterMapByKeys(lvMap, pvFilter);
return lvMap;
} | java | public static Map<Object, Object> getAllSetterMethodWithCache(Class<?> pvClass, String pvFilter[]) {
Map<Object, Object> lvMap = classPropertiesCacheSetter.getClassPropertiesMapByClass(pvClass);
if (lvMap == null) {
lvMap = getAllSetterMethod(pvClass);
classPropertiesCacheSetter.addClassPropertiesMap(pvClass, lvMap);
}
lvMap = Util.filterMapByKeys(lvMap, pvFilter);
return lvMap;
} | [
"public",
"static",
"Map",
"<",
"Object",
",",
"Object",
">",
"getAllSetterMethodWithCache",
"(",
"Class",
"<",
"?",
">",
"pvClass",
",",
"String",
"pvFilter",
"[",
"]",
")",
"{",
"Map",
"<",
"Object",
",",
"Object",
">",
"lvMap",
"=",
"classPropertiesCacheSetter",
".",
"getClassPropertiesMapByClass",
"(",
"pvClass",
")",
";",
"if",
"(",
"lvMap",
"==",
"null",
")",
"{",
"lvMap",
"=",
"getAllSetterMethod",
"(",
"pvClass",
")",
";",
"classPropertiesCacheSetter",
".",
"addClassPropertiesMap",
"(",
"pvClass",
",",
"lvMap",
")",
";",
"}",
"lvMap",
"=",
"Util",
".",
"filterMapByKeys",
"(",
"lvMap",
",",
"pvFilter",
")",
";",
"return",
"lvMap",
";",
"}"
] | Find all setter-method from a Class.
@param pvClass Class to analyse.
@return Map all setter-Method (key=property name, value=method). | [
"Find",
"all",
"setter",
"-",
"method",
"from",
"a",
"Class",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/core/reflect/ReflectionMethodHelper.java#L111-L119 |
1,216 | maddingo/sojo | src/main/java/net/sf/sojo/core/reflect/ReflectionMethodHelper.java | ReflectionMethodHelper.getAllMethodsByClassIntern | private static Collection<Method> getAllMethodsByClassIntern (Class<?> pvClass, Set<Method> pvMethodsMap) {
putAllMethodsIntern( pvClass.getMethods(), pvMethodsMap) ;
putAllMethodsIntern( pvClass.getDeclaredMethods(), pvMethodsMap);
if (!(pvClass.getSuperclass().equals(Object.class))) {
getAllMethodsByClassIntern(pvClass.getSuperclass(), pvMethodsMap);
}
return pvMethodsMap;
} | java | private static Collection<Method> getAllMethodsByClassIntern (Class<?> pvClass, Set<Method> pvMethodsMap) {
putAllMethodsIntern( pvClass.getMethods(), pvMethodsMap) ;
putAllMethodsIntern( pvClass.getDeclaredMethods(), pvMethodsMap);
if (!(pvClass.getSuperclass().equals(Object.class))) {
getAllMethodsByClassIntern(pvClass.getSuperclass(), pvMethodsMap);
}
return pvMethodsMap;
} | [
"private",
"static",
"Collection",
"<",
"Method",
">",
"getAllMethodsByClassIntern",
"(",
"Class",
"<",
"?",
">",
"pvClass",
",",
"Set",
"<",
"Method",
">",
"pvMethodsMap",
")",
"{",
"putAllMethodsIntern",
"(",
"pvClass",
".",
"getMethods",
"(",
")",
",",
"pvMethodsMap",
")",
";",
"putAllMethodsIntern",
"(",
"pvClass",
".",
"getDeclaredMethods",
"(",
")",
",",
"pvMethodsMap",
")",
";",
"if",
"(",
"!",
"(",
"pvClass",
".",
"getSuperclass",
"(",
")",
".",
"equals",
"(",
"Object",
".",
"class",
")",
")",
")",
"{",
"getAllMethodsByClassIntern",
"(",
"pvClass",
".",
"getSuperclass",
"(",
")",
",",
"pvMethodsMap",
")",
";",
"}",
"return",
"pvMethodsMap",
";",
"}"
] | Recursive search all method from the Class in the Class Hierarchy to Object.class.
@param pvClass Search class.
@param pvMethodsMap Set of Methods.
@return All methods found. | [
"Recursive",
"search",
"all",
"method",
"from",
"the",
"Class",
"in",
"the",
"Class",
"Hierarchy",
"to",
"Object",
".",
"class",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/core/reflect/ReflectionMethodHelper.java#L137-L146 |
1,217 | maddingo/sojo | src/main/java/net/sf/sojo/util/Table.java | Table.getColumnNames | public String getColumnNames() {
StringBuffer sb = new StringBuffer();
int lvSize = columnNames.size();
for (int i=0;i<lvSize; i++) {
sb.append(columnNames.get(i));
if (i < (lvSize-1)) {
sb.append(getDelimiter());
}
}
return sb.toString();
} | java | public String getColumnNames() {
StringBuffer sb = new StringBuffer();
int lvSize = columnNames.size();
for (int i=0;i<lvSize; i++) {
sb.append(columnNames.get(i));
if (i < (lvSize-1)) {
sb.append(getDelimiter());
}
}
return sb.toString();
} | [
"public",
"String",
"getColumnNames",
"(",
")",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"int",
"lvSize",
"=",
"columnNames",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lvSize",
";",
"i",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"columnNames",
".",
"get",
"(",
"i",
")",
")",
";",
"if",
"(",
"i",
"<",
"(",
"lvSize",
"-",
"1",
")",
")",
"{",
"sb",
".",
"append",
"(",
"getDelimiter",
"(",
")",
")",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Get all column - names as String, separated with a selected delimiter.
@return All column - names as String. | [
"Get",
"all",
"column",
"-",
"names",
"as",
"String",
"separated",
"with",
"a",
"selected",
"delimiter",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/util/Table.java#L161-L171 |
1,218 | maddingo/sojo | src/main/java/net/sf/sojo/util/Table.java | Table.row2String | public String row2String(int pvRow) {
StringBuffer sb = new StringBuffer();
List<?> lvColumn = rows.get(pvRow);
int lvSize = lvColumn.size();
for (int i=0;i<lvSize; i++) {
sb.append(lvColumn.get(i));
if (i < (lvSize-1)) {
sb.append(getDelimiter());
}
}
return sb.toString();
} | java | public String row2String(int pvRow) {
StringBuffer sb = new StringBuffer();
List<?> lvColumn = rows.get(pvRow);
int lvSize = lvColumn.size();
for (int i=0;i<lvSize; i++) {
sb.append(lvColumn.get(i));
if (i < (lvSize-1)) {
sb.append(getDelimiter());
}
}
return sb.toString();
} | [
"public",
"String",
"row2String",
"(",
"int",
"pvRow",
")",
"{",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"List",
"<",
"?",
">",
"lvColumn",
"=",
"rows",
".",
"get",
"(",
"pvRow",
")",
";",
"int",
"lvSize",
"=",
"lvColumn",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lvSize",
";",
"i",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"lvColumn",
".",
"get",
"(",
"i",
")",
")",
";",
"if",
"(",
"i",
"<",
"(",
"lvSize",
"-",
"1",
")",
")",
"{",
"sb",
".",
"append",
"(",
"getDelimiter",
"(",
")",
")",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Convert a row of the table in a String,
where the every column is seperated with a delimiter.
@param pvRow Number of row.
@return The row as String. | [
"Convert",
"a",
"row",
"of",
"the",
"table",
"in",
"a",
"String",
"where",
"the",
"every",
"column",
"is",
"seperated",
"with",
"a",
"delimiter",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/util/Table.java#L179-L190 |
1,219 | maddingo/sojo | src/main/java/net/sf/sojo/core/reflect/Property.java | Property.executeSetValue | public void executeSetValue(Object pvObject, Object pvArgs) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
AccessController.doPrivileged(new AccessiblePrivilegedAction(accessibleObject));
if (propertyType == PROPERTY_TYPE_METHOD) {
((Method) accessibleObject).invoke(pvObject, new Object[] { pvArgs });
} else {
((Field) accessibleObject).set(pvObject, pvArgs);
}
} | java | public void executeSetValue(Object pvObject, Object pvArgs) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
AccessController.doPrivileged(new AccessiblePrivilegedAction(accessibleObject));
if (propertyType == PROPERTY_TYPE_METHOD) {
((Method) accessibleObject).invoke(pvObject, new Object[] { pvArgs });
} else {
((Field) accessibleObject).set(pvObject, pvArgs);
}
} | [
"public",
"void",
"executeSetValue",
"(",
"Object",
"pvObject",
",",
"Object",
"pvArgs",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"AccessiblePrivilegedAction",
"(",
"accessibleObject",
")",
")",
";",
"if",
"(",
"propertyType",
"==",
"PROPERTY_TYPE_METHOD",
")",
"{",
"(",
"(",
"Method",
")",
"accessibleObject",
")",
".",
"invoke",
"(",
"pvObject",
",",
"new",
"Object",
"[",
"]",
"{",
"pvArgs",
"}",
")",
";",
"}",
"else",
"{",
"(",
"(",
"Field",
")",
"accessibleObject",
")",
".",
"set",
"(",
"pvObject",
",",
"pvArgs",
")",
";",
"}",
"}"
] | Call the setter Method or set value from Field.
@param pvObject Object, on which the value is set
@param pvArgs the set value | [
"Call",
"the",
"setter",
"Method",
"or",
"set",
"value",
"from",
"Field",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/core/reflect/Property.java#L58-L65 |
1,220 | maddingo/sojo | src/main/java/net/sf/sojo/core/reflect/Property.java | Property.executeGetValue | public Object executeGetValue(Object pvObject) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Object lvReturnValue = null;
AccessController.doPrivileged(new AccessiblePrivilegedAction(accessibleObject));
if (propertyType == PROPERTY_TYPE_METHOD) {
lvReturnValue = ((Method) accessibleObject).invoke(pvObject);
} else {
lvReturnValue = ((Field) accessibleObject).get(pvObject);
}
return lvReturnValue;
} | java | public Object executeGetValue(Object pvObject) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
Object lvReturnValue = null;
AccessController.doPrivileged(new AccessiblePrivilegedAction(accessibleObject));
if (propertyType == PROPERTY_TYPE_METHOD) {
lvReturnValue = ((Method) accessibleObject).invoke(pvObject);
} else {
lvReturnValue = ((Field) accessibleObject).get(pvObject);
}
return lvReturnValue;
} | [
"public",
"Object",
"executeGetValue",
"(",
"Object",
"pvObject",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"Object",
"lvReturnValue",
"=",
"null",
";",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"AccessiblePrivilegedAction",
"(",
"accessibleObject",
")",
")",
";",
"if",
"(",
"propertyType",
"==",
"PROPERTY_TYPE_METHOD",
")",
"{",
"lvReturnValue",
"=",
"(",
"(",
"Method",
")",
"accessibleObject",
")",
".",
"invoke",
"(",
"pvObject",
")",
";",
"}",
"else",
"{",
"lvReturnValue",
"=",
"(",
"(",
"Field",
")",
"accessibleObject",
")",
".",
"get",
"(",
"pvObject",
")",
";",
"}",
"return",
"lvReturnValue",
";",
"}"
] | Call the getter Method or get value from Field.
@param pvObject Object, on which the value is get | [
"Call",
"the",
"getter",
"Method",
"or",
"get",
"value",
"from",
"Field",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/core/reflect/Property.java#L73-L82 |
1,221 | maddingo/sojo | src/main/java/net/sf/sojo/core/filter/ClassPropertyFilterHelper.java | ClassPropertyFilterHelper.isPropertyToFiltering | public static boolean isPropertyToFiltering (ClassPropertyFilterHandler pvClassPropertyFilterHandler, Class<?> pvClassForFindFilter, Object pvKey) {
boolean lvAddProperty = false;
if (pvClassPropertyFilterHandler != null) {
ClassPropertyFilter lvClassPropertyFilter = pvClassPropertyFilterHandler.getClassPropertyFilterByClass(pvClassForFindFilter);
String lvKey = (pvKey == null ? null : pvKey.toString());
if (lvClassPropertyFilter != null && lvClassPropertyFilter.isKnownProperty(lvKey) == true) {
lvAddProperty = true;
}
}
return lvAddProperty;
} | java | public static boolean isPropertyToFiltering (ClassPropertyFilterHandler pvClassPropertyFilterHandler, Class<?> pvClassForFindFilter, Object pvKey) {
boolean lvAddProperty = false;
if (pvClassPropertyFilterHandler != null) {
ClassPropertyFilter lvClassPropertyFilter = pvClassPropertyFilterHandler.getClassPropertyFilterByClass(pvClassForFindFilter);
String lvKey = (pvKey == null ? null : pvKey.toString());
if (lvClassPropertyFilter != null && lvClassPropertyFilter.isKnownProperty(lvKey) == true) {
lvAddProperty = true;
}
}
return lvAddProperty;
} | [
"public",
"static",
"boolean",
"isPropertyToFiltering",
"(",
"ClassPropertyFilterHandler",
"pvClassPropertyFilterHandler",
",",
"Class",
"<",
"?",
">",
"pvClassForFindFilter",
",",
"Object",
"pvKey",
")",
"{",
"boolean",
"lvAddProperty",
"=",
"false",
";",
"if",
"(",
"pvClassPropertyFilterHandler",
"!=",
"null",
")",
"{",
"ClassPropertyFilter",
"lvClassPropertyFilter",
"=",
"pvClassPropertyFilterHandler",
".",
"getClassPropertyFilterByClass",
"(",
"pvClassForFindFilter",
")",
";",
"String",
"lvKey",
"=",
"(",
"pvKey",
"==",
"null",
"?",
"null",
":",
"pvKey",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"lvClassPropertyFilter",
"!=",
"null",
"&&",
"lvClassPropertyFilter",
".",
"isKnownProperty",
"(",
"lvKey",
")",
"==",
"true",
")",
"{",
"lvAddProperty",
"=",
"true",
";",
"}",
"}",
"return",
"lvAddProperty",
";",
"}"
] | Check a property from a class by a handler.
@param pvClassPropertyFilterHandler The handler implementation.
@param pvClassForFindFilter The class for the filter.
@param pvKey The to filtering property.
@return <code>true</code>, if the property from the class is known by the handler, else <code>false</code>. | [
"Check",
"a",
"property",
"from",
"a",
"class",
"by",
"a",
"handler",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/core/filter/ClassPropertyFilterHelper.java#L37-L47 |
1,222 | maddingo/sojo | src/main/java/net/sf/sojo/core/ConversionIterator.java | ConversionIterator.fireBeforeConvertRecursion | private ConversionContext fireBeforeConvertRecursion(int pvNumberOfIteration, Object pvKey, Object pvValue) {
ConversionContext lvContext = new ConversionContext(pvNumberOfIteration, pvKey, pvValue);
getConverterInterceptorHandler().fireBeforeConvertRecursion(lvContext);
return lvContext;
} | java | private ConversionContext fireBeforeConvertRecursion(int pvNumberOfIteration, Object pvKey, Object pvValue) {
ConversionContext lvContext = new ConversionContext(pvNumberOfIteration, pvKey, pvValue);
getConverterInterceptorHandler().fireBeforeConvertRecursion(lvContext);
return lvContext;
} | [
"private",
"ConversionContext",
"fireBeforeConvertRecursion",
"(",
"int",
"pvNumberOfIteration",
",",
"Object",
"pvKey",
",",
"Object",
"pvValue",
")",
"{",
"ConversionContext",
"lvContext",
"=",
"new",
"ConversionContext",
"(",
"pvNumberOfIteration",
",",
"pvKey",
",",
"pvValue",
")",
";",
"getConverterInterceptorHandler",
"(",
")",
".",
"fireBeforeConvertRecursion",
"(",
"lvContext",
")",
";",
"return",
"lvContext",
";",
"}"
] | Create a new ConversionContext and fire "before convert recursion" event.
@param pvNumberOfIteration Counter for the number of recursion.
@param pvKey The key can be the key by the <code>Map</code> or the property name by a JavaBean.
@param pvValue The value is the map-value or the value in a list or the property-value from a JavaBean.
@return New ConversionContext. | [
"Create",
"a",
"new",
"ConversionContext",
"and",
"fire",
"before",
"convert",
"recursion",
"event",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/core/ConversionIterator.java#L146-L150 |
1,223 | maddingo/sojo | src/main/java/net/sf/sojo/core/ConversionIterator.java | ConversionIterator.fireAfterConvertRecursion | private ConversionContext fireAfterConvertRecursion(final ConversionContext pvContext, Object pvKey, Object pvValue) {
pvContext.key = pvKey;
pvContext.value = pvValue;
getConverterInterceptorHandler().fireAfterConvertRecursion(pvContext);
return pvContext;
} | java | private ConversionContext fireAfterConvertRecursion(final ConversionContext pvContext, Object pvKey, Object pvValue) {
pvContext.key = pvKey;
pvContext.value = pvValue;
getConverterInterceptorHandler().fireAfterConvertRecursion(pvContext);
return pvContext;
} | [
"private",
"ConversionContext",
"fireAfterConvertRecursion",
"(",
"final",
"ConversionContext",
"pvContext",
",",
"Object",
"pvKey",
",",
"Object",
"pvValue",
")",
"{",
"pvContext",
".",
"key",
"=",
"pvKey",
";",
"pvContext",
".",
"value",
"=",
"pvValue",
";",
"getConverterInterceptorHandler",
"(",
")",
".",
"fireAfterConvertRecursion",
"(",
"pvContext",
")",
";",
"return",
"pvContext",
";",
"}"
] | Get a ConversionContext and fire "after convert recursion" event.
@param pvContext The ConversionContext.
@param pvKey The key can be the key by the <code>Map</code> or the property name by a JavaBean.
@param pvValue The value is the map-value or the value in a list or the property-value from a JavaBean.
@return The ConversionContext with new or old keys and values. | [
"Get",
"a",
"ConversionContext",
"and",
"fire",
"after",
"convert",
"recursion",
"event",
"."
] | 99e9e0a146b502deb7f507fe0623227402ed675b | https://github.com/maddingo/sojo/blob/99e9e0a146b502deb7f507fe0623227402ed675b/src/main/java/net/sf/sojo/core/ConversionIterator.java#L160-L165 |
1,224 | mojohaus/properties-maven-plugin | src/main/java/org/codehaus/mojo/properties/ReadPropertiesMojo.java | ReadPropertiesMojo.setUrls | public void setUrls( String[] urls )
{
if ( urls == null )
{
this.urls = null;
}
else
{
this.urls = new String[urls.length];
System.arraycopy( urls, 0, this.urls, 0, urls.length );
}
} | java | public void setUrls( String[] urls )
{
if ( urls == null )
{
this.urls = null;
}
else
{
this.urls = new String[urls.length];
System.arraycopy( urls, 0, this.urls, 0, urls.length );
}
} | [
"public",
"void",
"setUrls",
"(",
"String",
"[",
"]",
"urls",
")",
"{",
"if",
"(",
"urls",
"==",
"null",
")",
"{",
"this",
".",
"urls",
"=",
"null",
";",
"}",
"else",
"{",
"this",
".",
"urls",
"=",
"new",
"String",
"[",
"urls",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"urls",
",",
"0",
",",
"this",
".",
"urls",
",",
"0",
",",
"urls",
".",
"length",
")",
";",
"}",
"}"
] | Default scope for test access.
@param urls The URLs to set for tests. | [
"Default",
"scope",
"for",
"test",
"access",
"."
] | ff13d4be71fab374c271a337b2cf6d0e7d0d3d20 | https://github.com/mojohaus/properties-maven-plugin/blob/ff13d4be71fab374c271a337b2cf6d0e7d0d3d20/src/main/java/org/codehaus/mojo/properties/ReadPropertiesMojo.java#L92-L103 |
1,225 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountManager.java | AccountManager.exist | public boolean exist(String name, boolean bankAccount) {
String newName = name;
if (!Common.getInstance().getMainConfig().getBoolean("System.Case-sentitive")) {
newName = name.toLowerCase();
}
boolean result;
if (bankAccount) {
result = bankList.containsKey(newName);
if (!result) {
result = Common.getInstance().getStorageHandler().getStorageEngine().accountExist(newName, bankAccount);
}
} else {
result = accountList.containsKey(newName);
if (!result) {
result = Common.getInstance().getStorageHandler().getStorageEngine().accountExist(newName, bankAccount);
}
}
return result;
} | java | public boolean exist(String name, boolean bankAccount) {
String newName = name;
if (!Common.getInstance().getMainConfig().getBoolean("System.Case-sentitive")) {
newName = name.toLowerCase();
}
boolean result;
if (bankAccount) {
result = bankList.containsKey(newName);
if (!result) {
result = Common.getInstance().getStorageHandler().getStorageEngine().accountExist(newName, bankAccount);
}
} else {
result = accountList.containsKey(newName);
if (!result) {
result = Common.getInstance().getStorageHandler().getStorageEngine().accountExist(newName, bankAccount);
}
}
return result;
} | [
"public",
"boolean",
"exist",
"(",
"String",
"name",
",",
"boolean",
"bankAccount",
")",
"{",
"String",
"newName",
"=",
"name",
";",
"if",
"(",
"!",
"Common",
".",
"getInstance",
"(",
")",
".",
"getMainConfig",
"(",
")",
".",
"getBoolean",
"(",
"\"System.Case-sentitive\"",
")",
")",
"{",
"newName",
"=",
"name",
".",
"toLowerCase",
"(",
")",
";",
"}",
"boolean",
"result",
";",
"if",
"(",
"bankAccount",
")",
"{",
"result",
"=",
"bankList",
".",
"containsKey",
"(",
"newName",
")",
";",
"if",
"(",
"!",
"result",
")",
"{",
"result",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"accountExist",
"(",
"newName",
",",
"bankAccount",
")",
";",
"}",
"}",
"else",
"{",
"result",
"=",
"accountList",
".",
"containsKey",
"(",
"newName",
")",
";",
"if",
"(",
"!",
"result",
")",
"{",
"result",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"accountExist",
"(",
"newName",
",",
"bankAccount",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Check if a account exist in the database.
@param name The name to check
@param bankAccount If the account is a bank account
@return True if the account exists else false | [
"Check",
"if",
"a",
"account",
"exist",
"in",
"the",
"database",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountManager.java#L80-L98 |
1,226 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountManager.java | AccountManager.delete | public boolean delete(String name, boolean bankAccount) {
boolean result = false;
if (exist(name, bankAccount)) {
result = Common.getInstance().getStorageHandler().getStorageEngine().deleteAccount(name, bankAccount);
if (bankAccount) {
bankList.remove(name);
} else {
accountList.remove(name);
}
}
return result;
} | java | public boolean delete(String name, boolean bankAccount) {
boolean result = false;
if (exist(name, bankAccount)) {
result = Common.getInstance().getStorageHandler().getStorageEngine().deleteAccount(name, bankAccount);
if (bankAccount) {
bankList.remove(name);
} else {
accountList.remove(name);
}
}
return result;
} | [
"public",
"boolean",
"delete",
"(",
"String",
"name",
",",
"boolean",
"bankAccount",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"exist",
"(",
"name",
",",
"bankAccount",
")",
")",
"{",
"result",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"deleteAccount",
"(",
"name",
",",
"bankAccount",
")",
";",
"if",
"(",
"bankAccount",
")",
"{",
"bankList",
".",
"remove",
"(",
"name",
")",
";",
"}",
"else",
"{",
"accountList",
".",
"remove",
"(",
"name",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Delete a account from the system
@param name The account name
@param bankAccount If the account is a bank account
@return True if the account has been deleted. Else false. | [
"Delete",
"a",
"account",
"from",
"the",
"system"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountManager.java#L115-L126 |
1,227 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountManager.java | AccountManager.getAllAccounts | public List<String> getAllAccounts(boolean bank) {
return Common.getInstance().getStorageHandler().getStorageEngine().getAllAccounts(bank);
} | java | public List<String> getAllAccounts(boolean bank) {
return Common.getInstance().getStorageHandler().getStorageEngine().getAllAccounts(bank);
} | [
"public",
"List",
"<",
"String",
">",
"getAllAccounts",
"(",
"boolean",
"bank",
")",
"{",
"return",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"getAllAccounts",
"(",
"bank",
")",
";",
"}"
] | Retrieve a list of all the accounts
@param bank If we want a bank list or not
@return A List of accounts | [
"Retrieve",
"a",
"list",
"of",
"all",
"the",
"accounts"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountManager.java#L141-L143 |
1,228 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/converter/converters/Iconomy6.java | Iconomy6.loadFile | private boolean loadFile() {
boolean result = false;
File dbFile = new File(Common.getInstance().getServerCaller().getDataFolder(), getDbConnectInfo().get("filename"));
if (dbFile.exists()) {
try {
flatFileReader = new BufferedReader(new FileReader(dbFile));
result = true;
} catch (FileNotFoundException e) {
Common.getInstance().getLogger().severe("iConomy database file not found!");
}
}
return result;
} | java | private boolean loadFile() {
boolean result = false;
File dbFile = new File(Common.getInstance().getServerCaller().getDataFolder(), getDbConnectInfo().get("filename"));
if (dbFile.exists()) {
try {
flatFileReader = new BufferedReader(new FileReader(dbFile));
result = true;
} catch (FileNotFoundException e) {
Common.getInstance().getLogger().severe("iConomy database file not found!");
}
}
return result;
} | [
"private",
"boolean",
"loadFile",
"(",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"File",
"dbFile",
"=",
"new",
"File",
"(",
"Common",
".",
"getInstance",
"(",
")",
".",
"getServerCaller",
"(",
")",
".",
"getDataFolder",
"(",
")",
",",
"getDbConnectInfo",
"(",
")",
".",
"get",
"(",
"\"filename\"",
")",
")",
";",
"if",
"(",
"dbFile",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"flatFileReader",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"dbFile",
")",
")",
";",
"result",
"=",
"true",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getLogger",
"(",
")",
".",
"severe",
"(",
"\"iConomy database file not found!\"",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Allow to load a flatfile database.
@return True if the file is open. Else false. | [
"Allow",
"to",
"load",
"a",
"flatfile",
"database",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/converter/converters/Iconomy6.java#L99-L111 |
1,229 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/converter/converters/Iconomy6.java | Iconomy6.loadMySQL | private void loadMySQL() {
try {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(10);
config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
config.addDataSourceProperty("serverName", getDbConnectInfo().get("address"));
config.addDataSourceProperty("port", getDbConnectInfo().get("port"));
config.addDataSourceProperty("databaseName", getDbConnectInfo().get("database"));
config.addDataSourceProperty("user", getDbConnectInfo().get("username"));
config.addDataSourceProperty("password", getDbConnectInfo().get("password"));
config.addDataSourceProperty("autoDeserialize", true);
db = new HikariDataSource(config);
} catch (NumberFormatException e) {
Common.getInstance().getLogger().severe("Illegal Port!");
}
} | java | private void loadMySQL() {
try {
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(10);
config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
config.addDataSourceProperty("serverName", getDbConnectInfo().get("address"));
config.addDataSourceProperty("port", getDbConnectInfo().get("port"));
config.addDataSourceProperty("databaseName", getDbConnectInfo().get("database"));
config.addDataSourceProperty("user", getDbConnectInfo().get("username"));
config.addDataSourceProperty("password", getDbConnectInfo().get("password"));
config.addDataSourceProperty("autoDeserialize", true);
db = new HikariDataSource(config);
} catch (NumberFormatException e) {
Common.getInstance().getLogger().severe("Illegal Port!");
}
} | [
"private",
"void",
"loadMySQL",
"(",
")",
"{",
"try",
"{",
"HikariConfig",
"config",
"=",
"new",
"HikariConfig",
"(",
")",
";",
"config",
".",
"setMaximumPoolSize",
"(",
"10",
")",
";",
"config",
".",
"setDataSourceClassName",
"(",
"\"com.mysql.jdbc.jdbc2.optional.MysqlDataSource\"",
")",
";",
"config",
".",
"addDataSourceProperty",
"(",
"\"serverName\"",
",",
"getDbConnectInfo",
"(",
")",
".",
"get",
"(",
"\"address\"",
")",
")",
";",
"config",
".",
"addDataSourceProperty",
"(",
"\"port\"",
",",
"getDbConnectInfo",
"(",
")",
".",
"get",
"(",
"\"port\"",
")",
")",
";",
"config",
".",
"addDataSourceProperty",
"(",
"\"databaseName\"",
",",
"getDbConnectInfo",
"(",
")",
".",
"get",
"(",
"\"database\"",
")",
")",
";",
"config",
".",
"addDataSourceProperty",
"(",
"\"user\"",
",",
"getDbConnectInfo",
"(",
")",
".",
"get",
"(",
"\"username\"",
")",
")",
";",
"config",
".",
"addDataSourceProperty",
"(",
"\"password\"",
",",
"getDbConnectInfo",
"(",
")",
".",
"get",
"(",
"\"password\"",
")",
")",
";",
"config",
".",
"addDataSourceProperty",
"(",
"\"autoDeserialize\"",
",",
"true",
")",
";",
"db",
"=",
"new",
"HikariDataSource",
"(",
"config",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getLogger",
"(",
")",
".",
"severe",
"(",
"\"Illegal Port!\"",
")",
";",
"}",
"}"
] | Allow to load a MySQL database. | [
"Allow",
"to",
"load",
"a",
"MySQL",
"database",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/converter/converters/Iconomy6.java#L116-L131 |
1,230 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/converter/converters/Iconomy6.java | Iconomy6.importFlatFile | private boolean importFlatFile(String sender) {
boolean result = false;
try {
List<String> file = new ArrayList<>();
String str;
while ((str = flatFileReader.readLine()) != null) {
file.add(str);
}
flatFileReader.close();
List<User> userList = new ArrayList<>();
for (String aFile : file) {
String[] info = aFile.split(" ");
try {
double balance = Double.parseDouble(info[1].split(":")[1]);
userList.add(new User(info[0], balance));
} catch (NumberFormatException e) {
Common.getInstance().sendConsoleMessage(Level.SEVERE, "User " + info[0] + " have a invalid balance" + info[1]);
} catch (ArrayIndexOutOfBoundsException e) {
Common.getInstance().sendConsoleMessage(Level.WARNING, "Line not formatted correctly. I read:" + Arrays.toString(info));
}
}
addAccountToString(sender, userList);
result = true;
} catch (IOException e) {
Common.getInstance().getLogger().severe("A error occured while reading the iConomy database file! Message: " + e.getMessage());
}
return result;
} | java | private boolean importFlatFile(String sender) {
boolean result = false;
try {
List<String> file = new ArrayList<>();
String str;
while ((str = flatFileReader.readLine()) != null) {
file.add(str);
}
flatFileReader.close();
List<User> userList = new ArrayList<>();
for (String aFile : file) {
String[] info = aFile.split(" ");
try {
double balance = Double.parseDouble(info[1].split(":")[1]);
userList.add(new User(info[0], balance));
} catch (NumberFormatException e) {
Common.getInstance().sendConsoleMessage(Level.SEVERE, "User " + info[0] + " have a invalid balance" + info[1]);
} catch (ArrayIndexOutOfBoundsException e) {
Common.getInstance().sendConsoleMessage(Level.WARNING, "Line not formatted correctly. I read:" + Arrays.toString(info));
}
}
addAccountToString(sender, userList);
result = true;
} catch (IOException e) {
Common.getInstance().getLogger().severe("A error occured while reading the iConomy database file! Message: " + e.getMessage());
}
return result;
} | [
"private",
"boolean",
"importFlatFile",
"(",
"String",
"sender",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"try",
"{",
"List",
"<",
"String",
">",
"file",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"str",
";",
"while",
"(",
"(",
"str",
"=",
"flatFileReader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"file",
".",
"add",
"(",
"str",
")",
";",
"}",
"flatFileReader",
".",
"close",
"(",
")",
";",
"List",
"<",
"User",
">",
"userList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"aFile",
":",
"file",
")",
"{",
"String",
"[",
"]",
"info",
"=",
"aFile",
".",
"split",
"(",
"\" \"",
")",
";",
"try",
"{",
"double",
"balance",
"=",
"Double",
".",
"parseDouble",
"(",
"info",
"[",
"1",
"]",
".",
"split",
"(",
"\":\"",
")",
"[",
"1",
"]",
")",
";",
"userList",
".",
"add",
"(",
"new",
"User",
"(",
"info",
"[",
"0",
"]",
",",
"balance",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"sendConsoleMessage",
"(",
"Level",
".",
"SEVERE",
",",
"\"User \"",
"+",
"info",
"[",
"0",
"]",
"+",
"\" have a invalid balance\"",
"+",
"info",
"[",
"1",
"]",
")",
";",
"}",
"catch",
"(",
"ArrayIndexOutOfBoundsException",
"e",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"sendConsoleMessage",
"(",
"Level",
".",
"WARNING",
",",
"\"Line not formatted correctly. I read:\"",
"+",
"Arrays",
".",
"toString",
"(",
"info",
")",
")",
";",
"}",
"}",
"addAccountToString",
"(",
"sender",
",",
"userList",
")",
";",
"result",
"=",
"true",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getLogger",
"(",
")",
".",
"severe",
"(",
"\"A error occured while reading the iConomy database file! Message: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Import accounts from a flatfile.
@param sender The command sender so we can send back messages.
@return True if the convert is done. Else false. | [
"Import",
"accounts",
"from",
"a",
"flatfile",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/converter/converters/Iconomy6.java#L167-L195 |
1,231 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/events/EventManager.java | EventManager.playerJoinEvent | @EventHandler
public void playerJoinEvent(PlayerJoinEvent event) {
if (Common.getInstance().getMainConfig().getBoolean("System.CheckNewVersion") && Common.getInstance().getServerCaller().getPlayerCaller().isOp(event.getP().getName()) && Common.getInstance().getVersionChecker().getResult() == Updater.UpdateResult.UPDATE_AVAILABLE) {
Common.getInstance().getServerCaller().getPlayerCaller().sendMessage(event.getP().getName(), "{{DARK_CYAN}}Craftconomy is out of date! New version is " + Common.getInstance().getVersionChecker().getLatestName());
}
} | java | @EventHandler
public void playerJoinEvent(PlayerJoinEvent event) {
if (Common.getInstance().getMainConfig().getBoolean("System.CheckNewVersion") && Common.getInstance().getServerCaller().getPlayerCaller().isOp(event.getP().getName()) && Common.getInstance().getVersionChecker().getResult() == Updater.UpdateResult.UPDATE_AVAILABLE) {
Common.getInstance().getServerCaller().getPlayerCaller().sendMessage(event.getP().getName(), "{{DARK_CYAN}}Craftconomy is out of date! New version is " + Common.getInstance().getVersionChecker().getLatestName());
}
} | [
"@",
"EventHandler",
"public",
"void",
"playerJoinEvent",
"(",
"PlayerJoinEvent",
"event",
")",
"{",
"if",
"(",
"Common",
".",
"getInstance",
"(",
")",
".",
"getMainConfig",
"(",
")",
".",
"getBoolean",
"(",
"\"System.CheckNewVersion\"",
")",
"&&",
"Common",
".",
"getInstance",
"(",
")",
".",
"getServerCaller",
"(",
")",
".",
"getPlayerCaller",
"(",
")",
".",
"isOp",
"(",
"event",
".",
"getP",
"(",
")",
".",
"getName",
"(",
")",
")",
"&&",
"Common",
".",
"getInstance",
"(",
")",
".",
"getVersionChecker",
"(",
")",
".",
"getResult",
"(",
")",
"==",
"Updater",
".",
"UpdateResult",
".",
"UPDATE_AVAILABLE",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getServerCaller",
"(",
")",
".",
"getPlayerCaller",
"(",
")",
".",
"sendMessage",
"(",
"event",
".",
"getP",
"(",
")",
".",
"getName",
"(",
")",
",",
"\"{{DARK_CYAN}}Craftconomy is out of date! New version is \"",
"+",
"Common",
".",
"getInstance",
"(",
")",
".",
"getVersionChecker",
"(",
")",
".",
"getLatestName",
"(",
")",
")",
";",
"}",
"}"
] | Event handler for when a player is connecting to the server.
@param event The PlayerJoinEvent associated with the event | [
"Event",
"handler",
"for",
"when",
"a",
"player",
"is",
"connecting",
"to",
"the",
"server",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/events/EventManager.java#L39-L45 |
1,232 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/groups/WorldGroupsManager.java | WorldGroupsManager.addWorldToGroup | public void addWorldToGroup(String groupName, String world) {
if (!groupName.equalsIgnoreCase(DEFAULT_GROUP_NAME)) {
if (list.containsKey(groupName)) {
list.get(groupName).addWorld(world);
} else {
WorldGroup group = new WorldGroup(groupName);
group.addWorld(world);
}
}
} | java | public void addWorldToGroup(String groupName, String world) {
if (!groupName.equalsIgnoreCase(DEFAULT_GROUP_NAME)) {
if (list.containsKey(groupName)) {
list.get(groupName).addWorld(world);
} else {
WorldGroup group = new WorldGroup(groupName);
group.addWorld(world);
}
}
} | [
"public",
"void",
"addWorldToGroup",
"(",
"String",
"groupName",
",",
"String",
"world",
")",
"{",
"if",
"(",
"!",
"groupName",
".",
"equalsIgnoreCase",
"(",
"DEFAULT_GROUP_NAME",
")",
")",
"{",
"if",
"(",
"list",
".",
"containsKey",
"(",
"groupName",
")",
")",
"{",
"list",
".",
"get",
"(",
"groupName",
")",
".",
"addWorld",
"(",
"world",
")",
";",
"}",
"else",
"{",
"WorldGroup",
"group",
"=",
"new",
"WorldGroup",
"(",
"groupName",
")",
";",
"group",
".",
"addWorld",
"(",
"world",
")",
";",
"}",
"}",
"}"
] | Add a world to a group
@param groupName the group name
@param world the world to add | [
"Add",
"a",
"world",
"to",
"a",
"group"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/groups/WorldGroupsManager.java#L44-L53 |
1,233 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/groups/WorldGroupsManager.java | WorldGroupsManager.getWorldGroupName | public String getWorldGroupName(String world) {
String result = DEFAULT_GROUP_NAME;
for (Entry<String, WorldGroup> entry : list.entrySet()) {
if (entry.getValue().worldExist(world)) {
result = entry.getKey();
}
}
return result;
} | java | public String getWorldGroupName(String world) {
String result = DEFAULT_GROUP_NAME;
for (Entry<String, WorldGroup> entry : list.entrySet()) {
if (entry.getValue().worldExist(world)) {
result = entry.getKey();
}
}
return result;
} | [
"public",
"String",
"getWorldGroupName",
"(",
"String",
"world",
")",
"{",
"String",
"result",
"=",
"DEFAULT_GROUP_NAME",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"WorldGroup",
">",
"entry",
":",
"list",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"worldExist",
"(",
"world",
")",
")",
"{",
"result",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Retrieve the name of the worldgroup a world belongs to
@param world The world name
@return The worldgroup name linked to this world | [
"Retrieve",
"the",
"name",
"of",
"the",
"worldgroup",
"a",
"world",
"belongs",
"to"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/groups/WorldGroupsManager.java#L61-L69 |
1,234 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/groups/WorldGroupsManager.java | WorldGroupsManager.removeWorldFromGroup | public void removeWorldFromGroup(String world) {
String groupName = getWorldGroupName(world);
if (!groupName.equals(DEFAULT_GROUP_NAME)) {
list.get(groupName).removeWorld(world);
}
} | java | public void removeWorldFromGroup(String world) {
String groupName = getWorldGroupName(world);
if (!groupName.equals(DEFAULT_GROUP_NAME)) {
list.get(groupName).removeWorld(world);
}
} | [
"public",
"void",
"removeWorldFromGroup",
"(",
"String",
"world",
")",
"{",
"String",
"groupName",
"=",
"getWorldGroupName",
"(",
"world",
")",
";",
"if",
"(",
"!",
"groupName",
".",
"equals",
"(",
"DEFAULT_GROUP_NAME",
")",
")",
"{",
"list",
".",
"get",
"(",
"groupName",
")",
".",
"removeWorld",
"(",
"world",
")",
";",
"}",
"}"
] | Remove a world from a worldgroup
@param world The world to reset to default | [
"Remove",
"a",
"world",
"from",
"a",
"worldgroup"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/groups/WorldGroupsManager.java#L76-L81 |
1,235 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/groups/WorldGroupsManager.java | WorldGroupsManager.removeGroup | public void removeGroup(String group) {
if (worldGroupExist(group)) {
Common.getInstance().getStorageHandler().getStorageEngine().removeWorldGroup(group);
list.remove(group);
}
} | java | public void removeGroup(String group) {
if (worldGroupExist(group)) {
Common.getInstance().getStorageHandler().getStorageEngine().removeWorldGroup(group);
list.remove(group);
}
} | [
"public",
"void",
"removeGroup",
"(",
"String",
"group",
")",
"{",
"if",
"(",
"worldGroupExist",
"(",
"group",
")",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"removeWorldGroup",
"(",
"group",
")",
";",
"list",
".",
"remove",
"(",
"group",
")",
";",
"}",
"}"
] | Remove a world group. Reverting all the world into this group to the default one.
@param group The group to remove. | [
"Remove",
"a",
"world",
"group",
".",
"Reverting",
"all",
"the",
"world",
"into",
"this",
"group",
"to",
"the",
"default",
"one",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/groups/WorldGroupsManager.java#L88-L93 |
1,236 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/groups/WorldGroupsManager.java | WorldGroupsManager.addWorldGroup | public void addWorldGroup(String name) {
if (!worldGroupExist(name)) {
list.put(name, new WorldGroup(name));
}
} | java | public void addWorldGroup(String name) {
if (!worldGroupExist(name)) {
list.put(name, new WorldGroup(name));
}
} | [
"public",
"void",
"addWorldGroup",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"!",
"worldGroupExist",
"(",
"name",
")",
")",
"{",
"list",
".",
"put",
"(",
"name",
",",
"new",
"WorldGroup",
"(",
"name",
")",
")",
";",
"}",
"}"
] | Create a world group
@param name the world group name. | [
"Create",
"a",
"world",
"group"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/groups/WorldGroupsManager.java#L110-L114 |
1,237 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.onDisable | @Override
public void onDisable() {
if (getStorageHandler() != null) {
getLogger().info(getLanguageManager().getString("closing_db_link"));
getStorageHandler().disable();
}
// Managers
accountManager = null;
config = null;
currencyManager = null;
storageHandler = null;
eventManager = null;
languageManager = null;
worldGroupManager = null;
commandManager = null;
databaseInitialized = false;
currencyInitialized = false;
initialized = false;
metrics = null;
mainConfig = null;
updater = null;
//Default values
displayFormat = null;
holdings = 0.0;
bankPrice = 0.0;
} | java | @Override
public void onDisable() {
if (getStorageHandler() != null) {
getLogger().info(getLanguageManager().getString("closing_db_link"));
getStorageHandler().disable();
}
// Managers
accountManager = null;
config = null;
currencyManager = null;
storageHandler = null;
eventManager = null;
languageManager = null;
worldGroupManager = null;
commandManager = null;
databaseInitialized = false;
currencyInitialized = false;
initialized = false;
metrics = null;
mainConfig = null;
updater = null;
//Default values
displayFormat = null;
holdings = 0.0;
bankPrice = 0.0;
} | [
"@",
"Override",
"public",
"void",
"onDisable",
"(",
")",
"{",
"if",
"(",
"getStorageHandler",
"(",
")",
"!=",
"null",
")",
"{",
"getLogger",
"(",
")",
".",
"info",
"(",
"getLanguageManager",
"(",
")",
".",
"getString",
"(",
"\"closing_db_link\"",
")",
")",
";",
"getStorageHandler",
"(",
")",
".",
"disable",
"(",
")",
";",
"}",
"// Managers",
"accountManager",
"=",
"null",
";",
"config",
"=",
"null",
";",
"currencyManager",
"=",
"null",
";",
"storageHandler",
"=",
"null",
";",
"eventManager",
"=",
"null",
";",
"languageManager",
"=",
"null",
";",
"worldGroupManager",
"=",
"null",
";",
"commandManager",
"=",
"null",
";",
"databaseInitialized",
"=",
"false",
";",
"currencyInitialized",
"=",
"false",
";",
"initialized",
"=",
"false",
";",
"metrics",
"=",
"null",
";",
"mainConfig",
"=",
"null",
";",
"updater",
"=",
"null",
";",
"//Default values",
"displayFormat",
"=",
"null",
";",
"holdings",
"=",
"0.0",
";",
"bankPrice",
"=",
"0.0",
";",
"}"
] | Disable the plugin. | [
"Disable",
"the",
"plugin",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L164-L189 |
1,238 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.reloadPlugin | public void reloadPlugin() {
sendConsoleMessage(Level.INFO, "Starting up!");
sendConsoleMessage(Level.INFO, "Loading the Configuration");
config = new ConfigurationManager(serverCaller);
mainConfig = config.loadFile(serverCaller.getDataFolder(), "config.yml");
if (!mainConfig.has("System.Setup")) {
initializeConfig();
}
if (!getMainConfig().has("System.Database.Prefix")) {
getMainConfig().setValue("System.Database.Prefix", "cc3_");
}
languageManager = new LanguageManager(serverCaller, serverCaller.getDataFolder(), "lang.yml");
loadLanguage();
serverCaller.setCommandPrefix(languageManager.getString("command_prefix"));
commandManager.setCurrentLevel(1);
initialiseDatabase();
updateDatabase();
initializeCurrency();
sendConsoleMessage(Level.INFO, getLanguageManager().getString("loading_default_settings"));
loadDefaultSettings();
sendConsoleMessage(Level.INFO, getLanguageManager().getString("default_settings_loaded"));
startUp();
sendConsoleMessage(Level.INFO, getLanguageManager().getString("ready"));
} | java | public void reloadPlugin() {
sendConsoleMessage(Level.INFO, "Starting up!");
sendConsoleMessage(Level.INFO, "Loading the Configuration");
config = new ConfigurationManager(serverCaller);
mainConfig = config.loadFile(serverCaller.getDataFolder(), "config.yml");
if (!mainConfig.has("System.Setup")) {
initializeConfig();
}
if (!getMainConfig().has("System.Database.Prefix")) {
getMainConfig().setValue("System.Database.Prefix", "cc3_");
}
languageManager = new LanguageManager(serverCaller, serverCaller.getDataFolder(), "lang.yml");
loadLanguage();
serverCaller.setCommandPrefix(languageManager.getString("command_prefix"));
commandManager.setCurrentLevel(1);
initialiseDatabase();
updateDatabase();
initializeCurrency();
sendConsoleMessage(Level.INFO, getLanguageManager().getString("loading_default_settings"));
loadDefaultSettings();
sendConsoleMessage(Level.INFO, getLanguageManager().getString("default_settings_loaded"));
startUp();
sendConsoleMessage(Level.INFO, getLanguageManager().getString("ready"));
} | [
"public",
"void",
"reloadPlugin",
"(",
")",
"{",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"\"Starting up!\"",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"\"Loading the Configuration\"",
")",
";",
"config",
"=",
"new",
"ConfigurationManager",
"(",
"serverCaller",
")",
";",
"mainConfig",
"=",
"config",
".",
"loadFile",
"(",
"serverCaller",
".",
"getDataFolder",
"(",
")",
",",
"\"config.yml\"",
")",
";",
"if",
"(",
"!",
"mainConfig",
".",
"has",
"(",
"\"System.Setup\"",
")",
")",
"{",
"initializeConfig",
"(",
")",
";",
"}",
"if",
"(",
"!",
"getMainConfig",
"(",
")",
".",
"has",
"(",
"\"System.Database.Prefix\"",
")",
")",
"{",
"getMainConfig",
"(",
")",
".",
"setValue",
"(",
"\"System.Database.Prefix\"",
",",
"\"cc3_\"",
")",
";",
"}",
"languageManager",
"=",
"new",
"LanguageManager",
"(",
"serverCaller",
",",
"serverCaller",
".",
"getDataFolder",
"(",
")",
",",
"\"lang.yml\"",
")",
";",
"loadLanguage",
"(",
")",
";",
"serverCaller",
".",
"setCommandPrefix",
"(",
"languageManager",
".",
"getString",
"(",
"\"command_prefix\"",
")",
")",
";",
"commandManager",
".",
"setCurrentLevel",
"(",
"1",
")",
";",
"initialiseDatabase",
"(",
")",
";",
"updateDatabase",
"(",
")",
";",
"initializeCurrency",
"(",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"getLanguageManager",
"(",
")",
".",
"getString",
"(",
"\"loading_default_settings\"",
")",
")",
";",
"loadDefaultSettings",
"(",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"getLanguageManager",
"(",
")",
".",
"getString",
"(",
"\"default_settings_loaded\"",
")",
")",
";",
"startUp",
"(",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"getLanguageManager",
"(",
")",
".",
"getString",
"(",
"\"ready\"",
")",
")",
";",
"}"
] | Reload the plugin. | [
"Reload",
"the",
"plugin",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L194-L219 |
1,239 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.sendConsoleMessage | public void sendConsoleMessage(Level level, String msg) {
if (!(getServerCaller() instanceof UnitTestServerCaller)) {
getLogger().log(level, msg);
}
} | java | public void sendConsoleMessage(Level level, String msg) {
if (!(getServerCaller() instanceof UnitTestServerCaller)) {
getLogger().log(level, msg);
}
} | [
"public",
"void",
"sendConsoleMessage",
"(",
"Level",
"level",
",",
"String",
"msg",
")",
"{",
"if",
"(",
"!",
"(",
"getServerCaller",
"(",
")",
"instanceof",
"UnitTestServerCaller",
")",
")",
"{",
"getLogger",
"(",
")",
".",
"log",
"(",
"level",
",",
"msg",
")",
";",
"}",
"}"
] | Sends a message to the console through the Logge.r
@param level The log level to show.
@param msg The message to send. | [
"Sends",
"a",
"message",
"to",
"the",
"console",
"through",
"the",
"Logge",
".",
"r"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L245-L249 |
1,240 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.format | public String format(String worldName, Currency currency, double balance, DisplayFormat format) {
StringBuilder string = new StringBuilder();
if (worldName != null && !worldName.equals(WorldGroupsManager.DEFAULT_GROUP_NAME)) {
// We put the world name if the conf is true
string.append(worldName).append(": ");
}
if (currency != null) {
// We removes some cents if it's something like 20.20381 it would set it
// to 20.20
String[] theAmount = BigDecimal.valueOf(balance).toPlainString().split("\\.");
DecimalFormatSymbols unusualSymbols = new DecimalFormatSymbols();
unusualSymbols.setGroupingSeparator(',');
DecimalFormat decimalFormat = new DecimalFormat("###,###", unusualSymbols);
String name = currency.getName();
if (balance > 1.0 || balance < 1.0) {
name = currency.getPlural();
}
String coin;
if (theAmount.length == 2) {
if (theAmount[1].length() >= 2) {
coin = theAmount[1].substring(0, 2);
} else {
coin = theAmount[1] + "0";
}
} else {
coin = "0";
}
String amount;
try {
amount = decimalFormat.format(Double.parseDouble(theAmount[0]));
} catch (NumberFormatException e) {
amount = theAmount[0];
}
// Do we seperate money and dollar or not?
if (format == DisplayFormat.LONG) {
String subName = currency.getMinor();
if (Long.parseLong(coin) > 1) {
subName = currency.getMinorPlural();
}
string.append(amount).append(" ").append(name).append(" ").append(coin).append(" ").append(subName);
} else if (format == DisplayFormat.SMALL) {
string.append(amount).append(".").append(coin).append(" ").append(name);
} else if (format == DisplayFormat.SIGN) {
string.append(currency.getSign()).append(amount).append(".").append(coin);
} else if (format == DisplayFormat.SIGNFRONT) {
string.append(amount).append(".").append(coin).append(currency.getSign());
}else if (format == DisplayFormat.MAJORONLY) {
string.append(amount).append(" ").append(name);
}
}
return string.toString();
} | java | public String format(String worldName, Currency currency, double balance, DisplayFormat format) {
StringBuilder string = new StringBuilder();
if (worldName != null && !worldName.equals(WorldGroupsManager.DEFAULT_GROUP_NAME)) {
// We put the world name if the conf is true
string.append(worldName).append(": ");
}
if (currency != null) {
// We removes some cents if it's something like 20.20381 it would set it
// to 20.20
String[] theAmount = BigDecimal.valueOf(balance).toPlainString().split("\\.");
DecimalFormatSymbols unusualSymbols = new DecimalFormatSymbols();
unusualSymbols.setGroupingSeparator(',');
DecimalFormat decimalFormat = new DecimalFormat("###,###", unusualSymbols);
String name = currency.getName();
if (balance > 1.0 || balance < 1.0) {
name = currency.getPlural();
}
String coin;
if (theAmount.length == 2) {
if (theAmount[1].length() >= 2) {
coin = theAmount[1].substring(0, 2);
} else {
coin = theAmount[1] + "0";
}
} else {
coin = "0";
}
String amount;
try {
amount = decimalFormat.format(Double.parseDouble(theAmount[0]));
} catch (NumberFormatException e) {
amount = theAmount[0];
}
// Do we seperate money and dollar or not?
if (format == DisplayFormat.LONG) {
String subName = currency.getMinor();
if (Long.parseLong(coin) > 1) {
subName = currency.getMinorPlural();
}
string.append(amount).append(" ").append(name).append(" ").append(coin).append(" ").append(subName);
} else if (format == DisplayFormat.SMALL) {
string.append(amount).append(".").append(coin).append(" ").append(name);
} else if (format == DisplayFormat.SIGN) {
string.append(currency.getSign()).append(amount).append(".").append(coin);
} else if (format == DisplayFormat.SIGNFRONT) {
string.append(amount).append(".").append(coin).append(currency.getSign());
}else if (format == DisplayFormat.MAJORONLY) {
string.append(amount).append(" ").append(name);
}
}
return string.toString();
} | [
"public",
"String",
"format",
"(",
"String",
"worldName",
",",
"Currency",
"currency",
",",
"double",
"balance",
",",
"DisplayFormat",
"format",
")",
"{",
"StringBuilder",
"string",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"worldName",
"!=",
"null",
"&&",
"!",
"worldName",
".",
"equals",
"(",
"WorldGroupsManager",
".",
"DEFAULT_GROUP_NAME",
")",
")",
"{",
"// We put the world name if the conf is true",
"string",
".",
"append",
"(",
"worldName",
")",
".",
"append",
"(",
"\": \"",
")",
";",
"}",
"if",
"(",
"currency",
"!=",
"null",
")",
"{",
"// We removes some cents if it's something like 20.20381 it would set it",
"// to 20.20",
"String",
"[",
"]",
"theAmount",
"=",
"BigDecimal",
".",
"valueOf",
"(",
"balance",
")",
".",
"toPlainString",
"(",
")",
".",
"split",
"(",
"\"\\\\.\"",
")",
";",
"DecimalFormatSymbols",
"unusualSymbols",
"=",
"new",
"DecimalFormatSymbols",
"(",
")",
";",
"unusualSymbols",
".",
"setGroupingSeparator",
"(",
"'",
"'",
")",
";",
"DecimalFormat",
"decimalFormat",
"=",
"new",
"DecimalFormat",
"(",
"\"###,###\"",
",",
"unusualSymbols",
")",
";",
"String",
"name",
"=",
"currency",
".",
"getName",
"(",
")",
";",
"if",
"(",
"balance",
">",
"1.0",
"||",
"balance",
"<",
"1.0",
")",
"{",
"name",
"=",
"currency",
".",
"getPlural",
"(",
")",
";",
"}",
"String",
"coin",
";",
"if",
"(",
"theAmount",
".",
"length",
"==",
"2",
")",
"{",
"if",
"(",
"theAmount",
"[",
"1",
"]",
".",
"length",
"(",
")",
">=",
"2",
")",
"{",
"coin",
"=",
"theAmount",
"[",
"1",
"]",
".",
"substring",
"(",
"0",
",",
"2",
")",
";",
"}",
"else",
"{",
"coin",
"=",
"theAmount",
"[",
"1",
"]",
"+",
"\"0\"",
";",
"}",
"}",
"else",
"{",
"coin",
"=",
"\"0\"",
";",
"}",
"String",
"amount",
";",
"try",
"{",
"amount",
"=",
"decimalFormat",
".",
"format",
"(",
"Double",
".",
"parseDouble",
"(",
"theAmount",
"[",
"0",
"]",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"amount",
"=",
"theAmount",
"[",
"0",
"]",
";",
"}",
"// Do we seperate money and dollar or not?",
"if",
"(",
"format",
"==",
"DisplayFormat",
".",
"LONG",
")",
"{",
"String",
"subName",
"=",
"currency",
".",
"getMinor",
"(",
")",
";",
"if",
"(",
"Long",
".",
"parseLong",
"(",
"coin",
")",
">",
"1",
")",
"{",
"subName",
"=",
"currency",
".",
"getMinorPlural",
"(",
")",
";",
"}",
"string",
".",
"append",
"(",
"amount",
")",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"name",
")",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"coin",
")",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"subName",
")",
";",
"}",
"else",
"if",
"(",
"format",
"==",
"DisplayFormat",
".",
"SMALL",
")",
"{",
"string",
".",
"append",
"(",
"amount",
")",
".",
"append",
"(",
"\".\"",
")",
".",
"append",
"(",
"coin",
")",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"name",
")",
";",
"}",
"else",
"if",
"(",
"format",
"==",
"DisplayFormat",
".",
"SIGN",
")",
"{",
"string",
".",
"append",
"(",
"currency",
".",
"getSign",
"(",
")",
")",
".",
"append",
"(",
"amount",
")",
".",
"append",
"(",
"\".\"",
")",
".",
"append",
"(",
"coin",
")",
";",
"}",
"else",
"if",
"(",
"format",
"==",
"DisplayFormat",
".",
"SIGNFRONT",
")",
"{",
"string",
".",
"append",
"(",
"amount",
")",
".",
"append",
"(",
"\".\"",
")",
".",
"append",
"(",
"coin",
")",
".",
"append",
"(",
"currency",
".",
"getSign",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"format",
"==",
"DisplayFormat",
".",
"MAJORONLY",
")",
"{",
"string",
".",
"append",
"(",
"amount",
")",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"name",
")",
";",
"}",
"}",
"return",
"string",
".",
"toString",
"(",
")",
";",
"}"
] | Format a balance to a readable string.
@param worldName The world Name associated with this balance
@param currency The currency instance associated with this balance.
@param balance The balance.
@param format the display format to use
@return A pretty String showing the balance. Returns a empty string if currency is invalid. | [
"Format",
"a",
"balance",
"to",
"a",
"readable",
"string",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L323-L377 |
1,241 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.format | public String format(String worldName, Currency currency, double balance) {
return format(worldName, currency, balance, displayFormat);
} | java | public String format(String worldName, Currency currency, double balance) {
return format(worldName, currency, balance, displayFormat);
} | [
"public",
"String",
"format",
"(",
"String",
"worldName",
",",
"Currency",
"currency",
",",
"double",
"balance",
")",
"{",
"return",
"format",
"(",
"worldName",
",",
"currency",
",",
"balance",
",",
"displayFormat",
")",
";",
"}"
] | Format a balance to a readable string with the default formatting.
@param worldName The world Name associated with this balance
@param currency The currency instance associated with this balance.
@param balance The balance.
@return A pretty String showing the balance. Returns a empty string if currency is invalid. | [
"Format",
"a",
"balance",
"to",
"a",
"readable",
"string",
"with",
"the",
"default",
"formatting",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L387-L389 |
1,242 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.initialiseDatabase | public void initialiseDatabase() {
if (!databaseInitialized) {
sendConsoleMessage(Level.INFO, getLanguageManager().getString("loading_database_manager"));
storageHandler = new StorageHandler();
//TODO: Re-support that
if (getMainConfig().getBoolean("System.Database.ConvertFromH2")) {
convertDatabase();
}
databaseInitialized = true;
sendConsoleMessage(Level.INFO, getLanguageManager().getString("database_manager_loaded"));
}
} | java | public void initialiseDatabase() {
if (!databaseInitialized) {
sendConsoleMessage(Level.INFO, getLanguageManager().getString("loading_database_manager"));
storageHandler = new StorageHandler();
//TODO: Re-support that
if (getMainConfig().getBoolean("System.Database.ConvertFromH2")) {
convertDatabase();
}
databaseInitialized = true;
sendConsoleMessage(Level.INFO, getLanguageManager().getString("database_manager_loaded"));
}
} | [
"public",
"void",
"initialiseDatabase",
"(",
")",
"{",
"if",
"(",
"!",
"databaseInitialized",
")",
"{",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"getLanguageManager",
"(",
")",
".",
"getString",
"(",
"\"loading_database_manager\"",
")",
")",
";",
"storageHandler",
"=",
"new",
"StorageHandler",
"(",
")",
";",
"//TODO: Re-support that",
"if",
"(",
"getMainConfig",
"(",
")",
".",
"getBoolean",
"(",
"\"System.Database.ConvertFromH2\"",
")",
")",
"{",
"convertDatabase",
"(",
")",
";",
"}",
"databaseInitialized",
"=",
"true",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"getLanguageManager",
"(",
")",
".",
"getString",
"(",
"\"database_manager_loaded\"",
")",
")",
";",
"}",
"}"
] | Initialize the database Manager | [
"Initialize",
"the",
"database",
"Manager"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L394-L407 |
1,243 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.convertDatabase | private void convertDatabase(){
sendConsoleMessage(Level.INFO, getLanguageManager().getString("starting_database_convert"));
new H2ToMySQLConverter().run();
sendConsoleMessage(Level.INFO, getLanguageManager().getString("convert_done"));
getMainConfig().setValue("System.Database.ConvertFromH2", false);
} | java | private void convertDatabase(){
sendConsoleMessage(Level.INFO, getLanguageManager().getString("starting_database_convert"));
new H2ToMySQLConverter().run();
sendConsoleMessage(Level.INFO, getLanguageManager().getString("convert_done"));
getMainConfig().setValue("System.Database.ConvertFromH2", false);
} | [
"private",
"void",
"convertDatabase",
"(",
")",
"{",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"getLanguageManager",
"(",
")",
".",
"getString",
"(",
"\"starting_database_convert\"",
")",
")",
";",
"new",
"H2ToMySQLConverter",
"(",
")",
".",
"run",
"(",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"getLanguageManager",
"(",
")",
".",
"getString",
"(",
"\"convert_done\"",
")",
")",
";",
"getMainConfig",
"(",
")",
".",
"setValue",
"(",
"\"System.Database.ConvertFromH2\"",
",",
"false",
")",
";",
"}"
] | Convert from SQLite to MySQL | [
"Convert",
"from",
"SQLite",
"to",
"MySQL"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L412-L417 |
1,244 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.addMetricsGraph | public void addMetricsGraph(String title, String value) {
if (metrics != null) {
Metrics.Graph graph = metrics.createGraph(title);
graph.addPlotter(new Metrics.Plotter(value) {
@Override
public int getValue() {
return 1;
}
});
}
} | java | public void addMetricsGraph(String title, String value) {
if (metrics != null) {
Metrics.Graph graph = metrics.createGraph(title);
graph.addPlotter(new Metrics.Plotter(value) {
@Override
public int getValue() {
return 1;
}
});
}
} | [
"public",
"void",
"addMetricsGraph",
"(",
"String",
"title",
",",
"String",
"value",
")",
"{",
"if",
"(",
"metrics",
"!=",
"null",
")",
"{",
"Metrics",
".",
"Graph",
"graph",
"=",
"metrics",
".",
"createGraph",
"(",
"title",
")",
";",
"graph",
".",
"addPlotter",
"(",
"new",
"Metrics",
".",
"Plotter",
"(",
"value",
")",
"{",
"@",
"Override",
"public",
"int",
"getValue",
"(",
")",
"{",
"return",
"1",
";",
"}",
"}",
")",
";",
"}",
"}"
] | Add a graph to Metrics
@param title The title of the Graph
@param value The value of the entry | [
"Add",
"a",
"graph",
"to",
"Metrics"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L460-L470 |
1,245 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.writeLog | public void writeLog(LogInfo info, Cause cause, String causeReason, Account account, double amount, Currency currency, String worldName) {
if (getMainConfig().getBoolean("System.Logging.Enabled")) {
getStorageHandler().getStorageEngine().saveLog(info, cause, causeReason, account, amount, currency, worldName);
}
} | java | public void writeLog(LogInfo info, Cause cause, String causeReason, Account account, double amount, Currency currency, String worldName) {
if (getMainConfig().getBoolean("System.Logging.Enabled")) {
getStorageHandler().getStorageEngine().saveLog(info, cause, causeReason, account, amount, currency, worldName);
}
} | [
"public",
"void",
"writeLog",
"(",
"LogInfo",
"info",
",",
"Cause",
"cause",
",",
"String",
"causeReason",
",",
"Account",
"account",
",",
"double",
"amount",
",",
"Currency",
"currency",
",",
"String",
"worldName",
")",
"{",
"if",
"(",
"getMainConfig",
"(",
")",
".",
"getBoolean",
"(",
"\"System.Logging.Enabled\"",
")",
")",
"{",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"saveLog",
"(",
"info",
",",
"cause",
",",
"causeReason",
",",
"account",
",",
"amount",
",",
"currency",
",",
"worldName",
")",
";",
"}",
"}"
] | Write a transaction to the Log.
@param info The type of transaction to log.
@param cause The cause of the transaction.
@param causeReason The reason of the cause
@param account The account being impacted by the change
@param amount The amount of money in this transaction.
@param currency The currency associated with this transaction
@param worldName The world name associated with this transaction | [
"Write",
"a",
"transaction",
"to",
"the",
"Log",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L503-L507 |
1,246 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.loadDefaultSettings | public void loadDefaultSettings() {
String value = getStorageHandler().getStorageEngine().getConfigEntry("longmode");
if (value != null) {
displayFormat = DisplayFormat.valueOf(value.toUpperCase());
} else {
getStorageHandler().getStorageEngine().setConfigEntry("longmode", "long");
displayFormat = DisplayFormat.LONG;
}
addMetricsGraph("Display Format", displayFormat.toString());
value = getStorageHandler().getStorageEngine().getConfigEntry("holdings");
if (value != null && Tools.isValidDouble(value)) {
holdings = Double.parseDouble(value);
} else {
getStorageHandler().getStorageEngine().setConfigEntry("holdings", 100.0 + "");
sendConsoleMessage(Level.SEVERE, "No default value was set for account creation or was invalid! Defaulting to 100.");
holdings = 100.0;
}
value = getStorageHandler().getStorageEngine().getConfigEntry("bankprice");
if (value != null && Tools.isValidDouble(value)) {
bankPrice = Double.parseDouble(value);
} else {
getStorageHandler().getStorageEngine().setConfigEntry("bankprice", 100.0 + "");
sendConsoleMessage(Level.SEVERE, "No default value was set for bank creation or was invalid! Defaulting to 100.");
bankPrice = 100.0;
}
} | java | public void loadDefaultSettings() {
String value = getStorageHandler().getStorageEngine().getConfigEntry("longmode");
if (value != null) {
displayFormat = DisplayFormat.valueOf(value.toUpperCase());
} else {
getStorageHandler().getStorageEngine().setConfigEntry("longmode", "long");
displayFormat = DisplayFormat.LONG;
}
addMetricsGraph("Display Format", displayFormat.toString());
value = getStorageHandler().getStorageEngine().getConfigEntry("holdings");
if (value != null && Tools.isValidDouble(value)) {
holdings = Double.parseDouble(value);
} else {
getStorageHandler().getStorageEngine().setConfigEntry("holdings", 100.0 + "");
sendConsoleMessage(Level.SEVERE, "No default value was set for account creation or was invalid! Defaulting to 100.");
holdings = 100.0;
}
value = getStorageHandler().getStorageEngine().getConfigEntry("bankprice");
if (value != null && Tools.isValidDouble(value)) {
bankPrice = Double.parseDouble(value);
} else {
getStorageHandler().getStorageEngine().setConfigEntry("bankprice", 100.0 + "");
sendConsoleMessage(Level.SEVERE, "No default value was set for bank creation or was invalid! Defaulting to 100.");
bankPrice = 100.0;
}
} | [
"public",
"void",
"loadDefaultSettings",
"(",
")",
"{",
"String",
"value",
"=",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"getConfigEntry",
"(",
"\"longmode\"",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"displayFormat",
"=",
"DisplayFormat",
".",
"valueOf",
"(",
"value",
".",
"toUpperCase",
"(",
")",
")",
";",
"}",
"else",
"{",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setConfigEntry",
"(",
"\"longmode\"",
",",
"\"long\"",
")",
";",
"displayFormat",
"=",
"DisplayFormat",
".",
"LONG",
";",
"}",
"addMetricsGraph",
"(",
"\"Display Format\"",
",",
"displayFormat",
".",
"toString",
"(",
")",
")",
";",
"value",
"=",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"getConfigEntry",
"(",
"\"holdings\"",
")",
";",
"if",
"(",
"value",
"!=",
"null",
"&&",
"Tools",
".",
"isValidDouble",
"(",
"value",
")",
")",
"{",
"holdings",
"=",
"Double",
".",
"parseDouble",
"(",
"value",
")",
";",
"}",
"else",
"{",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setConfigEntry",
"(",
"\"holdings\"",
",",
"100.0",
"+",
"\"\"",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"SEVERE",
",",
"\"No default value was set for account creation or was invalid! Defaulting to 100.\"",
")",
";",
"holdings",
"=",
"100.0",
";",
"}",
"value",
"=",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"getConfigEntry",
"(",
"\"bankprice\"",
")",
";",
"if",
"(",
"value",
"!=",
"null",
"&&",
"Tools",
".",
"isValidDouble",
"(",
"value",
")",
")",
"{",
"bankPrice",
"=",
"Double",
".",
"parseDouble",
"(",
"value",
")",
";",
"}",
"else",
"{",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setConfigEntry",
"(",
"\"bankprice\"",
",",
"100.0",
"+",
"\"\"",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"SEVERE",
",",
"\"No default value was set for bank creation or was invalid! Defaulting to 100.\"",
")",
";",
"bankPrice",
"=",
"100.0",
";",
"}",
"}"
] | Reload the default settings. | [
"Reload",
"the",
"default",
"settings",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L557-L582 |
1,247 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.setDefaultHoldings | public void setDefaultHoldings(double value) {
getStorageHandler().getStorageEngine().setConfigEntry("holdings", String.valueOf(value));
holdings = value;
} | java | public void setDefaultHoldings(double value) {
getStorageHandler().getStorageEngine().setConfigEntry("holdings", String.valueOf(value));
holdings = value;
} | [
"public",
"void",
"setDefaultHoldings",
"(",
"double",
"value",
")",
"{",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setConfigEntry",
"(",
"\"holdings\"",
",",
"String",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"holdings",
"=",
"value",
";",
"}"
] | Set the default amount of money a account will have
@param value the default amount of money | [
"Set",
"the",
"default",
"amount",
"of",
"money",
"a",
"account",
"will",
"have"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L617-L620 |
1,248 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.setBankPrice | public void setBankPrice(double value) {
getStorageHandler().getStorageEngine().setConfigEntry("bankprice", String.valueOf(value));
bankPrice = value;
} | java | public void setBankPrice(double value) {
getStorageHandler().getStorageEngine().setConfigEntry("bankprice", String.valueOf(value));
bankPrice = value;
} | [
"public",
"void",
"setBankPrice",
"(",
"double",
"value",
")",
"{",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setConfigEntry",
"(",
"\"bankprice\"",
",",
"String",
".",
"valueOf",
"(",
"value",
")",
")",
";",
"bankPrice",
"=",
"value",
";",
"}"
] | Set the bank account creation price
@param value the bank account creation price | [
"Set",
"the",
"bank",
"account",
"creation",
"price"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L636-L639 |
1,249 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.quickSetup | private void quickSetup() {
initialiseDatabase();
Common.getInstance().initializeCurrency();
Currency currency = Common.getInstance().getCurrencyManager().addCurrency(getMainConfig().getString("System.QuickSetup.Currency.Name"), getMainConfig().getString("System.QuickSetup.Currency.NamePlural"), getMainConfig().getString("System.QuickSetup.Currency.Minor"), getMainConfig().getString("System.QuickSetup.Currency.MinorPlural"), getMainConfig().getString("System.QuickSetup.Currency.Sign"), true);
Common.getInstance().getCurrencyManager().setDefault(currency);
Common.getInstance().getCurrencyManager().setDefaultBankCurrency(currency);
getStorageHandler().getStorageEngine().setConfigEntry("longmode", DisplayFormat.valueOf(getMainConfig().getString("System.QuickSetup.DisplayMode").toUpperCase()).toString());
getStorageHandler().getStorageEngine().setConfigEntry("holdings", getMainConfig().getString("System.QuickSetup.StartBalance"));
getStorageHandler().getStorageEngine().setConfigEntry("bankprice", getMainConfig().getString("System.QuickSetup.PriceBank"));
initializeCurrency();
loadDefaultSettings();
Common.getInstance().startUp();
Common.getInstance().getMainConfig().setValue("System.Setup", false);
commandManager.setCurrentLevel(1);
sendConsoleMessage(Level.INFO, "Quick-Config done!");
} | java | private void quickSetup() {
initialiseDatabase();
Common.getInstance().initializeCurrency();
Currency currency = Common.getInstance().getCurrencyManager().addCurrency(getMainConfig().getString("System.QuickSetup.Currency.Name"), getMainConfig().getString("System.QuickSetup.Currency.NamePlural"), getMainConfig().getString("System.QuickSetup.Currency.Minor"), getMainConfig().getString("System.QuickSetup.Currency.MinorPlural"), getMainConfig().getString("System.QuickSetup.Currency.Sign"), true);
Common.getInstance().getCurrencyManager().setDefault(currency);
Common.getInstance().getCurrencyManager().setDefaultBankCurrency(currency);
getStorageHandler().getStorageEngine().setConfigEntry("longmode", DisplayFormat.valueOf(getMainConfig().getString("System.QuickSetup.DisplayMode").toUpperCase()).toString());
getStorageHandler().getStorageEngine().setConfigEntry("holdings", getMainConfig().getString("System.QuickSetup.StartBalance"));
getStorageHandler().getStorageEngine().setConfigEntry("bankprice", getMainConfig().getString("System.QuickSetup.PriceBank"));
initializeCurrency();
loadDefaultSettings();
Common.getInstance().startUp();
Common.getInstance().getMainConfig().setValue("System.Setup", false);
commandManager.setCurrentLevel(1);
sendConsoleMessage(Level.INFO, "Quick-Config done!");
} | [
"private",
"void",
"quickSetup",
"(",
")",
"{",
"initialiseDatabase",
"(",
")",
";",
"Common",
".",
"getInstance",
"(",
")",
".",
"initializeCurrency",
"(",
")",
";",
"Currency",
"currency",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getCurrencyManager",
"(",
")",
".",
"addCurrency",
"(",
"getMainConfig",
"(",
")",
".",
"getString",
"(",
"\"System.QuickSetup.Currency.Name\"",
")",
",",
"getMainConfig",
"(",
")",
".",
"getString",
"(",
"\"System.QuickSetup.Currency.NamePlural\"",
")",
",",
"getMainConfig",
"(",
")",
".",
"getString",
"(",
"\"System.QuickSetup.Currency.Minor\"",
")",
",",
"getMainConfig",
"(",
")",
".",
"getString",
"(",
"\"System.QuickSetup.Currency.MinorPlural\"",
")",
",",
"getMainConfig",
"(",
")",
".",
"getString",
"(",
"\"System.QuickSetup.Currency.Sign\"",
")",
",",
"true",
")",
";",
"Common",
".",
"getInstance",
"(",
")",
".",
"getCurrencyManager",
"(",
")",
".",
"setDefault",
"(",
"currency",
")",
";",
"Common",
".",
"getInstance",
"(",
")",
".",
"getCurrencyManager",
"(",
")",
".",
"setDefaultBankCurrency",
"(",
"currency",
")",
";",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setConfigEntry",
"(",
"\"longmode\"",
",",
"DisplayFormat",
".",
"valueOf",
"(",
"getMainConfig",
"(",
")",
".",
"getString",
"(",
"\"System.QuickSetup.DisplayMode\"",
")",
".",
"toUpperCase",
"(",
")",
")",
".",
"toString",
"(",
")",
")",
";",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setConfigEntry",
"(",
"\"holdings\"",
",",
"getMainConfig",
"(",
")",
".",
"getString",
"(",
"\"System.QuickSetup.StartBalance\"",
")",
")",
";",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setConfigEntry",
"(",
"\"bankprice\"",
",",
"getMainConfig",
"(",
")",
".",
"getString",
"(",
"\"System.QuickSetup.PriceBank\"",
")",
")",
";",
"initializeCurrency",
"(",
")",
";",
"loadDefaultSettings",
"(",
")",
";",
"Common",
".",
"getInstance",
"(",
")",
".",
"startUp",
"(",
")",
";",
"Common",
".",
"getInstance",
"(",
")",
".",
"getMainConfig",
"(",
")",
".",
"setValue",
"(",
"\"System.Setup\"",
",",
"false",
")",
";",
"commandManager",
".",
"setCurrentLevel",
"(",
"1",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"\"Quick-Config done!\"",
")",
";",
"}"
] | Perform a quick setup | [
"Perform",
"a",
"quick",
"setup"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L644-L659 |
1,250 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.updateDatabase | private void updateDatabase() {
if (getMainConfig().getInt("Database.dbVersion") == 0) {
alertOldDbVersion(0, 1);
//We first check if we have the DB version in the database. If we do, we have a old layout in our hands
String value = getStorageHandler().getStorageEngine().getConfigEntry("dbVersion");
if (value != null) {
//We have a old database, do the whole conversion
try {
new OldFormatConverter().run();
getMainConfig().setValue("Database.dbVersion", 1);
sendConsoleMessage(Level.INFO, "Updated to Revision 1!");
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
} else {
getMainConfig().setValue("Database.dbVersion", 1);
sendConsoleMessage(Level.INFO, "Updated to Revision 1!");
}
} else if (getMainConfig().getInt("Database.dbVersion") == -1) {
alertOldDbVersion(-1,1);
try {
new OldFormatConverter().step2();
getMainConfig().setValue("Database.dbVersion", 1);
sendConsoleMessage(Level.INFO, "Updated to Revision 1!");
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}
} | java | private void updateDatabase() {
if (getMainConfig().getInt("Database.dbVersion") == 0) {
alertOldDbVersion(0, 1);
//We first check if we have the DB version in the database. If we do, we have a old layout in our hands
String value = getStorageHandler().getStorageEngine().getConfigEntry("dbVersion");
if (value != null) {
//We have a old database, do the whole conversion
try {
new OldFormatConverter().run();
getMainConfig().setValue("Database.dbVersion", 1);
sendConsoleMessage(Level.INFO, "Updated to Revision 1!");
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
} else {
getMainConfig().setValue("Database.dbVersion", 1);
sendConsoleMessage(Level.INFO, "Updated to Revision 1!");
}
} else if (getMainConfig().getInt("Database.dbVersion") == -1) {
alertOldDbVersion(-1,1);
try {
new OldFormatConverter().step2();
getMainConfig().setValue("Database.dbVersion", 1);
sendConsoleMessage(Level.INFO, "Updated to Revision 1!");
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}
} | [
"private",
"void",
"updateDatabase",
"(",
")",
"{",
"if",
"(",
"getMainConfig",
"(",
")",
".",
"getInt",
"(",
"\"Database.dbVersion\"",
")",
"==",
"0",
")",
"{",
"alertOldDbVersion",
"(",
"0",
",",
"1",
")",
";",
"//We first check if we have the DB version in the database. If we do, we have a old layout in our hands",
"String",
"value",
"=",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"getConfigEntry",
"(",
"\"dbVersion\"",
")",
";",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"//We have a old database, do the whole conversion",
"try",
"{",
"new",
"OldFormatConverter",
"(",
")",
".",
"run",
"(",
")",
";",
"getMainConfig",
"(",
")",
".",
"setValue",
"(",
"\"Database.dbVersion\"",
",",
"1",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"\"Updated to Revision 1!\"",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"else",
"{",
"getMainConfig",
"(",
")",
".",
"setValue",
"(",
"\"Database.dbVersion\"",
",",
"1",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"\"Updated to Revision 1!\"",
")",
";",
"}",
"}",
"else",
"if",
"(",
"getMainConfig",
"(",
")",
".",
"getInt",
"(",
"\"Database.dbVersion\"",
")",
"==",
"-",
"1",
")",
"{",
"alertOldDbVersion",
"(",
"-",
"1",
",",
"1",
")",
";",
"try",
"{",
"new",
"OldFormatConverter",
"(",
")",
".",
"step2",
"(",
")",
";",
"getMainConfig",
"(",
")",
".",
"setValue",
"(",
"\"Database.dbVersion\"",
",",
"1",
")",
";",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"\"Updated to Revision 1!\"",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}"
] | Run a database update. | [
"Run",
"a",
"database",
"update",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L967-L1005 |
1,251 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/Common.java | Common.alertOldDbVersion | private void alertOldDbVersion(int currentVersion, int newVersion) {
Common.getInstance().sendConsoleMessage(Level.INFO, "Your database is out of date! (Version " + currentVersion + "). Updating it to Revision " + newVersion + ".");
} | java | private void alertOldDbVersion(int currentVersion, int newVersion) {
Common.getInstance().sendConsoleMessage(Level.INFO, "Your database is out of date! (Version " + currentVersion + "). Updating it to Revision " + newVersion + ".");
} | [
"private",
"void",
"alertOldDbVersion",
"(",
"int",
"currentVersion",
",",
"int",
"newVersion",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"sendConsoleMessage",
"(",
"Level",
".",
"INFO",
",",
"\"Your database is out of date! (Version \"",
"+",
"currentVersion",
"+",
"\"). Updating it to Revision \"",
"+",
"newVersion",
"+",
"\".\"",
")",
";",
"}"
] | Alert in the console of a database update.
@param currentVersion The current version
@param newVersion The database update version | [
"Alert",
"in",
"the",
"console",
"of",
"a",
"database",
"update",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/Common.java#L1013-L1015 |
1,252 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java | AccountACL.canDeposit | public boolean canDeposit(String name) {
if (getParent().ignoreACL()) {
return true;
}
String newName = name.toLowerCase();
boolean result = false;
if (aclList.containsKey(newName)) {
result = aclList.get(newName).canDeposit();
}
return result;
} | java | public boolean canDeposit(String name) {
if (getParent().ignoreACL()) {
return true;
}
String newName = name.toLowerCase();
boolean result = false;
if (aclList.containsKey(newName)) {
result = aclList.get(newName).canDeposit();
}
return result;
} | [
"public",
"boolean",
"canDeposit",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"getParent",
"(",
")",
".",
"ignoreACL",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"String",
"newName",
"=",
"name",
".",
"toLowerCase",
"(",
")",
";",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"aclList",
".",
"containsKey",
"(",
"newName",
")",
")",
"{",
"result",
"=",
"aclList",
".",
"get",
"(",
"newName",
")",
".",
"canDeposit",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Checks if a player can deposit money
@param name The player name
@return True if the player can deposit money, else false | [
"Checks",
"if",
"a",
"player",
"can",
"deposit",
"money"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java#L45-L55 |
1,253 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java | AccountACL.canAcl | public boolean canAcl(String name) {
if (getParent().ignoreACL()) {
return false;
}
String newName = name.toLowerCase();
boolean result = false;
if (aclList.containsKey(newName)) {
result = aclList.get(newName).canAcl();
}
return result;
} | java | public boolean canAcl(String name) {
if (getParent().ignoreACL()) {
return false;
}
String newName = name.toLowerCase();
boolean result = false;
if (aclList.containsKey(newName)) {
result = aclList.get(newName).canAcl();
}
return result;
} | [
"public",
"boolean",
"canAcl",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"getParent",
"(",
")",
".",
"ignoreACL",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"String",
"newName",
"=",
"name",
".",
"toLowerCase",
"(",
")",
";",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"aclList",
".",
"containsKey",
"(",
"newName",
")",
")",
"{",
"result",
"=",
"aclList",
".",
"get",
"(",
"newName",
")",
".",
"canAcl",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Checks if a player can modify the ACL
@param name The player name
@return True if the player can modify the ACL, else false. | [
"Checks",
"if",
"a",
"player",
"can",
"modify",
"the",
"ACL"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java#L81-L91 |
1,254 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java | AccountACL.setDeposit | public void setDeposit(String name, boolean deposit) {
String newName = name.toLowerCase();
if (aclList.containsKey(newName)) {
AccountACLValue value = aclList.get(newName);
set(newName, deposit, value.canWithdraw(), value.canAcl(), value.canBalance(), value.isOwner());
} else {
set(newName, deposit, false, false, false, false);
}
} | java | public void setDeposit(String name, boolean deposit) {
String newName = name.toLowerCase();
if (aclList.containsKey(newName)) {
AccountACLValue value = aclList.get(newName);
set(newName, deposit, value.canWithdraw(), value.canAcl(), value.canBalance(), value.isOwner());
} else {
set(newName, deposit, false, false, false, false);
}
} | [
"public",
"void",
"setDeposit",
"(",
"String",
"name",
",",
"boolean",
"deposit",
")",
"{",
"String",
"newName",
"=",
"name",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"aclList",
".",
"containsKey",
"(",
"newName",
")",
")",
"{",
"AccountACLValue",
"value",
"=",
"aclList",
".",
"get",
"(",
"newName",
")",
";",
"set",
"(",
"newName",
",",
"deposit",
",",
"value",
".",
"canWithdraw",
"(",
")",
",",
"value",
".",
"canAcl",
"(",
")",
",",
"value",
".",
"canBalance",
"(",
")",
",",
"value",
".",
"isOwner",
"(",
")",
")",
";",
"}",
"else",
"{",
"set",
"(",
"newName",
",",
"deposit",
",",
"false",
",",
"false",
",",
"false",
",",
"false",
")",
";",
"}",
"}"
] | Set if a player can deposit money in the account
@param name The Player name
@param deposit Can deposit or not | [
"Set",
"if",
"a",
"player",
"can",
"deposit",
"money",
"in",
"the",
"account"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java#L117-L125 |
1,255 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java | AccountACL.setWithdraw | public void setWithdraw(String name, boolean withdraw) {
String newName = name.toLowerCase();
if (aclList.containsKey(name)) {
AccountACLValue value = aclList.get(newName);
set(newName, value.canDeposit(), withdraw, value.canAcl(), value.canBalance(), value.isOwner());
} else {
set(newName, false, withdraw, false, false, false);
}
} | java | public void setWithdraw(String name, boolean withdraw) {
String newName = name.toLowerCase();
if (aclList.containsKey(name)) {
AccountACLValue value = aclList.get(newName);
set(newName, value.canDeposit(), withdraw, value.canAcl(), value.canBalance(), value.isOwner());
} else {
set(newName, false, withdraw, false, false, false);
}
} | [
"public",
"void",
"setWithdraw",
"(",
"String",
"name",
",",
"boolean",
"withdraw",
")",
"{",
"String",
"newName",
"=",
"name",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"aclList",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"AccountACLValue",
"value",
"=",
"aclList",
".",
"get",
"(",
"newName",
")",
";",
"set",
"(",
"newName",
",",
"value",
".",
"canDeposit",
"(",
")",
",",
"withdraw",
",",
"value",
".",
"canAcl",
"(",
")",
",",
"value",
".",
"canBalance",
"(",
")",
",",
"value",
".",
"isOwner",
"(",
")",
")",
";",
"}",
"else",
"{",
"set",
"(",
"newName",
",",
"false",
",",
"withdraw",
",",
"false",
",",
"false",
",",
"false",
")",
";",
"}",
"}"
] | Set if a player can withdraw money in the account
@param name The Player name
@param withdraw Can withdraw or not | [
"Set",
"if",
"a",
"player",
"can",
"withdraw",
"money",
"in",
"the",
"account"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java#L133-L141 |
1,256 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java | AccountACL.setAcl | public void setAcl(String name, boolean acl) {
String newName = name.toLowerCase();
if (aclList.containsKey(newName)) {
AccountACLValue value = aclList.get(newName);
set(newName, value.canDeposit(), value.canWithdraw(), acl, value.canBalance(), value.isOwner());
} else {
set(newName, false, false, acl, false, false);
}
} | java | public void setAcl(String name, boolean acl) {
String newName = name.toLowerCase();
if (aclList.containsKey(newName)) {
AccountACLValue value = aclList.get(newName);
set(newName, value.canDeposit(), value.canWithdraw(), acl, value.canBalance(), value.isOwner());
} else {
set(newName, false, false, acl, false, false);
}
} | [
"public",
"void",
"setAcl",
"(",
"String",
"name",
",",
"boolean",
"acl",
")",
"{",
"String",
"newName",
"=",
"name",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"aclList",
".",
"containsKey",
"(",
"newName",
")",
")",
"{",
"AccountACLValue",
"value",
"=",
"aclList",
".",
"get",
"(",
"newName",
")",
";",
"set",
"(",
"newName",
",",
"value",
".",
"canDeposit",
"(",
")",
",",
"value",
".",
"canWithdraw",
"(",
")",
",",
"acl",
",",
"value",
".",
"canBalance",
"(",
")",
",",
"value",
".",
"isOwner",
"(",
")",
")",
";",
"}",
"else",
"{",
"set",
"(",
"newName",
",",
"false",
",",
"false",
",",
"acl",
",",
"false",
",",
"false",
")",
";",
"}",
"}"
] | Set if a player can modify the ACL list
@param name The player name
@param acl can modify the ACL or not | [
"Set",
"if",
"a",
"player",
"can",
"modify",
"the",
"ACL",
"list"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java#L149-L157 |
1,257 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java | AccountACL.setShow | public void setShow(String name, boolean show) {
String newName = name.toLowerCase();
if (aclList.containsKey(newName)) {
AccountACLValue value = aclList.get(newName);
set(newName, value.canDeposit(), value.canWithdraw(), value.canAcl(), show, value.isOwner());
} else {
set(newName, false, false, false, show, false);
}
} | java | public void setShow(String name, boolean show) {
String newName = name.toLowerCase();
if (aclList.containsKey(newName)) {
AccountACLValue value = aclList.get(newName);
set(newName, value.canDeposit(), value.canWithdraw(), value.canAcl(), show, value.isOwner());
} else {
set(newName, false, false, false, show, false);
}
} | [
"public",
"void",
"setShow",
"(",
"String",
"name",
",",
"boolean",
"show",
")",
"{",
"String",
"newName",
"=",
"name",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"aclList",
".",
"containsKey",
"(",
"newName",
")",
")",
"{",
"AccountACLValue",
"value",
"=",
"aclList",
".",
"get",
"(",
"newName",
")",
";",
"set",
"(",
"newName",
",",
"value",
".",
"canDeposit",
"(",
")",
",",
"value",
".",
"canWithdraw",
"(",
")",
",",
"value",
".",
"canAcl",
"(",
")",
",",
"show",
",",
"value",
".",
"isOwner",
"(",
")",
")",
";",
"}",
"else",
"{",
"set",
"(",
"newName",
",",
"false",
",",
"false",
",",
"false",
",",
"show",
",",
"false",
")",
";",
"}",
"}"
] | Set if a player can show the bank balance.
@param name The player name
@param show can show the bank balance or not. | [
"Set",
"if",
"a",
"player",
"can",
"show",
"the",
"bank",
"balance",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java#L165-L173 |
1,258 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java | AccountACL.set | public void set(String name, boolean deposit, boolean withdraw, boolean acl, boolean show, boolean owner) {
String newName = name.toLowerCase();
aclList.put(name, Common.getInstance().getStorageHandler().getStorageEngine().saveACL(account, newName, deposit, withdraw, acl, show, owner));
} | java | public void set(String name, boolean deposit, boolean withdraw, boolean acl, boolean show, boolean owner) {
String newName = name.toLowerCase();
aclList.put(name, Common.getInstance().getStorageHandler().getStorageEngine().saveACL(account, newName, deposit, withdraw, acl, show, owner));
} | [
"public",
"void",
"set",
"(",
"String",
"name",
",",
"boolean",
"deposit",
",",
"boolean",
"withdraw",
",",
"boolean",
"acl",
",",
"boolean",
"show",
",",
"boolean",
"owner",
")",
"{",
"String",
"newName",
"=",
"name",
".",
"toLowerCase",
"(",
")",
";",
"aclList",
".",
"put",
"(",
"name",
",",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"saveACL",
"(",
"account",
",",
"newName",
",",
"deposit",
",",
"withdraw",
",",
"acl",
",",
"show",
",",
"owner",
")",
")",
";",
"}"
] | Set a player in the ACL list
@param name The Player
@param deposit Can deposit or not
@param withdraw Can withdraw or not
@param acl Can modify the ACL or not
@param show Can show the balance
@param owner If he is the owner | [
"Set",
"a",
"player",
"in",
"the",
"ACL",
"list"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java#L185-L188 |
1,259 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java | AccountACL.isOwner | public boolean isOwner(String name) {
boolean result = false;
if (aclList.containsKey(name)) {
result = aclList.get(name).isOwner();
}
return result;
} | java | public boolean isOwner(String name) {
boolean result = false;
if (aclList.containsKey(name)) {
result = aclList.get(name).isOwner();
}
return result;
} | [
"public",
"boolean",
"isOwner",
"(",
"String",
"name",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"aclList",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"result",
"=",
"aclList",
".",
"get",
"(",
"name",
")",
".",
"isOwner",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Checks if the player is the bank owner. This is not affected by the ACL ignore.
@param name The player name to check
@return True if the player is the owner of the account. Else false. | [
"Checks",
"if",
"the",
"player",
"is",
"the",
"bank",
"owner",
".",
"This",
"is",
"not",
"affected",
"by",
"the",
"ACL",
"ignore",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/AccountACL.java#L196-L202 |
1,260 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/currency/CurrencyManager.java | CurrencyManager.getCurrency | public Currency getCurrency(String name) {
Currency result;
if (!currencyList.containsKey(name)) {
result = Common.getInstance().getStorageHandler().getStorageEngine().getCurrency(name);
if (result != null) {
currencyList.put(result.getName(), result);
}
} else {
result = currencyList.get(name);
}
return result;
} | java | public Currency getCurrency(String name) {
Currency result;
if (!currencyList.containsKey(name)) {
result = Common.getInstance().getStorageHandler().getStorageEngine().getCurrency(name);
if (result != null) {
currencyList.put(result.getName(), result);
}
} else {
result = currencyList.get(name);
}
return result;
} | [
"public",
"Currency",
"getCurrency",
"(",
"String",
"name",
")",
"{",
"Currency",
"result",
";",
"if",
"(",
"!",
"currencyList",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"result",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"getCurrency",
"(",
"name",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"currencyList",
".",
"put",
"(",
"result",
".",
"getName",
"(",
")",
",",
"result",
")",
";",
"}",
"}",
"else",
"{",
"result",
"=",
"currencyList",
".",
"get",
"(",
"name",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Get a currency
@param name The name of the currency
@return A currency instance if the currency is found else null | [
"Get",
"a",
"currency"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/currency/CurrencyManager.java#L58-L69 |
1,261 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/currency/CurrencyManager.java | CurrencyManager.setDefault | public void setDefault(Currency currency) {
if (currencyList.containsKey(currency.getName())) {
Common.getInstance().getStorageHandler().getStorageEngine().setDefaultCurrency(currency);
defaultCurrency = currency;
currency.setDefault(true);
for (Map.Entry<String, Currency> currencyEntry : currencyList.entrySet()) {
if (!currencyEntry.getValue().equals(currency)) {
currency.setDefault(false);
}
}
}
} | java | public void setDefault(Currency currency) {
if (currencyList.containsKey(currency.getName())) {
Common.getInstance().getStorageHandler().getStorageEngine().setDefaultCurrency(currency);
defaultCurrency = currency;
currency.setDefault(true);
for (Map.Entry<String, Currency> currencyEntry : currencyList.entrySet()) {
if (!currencyEntry.getValue().equals(currency)) {
currency.setDefault(false);
}
}
}
} | [
"public",
"void",
"setDefault",
"(",
"Currency",
"currency",
")",
"{",
"if",
"(",
"currencyList",
".",
"containsKey",
"(",
"currency",
".",
"getName",
"(",
")",
")",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setDefaultCurrency",
"(",
"currency",
")",
";",
"defaultCurrency",
"=",
"currency",
";",
"currency",
".",
"setDefault",
"(",
"true",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Currency",
">",
"currencyEntry",
":",
"currencyList",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"currencyEntry",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"currency",
")",
")",
"{",
"currency",
".",
"setDefault",
"(",
"false",
")",
";",
"}",
"}",
"}",
"}"
] | Set a currency as the default one.
@param currency The currency to set to default | [
"Set",
"a",
"currency",
"as",
"the",
"default",
"one",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/currency/CurrencyManager.java#L111-L122 |
1,262 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/currency/CurrencyManager.java | CurrencyManager.deleteCurrency | public void deleteCurrency(Currency currency) {
if (currencyList.containsKey(currency.getName())) {
Common.getInstance().getStorageHandler().getStorageEngine().deleteCurrency(currency);
currencyList.remove(currency.getName());
}
} | java | public void deleteCurrency(Currency currency) {
if (currencyList.containsKey(currency.getName())) {
Common.getInstance().getStorageHandler().getStorageEngine().deleteCurrency(currency);
currencyList.remove(currency.getName());
}
} | [
"public",
"void",
"deleteCurrency",
"(",
"Currency",
"currency",
")",
"{",
"if",
"(",
"currencyList",
".",
"containsKey",
"(",
"currency",
".",
"getName",
"(",
")",
")",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"deleteCurrency",
"(",
"currency",
")",
";",
"currencyList",
".",
"remove",
"(",
"currency",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] | Delete a currency.
@param currency The currency to delete | [
"Delete",
"a",
"currency",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/currency/CurrencyManager.java#L129-L134 |
1,263 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/Account.java | Account.getBalance | public double getBalance(String world, String currencyName) {
double balance = Double.MIN_NORMAL;
if (!Common.getInstance().getWorldGroupManager().worldGroupExist(world)) {
world = Common.getInstance().getWorldGroupManager().getWorldGroupName(world);
}
Currency currency = Common.getInstance().getCurrencyManager().getCurrency(currencyName);
if (currency != null) {
if (!hasInfiniteMoney()) {
balance = Common.getInstance().getStorageHandler().getStorageEngine().getBalance(this, currency, world);
} else {
balance = Double.MAX_VALUE;
}
}
return format(balance);
} | java | public double getBalance(String world, String currencyName) {
double balance = Double.MIN_NORMAL;
if (!Common.getInstance().getWorldGroupManager().worldGroupExist(world)) {
world = Common.getInstance().getWorldGroupManager().getWorldGroupName(world);
}
Currency currency = Common.getInstance().getCurrencyManager().getCurrency(currencyName);
if (currency != null) {
if (!hasInfiniteMoney()) {
balance = Common.getInstance().getStorageHandler().getStorageEngine().getBalance(this, currency, world);
} else {
balance = Double.MAX_VALUE;
}
}
return format(balance);
} | [
"public",
"double",
"getBalance",
"(",
"String",
"world",
",",
"String",
"currencyName",
")",
"{",
"double",
"balance",
"=",
"Double",
".",
"MIN_NORMAL",
";",
"if",
"(",
"!",
"Common",
".",
"getInstance",
"(",
")",
".",
"getWorldGroupManager",
"(",
")",
".",
"worldGroupExist",
"(",
"world",
")",
")",
"{",
"world",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getWorldGroupManager",
"(",
")",
".",
"getWorldGroupName",
"(",
"world",
")",
";",
"}",
"Currency",
"currency",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getCurrencyManager",
"(",
")",
".",
"getCurrency",
"(",
"currencyName",
")",
";",
"if",
"(",
"currency",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"hasInfiniteMoney",
"(",
")",
")",
"{",
"balance",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"getBalance",
"(",
"this",
",",
"currency",
",",
"world",
")",
";",
"}",
"else",
"{",
"balance",
"=",
"Double",
".",
"MAX_VALUE",
";",
"}",
"}",
"return",
"format",
"(",
"balance",
")",
";",
"}"
] | Get's the player balance. Sends double.MIN_NORMAL in case of a error
@param world The world / world group to search in
@param currencyName The currency Name
@return The balance. If the account has infinite money. Double.MAX_VALUE is returned. | [
"Get",
"s",
"the",
"player",
"balance",
".",
"Sends",
"double",
".",
"MIN_NORMAL",
"in",
"case",
"of",
"a",
"error"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/Account.java#L121-L135 |
1,264 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/Account.java | Account.withdraw | public double withdraw(double amount, String world, String currencyName, Cause cause, String causeReason) {
BalanceTable balanceTable;
double result = getBalance(world,currencyName) - format(amount);
if (!Common.getInstance().getWorldGroupManager().worldGroupExist(world)) {
world = Common.getInstance().getWorldGroupManager().getWorldGroupName(world);
}
Currency currency = Common.getInstance().getCurrencyManager().getCurrency(currencyName);
if (currency != null) {
if (!hasInfiniteMoney()) {
result = Common.getInstance().getStorageHandler().getStorageEngine().setBalance(this, result, currency, world);
Common.getInstance().writeLog(LogInfo.WITHDRAW, cause, causeReason, this, amount, currency, world);
Common.getInstance().getServerCaller().throwEvent(new EconomyChangeEvent(this.getAccountName(), result));
} else {
result = Double.MAX_VALUE;
}
}
return format(result);
} | java | public double withdraw(double amount, String world, String currencyName, Cause cause, String causeReason) {
BalanceTable balanceTable;
double result = getBalance(world,currencyName) - format(amount);
if (!Common.getInstance().getWorldGroupManager().worldGroupExist(world)) {
world = Common.getInstance().getWorldGroupManager().getWorldGroupName(world);
}
Currency currency = Common.getInstance().getCurrencyManager().getCurrency(currencyName);
if (currency != null) {
if (!hasInfiniteMoney()) {
result = Common.getInstance().getStorageHandler().getStorageEngine().setBalance(this, result, currency, world);
Common.getInstance().writeLog(LogInfo.WITHDRAW, cause, causeReason, this, amount, currency, world);
Common.getInstance().getServerCaller().throwEvent(new EconomyChangeEvent(this.getAccountName(), result));
} else {
result = Double.MAX_VALUE;
}
}
return format(result);
} | [
"public",
"double",
"withdraw",
"(",
"double",
"amount",
",",
"String",
"world",
",",
"String",
"currencyName",
",",
"Cause",
"cause",
",",
"String",
"causeReason",
")",
"{",
"BalanceTable",
"balanceTable",
";",
"double",
"result",
"=",
"getBalance",
"(",
"world",
",",
"currencyName",
")",
"-",
"format",
"(",
"amount",
")",
";",
"if",
"(",
"!",
"Common",
".",
"getInstance",
"(",
")",
".",
"getWorldGroupManager",
"(",
")",
".",
"worldGroupExist",
"(",
"world",
")",
")",
"{",
"world",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getWorldGroupManager",
"(",
")",
".",
"getWorldGroupName",
"(",
"world",
")",
";",
"}",
"Currency",
"currency",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getCurrencyManager",
"(",
")",
".",
"getCurrency",
"(",
"currencyName",
")",
";",
"if",
"(",
"currency",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"hasInfiniteMoney",
"(",
")",
")",
"{",
"result",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setBalance",
"(",
"this",
",",
"result",
",",
"currency",
",",
"world",
")",
";",
"Common",
".",
"getInstance",
"(",
")",
".",
"writeLog",
"(",
"LogInfo",
".",
"WITHDRAW",
",",
"cause",
",",
"causeReason",
",",
"this",
",",
"amount",
",",
"currency",
",",
"world",
")",
";",
"Common",
".",
"getInstance",
"(",
")",
".",
"getServerCaller",
"(",
")",
".",
"throwEvent",
"(",
"new",
"EconomyChangeEvent",
"(",
"this",
".",
"getAccountName",
"(",
")",
",",
"result",
")",
")",
";",
"}",
"else",
"{",
"result",
"=",
"Double",
".",
"MAX_VALUE",
";",
"}",
"}",
"return",
"format",
"(",
"result",
")",
";",
"}"
] | withdraw a certain amount of money in the account
@param amount The amount of money to withdraw
@param world The World / World group we want to withdraw money from
@param currencyName The currency we want to withdraw money from
@param cause The cause of the change.
@param causeReason The reason of the cause.
@return The new balance. If the account has infinite money. Double.MAX_VALUE is returned. | [
"withdraw",
"a",
"certain",
"amount",
"of",
"money",
"in",
"the",
"account"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/Account.java#L204-L221 |
1,265 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/Account.java | Account.set | @Deprecated
public double set(double amount, String world, String currencyName) {
return set(amount, world, currencyName, Cause.UNKNOWN, null);
} | java | @Deprecated
public double set(double amount, String world, String currencyName) {
return set(amount, world, currencyName, Cause.UNKNOWN, null);
} | [
"@",
"Deprecated",
"public",
"double",
"set",
"(",
"double",
"amount",
",",
"String",
"world",
",",
"String",
"currencyName",
")",
"{",
"return",
"set",
"(",
"amount",
",",
"world",
",",
"currencyName",
",",
"Cause",
".",
"UNKNOWN",
",",
"null",
")",
";",
"}"
] | set a certain amount of money in the account
@param amount The amount of money to set
@param world The World / World group we want to set money to
@param currencyName The currency we want to set money to
@return The new balance
@deprecated use {@link #set(double, String, String, com.greatmancode.craftconomy3.Cause, String)} | [
"set",
"a",
"certain",
"amount",
"of",
"money",
"in",
"the",
"account"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/Account.java#L232-L235 |
1,266 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/Account.java | Account.hasEnough | public boolean hasEnough(double amount, String worldName, String currencyName) {
boolean result = false;
amount = format(amount);
if (!Common.getInstance().getWorldGroupManager().worldGroupExist(worldName)) {
worldName = Common.getInstance().getWorldGroupManager().getWorldGroupName(worldName);
}
Currency currency = Common.getInstance().getCurrencyManager().getCurrency(currencyName);
if (currency != null && (getBalance(worldName, currencyName) >= amount || hasInfiniteMoney())) {
result = true;
}
return result;
} | java | public boolean hasEnough(double amount, String worldName, String currencyName) {
boolean result = false;
amount = format(amount);
if (!Common.getInstance().getWorldGroupManager().worldGroupExist(worldName)) {
worldName = Common.getInstance().getWorldGroupManager().getWorldGroupName(worldName);
}
Currency currency = Common.getInstance().getCurrencyManager().getCurrency(currencyName);
if (currency != null && (getBalance(worldName, currencyName) >= amount || hasInfiniteMoney())) {
result = true;
}
return result;
} | [
"public",
"boolean",
"hasEnough",
"(",
"double",
"amount",
",",
"String",
"worldName",
",",
"String",
"currencyName",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"amount",
"=",
"format",
"(",
"amount",
")",
";",
"if",
"(",
"!",
"Common",
".",
"getInstance",
"(",
")",
".",
"getWorldGroupManager",
"(",
")",
".",
"worldGroupExist",
"(",
"worldName",
")",
")",
"{",
"worldName",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getWorldGroupManager",
"(",
")",
".",
"getWorldGroupName",
"(",
"worldName",
")",
";",
"}",
"Currency",
"currency",
"=",
"Common",
".",
"getInstance",
"(",
")",
".",
"getCurrencyManager",
"(",
")",
".",
"getCurrency",
"(",
"currencyName",
")",
";",
"if",
"(",
"currency",
"!=",
"null",
"&&",
"(",
"getBalance",
"(",
"worldName",
",",
"currencyName",
")",
">=",
"amount",
"||",
"hasInfiniteMoney",
"(",
")",
")",
")",
"{",
"result",
"=",
"true",
";",
"}",
"return",
"result",
";",
"}"
] | Checks if we have enough money in a certain balance
@param amount The amount of money to check
@param worldName The World / World group we want to check
@param currencyName The currency we want to check
@return True if there's enough money. Else false | [
"Checks",
"if",
"we",
"have",
"enough",
"money",
"in",
"a",
"certain",
"balance"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/Account.java#L275-L286 |
1,267 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/Account.java | Account.getWorldPlayerCurrentlyIn | private static String getWorldPlayerCurrentlyIn(String playerName) {
return Common.getInstance().getServerCaller().getPlayerCaller().getPlayerWorld(playerName);
} | java | private static String getWorldPlayerCurrentlyIn(String playerName) {
return Common.getInstance().getServerCaller().getPlayerCaller().getPlayerWorld(playerName);
} | [
"private",
"static",
"String",
"getWorldPlayerCurrentlyIn",
"(",
"String",
"playerName",
")",
"{",
"return",
"Common",
".",
"getInstance",
"(",
")",
".",
"getServerCaller",
"(",
")",
".",
"getPlayerCaller",
"(",
")",
".",
"getPlayerWorld",
"(",
"playerName",
")",
";",
"}"
] | Returns the world that the player is currently in
@param playerName The player name.
@return The world name that the player is currently in or any if he is not online/Multiworld system not enabled | [
"Returns",
"the",
"world",
"that",
"the",
"player",
"is",
"currently",
"in"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/Account.java#L294-L296 |
1,268 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/Account.java | Account.getWorldGroupOfPlayerCurrentlyIn | public static String getWorldGroupOfPlayerCurrentlyIn(String playerName) {
return Common.getInstance().getWorldGroupManager().getWorldGroupName(getWorldPlayerCurrentlyIn(playerName));
} | java | public static String getWorldGroupOfPlayerCurrentlyIn(String playerName) {
return Common.getInstance().getWorldGroupManager().getWorldGroupName(getWorldPlayerCurrentlyIn(playerName));
} | [
"public",
"static",
"String",
"getWorldGroupOfPlayerCurrentlyIn",
"(",
"String",
"playerName",
")",
"{",
"return",
"Common",
".",
"getInstance",
"(",
")",
".",
"getWorldGroupManager",
"(",
")",
".",
"getWorldGroupName",
"(",
"getWorldPlayerCurrentlyIn",
"(",
"playerName",
")",
")",
";",
"}"
] | Retrieve the world group of the player
@param playerName The player name
@return The worldGroup of the player. | [
"Retrieve",
"the",
"world",
"group",
"of",
"the",
"player"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/Account.java#L304-L306 |
1,269 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/Account.java | Account.setInfiniteMoney | public void setInfiniteMoney(boolean infinite) {
Common.getInstance().getStorageHandler().getStorageEngine().setInfiniteMoney(this, infinite);
infiniteMoney = infinite;
} | java | public void setInfiniteMoney(boolean infinite) {
Common.getInstance().getStorageHandler().getStorageEngine().setInfiniteMoney(this, infinite);
infiniteMoney = infinite;
} | [
"public",
"void",
"setInfiniteMoney",
"(",
"boolean",
"infinite",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setInfiniteMoney",
"(",
"this",
",",
"infinite",
")",
";",
"infiniteMoney",
"=",
"infinite",
";",
"}"
] | Sets the account to have infinite money.
@param infinite True if the account should have infinite money. Else false. | [
"Sets",
"the",
"account",
"to",
"have",
"infinite",
"money",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/Account.java#L313-L316 |
1,270 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/account/Account.java | Account.setIgnoreACL | public void setIgnoreACL(boolean ignore) {
Common.getInstance().getStorageHandler().getStorageEngine().setIgnoreACL(this, ignore);
ignoreACL = ignore;
} | java | public void setIgnoreACL(boolean ignore) {
Common.getInstance().getStorageHandler().getStorageEngine().setIgnoreACL(this, ignore);
ignoreACL = ignore;
} | [
"public",
"void",
"setIgnoreACL",
"(",
"boolean",
"ignore",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setIgnoreACL",
"(",
"this",
",",
"ignore",
")",
";",
"ignoreACL",
"=",
"ignore",
";",
"}"
] | Sets if a account should ignore his ACL. Only works on Bank accounts.
@param ignore If the ACL is ignored or not | [
"Sets",
"if",
"a",
"account",
"should",
"ignore",
"his",
"ACL",
".",
"Only",
"works",
"on",
"Bank",
"accounts",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/account/Account.java#L359-L362 |
1,271 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/currency/Currency.java | Currency.setName | public void setName(String name) {
String oldname = this.name;
this.name = name;
//TODO Reset the main map
save(oldname);
} | java | public void setName(String name) {
String oldname = this.name;
this.name = name;
//TODO Reset the main map
save(oldname);
} | [
"public",
"void",
"setName",
"(",
"String",
"name",
")",
"{",
"String",
"oldname",
"=",
"this",
".",
"name",
";",
"this",
".",
"name",
"=",
"name",
";",
"//TODO Reset the main map",
"save",
"(",
"oldname",
")",
";",
"}"
] | Set the currency name
@param name The currency name to set to. | [
"Set",
"the",
"currency",
"name"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/currency/Currency.java#L76-L81 |
1,272 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/currency/Currency.java | Currency.getExchangeRate | public double getExchangeRate(Currency otherCurrency) throws NoExchangeRate {
return Common.getInstance().getStorageHandler().getStorageEngine().getExchangeRate(this, otherCurrency);
} | java | public double getExchangeRate(Currency otherCurrency) throws NoExchangeRate {
return Common.getInstance().getStorageHandler().getStorageEngine().getExchangeRate(this, otherCurrency);
} | [
"public",
"double",
"getExchangeRate",
"(",
"Currency",
"otherCurrency",
")",
"throws",
"NoExchangeRate",
"{",
"return",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"getExchangeRate",
"(",
"this",
",",
"otherCurrency",
")",
";",
"}"
] | Returns the exchange rate between 2 currency.
@param otherCurrency The other currency to exchange to
@return The exchange rate or Double.MIN_VALUE if no exchange information are found.
@throws com.greatmancode.craftconomy3.utils.NoExchangeRate If there's no exchange rate between the 2 currencies. | [
"Returns",
"the",
"exchange",
"rate",
"between",
"2",
"currency",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/currency/Currency.java#L166-L168 |
1,273 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/currency/Currency.java | Currency.setExchangeRate | public void setExchangeRate(Currency otherCurrency, double amount) {
Common.getInstance().getStorageHandler().getStorageEngine().setExchangeRate(this, otherCurrency, amount);
} | java | public void setExchangeRate(Currency otherCurrency, double amount) {
Common.getInstance().getStorageHandler().getStorageEngine().setExchangeRate(this, otherCurrency, amount);
} | [
"public",
"void",
"setExchangeRate",
"(",
"Currency",
"otherCurrency",
",",
"double",
"amount",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"setExchangeRate",
"(",
"this",
",",
"otherCurrency",
",",
"amount",
")",
";",
"}"
] | Set the exchange rate between 2 currency
@param otherCurrency The other currency
@param amount THe exchange rate. | [
"Set",
"the",
"exchange",
"rate",
"between",
"2",
"currency"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/currency/Currency.java#L176-L178 |
1,274 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/currency/Currency.java | Currency.save | private void save(String oldName) {
Common.getInstance().getStorageHandler().getStorageEngine().saveCurrency(oldName, this);
Common.getInstance().getCurrencyManager().updateEntry(oldName, this);
} | java | private void save(String oldName) {
Common.getInstance().getStorageHandler().getStorageEngine().saveCurrency(oldName, this);
Common.getInstance().getCurrencyManager().updateEntry(oldName, this);
} | [
"private",
"void",
"save",
"(",
"String",
"oldName",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"saveCurrency",
"(",
"oldName",
",",
"this",
")",
";",
"Common",
".",
"getInstance",
"(",
")",
".",
"getCurrencyManager",
"(",
")",
".",
"updateEntry",
"(",
"oldName",
",",
"this",
")",
";",
"}"
] | Save the currency information. Used while changing the main currency name.
@param oldName The old currency name. | [
"Save",
"the",
"currency",
"information",
".",
"Used",
"while",
"changing",
"the",
"main",
"currency",
"name",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/currency/Currency.java#L191-L194 |
1,275 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/converter/Converter.java | Converter.setDbType | public boolean setDbType(String dbType) {
boolean result = false;
if (dbTypes.contains(dbType)) {
setSelectedDbType(dbType);
result = true;
}
return result;
} | java | public boolean setDbType(String dbType) {
boolean result = false;
if (dbTypes.contains(dbType)) {
setSelectedDbType(dbType);
result = true;
}
return result;
} | [
"public",
"boolean",
"setDbType",
"(",
"String",
"dbType",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"dbTypes",
".",
"contains",
"(",
"dbType",
")",
")",
"{",
"setSelectedDbType",
"(",
"dbType",
")",
";",
"result",
"=",
"true",
";",
"}",
"return",
"result",
";",
"}"
] | Sets the selected database type.
@param dbType The database type selected
@return True if the database type has been saved else false (A invalid type) | [
"Sets",
"the",
"selected",
"database",
"type",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/converter/Converter.java#L75-L82 |
1,276 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/converter/Converter.java | Converter.setDbInfo | public boolean setDbInfo(String field, String value) {
boolean result = false;
if (dbInfo.contains(field)) {
dbConnectInfo.put(field, value);
result = true;
}
return result;
} | java | public boolean setDbInfo(String field, String value) {
boolean result = false;
if (dbInfo.contains(field)) {
dbConnectInfo.put(field, value);
result = true;
}
return result;
} | [
"public",
"boolean",
"setDbInfo",
"(",
"String",
"field",
",",
"String",
"value",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"if",
"(",
"dbInfo",
".",
"contains",
"(",
"field",
")",
")",
"{",
"dbConnectInfo",
".",
"put",
"(",
"field",
",",
"value",
")",
";",
"result",
"=",
"true",
";",
"}",
"return",
"result",
";",
"}"
] | Sets a field information for the selected database type
@param field The field name.
@param value The value of the field.
@return True if the field has been saved else false (A invalid field) | [
"Sets",
"a",
"field",
"information",
"for",
"the",
"selected",
"database",
"type"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/converter/Converter.java#L98-L105 |
1,277 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/converter/Converter.java | Converter.addAccountToString | protected void addAccountToString(String sender, List<User> userList2) {
Common.getInstance().getServerCaller().getPlayerCaller().sendMessage(sender, "{{DARK_RED}}Converting accounts. This may take a while.");
Common.getInstance().getStorageHandler().getStorageEngine().saveImporterUsers(userList2);
Common.getInstance().getServerCaller().getPlayerCaller().sendMessage(sender, userList2.size() + " {{DARK_GREEN}}accounts converted! Enjoy!");
} | java | protected void addAccountToString(String sender, List<User> userList2) {
Common.getInstance().getServerCaller().getPlayerCaller().sendMessage(sender, "{{DARK_RED}}Converting accounts. This may take a while.");
Common.getInstance().getStorageHandler().getStorageEngine().saveImporterUsers(userList2);
Common.getInstance().getServerCaller().getPlayerCaller().sendMessage(sender, userList2.size() + " {{DARK_GREEN}}accounts converted! Enjoy!");
} | [
"protected",
"void",
"addAccountToString",
"(",
"String",
"sender",
",",
"List",
"<",
"User",
">",
"userList2",
")",
"{",
"Common",
".",
"getInstance",
"(",
")",
".",
"getServerCaller",
"(",
")",
".",
"getPlayerCaller",
"(",
")",
".",
"sendMessage",
"(",
"sender",
",",
"\"{{DARK_RED}}Converting accounts. This may take a while.\"",
")",
";",
"Common",
".",
"getInstance",
"(",
")",
".",
"getStorageHandler",
"(",
")",
".",
"getStorageEngine",
"(",
")",
".",
"saveImporterUsers",
"(",
"userList2",
")",
";",
"Common",
".",
"getInstance",
"(",
")",
".",
"getServerCaller",
"(",
")",
".",
"getPlayerCaller",
"(",
")",
".",
"sendMessage",
"(",
"sender",
",",
"userList2",
".",
"size",
"(",
")",
"+",
"\" {{DARK_GREEN}}accounts converted! Enjoy!\"",
")",
";",
"}"
] | Add the given accounts to the system
@param sender The sender so we can send messages back to him
@param userList2 Account list | [
"Add",
"the",
"given",
"accounts",
"to",
"the",
"system"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/converter/Converter.java#L165-L169 |
1,278 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/groups/WorldGroup.java | WorldGroup.addWorld | public void addWorld(String name) {
if (name != null && Common.getInstance().getServerCaller().worldExist(name) && !worldExist(name)) {
worldList.add(name);
save();
}
} | java | public void addWorld(String name) {
if (name != null && Common.getInstance().getServerCaller().worldExist(name) && !worldExist(name)) {
worldList.add(name);
save();
}
} | [
"public",
"void",
"addWorld",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"!=",
"null",
"&&",
"Common",
".",
"getInstance",
"(",
")",
".",
"getServerCaller",
"(",
")",
".",
"worldExist",
"(",
"name",
")",
"&&",
"!",
"worldExist",
"(",
"name",
")",
")",
"{",
"worldList",
".",
"add",
"(",
"name",
")",
";",
"save",
"(",
")",
";",
"}",
"}"
] | Add a world to this worldGroup. It needs to exist so it can be added!
@param name The world name. | [
"Add",
"a",
"world",
"to",
"this",
"worldGroup",
".",
"It",
"needs",
"to",
"exist",
"so",
"it",
"can",
"be",
"added!"
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/groups/WorldGroup.java#L50-L55 |
1,279 | greatman/craftconomy3 | src/main/java/com/greatmancode/craftconomy3/groups/WorldGroup.java | WorldGroup.removeWorld | public void removeWorld(String world) {
if (worldList.contains(world)) {
worldList.remove(world);
save();
}
} | java | public void removeWorld(String world) {
if (worldList.contains(world)) {
worldList.remove(world);
save();
}
} | [
"public",
"void",
"removeWorld",
"(",
"String",
"world",
")",
"{",
"if",
"(",
"worldList",
".",
"contains",
"(",
"world",
")",
")",
"{",
"worldList",
".",
"remove",
"(",
"world",
")",
";",
"save",
"(",
")",
";",
"}",
"}"
] | Remove a world from the group if it exists.
@param world The world name | [
"Remove",
"a",
"world",
"from",
"the",
"group",
"if",
"it",
"exists",
"."
] | 51b1b3de7d039e20c7418d1e70b8c4b02b8cf840 | https://github.com/greatman/craftconomy3/blob/51b1b3de7d039e20c7418d1e70b8c4b02b8cf840/src/main/java/com/greatmancode/craftconomy3/groups/WorldGroup.java#L62-L67 |
1,280 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/impl/AlertsEngineImpl.java | AlertsEngineImpl.sendData | @Override
public void sendData(TreeSet<Data> data) {
if (data == null) {
throw new IllegalArgumentException("Data must be not null");
}
if (data.isEmpty()) {
return;
}
addData(data);
if (distributed) {
partitionManager.notifyData(new ArrayList<>(data));
}
} | java | @Override
public void sendData(TreeSet<Data> data) {
if (data == null) {
throw new IllegalArgumentException("Data must be not null");
}
if (data.isEmpty()) {
return;
}
addData(data);
if (distributed) {
partitionManager.notifyData(new ArrayList<>(data));
}
} | [
"@",
"Override",
"public",
"void",
"sendData",
"(",
"TreeSet",
"<",
"Data",
">",
"data",
")",
"{",
"if",
"(",
"data",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Data must be not null\"",
")",
";",
"}",
"if",
"(",
"data",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"addData",
"(",
"data",
")",
";",
"if",
"(",
"distributed",
")",
"{",
"partitionManager",
".",
"notifyData",
"(",
"new",
"ArrayList",
"<>",
"(",
"data",
")",
")",
";",
"}",
"}"
] | use synchronized blocks to protect pendingData. | [
"use",
"synchronized",
"blocks",
"to",
"protect",
"pendingData",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/impl/AlertsEngineImpl.java#L484-L498 |
1,281 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/impl/AlertsEngineImpl.java | AlertsEngineImpl.sendEvents | @Override
public void sendEvents(TreeSet<Event> events) {
if (events == null) {
throw new IllegalArgumentException("Events must be not null");
}
if (events.isEmpty()) {
return;
}
addEvents(events);
if (distributed) {
partitionManager.notifyEvents(new ArrayList<>(events));
}
} | java | @Override
public void sendEvents(TreeSet<Event> events) {
if (events == null) {
throw new IllegalArgumentException("Events must be not null");
}
if (events.isEmpty()) {
return;
}
addEvents(events);
if (distributed) {
partitionManager.notifyEvents(new ArrayList<>(events));
}
} | [
"@",
"Override",
"public",
"void",
"sendEvents",
"(",
"TreeSet",
"<",
"Event",
">",
"events",
")",
"{",
"if",
"(",
"events",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Events must be not null\"",
")",
";",
"}",
"if",
"(",
"events",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"addEvents",
"(",
"events",
")",
";",
"if",
"(",
"distributed",
")",
"{",
"partitionManager",
".",
"notifyEvents",
"(",
"new",
"ArrayList",
"<>",
"(",
"events",
")",
")",
";",
"}",
"}"
] | use synchronized blocks to protect pendingEvents. | [
"use",
"synchronized",
"blocks",
"to",
"protect",
"pendingEvents",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/impl/AlertsEngineImpl.java#L538-L552 |
1,282 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/impl/ispn/IspnDefinitionsServiceImpl.java | IspnDefinitionsServiceImpl.addFullTrigger | private void addFullTrigger(String tenantId, FullTrigger fullTrigger) throws Exception {
if (null == fullTrigger) {
throw new IllegalArgumentException("FullTrigger must be not null");
}
if (fullTrigger.getTrigger() != null) {
Trigger trigger = fullTrigger.getTrigger();
trigger.setTenantId(tenantId);
addTrigger(trigger);
if (!isEmpty(fullTrigger.getDampenings())) {
for (Dampening d : fullTrigger.getDampenings()) {
d.setTenantId(tenantId);
d.setTriggerId(trigger.getId());
addDampening(d);
}
}
if (!isEmpty(fullTrigger.getConditions())) {
setAllConditions(tenantId, trigger.getId(), fullTrigger.getConditions());
}
}
} | java | private void addFullTrigger(String tenantId, FullTrigger fullTrigger) throws Exception {
if (null == fullTrigger) {
throw new IllegalArgumentException("FullTrigger must be not null");
}
if (fullTrigger.getTrigger() != null) {
Trigger trigger = fullTrigger.getTrigger();
trigger.setTenantId(tenantId);
addTrigger(trigger);
if (!isEmpty(fullTrigger.getDampenings())) {
for (Dampening d : fullTrigger.getDampenings()) {
d.setTenantId(tenantId);
d.setTriggerId(trigger.getId());
addDampening(d);
}
}
if (!isEmpty(fullTrigger.getConditions())) {
setAllConditions(tenantId, trigger.getId(), fullTrigger.getConditions());
}
}
} | [
"private",
"void",
"addFullTrigger",
"(",
"String",
"tenantId",
",",
"FullTrigger",
"fullTrigger",
")",
"throws",
"Exception",
"{",
"if",
"(",
"null",
"==",
"fullTrigger",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"FullTrigger must be not null\"",
")",
";",
"}",
"if",
"(",
"fullTrigger",
".",
"getTrigger",
"(",
")",
"!=",
"null",
")",
"{",
"Trigger",
"trigger",
"=",
"fullTrigger",
".",
"getTrigger",
"(",
")",
";",
"trigger",
".",
"setTenantId",
"(",
"tenantId",
")",
";",
"addTrigger",
"(",
"trigger",
")",
";",
"if",
"(",
"!",
"isEmpty",
"(",
"fullTrigger",
".",
"getDampenings",
"(",
")",
")",
")",
"{",
"for",
"(",
"Dampening",
"d",
":",
"fullTrigger",
".",
"getDampenings",
"(",
")",
")",
"{",
"d",
".",
"setTenantId",
"(",
"tenantId",
")",
";",
"d",
".",
"setTriggerId",
"(",
"trigger",
".",
"getId",
"(",
")",
")",
";",
"addDampening",
"(",
"d",
")",
";",
"}",
"}",
"if",
"(",
"!",
"isEmpty",
"(",
"fullTrigger",
".",
"getConditions",
"(",
")",
")",
")",
"{",
"setAllConditions",
"(",
"tenantId",
",",
"trigger",
".",
"getId",
"(",
")",
",",
"fullTrigger",
".",
"getConditions",
"(",
")",
")",
";",
"}",
"}",
"}"
] | caller should be deferring notifications | [
"caller",
"should",
"be",
"deferring",
"notifications"
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/impl/ispn/IspnDefinitionsServiceImpl.java#L2048-L2067 |
1,283 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/impl/PartitionManagerImpl.java | PartitionManagerImpl.calculatePartition | public Map<PartitionEntry, Integer> calculatePartition(List<PartitionEntry> entries,
Map<Integer, Integer> buckets) {
if (entries == null) {
throw new IllegalArgumentException("entries must be not null");
}
if (isEmpty(buckets)) {
throw new IllegalArgumentException("entries must be not null");
}
HashFunction md5 = Hashing.md5();
int numBuckets = buckets.size();
Map<PartitionEntry, Integer> newPartition = new HashMap<>();
for (PartitionEntry entry : entries) {
newPartition.put(entry, buckets.get(Hashing.consistentHash(md5.hashInt(entry.hashCode()), numBuckets)));
}
return newPartition;
} | java | public Map<PartitionEntry, Integer> calculatePartition(List<PartitionEntry> entries,
Map<Integer, Integer> buckets) {
if (entries == null) {
throw new IllegalArgumentException("entries must be not null");
}
if (isEmpty(buckets)) {
throw new IllegalArgumentException("entries must be not null");
}
HashFunction md5 = Hashing.md5();
int numBuckets = buckets.size();
Map<PartitionEntry, Integer> newPartition = new HashMap<>();
for (PartitionEntry entry : entries) {
newPartition.put(entry, buckets.get(Hashing.consistentHash(md5.hashInt(entry.hashCode()), numBuckets)));
}
return newPartition;
} | [
"public",
"Map",
"<",
"PartitionEntry",
",",
"Integer",
">",
"calculatePartition",
"(",
"List",
"<",
"PartitionEntry",
">",
"entries",
",",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"buckets",
")",
"{",
"if",
"(",
"entries",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"entries must be not null\"",
")",
";",
"}",
"if",
"(",
"isEmpty",
"(",
"buckets",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"entries must be not null\"",
")",
";",
"}",
"HashFunction",
"md5",
"=",
"Hashing",
".",
"md5",
"(",
")",
";",
"int",
"numBuckets",
"=",
"buckets",
".",
"size",
"(",
")",
";",
"Map",
"<",
"PartitionEntry",
",",
"Integer",
">",
"newPartition",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"PartitionEntry",
"entry",
":",
"entries",
")",
"{",
"newPartition",
".",
"put",
"(",
"entry",
",",
"buckets",
".",
"get",
"(",
"Hashing",
".",
"consistentHash",
"(",
"md5",
".",
"hashInt",
"(",
"entry",
".",
"hashCode",
"(",
")",
")",
",",
"numBuckets",
")",
")",
")",
";",
"}",
"return",
"newPartition",
";",
"}"
] | Distribute triggers on nodes using a consistent hashing strategy.
This strategy allows to scale and minimize changes and re-distribution when cluster changes.
@param entries a list of entries to distribute
@param buckets a table of nodes
@return a map of entries distributed across nodes | [
"Distribute",
"triggers",
"on",
"nodes",
"using",
"a",
"consistent",
"hashing",
"strategy",
".",
"This",
"strategy",
"allows",
"to",
"scale",
"and",
"minimize",
"changes",
"and",
"re",
"-",
"distribution",
"when",
"cluster",
"changes",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/impl/PartitionManagerImpl.java#L408-L423 |
1,284 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/impl/PartitionManagerImpl.java | PartitionManagerImpl.calculateNewEntry | public Integer calculateNewEntry(PartitionEntry newEntry, Map<Integer, Integer> buckets) {
if (newEntry == null) {
throw new IllegalArgumentException("newEntry must be not null");
}
if (isEmpty(buckets)) {
throw new IllegalArgumentException("buckets must be not null");
}
HashFunction md5 = Hashing.md5();
int numBuckets = buckets.size();
return buckets.get(Hashing.consistentHash(md5.hashInt(newEntry.hashCode()), numBuckets));
} | java | public Integer calculateNewEntry(PartitionEntry newEntry, Map<Integer, Integer> buckets) {
if (newEntry == null) {
throw new IllegalArgumentException("newEntry must be not null");
}
if (isEmpty(buckets)) {
throw new IllegalArgumentException("buckets must be not null");
}
HashFunction md5 = Hashing.md5();
int numBuckets = buckets.size();
return buckets.get(Hashing.consistentHash(md5.hashInt(newEntry.hashCode()), numBuckets));
} | [
"public",
"Integer",
"calculateNewEntry",
"(",
"PartitionEntry",
"newEntry",
",",
"Map",
"<",
"Integer",
",",
"Integer",
">",
"buckets",
")",
"{",
"if",
"(",
"newEntry",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"newEntry must be not null\"",
")",
";",
"}",
"if",
"(",
"isEmpty",
"(",
"buckets",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"buckets must be not null\"",
")",
";",
"}",
"HashFunction",
"md5",
"=",
"Hashing",
".",
"md5",
"(",
")",
";",
"int",
"numBuckets",
"=",
"buckets",
".",
"size",
"(",
")",
";",
"return",
"buckets",
".",
"get",
"(",
"Hashing",
".",
"consistentHash",
"(",
"md5",
".",
"hashInt",
"(",
"newEntry",
".",
"hashCode",
"(",
")",
")",
",",
"numBuckets",
")",
")",
";",
"}"
] | Distribute a new entry across buckets using a consistent hashing strategy.
@param newEntry the new entry to distribute
@param buckets a table of nodes
@return a code of the node which the new entry is placed | [
"Distribute",
"a",
"new",
"entry",
"across",
"buckets",
"using",
"a",
"consistent",
"hashing",
"strategy",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/impl/PartitionManagerImpl.java#L432-L442 |
1,285 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/util/ActionsValidator.java | ActionsValidator.validate | public static boolean validate(TriggerAction triggerAction, Event event) {
if (triggerAction == null || event == null) {
return true;
}
if ((isEmpty(triggerAction.getStates()))
&& triggerAction.getCalendar() == null) {
return true;
}
if (event instanceof Alert
&& triggerAction.getStates() != null
&& !triggerAction.getStates().isEmpty()
&& !triggerAction.getStates().contains( ((Alert)event).getStatus().name()) ) {
return false;
}
if (triggerAction.getCalendar() != null) {
try {
return triggerAction.getCalendar().isSatisfiedBy(event.getCtime());
} catch (Exception e) {
log.debug(e.getMessage(), e);
log.errorCannotValidateAction(e.getMessage());
}
}
return true;
} | java | public static boolean validate(TriggerAction triggerAction, Event event) {
if (triggerAction == null || event == null) {
return true;
}
if ((isEmpty(triggerAction.getStates()))
&& triggerAction.getCalendar() == null) {
return true;
}
if (event instanceof Alert
&& triggerAction.getStates() != null
&& !triggerAction.getStates().isEmpty()
&& !triggerAction.getStates().contains( ((Alert)event).getStatus().name()) ) {
return false;
}
if (triggerAction.getCalendar() != null) {
try {
return triggerAction.getCalendar().isSatisfiedBy(event.getCtime());
} catch (Exception e) {
log.debug(e.getMessage(), e);
log.errorCannotValidateAction(e.getMessage());
}
}
return true;
} | [
"public",
"static",
"boolean",
"validate",
"(",
"TriggerAction",
"triggerAction",
",",
"Event",
"event",
")",
"{",
"if",
"(",
"triggerAction",
"==",
"null",
"||",
"event",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"(",
"isEmpty",
"(",
"triggerAction",
".",
"getStates",
"(",
")",
")",
")",
"&&",
"triggerAction",
".",
"getCalendar",
"(",
")",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"event",
"instanceof",
"Alert",
"&&",
"triggerAction",
".",
"getStates",
"(",
")",
"!=",
"null",
"&&",
"!",
"triggerAction",
".",
"getStates",
"(",
")",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"triggerAction",
".",
"getStates",
"(",
")",
".",
"contains",
"(",
"(",
"(",
"Alert",
")",
"event",
")",
".",
"getStatus",
"(",
")",
".",
"name",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"triggerAction",
".",
"getCalendar",
"(",
")",
"!=",
"null",
")",
"{",
"try",
"{",
"return",
"triggerAction",
".",
"getCalendar",
"(",
")",
".",
"isSatisfiedBy",
"(",
"event",
".",
"getCtime",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"debug",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"log",
".",
"errorCannotValidateAction",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Validate if an Event should generate an Action based on the constraints defined on a TriggerAction.
@param triggerAction a TriggerAction where status and time constraints are defined.
@param event a given Event to validate against a TriggerAction
@return true if the Event is validated and it should generated an action
false on the contrary | [
"Validate",
"if",
"an",
"Event",
"should",
"generate",
"an",
"Action",
"based",
"on",
"the",
"constraints",
"defined",
"on",
"a",
"TriggerAction",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/util/ActionsValidator.java#L48-L71 |
1,286 | hawkular/hawkular-alerts | actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/EmailTemplate.java | EmailTemplate.processTemplate | public Map<String, String> processTemplate(ActionMessage msg) throws Exception {
Map<String, String> emailProcessed = new HashMap<>();
PluginMessageDescription pmDesc = new PluginMessageDescription(msg);
// Prepare emailSubject directly from PluginMessageDescription class
emailProcessed.put("emailSubject", pmDesc.getEmailSubject());
// Check if templates are defined in properties
String plain;
String html;
String templateLocale = pmDesc.getProps() != null ?
pmDesc.getProps().get(EmailPlugin.PROP_TEMPLATE_LOCALE) : null;
if (templateLocale != null) {
plain = pmDesc.getProps().get(EmailPlugin.PROP_TEMPLATE_PLAIN + "." + templateLocale);
html = pmDesc.getProps().get(EmailPlugin.PROP_TEMPLATE_HTML + "." + templateLocale);
} else {
plain = pmDesc.getProps() != null ? pmDesc.getProps().get(EmailPlugin.PROP_TEMPLATE_PLAIN) : null;
html = pmDesc.getProps() != null ? pmDesc.getProps().get(EmailPlugin.PROP_TEMPLATE_HTML) : null;
}
/*
Invoke freemarker template with PluginMessageDescription as root object for dynamic data.
PluginMessageDescription fields are accessible within .ftl templates.
*/
StringWriter writerPlain = new StringWriter();
StringWriter writerHtml = new StringWriter();
if (!isEmpty(plain)) {
StringReader plainReader = new StringReader(plain);
ftlTemplate = new Template("plainTemplate", plainReader, ftlCfg);
ftlTemplate.process(pmDesc, writerPlain);
} else {
ftlTemplatePlain.process(pmDesc, writerPlain);
}
if (!isEmpty(html)) {
StringReader htmlReader = new StringReader(html);
ftlTemplate = new Template("htmlTemplate", htmlReader, ftlCfg);
ftlTemplate.process(pmDesc, writerHtml);
} else {
ftlTemplateHtml.process(pmDesc, writerHtml);
}
writerPlain.flush();
writerPlain.close();
emailProcessed.put("emailBodyPlain", writerPlain.toString());
writerHtml.flush();
writerHtml.close();
emailProcessed.put("emailBodyHtml", writerHtml.toString());
return emailProcessed;
} | java | public Map<String, String> processTemplate(ActionMessage msg) throws Exception {
Map<String, String> emailProcessed = new HashMap<>();
PluginMessageDescription pmDesc = new PluginMessageDescription(msg);
// Prepare emailSubject directly from PluginMessageDescription class
emailProcessed.put("emailSubject", pmDesc.getEmailSubject());
// Check if templates are defined in properties
String plain;
String html;
String templateLocale = pmDesc.getProps() != null ?
pmDesc.getProps().get(EmailPlugin.PROP_TEMPLATE_LOCALE) : null;
if (templateLocale != null) {
plain = pmDesc.getProps().get(EmailPlugin.PROP_TEMPLATE_PLAIN + "." + templateLocale);
html = pmDesc.getProps().get(EmailPlugin.PROP_TEMPLATE_HTML + "." + templateLocale);
} else {
plain = pmDesc.getProps() != null ? pmDesc.getProps().get(EmailPlugin.PROP_TEMPLATE_PLAIN) : null;
html = pmDesc.getProps() != null ? pmDesc.getProps().get(EmailPlugin.PROP_TEMPLATE_HTML) : null;
}
/*
Invoke freemarker template with PluginMessageDescription as root object for dynamic data.
PluginMessageDescription fields are accessible within .ftl templates.
*/
StringWriter writerPlain = new StringWriter();
StringWriter writerHtml = new StringWriter();
if (!isEmpty(plain)) {
StringReader plainReader = new StringReader(plain);
ftlTemplate = new Template("plainTemplate", plainReader, ftlCfg);
ftlTemplate.process(pmDesc, writerPlain);
} else {
ftlTemplatePlain.process(pmDesc, writerPlain);
}
if (!isEmpty(html)) {
StringReader htmlReader = new StringReader(html);
ftlTemplate = new Template("htmlTemplate", htmlReader, ftlCfg);
ftlTemplate.process(pmDesc, writerHtml);
} else {
ftlTemplateHtml.process(pmDesc, writerHtml);
}
writerPlain.flush();
writerPlain.close();
emailProcessed.put("emailBodyPlain", writerPlain.toString());
writerHtml.flush();
writerHtml.close();
emailProcessed.put("emailBodyHtml", writerHtml.toString());
return emailProcessed;
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"processTemplate",
"(",
"ActionMessage",
"msg",
")",
"throws",
"Exception",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"emailProcessed",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"PluginMessageDescription",
"pmDesc",
"=",
"new",
"PluginMessageDescription",
"(",
"msg",
")",
";",
"// Prepare emailSubject directly from PluginMessageDescription class",
"emailProcessed",
".",
"put",
"(",
"\"emailSubject\"",
",",
"pmDesc",
".",
"getEmailSubject",
"(",
")",
")",
";",
"// Check if templates are defined in properties",
"String",
"plain",
";",
"String",
"html",
";",
"String",
"templateLocale",
"=",
"pmDesc",
".",
"getProps",
"(",
")",
"!=",
"null",
"?",
"pmDesc",
".",
"getProps",
"(",
")",
".",
"get",
"(",
"EmailPlugin",
".",
"PROP_TEMPLATE_LOCALE",
")",
":",
"null",
";",
"if",
"(",
"templateLocale",
"!=",
"null",
")",
"{",
"plain",
"=",
"pmDesc",
".",
"getProps",
"(",
")",
".",
"get",
"(",
"EmailPlugin",
".",
"PROP_TEMPLATE_PLAIN",
"+",
"\".\"",
"+",
"templateLocale",
")",
";",
"html",
"=",
"pmDesc",
".",
"getProps",
"(",
")",
".",
"get",
"(",
"EmailPlugin",
".",
"PROP_TEMPLATE_HTML",
"+",
"\".\"",
"+",
"templateLocale",
")",
";",
"}",
"else",
"{",
"plain",
"=",
"pmDesc",
".",
"getProps",
"(",
")",
"!=",
"null",
"?",
"pmDesc",
".",
"getProps",
"(",
")",
".",
"get",
"(",
"EmailPlugin",
".",
"PROP_TEMPLATE_PLAIN",
")",
":",
"null",
";",
"html",
"=",
"pmDesc",
".",
"getProps",
"(",
")",
"!=",
"null",
"?",
"pmDesc",
".",
"getProps",
"(",
")",
".",
"get",
"(",
"EmailPlugin",
".",
"PROP_TEMPLATE_HTML",
")",
":",
"null",
";",
"}",
"/*\n Invoke freemarker template with PluginMessageDescription as root object for dynamic data.\n PluginMessageDescription fields are accessible within .ftl templates.\n */",
"StringWriter",
"writerPlain",
"=",
"new",
"StringWriter",
"(",
")",
";",
"StringWriter",
"writerHtml",
"=",
"new",
"StringWriter",
"(",
")",
";",
"if",
"(",
"!",
"isEmpty",
"(",
"plain",
")",
")",
"{",
"StringReader",
"plainReader",
"=",
"new",
"StringReader",
"(",
"plain",
")",
";",
"ftlTemplate",
"=",
"new",
"Template",
"(",
"\"plainTemplate\"",
",",
"plainReader",
",",
"ftlCfg",
")",
";",
"ftlTemplate",
".",
"process",
"(",
"pmDesc",
",",
"writerPlain",
")",
";",
"}",
"else",
"{",
"ftlTemplatePlain",
".",
"process",
"(",
"pmDesc",
",",
"writerPlain",
")",
";",
"}",
"if",
"(",
"!",
"isEmpty",
"(",
"html",
")",
")",
"{",
"StringReader",
"htmlReader",
"=",
"new",
"StringReader",
"(",
"html",
")",
";",
"ftlTemplate",
"=",
"new",
"Template",
"(",
"\"htmlTemplate\"",
",",
"htmlReader",
",",
"ftlCfg",
")",
";",
"ftlTemplate",
".",
"process",
"(",
"pmDesc",
",",
"writerHtml",
")",
";",
"}",
"else",
"{",
"ftlTemplateHtml",
".",
"process",
"(",
"pmDesc",
",",
"writerHtml",
")",
";",
"}",
"writerPlain",
".",
"flush",
"(",
")",
";",
"writerPlain",
".",
"close",
"(",
")",
";",
"emailProcessed",
".",
"put",
"(",
"\"emailBodyPlain\"",
",",
"writerPlain",
".",
"toString",
"(",
")",
")",
";",
"writerHtml",
".",
"flush",
"(",
")",
";",
"writerHtml",
".",
"close",
"(",
")",
";",
"emailProcessed",
".",
"put",
"(",
"\"emailBodyHtml\"",
",",
"writerHtml",
".",
"toString",
"(",
")",
")",
";",
"return",
"emailProcessed",
";",
"}"
] | Process a PluginMessage and creates email content based on templates.
@param msg the PluginMessage to be processed
@return a Map with following entries:
- "emailSubject": Subject of the email
- "emailBodyPlain": Content for plain text email
- "emailBodyHtml": Content for html email
@throws Exception on any problem | [
"Process",
"a",
"PluginMessage",
"and",
"creates",
"email",
"content",
"based",
"on",
"templates",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/EmailTemplate.java#L133-L186 |
1,287 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/util/NelsonData.java | NelsonData.rule1 | private boolean rule1(double sample) {
if (!hasMean()) {
return false;
}
return Math.abs(sample - mean.getResult()) > threeDeviations;
} | java | private boolean rule1(double sample) {
if (!hasMean()) {
return false;
}
return Math.abs(sample - mean.getResult()) > threeDeviations;
} | [
"private",
"boolean",
"rule1",
"(",
"double",
"sample",
")",
"{",
"if",
"(",
"!",
"hasMean",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"Math",
".",
"abs",
"(",
"sample",
"-",
"mean",
".",
"getResult",
"(",
")",
")",
">",
"threeDeviations",
";",
"}"
] | one point is more than 3 standard deviations from the mean | [
"one",
"point",
"is",
"more",
"than",
"3",
"standard",
"deviations",
"from",
"the",
"mean"
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/util/NelsonData.java#L180-L186 |
1,288 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/util/NelsonData.java | NelsonData.rule5 | private boolean rule5(double sample) {
if (!hasMean()) {
return false;
}
if (rule5LastThree.size() == 3) {
switch (rule5LastThree.removeLast()) {
case ">":
--rule5Above;
break;
case "<":
--rule5Below;
break;
}
}
if (Math.abs(sample - mean.getResult()) > twoDeviations) {
if (sample > mean.getResult()) {
++rule5Above;
rule5LastThree.push(">");
} else {
++rule5Below;
rule5LastThree.push("<");
}
} else {
rule5LastThree.push("");
}
return rule5Above >= 2 || rule5Below >= 2;
} | java | private boolean rule5(double sample) {
if (!hasMean()) {
return false;
}
if (rule5LastThree.size() == 3) {
switch (rule5LastThree.removeLast()) {
case ">":
--rule5Above;
break;
case "<":
--rule5Below;
break;
}
}
if (Math.abs(sample - mean.getResult()) > twoDeviations) {
if (sample > mean.getResult()) {
++rule5Above;
rule5LastThree.push(">");
} else {
++rule5Below;
rule5LastThree.push("<");
}
} else {
rule5LastThree.push("");
}
return rule5Above >= 2 || rule5Below >= 2;
} | [
"private",
"boolean",
"rule5",
"(",
"double",
"sample",
")",
"{",
"if",
"(",
"!",
"hasMean",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"rule5LastThree",
".",
"size",
"(",
")",
"==",
"3",
")",
"{",
"switch",
"(",
"rule5LastThree",
".",
"removeLast",
"(",
")",
")",
"{",
"case",
"\">\"",
":",
"--",
"rule5Above",
";",
"break",
";",
"case",
"\"<\"",
":",
"--",
"rule5Below",
";",
"break",
";",
"}",
"}",
"if",
"(",
"Math",
".",
"abs",
"(",
"sample",
"-",
"mean",
".",
"getResult",
"(",
")",
")",
">",
"twoDeviations",
")",
"{",
"if",
"(",
"sample",
">",
"mean",
".",
"getResult",
"(",
")",
")",
"{",
"++",
"rule5Above",
";",
"rule5LastThree",
".",
"push",
"(",
"\">\"",
")",
";",
"}",
"else",
"{",
"++",
"rule5Below",
";",
"rule5LastThree",
".",
"push",
"(",
"\"<\"",
")",
";",
"}",
"}",
"else",
"{",
"rule5LastThree",
".",
"push",
"(",
"\"\"",
")",
";",
"}",
"return",
"rule5Above",
">=",
"2",
"||",
"rule5Below",
">=",
"2",
";",
"}"
] | At least 2 of 3 points in a row are > 2 standard deviations from the mean in the same direction | [
"At",
"least",
"2",
"of",
"3",
"points",
"in",
"a",
"row",
"are",
">",
"2",
"standard",
"deviations",
"from",
"the",
"mean",
"in",
"the",
"same",
"direction"
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/util/NelsonData.java#L264-L292 |
1,289 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/util/NelsonData.java | NelsonData.rule6 | private boolean rule6(double sample) {
if (!hasMean()) {
return false;
}
if (rule6LastFive.size() == 5) {
switch (rule6LastFive.removeLast()) {
case ">":
--rule6Above;
break;
case "<":
--rule6Below;
break;
}
}
if (Math.abs(sample - mean.getResult()) > oneDeviation) {
if (sample > mean.getResult()) {
++rule6Above;
rule6LastFive.push(">");
} else {
++rule6Below;
rule6LastFive.push("<");
}
} else {
rule6LastFive.push("");
}
return rule6Above >= 4 || rule6Below >= 4;
} | java | private boolean rule6(double sample) {
if (!hasMean()) {
return false;
}
if (rule6LastFive.size() == 5) {
switch (rule6LastFive.removeLast()) {
case ">":
--rule6Above;
break;
case "<":
--rule6Below;
break;
}
}
if (Math.abs(sample - mean.getResult()) > oneDeviation) {
if (sample > mean.getResult()) {
++rule6Above;
rule6LastFive.push(">");
} else {
++rule6Below;
rule6LastFive.push("<");
}
} else {
rule6LastFive.push("");
}
return rule6Above >= 4 || rule6Below >= 4;
} | [
"private",
"boolean",
"rule6",
"(",
"double",
"sample",
")",
"{",
"if",
"(",
"!",
"hasMean",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"rule6LastFive",
".",
"size",
"(",
")",
"==",
"5",
")",
"{",
"switch",
"(",
"rule6LastFive",
".",
"removeLast",
"(",
")",
")",
"{",
"case",
"\">\"",
":",
"--",
"rule6Above",
";",
"break",
";",
"case",
"\"<\"",
":",
"--",
"rule6Below",
";",
"break",
";",
"}",
"}",
"if",
"(",
"Math",
".",
"abs",
"(",
"sample",
"-",
"mean",
".",
"getResult",
"(",
")",
")",
">",
"oneDeviation",
")",
"{",
"if",
"(",
"sample",
">",
"mean",
".",
"getResult",
"(",
")",
")",
"{",
"++",
"rule6Above",
";",
"rule6LastFive",
".",
"push",
"(",
"\">\"",
")",
";",
"}",
"else",
"{",
"++",
"rule6Below",
";",
"rule6LastFive",
".",
"push",
"(",
"\"<\"",
")",
";",
"}",
"}",
"else",
"{",
"rule6LastFive",
".",
"push",
"(",
"\"\"",
")",
";",
"}",
"return",
"rule6Above",
">=",
"4",
"||",
"rule6Below",
">=",
"4",
";",
"}"
] | At least 4 of 5 points in a row are > 1 standard deviation from the mean in the same direction | [
"At",
"least",
"4",
"of",
"5",
"points",
"in",
"a",
"row",
"are",
">",
"1",
"standard",
"deviation",
"from",
"the",
"mean",
"in",
"the",
"same",
"direction"
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/util/NelsonData.java#L295-L324 |
1,290 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/util/NelsonData.java | NelsonData.rule7 | private boolean rule7(double sample) {
if (!hasMean()) {
return false;
}
if (sample == mean.getResult()) {
rule7Count = 0;
return false;
}
if (Math.abs(sample - mean.getResult()) <= oneDeviation) {
++rule7Count;
} else {
rule7Count = 0;
}
return rule7Count >= 15;
} | java | private boolean rule7(double sample) {
if (!hasMean()) {
return false;
}
if (sample == mean.getResult()) {
rule7Count = 0;
return false;
}
if (Math.abs(sample - mean.getResult()) <= oneDeviation) {
++rule7Count;
} else {
rule7Count = 0;
}
return rule7Count >= 15;
} | [
"private",
"boolean",
"rule7",
"(",
"double",
"sample",
")",
"{",
"if",
"(",
"!",
"hasMean",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"sample",
"==",
"mean",
".",
"getResult",
"(",
")",
")",
"{",
"rule7Count",
"=",
"0",
";",
"return",
"false",
";",
"}",
"if",
"(",
"Math",
".",
"abs",
"(",
"sample",
"-",
"mean",
".",
"getResult",
"(",
")",
")",
"<=",
"oneDeviation",
")",
"{",
"++",
"rule7Count",
";",
"}",
"else",
"{",
"rule7Count",
"=",
"0",
";",
"}",
"return",
"rule7Count",
">=",
"15",
";",
"}"
] | a very steady metric. Minimally, I have taken away the flat-line case where all samples are the mean. | [
"a",
"very",
"steady",
"metric",
".",
"Minimally",
"I",
"have",
"taken",
"away",
"the",
"flat",
"-",
"line",
"case",
"where",
"all",
"samples",
"are",
"the",
"mean",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/util/NelsonData.java#L329-L346 |
1,291 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/util/NelsonData.java | NelsonData.rule8 | private boolean rule8(Double sample) {
if (!hasMean()) {
return false;
}
if (Math.abs(sample - mean.getResult()) > oneDeviation) {
++rule8Count;
} else {
rule8Count = 0;
}
return rule8Count >= 8;
} | java | private boolean rule8(Double sample) {
if (!hasMean()) {
return false;
}
if (Math.abs(sample - mean.getResult()) > oneDeviation) {
++rule8Count;
} else {
rule8Count = 0;
}
return rule8Count >= 8;
} | [
"private",
"boolean",
"rule8",
"(",
"Double",
"sample",
")",
"{",
"if",
"(",
"!",
"hasMean",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"Math",
".",
"abs",
"(",
"sample",
"-",
"mean",
".",
"getResult",
"(",
")",
")",
">",
"oneDeviation",
")",
"{",
"++",
"rule8Count",
";",
"}",
"else",
"{",
"rule8Count",
"=",
"0",
";",
"}",
"return",
"rule8Count",
">=",
"8",
";",
"}"
] | and the points are in both directions from the mean | [
"and",
"the",
"points",
"are",
"in",
"both",
"directions",
"from",
"the",
"mean"
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/util/NelsonData.java#L350-L362 |
1,292 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/impl/AlertsEngineCache.java | AlertsEngineCache.isDataIdActive | public boolean isDataIdActive(String tenantId, String dataId) {
return tenantId != null && dataId != null && activeDataIds.contains(new DataId(tenantId, dataId));
} | java | public boolean isDataIdActive(String tenantId, String dataId) {
return tenantId != null && dataId != null && activeDataIds.contains(new DataId(tenantId, dataId));
} | [
"public",
"boolean",
"isDataIdActive",
"(",
"String",
"tenantId",
",",
"String",
"dataId",
")",
"{",
"return",
"tenantId",
"!=",
"null",
"&&",
"dataId",
"!=",
"null",
"&&",
"activeDataIds",
".",
"contains",
"(",
"new",
"DataId",
"(",
"tenantId",
",",
"dataId",
")",
")",
";",
"}"
] | Check if a specific dataId is active on this node
@param tenantId to check if has triggers deployed on this node
@param dataId to check if it has triggers deployed on this node
@return true if it is active
false otherwise | [
"Check",
"if",
"a",
"specific",
"dataId",
"is",
"active",
"on",
"this",
"node"
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/impl/AlertsEngineCache.java#L60-L62 |
1,293 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/impl/AlertsEngineCache.java | AlertsEngineCache.remove | public void remove(String tenantId, String triggerId) {
if (tenantId == null) {
throw new IllegalArgumentException("tenantId must be not null");
}
if (triggerId == null) {
throw new IllegalArgumentException("triggerId must be not null");
}
Set<DataEntry> dataEntriesToRemove = new HashSet<>();
activeDataEntries.stream().forEach(e -> {
if (e.getTenantId().equals(tenantId) && e.getTriggerId().equals(triggerId)) {
dataEntriesToRemove.add(e);
}
});
activeDataEntries.removeAll(dataEntriesToRemove);
Set<DataId> dataIdToCheck = new HashSet<>();
dataEntriesToRemove.stream().forEach(e -> {
dataIdToCheck.add(new DataId(e.getTenantId(), e.getDataId()));
});
Set<DataId> dataIdToRemove = new HashSet<>();
dataIdToCheck.stream().forEach(dataId -> {
boolean found = false;
for (DataEntry entry : activeDataEntries) {
DataId currentDataId = new DataId(entry.getTenantId(), entry.getDataId());
if (currentDataId.equals(dataId)) {
found = true;
break;
}
}
if (!found) {
dataIdToRemove.add(dataId);
}
});
activeDataIds.removeAll(dataIdToRemove);
} | java | public void remove(String tenantId, String triggerId) {
if (tenantId == null) {
throw new IllegalArgumentException("tenantId must be not null");
}
if (triggerId == null) {
throw new IllegalArgumentException("triggerId must be not null");
}
Set<DataEntry> dataEntriesToRemove = new HashSet<>();
activeDataEntries.stream().forEach(e -> {
if (e.getTenantId().equals(tenantId) && e.getTriggerId().equals(triggerId)) {
dataEntriesToRemove.add(e);
}
});
activeDataEntries.removeAll(dataEntriesToRemove);
Set<DataId> dataIdToCheck = new HashSet<>();
dataEntriesToRemove.stream().forEach(e -> {
dataIdToCheck.add(new DataId(e.getTenantId(), e.getDataId()));
});
Set<DataId> dataIdToRemove = new HashSet<>();
dataIdToCheck.stream().forEach(dataId -> {
boolean found = false;
for (DataEntry entry : activeDataEntries) {
DataId currentDataId = new DataId(entry.getTenantId(), entry.getDataId());
if (currentDataId.equals(dataId)) {
found = true;
break;
}
}
if (!found) {
dataIdToRemove.add(dataId);
}
});
activeDataIds.removeAll(dataIdToRemove);
} | [
"public",
"void",
"remove",
"(",
"String",
"tenantId",
",",
"String",
"triggerId",
")",
"{",
"if",
"(",
"tenantId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"tenantId must be not null\"",
")",
";",
"}",
"if",
"(",
"triggerId",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"triggerId must be not null\"",
")",
";",
"}",
"Set",
"<",
"DataEntry",
">",
"dataEntriesToRemove",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"activeDataEntries",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"e",
"->",
"{",
"if",
"(",
"e",
".",
"getTenantId",
"(",
")",
".",
"equals",
"(",
"tenantId",
")",
"&&",
"e",
".",
"getTriggerId",
"(",
")",
".",
"equals",
"(",
"triggerId",
")",
")",
"{",
"dataEntriesToRemove",
".",
"add",
"(",
"e",
")",
";",
"}",
"}",
")",
";",
"activeDataEntries",
".",
"removeAll",
"(",
"dataEntriesToRemove",
")",
";",
"Set",
"<",
"DataId",
">",
"dataIdToCheck",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"dataEntriesToRemove",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"e",
"->",
"{",
"dataIdToCheck",
".",
"add",
"(",
"new",
"DataId",
"(",
"e",
".",
"getTenantId",
"(",
")",
",",
"e",
".",
"getDataId",
"(",
")",
")",
")",
";",
"}",
")",
";",
"Set",
"<",
"DataId",
">",
"dataIdToRemove",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"dataIdToCheck",
".",
"stream",
"(",
")",
".",
"forEach",
"(",
"dataId",
"->",
"{",
"boolean",
"found",
"=",
"false",
";",
"for",
"(",
"DataEntry",
"entry",
":",
"activeDataEntries",
")",
"{",
"DataId",
"currentDataId",
"=",
"new",
"DataId",
"(",
"entry",
".",
"getTenantId",
"(",
")",
",",
"entry",
".",
"getDataId",
"(",
")",
")",
";",
"if",
"(",
"currentDataId",
".",
"equals",
"(",
"dataId",
")",
")",
"{",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"{",
"dataIdToRemove",
".",
"add",
"(",
"dataId",
")",
";",
"}",
"}",
")",
";",
"activeDataIds",
".",
"removeAll",
"(",
"dataIdToRemove",
")",
";",
"}"
] | Remove all DataEntry for a specified trigger.
@param triggerId to remove | [
"Remove",
"all",
"DataEntry",
"for",
"a",
"specified",
"trigger",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/impl/AlertsEngineCache.java#L82-L115 |
1,294 | hawkular/hawkular-alerts | engine/src/main/java/org/hawkular/alerts/engine/impl/DataDrivenGroupCacheManager.java | DataDrivenGroupCacheManager.requestCacheUpdate | private void requestCacheUpdate() {
log.debug("Cache update requested");
if (updateRequested) {
log.debug("Cache update, redundant request ignored.");
return;
}
updateRequested = true;
if (!updating) {
updateCache();
}
} | java | private void requestCacheUpdate() {
log.debug("Cache update requested");
if (updateRequested) {
log.debug("Cache update, redundant request ignored.");
return;
}
updateRequested = true;
if (!updating) {
updateCache();
}
} | [
"private",
"void",
"requestCacheUpdate",
"(",
")",
"{",
"log",
".",
"debug",
"(",
"\"Cache update requested\"",
")",
";",
"if",
"(",
"updateRequested",
")",
"{",
"log",
".",
"debug",
"(",
"\"Cache update, redundant request ignored.\"",
")",
";",
"return",
";",
"}",
"updateRequested",
"=",
"true",
";",
"if",
"(",
"!",
"updating",
")",
"{",
"updateCache",
"(",
")",
";",
"}",
"}"
] | Just run updateCache one time if multiple requests come in while an update is already in progress... | [
"Just",
"run",
"updateCache",
"one",
"time",
"if",
"multiple",
"requests",
"come",
"in",
"while",
"an",
"update",
"is",
"already",
"in",
"progress",
"..."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/engine/src/main/java/org/hawkular/alerts/engine/impl/DataDrivenGroupCacheManager.java#L86-L98 |
1,295 | hawkular/hawkular-alerts | actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/PluginMessageDescription.java | PluginMessageDescription.external | public String external(ExternalCondition condition) {
String description = "AlerterId: " + condition.getAlerterId();
description += " DataId: " + condition.getDataId();
description += " Expression: " + condition.getExpression();
return description;
} | java | public String external(ExternalCondition condition) {
String description = "AlerterId: " + condition.getAlerterId();
description += " DataId: " + condition.getDataId();
description += " Expression: " + condition.getExpression();
return description;
} | [
"public",
"String",
"external",
"(",
"ExternalCondition",
"condition",
")",
"{",
"String",
"description",
"=",
"\"AlerterId: \"",
"+",
"condition",
".",
"getAlerterId",
"(",
")",
";",
"description",
"+=",
"\" DataId: \"",
"+",
"condition",
".",
"getDataId",
"(",
")",
";",
"description",
"+=",
"\" Expression: \"",
"+",
"condition",
".",
"getExpression",
"(",
")",
";",
"return",
"description",
";",
"}"
] | Create a description for an ExternalCondition object.
@param condition the condition
@return a description to be used on email templates | [
"Create",
"a",
"description",
"for",
"an",
"ExternalCondition",
"object",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/PluginMessageDescription.java#L497-L502 |
1,296 | hawkular/hawkular-alerts | actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/PluginMessageDescription.java | PluginMessageDescription.events | public String events(EventCondition condition) {
String description = "event on: " + condition.getDataId();
if (condition.getExpression() != null) {
description += " [" + condition.getExpression() + "]";
}
return description;
} | java | public String events(EventCondition condition) {
String description = "event on: " + condition.getDataId();
if (condition.getExpression() != null) {
description += " [" + condition.getExpression() + "]";
}
return description;
} | [
"public",
"String",
"events",
"(",
"EventCondition",
"condition",
")",
"{",
"String",
"description",
"=",
"\"event on: \"",
"+",
"condition",
".",
"getDataId",
"(",
")",
";",
"if",
"(",
"condition",
".",
"getExpression",
"(",
")",
"!=",
"null",
")",
"{",
"description",
"+=",
"\" [\"",
"+",
"condition",
".",
"getExpression",
"(",
")",
"+",
"\"]\"",
";",
"}",
"return",
"description",
";",
"}"
] | Create a description for an EventCondition object.
@param condition the condition
@return a description to be used on email templates | [
"Create",
"a",
"description",
"for",
"an",
"EventCondition",
"object",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/PluginMessageDescription.java#L510-L516 |
1,297 | hawkular/hawkular-alerts | actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/PluginMessageDescription.java | PluginMessageDescription.missing | public String missing(MissingCondition condition) {
String description;
if (condition.getContext() != null && condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION) != null) {
description = condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION);
} else {
description = condition.getDataId();
}
description += " not reported for " + condition.getInterval() + "ms";
return description;
} | java | public String missing(MissingCondition condition) {
String description;
if (condition.getContext() != null && condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION) != null) {
description = condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION);
} else {
description = condition.getDataId();
}
description += " not reported for " + condition.getInterval() + "ms";
return description;
} | [
"public",
"String",
"missing",
"(",
"MissingCondition",
"condition",
")",
"{",
"String",
"description",
";",
"if",
"(",
"condition",
".",
"getContext",
"(",
")",
"!=",
"null",
"&&",
"condition",
".",
"getContext",
"(",
")",
".",
"get",
"(",
"CONTEXT_PROPERTY_DESCRIPTION",
")",
"!=",
"null",
")",
"{",
"description",
"=",
"condition",
".",
"getContext",
"(",
")",
".",
"get",
"(",
"CONTEXT_PROPERTY_DESCRIPTION",
")",
";",
"}",
"else",
"{",
"description",
"=",
"condition",
".",
"getDataId",
"(",
")",
";",
"}",
"description",
"+=",
"\" not reported for \"",
"+",
"condition",
".",
"getInterval",
"(",
")",
"+",
"\"ms\"",
";",
"return",
"description",
";",
"}"
] | Create a description for a MissingCondition object.
@param condition the condition
@return a description to be used on email templates | [
"Create",
"a",
"description",
"for",
"a",
"MissingCondition",
"object",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/PluginMessageDescription.java#L524-L533 |
1,298 | hawkular/hawkular-alerts | actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/PluginMessageDescription.java | PluginMessageDescription.nelson | public String nelson(NelsonCondition condition) {
String description;
if (condition.getContext() != null && condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION) != null) {
description = condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION);
} else {
description = condition.getDataId();
}
description += " violates one or the following Nelson rules: " + condition.getActiveRules();
return description;
} | java | public String nelson(NelsonCondition condition) {
String description;
if (condition.getContext() != null && condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION) != null) {
description = condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION);
} else {
description = condition.getDataId();
}
description += " violates one or the following Nelson rules: " + condition.getActiveRules();
return description;
} | [
"public",
"String",
"nelson",
"(",
"NelsonCondition",
"condition",
")",
"{",
"String",
"description",
";",
"if",
"(",
"condition",
".",
"getContext",
"(",
")",
"!=",
"null",
"&&",
"condition",
".",
"getContext",
"(",
")",
".",
"get",
"(",
"CONTEXT_PROPERTY_DESCRIPTION",
")",
"!=",
"null",
")",
"{",
"description",
"=",
"condition",
".",
"getContext",
"(",
")",
".",
"get",
"(",
"CONTEXT_PROPERTY_DESCRIPTION",
")",
";",
"}",
"else",
"{",
"description",
"=",
"condition",
".",
"getDataId",
"(",
")",
";",
"}",
"description",
"+=",
"\" violates one or the following Nelson rules: \"",
"+",
"condition",
".",
"getActiveRules",
"(",
")",
";",
"return",
"description",
";",
"}"
] | Create a description for a NelsonCondition object.
@param condition the condition
@return a description to be used on email templates | [
"Create",
"a",
"description",
"for",
"a",
"NelsonCondition",
"object",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/PluginMessageDescription.java#L541-L550 |
1,299 | hawkular/hawkular-alerts | actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/PluginMessageDescription.java | PluginMessageDescription.rate | public String rate(RateCondition condition) {
String description;
if (condition.getContext() != null && condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION) != null) {
description = condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION);
} else {
description = condition.getDataId();
}
switch (condition.getDirection()) {
case DECREASING:
description += " decreasing ";
break;
case INCREASING:
description += " increasing ";
break;
case NA:
break;
default:
throw new IllegalArgumentException(condition.getDirection().name());
}
switch (condition.getOperator()) {
case GT:
description += " greater than ";
break;
case GTE:
description += " greater or equal than ";
break;
case LT:
description += " less than ";
break;
case LTE:
description += " less or equal than ";
break;
default:
throw new IllegalArgumentException(condition.getOperator().name());
}
description += decimalFormat.format(condition.getThreshold());
if (condition.getContext() != null && condition.getContext().get(CONTEXT_PROPERTY_UNIT) != null) {
description += " " + condition.getContext().get(CONTEXT_PROPERTY_UNIT);
}
switch (condition.getPeriod()) {
case DAY:
description = " per day ";
break;
case HOUR:
description = " per hour ";
break;
case MINUTE:
description = " per minute ";
break;
case SECOND:
description = " per second ";
break;
case WEEK:
description = " per week ";
break;
default:
throw new IllegalArgumentException(condition.getOperator().name());
}
return description;
} | java | public String rate(RateCondition condition) {
String description;
if (condition.getContext() != null && condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION) != null) {
description = condition.getContext().get(CONTEXT_PROPERTY_DESCRIPTION);
} else {
description = condition.getDataId();
}
switch (condition.getDirection()) {
case DECREASING:
description += " decreasing ";
break;
case INCREASING:
description += " increasing ";
break;
case NA:
break;
default:
throw new IllegalArgumentException(condition.getDirection().name());
}
switch (condition.getOperator()) {
case GT:
description += " greater than ";
break;
case GTE:
description += " greater or equal than ";
break;
case LT:
description += " less than ";
break;
case LTE:
description += " less or equal than ";
break;
default:
throw new IllegalArgumentException(condition.getOperator().name());
}
description += decimalFormat.format(condition.getThreshold());
if (condition.getContext() != null && condition.getContext().get(CONTEXT_PROPERTY_UNIT) != null) {
description += " " + condition.getContext().get(CONTEXT_PROPERTY_UNIT);
}
switch (condition.getPeriod()) {
case DAY:
description = " per day ";
break;
case HOUR:
description = " per hour ";
break;
case MINUTE:
description = " per minute ";
break;
case SECOND:
description = " per second ";
break;
case WEEK:
description = " per week ";
break;
default:
throw new IllegalArgumentException(condition.getOperator().name());
}
return description;
} | [
"public",
"String",
"rate",
"(",
"RateCondition",
"condition",
")",
"{",
"String",
"description",
";",
"if",
"(",
"condition",
".",
"getContext",
"(",
")",
"!=",
"null",
"&&",
"condition",
".",
"getContext",
"(",
")",
".",
"get",
"(",
"CONTEXT_PROPERTY_DESCRIPTION",
")",
"!=",
"null",
")",
"{",
"description",
"=",
"condition",
".",
"getContext",
"(",
")",
".",
"get",
"(",
"CONTEXT_PROPERTY_DESCRIPTION",
")",
";",
"}",
"else",
"{",
"description",
"=",
"condition",
".",
"getDataId",
"(",
")",
";",
"}",
"switch",
"(",
"condition",
".",
"getDirection",
"(",
")",
")",
"{",
"case",
"DECREASING",
":",
"description",
"+=",
"\" decreasing \"",
";",
"break",
";",
"case",
"INCREASING",
":",
"description",
"+=",
"\" increasing \"",
";",
"break",
";",
"case",
"NA",
":",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"condition",
".",
"getDirection",
"(",
")",
".",
"name",
"(",
")",
")",
";",
"}",
"switch",
"(",
"condition",
".",
"getOperator",
"(",
")",
")",
"{",
"case",
"GT",
":",
"description",
"+=",
"\" greater than \"",
";",
"break",
";",
"case",
"GTE",
":",
"description",
"+=",
"\" greater or equal than \"",
";",
"break",
";",
"case",
"LT",
":",
"description",
"+=",
"\" less than \"",
";",
"break",
";",
"case",
"LTE",
":",
"description",
"+=",
"\" less or equal than \"",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"condition",
".",
"getOperator",
"(",
")",
".",
"name",
"(",
")",
")",
";",
"}",
"description",
"+=",
"decimalFormat",
".",
"format",
"(",
"condition",
".",
"getThreshold",
"(",
")",
")",
";",
"if",
"(",
"condition",
".",
"getContext",
"(",
")",
"!=",
"null",
"&&",
"condition",
".",
"getContext",
"(",
")",
".",
"get",
"(",
"CONTEXT_PROPERTY_UNIT",
")",
"!=",
"null",
")",
"{",
"description",
"+=",
"\" \"",
"+",
"condition",
".",
"getContext",
"(",
")",
".",
"get",
"(",
"CONTEXT_PROPERTY_UNIT",
")",
";",
"}",
"switch",
"(",
"condition",
".",
"getPeriod",
"(",
")",
")",
"{",
"case",
"DAY",
":",
"description",
"=",
"\" per day \"",
";",
"break",
";",
"case",
"HOUR",
":",
"description",
"=",
"\" per hour \"",
";",
"break",
";",
"case",
"MINUTE",
":",
"description",
"=",
"\" per minute \"",
";",
"break",
";",
"case",
"SECOND",
":",
"description",
"=",
"\" per second \"",
";",
"break",
";",
"case",
"WEEK",
":",
"description",
"=",
"\" per week \"",
";",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"condition",
".",
"getOperator",
"(",
")",
".",
"name",
"(",
")",
")",
";",
"}",
"return",
"description",
";",
"}"
] | Create a description for a RateCondition object.
@param condition the condition
@return a description to be used on email templates | [
"Create",
"a",
"description",
"for",
"a",
"RateCondition",
"object",
"."
] | b4a0c2909b38e03e72cc1828219562ee8fcbf426 | https://github.com/hawkular/hawkular-alerts/blob/b4a0c2909b38e03e72cc1828219562ee8fcbf426/actions/actions-plugins/actions-email/src/main/java/org/hawkular/alerts/actions/email/PluginMessageDescription.java#L558-L617 |
Subsets and Splits