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
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
153,800
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.search
|
public static int search(char[] charArray, char value, int occurrence) {
if(occurrence <= 0 || occurrence > charArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < charArray.length; i++) {
if(charArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int search(char[] charArray, char value, int occurrence) {
if(occurrence <= 0 || occurrence > charArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < charArray.length; i++) {
if(charArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"search",
"(",
"char",
"[",
"]",
"charArray",
",",
"char",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"charArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"charArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"charArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the char array and return the index of the first occurrence from the
beginning of the array.
@param charArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"char",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"beginning",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L684-L703
|
153,801
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.search
|
public static int search(byte[] byteArray, byte value, int occurrence) {
if(occurrence <= 0 || occurrence > byteArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < byteArray.length; i++) {
if(byteArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int search(byte[] byteArray, byte value, int occurrence) {
if(occurrence <= 0 || occurrence > byteArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < byteArray.length; i++) {
if(byteArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"search",
"(",
"byte",
"[",
"]",
"byteArray",
",",
"byte",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"byteArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"byteArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"byteArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the byte array and return the index of the first occurrence from the
beginning of the array.
@param byteArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"byte",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"beginning",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L814-L833
|
153,802
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.search
|
public static int search(short[] shortArray, short value, int occurrence) {
if(occurrence <= 0 || occurrence > shortArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < shortArray.length; i++) {
if(shortArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int search(short[] shortArray, short value, int occurrence) {
if(occurrence <= 0 || occurrence > shortArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < shortArray.length; i++) {
if(shortArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"search",
"(",
"short",
"[",
"]",
"shortArray",
",",
"short",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"shortArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"shortArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"shortArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the short array and return the index of the first occurrence from the
beginning of the array.
@param shortArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"short",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"beginning",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L944-L963
|
153,803
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.search
|
public static int search(long[] longArray, long value, int occurrence) {
if(occurrence <= 0 || occurrence > longArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < longArray.length; i++) {
if(longArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int search(long[] longArray, long value, int occurrence) {
if(occurrence <= 0 || occurrence > longArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < longArray.length; i++) {
if(longArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"search",
"(",
"long",
"[",
"]",
"longArray",
",",
"long",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"longArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"longArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"longArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the long array and return the index of the first occurrence from the
beginning of the array.
@param longArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"long",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"beginning",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1074-L1093
|
153,804
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.search
|
public static int search(float[] floatArray, float value, int occurrence) {
if(occurrence <= 0 || occurrence > floatArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < floatArray.length; i++) {
if(floatArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int search(float[] floatArray, float value, int occurrence) {
if(occurrence <= 0 || occurrence > floatArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < floatArray.length; i++) {
if(floatArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"search",
"(",
"float",
"[",
"]",
"floatArray",
",",
"float",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"floatArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"floatArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"floatArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the float array and return the index of the first occurrence from the
beginning of the array.
@param floatArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"float",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"beginning",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1204-L1223
|
153,805
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.search
|
public static int search(double[] doubleArray, double value, int occurrence) {
if(occurrence <= 0 || occurrence > doubleArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < doubleArray.length; i++) {
if(doubleArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int search(double[] doubleArray, double value, int occurrence) {
if(occurrence <= 0 || occurrence > doubleArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = 0; i < doubleArray.length; i++) {
if(doubleArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"search",
"(",
"double",
"[",
"]",
"doubleArray",
",",
"double",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"doubleArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"doubleArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"doubleArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the double array and return the index of the first occurrence from the
beginning of the array.
@param doubleArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"double",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"beginning",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1334-L1353
|
153,806
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.searchLast
|
public static int searchLast(int[] intArray, int value, int occurrence) {
if(occurrence <= 0 || occurrence > intArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = intArray.length-1; i >=0; i--) {
if(intArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int searchLast(int[] intArray, int value, int occurrence) {
if(occurrence <= 0 || occurrence > intArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = intArray.length-1; i >=0; i--) {
if(intArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"searchLast",
"(",
"int",
"[",
"]",
"intArray",
",",
"int",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"intArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"intArray",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"intArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the int array and return the index of the specified occurrence from the
end of the array.
@param intArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"int",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"specified",
"occurrence",
"from",
"the",
"end",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1530-L1549
|
153,807
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.searchLast
|
public static int searchLast(char[] charArray, char value, int occurrence) {
if(occurrence <= 0 || occurrence > charArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = charArray.length-1; i >=0; i--) {
if(charArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int searchLast(char[] charArray, char value, int occurrence) {
if(occurrence <= 0 || occurrence > charArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = charArray.length-1; i >=0; i--) {
if(charArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"searchLast",
"(",
"char",
"[",
"]",
"charArray",
",",
"char",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"charArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"charArray",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"charArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the char array and return the index of the first occurrence from the
end of the array.
@param charArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"char",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"end",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1560-L1579
|
153,808
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.searchLast
|
public static int searchLast(byte[] byteArray, byte value, int occurrence) {
if(occurrence <= 0 || occurrence > byteArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = byteArray.length-1; i >=0; i--) {
if(byteArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int searchLast(byte[] byteArray, byte value, int occurrence) {
if(occurrence <= 0 || occurrence > byteArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = byteArray.length-1; i >=0; i--) {
if(byteArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"searchLast",
"(",
"byte",
"[",
"]",
"byteArray",
",",
"byte",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"byteArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"byteArray",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"byteArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the byte array and return the index of the first occurrence from the
end of the array.
@param byteArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"byte",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"end",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1590-L1609
|
153,809
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.searchLast
|
public static int searchLast(short[] shortArray, short value, int occurrence) {
if(occurrence <= 0 || occurrence > shortArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = shortArray.length-1; i >=0; i--) {
if(shortArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int searchLast(short[] shortArray, short value, int occurrence) {
if(occurrence <= 0 || occurrence > shortArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = shortArray.length-1; i >=0; i--) {
if(shortArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"searchLast",
"(",
"short",
"[",
"]",
"shortArray",
",",
"short",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"shortArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"shortArray",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"shortArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the short array and return the index of the first occurrence from the
end of the array.
@param shortArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"short",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"end",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1620-L1639
|
153,810
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.searchLast
|
public static int searchLast(long[] longArray, long value, int occurrence) {
if(occurrence <= 0 || occurrence > longArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = longArray.length-1; i >=0; i--) {
if(longArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int searchLast(long[] longArray, long value, int occurrence) {
if(occurrence <= 0 || occurrence > longArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = longArray.length-1; i >=0; i--) {
if(longArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"searchLast",
"(",
"long",
"[",
"]",
"longArray",
",",
"long",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"longArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"longArray",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"longArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the long array and return the index of the first occurrence from the
end of the array.
@param longArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"long",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"end",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1650-L1669
|
153,811
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.searchLast
|
public static int searchLast(float[] floatArray, float value, int occurrence) {
if(occurrence <= 0 || occurrence > floatArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = floatArray.length-1; i >=0; i--) {
if(floatArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int searchLast(float[] floatArray, float value, int occurrence) {
if(occurrence <= 0 || occurrence > floatArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = floatArray.length-1; i >=0; i--) {
if(floatArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"searchLast",
"(",
"float",
"[",
"]",
"floatArray",
",",
"float",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"floatArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"floatArray",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"floatArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the float array and return the index of the first occurrence from the
end of the array.
@param floatArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"float",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"end",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1680-L1699
|
153,812
|
mijecu25/dsa
|
src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java
|
LinearSearch.searchLast
|
public static int searchLast(double[] doubleArray, double value, int occurrence) {
if(occurrence <= 0 || occurrence > doubleArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = doubleArray.length-1; i >=0; i--) {
if(doubleArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
java
|
public static int searchLast(double[] doubleArray, double value, int occurrence) {
if(occurrence <= 0 || occurrence > doubleArray.length) {
throw new IllegalArgumentException("Occurrence must be greater or equal to 1 and less than "
+ "the array length: " + occurrence);
}
int valuesSeen = 0;
for(int i = doubleArray.length-1; i >=0; i--) {
if(doubleArray[i] == value) {
valuesSeen++;
if(valuesSeen == occurrence) {
return i;
}
}
}
return -1;
}
|
[
"public",
"static",
"int",
"searchLast",
"(",
"double",
"[",
"]",
"doubleArray",
",",
"double",
"value",
",",
"int",
"occurrence",
")",
"{",
"if",
"(",
"occurrence",
"<=",
"0",
"||",
"occurrence",
">",
"doubleArray",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Occurrence must be greater or equal to 1 and less than \"",
"+",
"\"the array length: \"",
"+",
"occurrence",
")",
";",
"}",
"int",
"valuesSeen",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"doubleArray",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"(",
"doubleArray",
"[",
"i",
"]",
"==",
"value",
")",
"{",
"valuesSeen",
"++",
";",
"if",
"(",
"valuesSeen",
"==",
"occurrence",
")",
"{",
"return",
"i",
";",
"}",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Search for the value in the double array and return the index of the first occurrence from the
end of the array.
@param doubleArray array that we are searching in.
@param value value that is being searched in the array.
@param occurrence number of times we have seen the value before returning the index.
@return the index where the value is found in the array, else -1.
|
[
"Search",
"for",
"the",
"value",
"in",
"the",
"double",
"array",
"and",
"return",
"the",
"index",
"of",
"the",
"first",
"occurrence",
"from",
"the",
"end",
"of",
"the",
"array",
"."
] |
a22971b746833e78a3939ae4de65e8f6bf2e3fd4
|
https://github.com/mijecu25/dsa/blob/a22971b746833e78a3939ae4de65e8f6bf2e3fd4/src/main/java/com/mijecu25/dsa/algorithms/search/linear/LinearSearch.java#L1710-L1729
|
153,813
|
js-lib-com/commons
|
src/main/java/js/converter/FileConverter.java
|
FileConverter.asObject
|
@Override
public <T> T asObject(String string, Class<T> valueType) {
// at this point value type is guaranteed to be a File
return (T) new File(string);
}
|
java
|
@Override
public <T> T asObject(String string, Class<T> valueType) {
// at this point value type is guaranteed to be a File
return (T) new File(string);
}
|
[
"@",
"Override",
"public",
"<",
"T",
">",
"T",
"asObject",
"(",
"String",
"string",
",",
"Class",
"<",
"T",
">",
"valueType",
")",
"{",
"// at this point value type is guaranteed to be a File\r",
"return",
"(",
"T",
")",
"new",
"File",
"(",
"string",
")",
";",
"}"
] |
Return file instance for the given path string.
|
[
"Return",
"file",
"instance",
"for",
"the",
"given",
"path",
"string",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/converter/FileConverter.java#L20-L24
|
153,814
|
js-lib-com/commons
|
src/main/java/js/converter/FileConverter.java
|
FileConverter.asString
|
@Override
public String asString(Object object) {
// at this point object is guaranteed to be a File
return Files.path2unix(((File) object).getPath());
}
|
java
|
@Override
public String asString(Object object) {
// at this point object is guaranteed to be a File
return Files.path2unix(((File) object).getPath());
}
|
[
"@",
"Override",
"public",
"String",
"asString",
"(",
"Object",
"object",
")",
"{",
"// at this point object is guaranteed to be a File\r",
"return",
"Files",
".",
"path2unix",
"(",
"(",
"(",
"File",
")",
"object",
")",
".",
"getPath",
"(",
")",
")",
";",
"}"
] |
Return file object path.
|
[
"Return",
"file",
"object",
"path",
"."
] |
f8c64482142b163487745da74feb106f0765c16b
|
https://github.com/js-lib-com/commons/blob/f8c64482142b163487745da74feb106f0765c16b/src/main/java/js/converter/FileConverter.java#L27-L31
|
153,815
|
NessComputing/components-ness-httpclient
|
client/src/main/java/com/nesscomputing/httpclient/HttpClient.java
|
HttpClient.head
|
public <T> HttpClientRequest.Builder<T> head(final URI uri, final HttpClientResponseHandler<T> httpHandler)
{
return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.HEAD, uri, httpHandler);
}
|
java
|
public <T> HttpClientRequest.Builder<T> head(final URI uri, final HttpClientResponseHandler<T> httpHandler)
{
return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.HEAD, uri, httpHandler);
}
|
[
"public",
"<",
"T",
">",
"HttpClientRequest",
".",
"Builder",
"<",
"T",
">",
"head",
"(",
"final",
"URI",
"uri",
",",
"final",
"HttpClientResponseHandler",
"<",
"T",
">",
"httpHandler",
")",
"{",
"return",
"new",
"HttpClientRequest",
".",
"Builder",
"<",
"T",
">",
"(",
"httpClientFactory",
",",
"HttpClientMethod",
".",
"HEAD",
",",
"uri",
",",
"httpHandler",
")",
";",
"}"
] |
Start building a HEAD request.
@return a request builder which then can be used to create the actual request.
|
[
"Start",
"building",
"a",
"HEAD",
"request",
"."
] |
8e97e8576e470449672c81fa7890c60f9986966d
|
https://github.com/NessComputing/components-ness-httpclient/blob/8e97e8576e470449672c81fa7890c60f9986966d/client/src/main/java/com/nesscomputing/httpclient/HttpClient.java#L173-L176
|
153,816
|
NessComputing/components-ness-httpclient
|
client/src/main/java/com/nesscomputing/httpclient/HttpClient.java
|
HttpClient.delete
|
public <T> HttpClientRequest.Builder<T> delete(final URI uri, final HttpClientResponseHandler<T> httpHandler)
{
return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.DELETE, uri, httpHandler);
}
|
java
|
public <T> HttpClientRequest.Builder<T> delete(final URI uri, final HttpClientResponseHandler<T> httpHandler)
{
return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.DELETE, uri, httpHandler);
}
|
[
"public",
"<",
"T",
">",
"HttpClientRequest",
".",
"Builder",
"<",
"T",
">",
"delete",
"(",
"final",
"URI",
"uri",
",",
"final",
"HttpClientResponseHandler",
"<",
"T",
">",
"httpHandler",
")",
"{",
"return",
"new",
"HttpClientRequest",
".",
"Builder",
"<",
"T",
">",
"(",
"httpClientFactory",
",",
"HttpClientMethod",
".",
"DELETE",
",",
"uri",
",",
"httpHandler",
")",
";",
"}"
] |
Start building a DELETE request.
@return a request builder which then can be used to create the actual request.
|
[
"Start",
"building",
"a",
"DELETE",
"request",
"."
] |
8e97e8576e470449672c81fa7890c60f9986966d
|
https://github.com/NessComputing/components-ness-httpclient/blob/8e97e8576e470449672c81fa7890c60f9986966d/client/src/main/java/com/nesscomputing/httpclient/HttpClient.java#L193-L196
|
153,817
|
NessComputing/components-ness-httpclient
|
client/src/main/java/com/nesscomputing/httpclient/HttpClient.java
|
HttpClient.options
|
public <T> HttpClientRequest.Builder<T> options(final URI uri, final HttpClientResponseHandler<T> httpHandler)
{
return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.OPTIONS, uri, httpHandler);
}
|
java
|
public <T> HttpClientRequest.Builder<T> options(final URI uri, final HttpClientResponseHandler<T> httpHandler)
{
return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.OPTIONS, uri, httpHandler);
}
|
[
"public",
"<",
"T",
">",
"HttpClientRequest",
".",
"Builder",
"<",
"T",
">",
"options",
"(",
"final",
"URI",
"uri",
",",
"final",
"HttpClientResponseHandler",
"<",
"T",
">",
"httpHandler",
")",
"{",
"return",
"new",
"HttpClientRequest",
".",
"Builder",
"<",
"T",
">",
"(",
"httpClientFactory",
",",
"HttpClientMethod",
".",
"OPTIONS",
",",
"uri",
",",
"httpHandler",
")",
";",
"}"
] |
Start building a OPTIONS request.
@return a request builder which then can be used to create the actual request.
|
[
"Start",
"building",
"a",
"OPTIONS",
"request",
"."
] |
8e97e8576e470449672c81fa7890c60f9986966d
|
https://github.com/NessComputing/components-ness-httpclient/blob/8e97e8576e470449672c81fa7890c60f9986966d/client/src/main/java/com/nesscomputing/httpclient/HttpClient.java#L213-L216
|
153,818
|
NessComputing/components-ness-httpclient
|
client/src/main/java/com/nesscomputing/httpclient/HttpClient.java
|
HttpClient.put
|
public <T> HttpClientRequest.Builder<T> put(final URI uri, final HttpClientResponseHandler<T> httpHandler)
{
return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.PUT, uri, httpHandler);
}
|
java
|
public <T> HttpClientRequest.Builder<T> put(final URI uri, final HttpClientResponseHandler<T> httpHandler)
{
return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.PUT, uri, httpHandler);
}
|
[
"public",
"<",
"T",
">",
"HttpClientRequest",
".",
"Builder",
"<",
"T",
">",
"put",
"(",
"final",
"URI",
"uri",
",",
"final",
"HttpClientResponseHandler",
"<",
"T",
">",
"httpHandler",
")",
"{",
"return",
"new",
"HttpClientRequest",
".",
"Builder",
"<",
"T",
">",
"(",
"httpClientFactory",
",",
"HttpClientMethod",
".",
"PUT",
",",
"uri",
",",
"httpHandler",
")",
";",
"}"
] |
Start building a PUT request.
@return a request builder which then can be used to create the actual request.
|
[
"Start",
"building",
"a",
"PUT",
"request",
"."
] |
8e97e8576e470449672c81fa7890c60f9986966d
|
https://github.com/NessComputing/components-ness-httpclient/blob/8e97e8576e470449672c81fa7890c60f9986966d/client/src/main/java/com/nesscomputing/httpclient/HttpClient.java#L233-L236
|
153,819
|
NessComputing/components-ness-httpclient
|
client/src/main/java/com/nesscomputing/httpclient/HttpClient.java
|
HttpClient.post
|
public <T> HttpClientRequest.Builder<T> post(final URI uri, final HttpClientResponseHandler<T> httpHandler)
{
return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.POST, uri, httpHandler);
}
|
java
|
public <T> HttpClientRequest.Builder<T> post(final URI uri, final HttpClientResponseHandler<T> httpHandler)
{
return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.POST, uri, httpHandler);
}
|
[
"public",
"<",
"T",
">",
"HttpClientRequest",
".",
"Builder",
"<",
"T",
">",
"post",
"(",
"final",
"URI",
"uri",
",",
"final",
"HttpClientResponseHandler",
"<",
"T",
">",
"httpHandler",
")",
"{",
"return",
"new",
"HttpClientRequest",
".",
"Builder",
"<",
"T",
">",
"(",
"httpClientFactory",
",",
"HttpClientMethod",
".",
"POST",
",",
"uri",
",",
"httpHandler",
")",
";",
"}"
] |
Start building a POST request.
@return a request builder which then can be used to create the actual request.
|
[
"Start",
"building",
"a",
"POST",
"request",
"."
] |
8e97e8576e470449672c81fa7890c60f9986966d
|
https://github.com/NessComputing/components-ness-httpclient/blob/8e97e8576e470449672c81fa7890c60f9986966d/client/src/main/java/com/nesscomputing/httpclient/HttpClient.java#L253-L256
|
153,820
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/db/shared/BaseSharedTable.java
|
BaseSharedTable.addListener
|
public void addListener(FieldListener listener, BaseField field)
{
super.addListener(listener, field);
if (listener.getOwner().getRecord() == this.getRecord()) // Only replicate listeners added to base.
{
Iterator<BaseTable> iterator = this.getTables();
while (iterator.hasNext())
{
BaseTable table = iterator.next();
if ((table != null) && (table != this.getNextTable()))
{
BaseField fldInTable = table.getRecord().getField(field.getFieldName());
if (fldInTable != null)
{
FieldListener newBehavior = null; // Clone the file behaviors
try {
newBehavior = (FieldListener)listener.clone(fldInTable); // Clone the file behaviors
} catch (CloneNotSupportedException ex) {
newBehavior = null;
}
if (newBehavior != null)
if (newBehavior.getOwner() == null) // This should have been set, just being careful (ie., next line never called)
fldInTable.addListener(newBehavior); // Add them to the new query
}
}
}
}
}
|
java
|
public void addListener(FieldListener listener, BaseField field)
{
super.addListener(listener, field);
if (listener.getOwner().getRecord() == this.getRecord()) // Only replicate listeners added to base.
{
Iterator<BaseTable> iterator = this.getTables();
while (iterator.hasNext())
{
BaseTable table = iterator.next();
if ((table != null) && (table != this.getNextTable()))
{
BaseField fldInTable = table.getRecord().getField(field.getFieldName());
if (fldInTable != null)
{
FieldListener newBehavior = null; // Clone the file behaviors
try {
newBehavior = (FieldListener)listener.clone(fldInTable); // Clone the file behaviors
} catch (CloneNotSupportedException ex) {
newBehavior = null;
}
if (newBehavior != null)
if (newBehavior.getOwner() == null) // This should have been set, just being careful (ie., next line never called)
fldInTable.addListener(newBehavior); // Add them to the new query
}
}
}
}
}
|
[
"public",
"void",
"addListener",
"(",
"FieldListener",
"listener",
",",
"BaseField",
"field",
")",
"{",
"super",
".",
"addListener",
"(",
"listener",
",",
"field",
")",
";",
"if",
"(",
"listener",
".",
"getOwner",
"(",
")",
".",
"getRecord",
"(",
")",
"==",
"this",
".",
"getRecord",
"(",
")",
")",
"// Only replicate listeners added to base.",
"{",
"Iterator",
"<",
"BaseTable",
">",
"iterator",
"=",
"this",
".",
"getTables",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"BaseTable",
"table",
"=",
"iterator",
".",
"next",
"(",
")",
";",
"if",
"(",
"(",
"table",
"!=",
"null",
")",
"&&",
"(",
"table",
"!=",
"this",
".",
"getNextTable",
"(",
")",
")",
")",
"{",
"BaseField",
"fldInTable",
"=",
"table",
".",
"getRecord",
"(",
")",
".",
"getField",
"(",
"field",
".",
"getFieldName",
"(",
")",
")",
";",
"if",
"(",
"fldInTable",
"!=",
"null",
")",
"{",
"FieldListener",
"newBehavior",
"=",
"null",
";",
"// Clone the file behaviors",
"try",
"{",
"newBehavior",
"=",
"(",
"FieldListener",
")",
"listener",
".",
"clone",
"(",
"fldInTable",
")",
";",
"// Clone the file behaviors",
"}",
"catch",
"(",
"CloneNotSupportedException",
"ex",
")",
"{",
"newBehavior",
"=",
"null",
";",
"}",
"if",
"(",
"newBehavior",
"!=",
"null",
")",
"if",
"(",
"newBehavior",
".",
"getOwner",
"(",
")",
"==",
"null",
")",
"// This should have been set, just being careful (ie., next line never called)",
"fldInTable",
".",
"addListener",
"(",
"newBehavior",
")",
";",
"// Add them to the new query",
"}",
"}",
"}",
"}",
"}"
] |
Add a field listener to the chain.
The listener must be cloned and added to all records on the list.
@param listener The listener to add.
@param The field to add to.
|
[
"Add",
"a",
"field",
"listener",
"to",
"the",
"chain",
".",
"The",
"listener",
"must",
"be",
"cloned",
"and",
"added",
"to",
"all",
"records",
"on",
"the",
"list",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/shared/BaseSharedTable.java#L142-L169
|
153,821
|
sporniket/p3
|
src/main/java/com/sporniket/libre/p3/builtins/WrappedObjectMapperProcessor.java
|
WrappedObjectMapperProcessor.computeGetterName
|
private String computeGetterName(String name)
{
StringBuilder _result = new StringBuilder().append(PREFIX__GETTER);
_result.append(Character.toUpperCase(name.charAt(0))).append(name.substring(1));
return _result.toString();
}
|
java
|
private String computeGetterName(String name)
{
StringBuilder _result = new StringBuilder().append(PREFIX__GETTER);
_result.append(Character.toUpperCase(name.charAt(0))).append(name.substring(1));
return _result.toString();
}
|
[
"private",
"String",
"computeGetterName",
"(",
"String",
"name",
")",
"{",
"StringBuilder",
"_result",
"=",
"new",
"StringBuilder",
"(",
")",
".",
"append",
"(",
"PREFIX__GETTER",
")",
";",
"_result",
".",
"append",
"(",
"Character",
".",
"toUpperCase",
"(",
"name",
".",
"charAt",
"(",
"0",
")",
")",
")",
".",
"append",
"(",
"name",
".",
"substring",
"(",
"1",
")",
")",
";",
"return",
"_result",
".",
"toString",
"(",
")",
";",
"}"
] |
Compute the getter name.
@param name
the name of the property to read.
@return the getter name.
|
[
"Compute",
"the",
"getter",
"name",
"."
] |
fc20b3066dc4a9cd759090adae0a6b02508df135
|
https://github.com/sporniket/p3/blob/fc20b3066dc4a9cd759090adae0a6b02508df135/src/main/java/com/sporniket/libre/p3/builtins/WrappedObjectMapperProcessor.java#L105-L110
|
153,822
|
sporniket/p3
|
src/main/java/com/sporniket/libre/p3/builtins/WrappedObjectMapperProcessor.java
|
WrappedObjectMapperProcessor.computeSetterName
|
private String computeSetterName(String name)
{
StringBuilder _result = new StringBuilder().append(PREFIX__SETTER);
_result.append(Character.toUpperCase(name.charAt(0))).append(name.substring(1));
return _result.toString();
}
|
java
|
private String computeSetterName(String name)
{
StringBuilder _result = new StringBuilder().append(PREFIX__SETTER);
_result.append(Character.toUpperCase(name.charAt(0))).append(name.substring(1));
return _result.toString();
}
|
[
"private",
"String",
"computeSetterName",
"(",
"String",
"name",
")",
"{",
"StringBuilder",
"_result",
"=",
"new",
"StringBuilder",
"(",
")",
".",
"append",
"(",
"PREFIX__SETTER",
")",
";",
"_result",
".",
"append",
"(",
"Character",
".",
"toUpperCase",
"(",
"name",
".",
"charAt",
"(",
"0",
")",
")",
")",
".",
"append",
"(",
"name",
".",
"substring",
"(",
"1",
")",
")",
";",
"return",
"_result",
".",
"toString",
"(",
")",
";",
"}"
] |
Compute the setter name.
@param name
the name of the property to read.
@return the setter name.
|
[
"Compute",
"the",
"setter",
"name",
"."
] |
fc20b3066dc4a9cd759090adae0a6b02508df135
|
https://github.com/sporniket/p3/blob/fc20b3066dc4a9cd759090adae0a6b02508df135/src/main/java/com/sporniket/libre/p3/builtins/WrappedObjectMapperProcessor.java#L119-L124
|
153,823
|
sporniket/p3
|
src/main/java/com/sporniket/libre/p3/builtins/WrappedObjectMapperProcessor.java
|
WrappedObjectMapperProcessor.findSetterTarget
|
private SetterTarget findSetterTarget(String path) throws NoSuchMethodException, IllegalAccessException,
InvocationTargetException
{
String[] _accessStack = path.split(REGEXP__CHAR_DOT);
if (0 == _accessStack.length)
{
throw new IllegalArgumentException(path);
}
int _setterIndex = _accessStack.length - 1;
Object _toChange = getObject();
for (int _index = 0; _index < _setterIndex; _index++)
{
String _getterName = computeGetterName(_accessStack[_index]);
Method _getter = _toChange.getClass().getMethod(_getterName, (Class<?>[]) null);
_toChange = _getter.invoke(_toChange, (Object[]) null);
}
String _setterName = computeSetterName(_accessStack[_setterIndex]);
SetterTarget _target = new SetterTarget(_toChange, _setterName);
return _target;
}
|
java
|
private SetterTarget findSetterTarget(String path) throws NoSuchMethodException, IllegalAccessException,
InvocationTargetException
{
String[] _accessStack = path.split(REGEXP__CHAR_DOT);
if (0 == _accessStack.length)
{
throw new IllegalArgumentException(path);
}
int _setterIndex = _accessStack.length - 1;
Object _toChange = getObject();
for (int _index = 0; _index < _setterIndex; _index++)
{
String _getterName = computeGetterName(_accessStack[_index]);
Method _getter = _toChange.getClass().getMethod(_getterName, (Class<?>[]) null);
_toChange = _getter.invoke(_toChange, (Object[]) null);
}
String _setterName = computeSetterName(_accessStack[_setterIndex]);
SetterTarget _target = new SetterTarget(_toChange, _setterName);
return _target;
}
|
[
"private",
"SetterTarget",
"findSetterTarget",
"(",
"String",
"path",
")",
"throws",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"String",
"[",
"]",
"_accessStack",
"=",
"path",
".",
"split",
"(",
"REGEXP__CHAR_DOT",
")",
";",
"if",
"(",
"0",
"==",
"_accessStack",
".",
"length",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"path",
")",
";",
"}",
"int",
"_setterIndex",
"=",
"_accessStack",
".",
"length",
"-",
"1",
";",
"Object",
"_toChange",
"=",
"getObject",
"(",
")",
";",
"for",
"(",
"int",
"_index",
"=",
"0",
";",
"_index",
"<",
"_setterIndex",
";",
"_index",
"++",
")",
"{",
"String",
"_getterName",
"=",
"computeGetterName",
"(",
"_accessStack",
"[",
"_index",
"]",
")",
";",
"Method",
"_getter",
"=",
"_toChange",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"_getterName",
",",
"(",
"Class",
"<",
"?",
">",
"[",
"]",
")",
"null",
")",
";",
"_toChange",
"=",
"_getter",
".",
"invoke",
"(",
"_toChange",
",",
"(",
"Object",
"[",
"]",
")",
"null",
")",
";",
"}",
"String",
"_setterName",
"=",
"computeSetterName",
"(",
"_accessStack",
"[",
"_setterIndex",
"]",
")",
";",
"SetterTarget",
"_target",
"=",
"new",
"SetterTarget",
"(",
"_toChange",
",",
"_setterName",
")",
";",
"return",
"_target",
";",
"}"
] |
Find the object to change and the setter method name.
@param path
the path to the object and setter.
@return a {@link SetterTarget} storing the object to change and the setter name.
@throws NoSuchMethodException
when a getter does not exists.
@throws IllegalAccessException
when there is a problem.
@throws InvocationTargetException
when there is a problem.
|
[
"Find",
"the",
"object",
"to",
"change",
"and",
"the",
"setter",
"method",
"name",
"."
] |
fc20b3066dc4a9cd759090adae0a6b02508df135
|
https://github.com/sporniket/p3/blob/fc20b3066dc4a9cd759090adae0a6b02508df135/src/main/java/com/sporniket/libre/p3/builtins/WrappedObjectMapperProcessor.java#L208-L227
|
153,824
|
pressgang-ccms/PressGangCCMSRESTv1Common
|
src/main/java/org/jboss/pressgang/ccms/rest/v1/components/ComponentImageV1.java
|
ComponentImageV1.getDocbookFileName
|
public static String getDocbookFileName(final RESTImageV1 source) {
checkArgument(source != null, "The source parameter can not be null");
if (source.getLanguageImages_OTM() != null && source.getLanguageImages_OTM().getItems() != null) {
final List<RESTLanguageImageV1> langImages = source.getLanguageImages_OTM().returnItems();
for (final RESTLanguageImageV1 langImage : langImages) {
final String filename = langImage.getFilename();
if (filename != null) {
final int indexOfExtension = filename.lastIndexOf('.');
if (indexOfExtension != -1 && indexOfExtension < filename.length() - 1) {
final String extension = filename.substring(indexOfExtension, filename.length());
return source.getId() + extension;
}
}
}
}
return "";
}
|
java
|
public static String getDocbookFileName(final RESTImageV1 source) {
checkArgument(source != null, "The source parameter can not be null");
if (source.getLanguageImages_OTM() != null && source.getLanguageImages_OTM().getItems() != null) {
final List<RESTLanguageImageV1> langImages = source.getLanguageImages_OTM().returnItems();
for (final RESTLanguageImageV1 langImage : langImages) {
final String filename = langImage.getFilename();
if (filename != null) {
final int indexOfExtension = filename.lastIndexOf('.');
if (indexOfExtension != -1 && indexOfExtension < filename.length() - 1) {
final String extension = filename.substring(indexOfExtension, filename.length());
return source.getId() + extension;
}
}
}
}
return "";
}
|
[
"public",
"static",
"String",
"getDocbookFileName",
"(",
"final",
"RESTImageV1",
"source",
")",
"{",
"checkArgument",
"(",
"source",
"!=",
"null",
",",
"\"The source parameter can not be null\"",
")",
";",
"if",
"(",
"source",
".",
"getLanguageImages_OTM",
"(",
")",
"!=",
"null",
"&&",
"source",
".",
"getLanguageImages_OTM",
"(",
")",
".",
"getItems",
"(",
")",
"!=",
"null",
")",
"{",
"final",
"List",
"<",
"RESTLanguageImageV1",
">",
"langImages",
"=",
"source",
".",
"getLanguageImages_OTM",
"(",
")",
".",
"returnItems",
"(",
")",
";",
"for",
"(",
"final",
"RESTLanguageImageV1",
"langImage",
":",
"langImages",
")",
"{",
"final",
"String",
"filename",
"=",
"langImage",
".",
"getFilename",
"(",
")",
";",
"if",
"(",
"filename",
"!=",
"null",
")",
"{",
"final",
"int",
"indexOfExtension",
"=",
"filename",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"indexOfExtension",
"!=",
"-",
"1",
"&&",
"indexOfExtension",
"<",
"filename",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"final",
"String",
"extension",
"=",
"filename",
".",
"substring",
"(",
"indexOfExtension",
",",
"filename",
".",
"length",
"(",
")",
")",
";",
"return",
"source",
".",
"getId",
"(",
")",
"+",
"extension",
";",
"}",
"}",
"}",
"}",
"return",
"\"\"",
";",
"}"
] |
The docbook file name for an image is the ID of the image and the
extension of the first language image. This does imply that you can not
mix and match image formats within a single image.
@param source The RESTImageV1 object to get the docbook filename for
@return The docbook file name
|
[
"The",
"docbook",
"file",
"name",
"for",
"an",
"image",
"is",
"the",
"ID",
"of",
"the",
"image",
"and",
"the",
"extension",
"of",
"the",
"first",
"language",
"image",
".",
"This",
"does",
"imply",
"that",
"you",
"can",
"not",
"mix",
"and",
"match",
"image",
"formats",
"within",
"a",
"single",
"image",
"."
] |
0641d21b127297b47035f3b8e55fba81251b419c
|
https://github.com/pressgang-ccms/PressGangCCMSRESTv1Common/blob/0641d21b127297b47035f3b8e55fba81251b419c/src/main/java/org/jboss/pressgang/ccms/rest/v1/components/ComponentImageV1.java#L91-L110
|
153,825
|
jbundle/jbundle
|
app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java
|
WriteRecordClass.writeFieldOffsets
|
public void writeFieldOffsets(FieldIterator fieldIterator, CodeType codeType)
{ // Now, write all the field offsets out in the header file
ClassInfo recClassInfo = (ClassInfo)this.getMainRecord();
boolean firstTime = true;
String strBaseFieldName;
String strFieldName = "MainField"; // In case there are no fields
Record recFieldData = this.getRecord(FieldData.FIELD_DATA_FILE);
boolean alwaysInclude = false;
boolean alwaysExclude = false;
if (recClassInfo.isARecord(false))
{ // For record, all the fields are in the model class
if (codeType == CodeType.INTERFACE)
alwaysInclude = true;
else
alwaysExclude = true;
}
else
{ // screen record are thick only - no model
if (codeType == CodeType.THICK)
alwaysInclude = true;
else
alwaysExclude = true;
}
for (int pass = 1; pass <= 2; ++pass) // Do this two times (two passes)
{
fieldIterator.close();
while (fieldIterator.hasNext())
{
fieldIterator.next();
strFieldName = recFieldData.getField(FieldData.FIELD_NAME).getString();
strBaseFieldName = recFieldData.getField(FieldData.BASE_FIELD_NAME).getString();
String type = "String";
switch (pass)
{
case 1: // First, add all fields based on the super.New8 class
if (strBaseFieldName.length() > 0)
{
firstTime = false;
String value = convertNameToConstant(strBaseFieldName);
String strPre = DBConstants.BLANK;
if (recFieldData.getField(FieldData.FIELD_NAME).getString().equals(strBaseFieldName))
strPre = "//";
strFieldName = convertNameToConstant(strFieldName);
boolean includeThis = ((IncludeScopeField)recFieldData.getField(FieldData.INCLUDE_SCOPE)).includeThis(codeType, true);
if (alwaysInclude)
includeThis = true;
if (alwaysExclude)
includeThis = false;
if (includeThis)
m_StreamOut.writeit("\n" + strPre + "public static final " + type + " " + strFieldName + " = " + value + ";");
}
break;
case 2: // Now, add all fields new to this class
if (strBaseFieldName.length() == 0)
{
firstTime = false;
boolean includeThis = ((IncludeScopeField)recFieldData.getField(FieldData.INCLUDE_SCOPE)).includeThis(codeType, true);
if (alwaysInclude)
includeThis = true;
if (alwaysExclude)
includeThis = false;
if (Rec.ID.equals(strFieldName))
includeThis = false; // HACK
if (includeThis)
m_StreamOut.writeit("\n" + "public static final String " + this.convertNameToConstant(strFieldName) + " = \"" + strFieldName + "\";");
break;
}
}
}
recFieldData.close();
if (pass == 2)
{
if (!firstTime)
m_StreamOut.writeit("\n");
}
} // End of pass loop
}
|
java
|
public void writeFieldOffsets(FieldIterator fieldIterator, CodeType codeType)
{ // Now, write all the field offsets out in the header file
ClassInfo recClassInfo = (ClassInfo)this.getMainRecord();
boolean firstTime = true;
String strBaseFieldName;
String strFieldName = "MainField"; // In case there are no fields
Record recFieldData = this.getRecord(FieldData.FIELD_DATA_FILE);
boolean alwaysInclude = false;
boolean alwaysExclude = false;
if (recClassInfo.isARecord(false))
{ // For record, all the fields are in the model class
if (codeType == CodeType.INTERFACE)
alwaysInclude = true;
else
alwaysExclude = true;
}
else
{ // screen record are thick only - no model
if (codeType == CodeType.THICK)
alwaysInclude = true;
else
alwaysExclude = true;
}
for (int pass = 1; pass <= 2; ++pass) // Do this two times (two passes)
{
fieldIterator.close();
while (fieldIterator.hasNext())
{
fieldIterator.next();
strFieldName = recFieldData.getField(FieldData.FIELD_NAME).getString();
strBaseFieldName = recFieldData.getField(FieldData.BASE_FIELD_NAME).getString();
String type = "String";
switch (pass)
{
case 1: // First, add all fields based on the super.New8 class
if (strBaseFieldName.length() > 0)
{
firstTime = false;
String value = convertNameToConstant(strBaseFieldName);
String strPre = DBConstants.BLANK;
if (recFieldData.getField(FieldData.FIELD_NAME).getString().equals(strBaseFieldName))
strPre = "//";
strFieldName = convertNameToConstant(strFieldName);
boolean includeThis = ((IncludeScopeField)recFieldData.getField(FieldData.INCLUDE_SCOPE)).includeThis(codeType, true);
if (alwaysInclude)
includeThis = true;
if (alwaysExclude)
includeThis = false;
if (includeThis)
m_StreamOut.writeit("\n" + strPre + "public static final " + type + " " + strFieldName + " = " + value + ";");
}
break;
case 2: // Now, add all fields new to this class
if (strBaseFieldName.length() == 0)
{
firstTime = false;
boolean includeThis = ((IncludeScopeField)recFieldData.getField(FieldData.INCLUDE_SCOPE)).includeThis(codeType, true);
if (alwaysInclude)
includeThis = true;
if (alwaysExclude)
includeThis = false;
if (Rec.ID.equals(strFieldName))
includeThis = false; // HACK
if (includeThis)
m_StreamOut.writeit("\n" + "public static final String " + this.convertNameToConstant(strFieldName) + " = \"" + strFieldName + "\";");
break;
}
}
}
recFieldData.close();
if (pass == 2)
{
if (!firstTime)
m_StreamOut.writeit("\n");
}
} // End of pass loop
}
|
[
"public",
"void",
"writeFieldOffsets",
"(",
"FieldIterator",
"fieldIterator",
",",
"CodeType",
"codeType",
")",
"{",
"// Now, write all the field offsets out in the header file",
"ClassInfo",
"recClassInfo",
"=",
"(",
"ClassInfo",
")",
"this",
".",
"getMainRecord",
"(",
")",
";",
"boolean",
"firstTime",
"=",
"true",
";",
"String",
"strBaseFieldName",
";",
"String",
"strFieldName",
"=",
"\"MainField\"",
";",
"// In case there are no fields",
"Record",
"recFieldData",
"=",
"this",
".",
"getRecord",
"(",
"FieldData",
".",
"FIELD_DATA_FILE",
")",
";",
"boolean",
"alwaysInclude",
"=",
"false",
";",
"boolean",
"alwaysExclude",
"=",
"false",
";",
"if",
"(",
"recClassInfo",
".",
"isARecord",
"(",
"false",
")",
")",
"{",
"// For record, all the fields are in the model class",
"if",
"(",
"codeType",
"==",
"CodeType",
".",
"INTERFACE",
")",
"alwaysInclude",
"=",
"true",
";",
"else",
"alwaysExclude",
"=",
"true",
";",
"}",
"else",
"{",
"// screen record are thick only - no model",
"if",
"(",
"codeType",
"==",
"CodeType",
".",
"THICK",
")",
"alwaysInclude",
"=",
"true",
";",
"else",
"alwaysExclude",
"=",
"true",
";",
"}",
"for",
"(",
"int",
"pass",
"=",
"1",
";",
"pass",
"<=",
"2",
";",
"++",
"pass",
")",
"// Do this two times (two passes)",
"{",
"fieldIterator",
".",
"close",
"(",
")",
";",
"while",
"(",
"fieldIterator",
".",
"hasNext",
"(",
")",
")",
"{",
"fieldIterator",
".",
"next",
"(",
")",
";",
"strFieldName",
"=",
"recFieldData",
".",
"getField",
"(",
"FieldData",
".",
"FIELD_NAME",
")",
".",
"getString",
"(",
")",
";",
"strBaseFieldName",
"=",
"recFieldData",
".",
"getField",
"(",
"FieldData",
".",
"BASE_FIELD_NAME",
")",
".",
"getString",
"(",
")",
";",
"String",
"type",
"=",
"\"String\"",
";",
"switch",
"(",
"pass",
")",
"{",
"case",
"1",
":",
"// First, add all fields based on the super.New8 class",
"if",
"(",
"strBaseFieldName",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"firstTime",
"=",
"false",
";",
"String",
"value",
"=",
"convertNameToConstant",
"(",
"strBaseFieldName",
")",
";",
"String",
"strPre",
"=",
"DBConstants",
".",
"BLANK",
";",
"if",
"(",
"recFieldData",
".",
"getField",
"(",
"FieldData",
".",
"FIELD_NAME",
")",
".",
"getString",
"(",
")",
".",
"equals",
"(",
"strBaseFieldName",
")",
")",
"strPre",
"=",
"\"//\"",
";",
"strFieldName",
"=",
"convertNameToConstant",
"(",
"strFieldName",
")",
";",
"boolean",
"includeThis",
"=",
"(",
"(",
"IncludeScopeField",
")",
"recFieldData",
".",
"getField",
"(",
"FieldData",
".",
"INCLUDE_SCOPE",
")",
")",
".",
"includeThis",
"(",
"codeType",
",",
"true",
")",
";",
"if",
"(",
"alwaysInclude",
")",
"includeThis",
"=",
"true",
";",
"if",
"(",
"alwaysExclude",
")",
"includeThis",
"=",
"false",
";",
"if",
"(",
"includeThis",
")",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\n\"",
"+",
"strPre",
"+",
"\"public static final \"",
"+",
"type",
"+",
"\" \"",
"+",
"strFieldName",
"+",
"\" = \"",
"+",
"value",
"+",
"\";\"",
")",
";",
"}",
"break",
";",
"case",
"2",
":",
"// Now, add all fields new to this class",
"if",
"(",
"strBaseFieldName",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"firstTime",
"=",
"false",
";",
"boolean",
"includeThis",
"=",
"(",
"(",
"IncludeScopeField",
")",
"recFieldData",
".",
"getField",
"(",
"FieldData",
".",
"INCLUDE_SCOPE",
")",
")",
".",
"includeThis",
"(",
"codeType",
",",
"true",
")",
";",
"if",
"(",
"alwaysInclude",
")",
"includeThis",
"=",
"true",
";",
"if",
"(",
"alwaysExclude",
")",
"includeThis",
"=",
"false",
";",
"if",
"(",
"Rec",
".",
"ID",
".",
"equals",
"(",
"strFieldName",
")",
")",
"includeThis",
"=",
"false",
";",
"// HACK",
"if",
"(",
"includeThis",
")",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\n\"",
"+",
"\"public static final String \"",
"+",
"this",
".",
"convertNameToConstant",
"(",
"strFieldName",
")",
"+",
"\" = \\\"\"",
"+",
"strFieldName",
"+",
"\"\\\";\"",
")",
";",
"break",
";",
"}",
"}",
"}",
"recFieldData",
".",
"close",
"(",
")",
";",
"if",
"(",
"pass",
"==",
"2",
")",
"{",
"if",
"(",
"!",
"firstTime",
")",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\n\"",
")",
";",
"}",
"}",
"// End of pass loop",
"}"
] |
Write the constants for the field offsets
@param codeType
|
[
"Write",
"the",
"constants",
"for",
"the",
"field",
"offsets"
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java#L749-L827
|
153,826
|
jbundle/jbundle
|
app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java
|
WriteRecordClass.keyInBase
|
public boolean keyInBase(Record recClassInfo, Record recKeyInfo)
{
try {
if (recClassInfo2 == null)
recClassInfo2 = new ClassInfo(this);
if (recKeyInfo2 == null)
{
recKeyInfo2 = new KeyInfo(this);
recKeyInfo2.setKeyArea(KeyInfo.KEY_FILENAME_KEY);
SubFileFilter keyBehavior = new SubFileFilter(recClassInfo2.getField(ClassInfo.CLASS_NAME), KeyInfo.KEY_FILENAME, null, null, null, null);
recKeyInfo2.addListener(keyBehavior);
}
String baseClass = recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).toString();
while ((baseClass != null) && (baseClass.length() > 0) && (!"FieldList".equalsIgnoreCase(baseClass)))
{
recClassInfo2.getField(ClassInfo.CLASS_NAME).setString(baseClass);
recClassInfo2.setKeyArea(ClassInfo.CLASS_NAME_KEY);
if (!recClassInfo2.seek("=")) // Get this class record back
break;
recKeyInfo2.close();
while (recKeyInfo2.hasNext())
{
recKeyInfo2.next();
String keyName = recKeyInfo.getField(KeyInfo.KEY_NAME).toString();
if ((keyName == null) || (keyName.length() == 0))
keyName = recKeyInfo.getField(KeyInfo.KEY_FIELD_1).toString();
String keyName2 = recKeyInfo2.getField(KeyInfo.KEY_NAME).toString();
if ((keyName2 == null) || (keyName2.length() == 0))
keyName2 = recKeyInfo2.getField(KeyInfo.KEY_FIELD_1).toString();
if (keyName2.equals(keyName))
return true; // Match!
}
baseClass = recClassInfo2.getField(ClassInfo.BASE_CLASS_NAME).toString();
}
} catch (DBException e) {
e.printStackTrace();
}
return false; // Not in base
}
|
java
|
public boolean keyInBase(Record recClassInfo, Record recKeyInfo)
{
try {
if (recClassInfo2 == null)
recClassInfo2 = new ClassInfo(this);
if (recKeyInfo2 == null)
{
recKeyInfo2 = new KeyInfo(this);
recKeyInfo2.setKeyArea(KeyInfo.KEY_FILENAME_KEY);
SubFileFilter keyBehavior = new SubFileFilter(recClassInfo2.getField(ClassInfo.CLASS_NAME), KeyInfo.KEY_FILENAME, null, null, null, null);
recKeyInfo2.addListener(keyBehavior);
}
String baseClass = recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).toString();
while ((baseClass != null) && (baseClass.length() > 0) && (!"FieldList".equalsIgnoreCase(baseClass)))
{
recClassInfo2.getField(ClassInfo.CLASS_NAME).setString(baseClass);
recClassInfo2.setKeyArea(ClassInfo.CLASS_NAME_KEY);
if (!recClassInfo2.seek("=")) // Get this class record back
break;
recKeyInfo2.close();
while (recKeyInfo2.hasNext())
{
recKeyInfo2.next();
String keyName = recKeyInfo.getField(KeyInfo.KEY_NAME).toString();
if ((keyName == null) || (keyName.length() == 0))
keyName = recKeyInfo.getField(KeyInfo.KEY_FIELD_1).toString();
String keyName2 = recKeyInfo2.getField(KeyInfo.KEY_NAME).toString();
if ((keyName2 == null) || (keyName2.length() == 0))
keyName2 = recKeyInfo2.getField(KeyInfo.KEY_FIELD_1).toString();
if (keyName2.equals(keyName))
return true; // Match!
}
baseClass = recClassInfo2.getField(ClassInfo.BASE_CLASS_NAME).toString();
}
} catch (DBException e) {
e.printStackTrace();
}
return false; // Not in base
}
|
[
"public",
"boolean",
"keyInBase",
"(",
"Record",
"recClassInfo",
",",
"Record",
"recKeyInfo",
")",
"{",
"try",
"{",
"if",
"(",
"recClassInfo2",
"==",
"null",
")",
"recClassInfo2",
"=",
"new",
"ClassInfo",
"(",
"this",
")",
";",
"if",
"(",
"recKeyInfo2",
"==",
"null",
")",
"{",
"recKeyInfo2",
"=",
"new",
"KeyInfo",
"(",
"this",
")",
";",
"recKeyInfo2",
".",
"setKeyArea",
"(",
"KeyInfo",
".",
"KEY_FILENAME_KEY",
")",
";",
"SubFileFilter",
"keyBehavior",
"=",
"new",
"SubFileFilter",
"(",
"recClassInfo2",
".",
"getField",
"(",
"ClassInfo",
".",
"CLASS_NAME",
")",
",",
"KeyInfo",
".",
"KEY_FILENAME",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"recKeyInfo2",
".",
"addListener",
"(",
"keyBehavior",
")",
";",
"}",
"String",
"baseClass",
"=",
"recClassInfo",
".",
"getField",
"(",
"ClassInfo",
".",
"BASE_CLASS_NAME",
")",
".",
"toString",
"(",
")",
";",
"while",
"(",
"(",
"baseClass",
"!=",
"null",
")",
"&&",
"(",
"baseClass",
".",
"length",
"(",
")",
">",
"0",
")",
"&&",
"(",
"!",
"\"FieldList\"",
".",
"equalsIgnoreCase",
"(",
"baseClass",
")",
")",
")",
"{",
"recClassInfo2",
".",
"getField",
"(",
"ClassInfo",
".",
"CLASS_NAME",
")",
".",
"setString",
"(",
"baseClass",
")",
";",
"recClassInfo2",
".",
"setKeyArea",
"(",
"ClassInfo",
".",
"CLASS_NAME_KEY",
")",
";",
"if",
"(",
"!",
"recClassInfo2",
".",
"seek",
"(",
"\"=\"",
")",
")",
"// Get this class record back",
"break",
";",
"recKeyInfo2",
".",
"close",
"(",
")",
";",
"while",
"(",
"recKeyInfo2",
".",
"hasNext",
"(",
")",
")",
"{",
"recKeyInfo2",
".",
"next",
"(",
")",
";",
"String",
"keyName",
"=",
"recKeyInfo",
".",
"getField",
"(",
"KeyInfo",
".",
"KEY_NAME",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"(",
"keyName",
"==",
"null",
")",
"||",
"(",
"keyName",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"keyName",
"=",
"recKeyInfo",
".",
"getField",
"(",
"KeyInfo",
".",
"KEY_FIELD_1",
")",
".",
"toString",
"(",
")",
";",
"String",
"keyName2",
"=",
"recKeyInfo2",
".",
"getField",
"(",
"KeyInfo",
".",
"KEY_NAME",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"(",
"keyName2",
"==",
"null",
")",
"||",
"(",
"keyName2",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"keyName2",
"=",
"recKeyInfo2",
".",
"getField",
"(",
"KeyInfo",
".",
"KEY_FIELD_1",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"keyName2",
".",
"equals",
"(",
"keyName",
")",
")",
"return",
"true",
";",
"// Match!",
"}",
"baseClass",
"=",
"recClassInfo2",
".",
"getField",
"(",
"ClassInfo",
".",
"BASE_CLASS_NAME",
")",
".",
"toString",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"DBException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"false",
";",
"// Not in base ",
"}"
] |
Is this key already included in a base record?
@return
|
[
"Is",
"this",
"key",
"already",
"included",
"in",
"a",
"base",
"record?"
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java#L832-L871
|
153,827
|
jbundle/jbundle
|
app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java
|
WriteRecordClass.writeFileMakeViews
|
public void writeFileMakeViews()
{
if (this.readThisMethod("makeScreen"))
{
this.writeThisMethod(CodeType.THICK);
return; // if no views specified, use default methods
}
if (true)
{
ClassInfo recClassInfo = (ClassInfo)this.getMainRecord();
ClassFields recClassFields = new ClassFields(this);
recClassFields.addListener(new SubFileFilter(ClassFields.CLASS_INFO_CLASS_NAME_KEY, recClassInfo.getField(ClassInfo.CLASS_NAME))); // Only read through the class fields
recClassFields.close();
try {
boolean firstTime = true;
while (recClassFields.hasNext())
{
recClassFields.next();
String strClassFieldType = recClassFields.getField(ClassFields.CLASS_FIELDS_TYPE).toString();
if (strClassFieldType.equalsIgnoreCase(ClassFieldsTypeField.SCREEN_CLASS_NAME))
{
if (firstTime)
{
this.writeMethodInterface(null, "makeScreen", "ScreenParent", "ScreenLoc itsLocation, ComponentParent parentScreen, int iDocMode, Map<String,Object> properties", "", "Make a default screen.", null);
m_StreamOut.writeit("\tScreenParent screen = null;\n");
}
String screenMode = recClassFields.getField(ClassFields.CLASS_FIELD_INITIAL_VALUE).toString();
if ((screenMode == null) || (screenMode.length() == 0))
screenMode = "MAINT_MODE";
if (!screenMode.contains("."))
screenMode = "ScreenConstants." + screenMode;
String fieldName = recClassFields.getField(ClassFields.CLASS_FIELD_NAME).toString();
if (firstTime)
m_StreamOut.writeit("\t");
else
m_StreamOut.writeit("\telse ");
m_StreamOut.write("if ((iDocMode & " + screenMode + ") == " + screenMode + ")\n");
m_StreamOut.writeit("\t\tscreen = Record.makeNewScreen(" + fieldName + ", itsLocation, parentScreen, iDocMode | ScreenConstants.DONT_DISPLAY_FIELD_DESC, properties, this, true);\n");
firstTime = false;
}
}
if (!firstTime)
{
m_StreamOut.writeit("\telse\n");
m_StreamOut.writeit("\t\tscreen = super.makeScreen(itsLocation, parentScreen, iDocMode, properties);\n");
m_StreamOut.writeit("\treturn screen;\n}\n");
}
} catch (DBException e) {
e.printStackTrace();
}
}
}
|
java
|
public void writeFileMakeViews()
{
if (this.readThisMethod("makeScreen"))
{
this.writeThisMethod(CodeType.THICK);
return; // if no views specified, use default methods
}
if (true)
{
ClassInfo recClassInfo = (ClassInfo)this.getMainRecord();
ClassFields recClassFields = new ClassFields(this);
recClassFields.addListener(new SubFileFilter(ClassFields.CLASS_INFO_CLASS_NAME_KEY, recClassInfo.getField(ClassInfo.CLASS_NAME))); // Only read through the class fields
recClassFields.close();
try {
boolean firstTime = true;
while (recClassFields.hasNext())
{
recClassFields.next();
String strClassFieldType = recClassFields.getField(ClassFields.CLASS_FIELDS_TYPE).toString();
if (strClassFieldType.equalsIgnoreCase(ClassFieldsTypeField.SCREEN_CLASS_NAME))
{
if (firstTime)
{
this.writeMethodInterface(null, "makeScreen", "ScreenParent", "ScreenLoc itsLocation, ComponentParent parentScreen, int iDocMode, Map<String,Object> properties", "", "Make a default screen.", null);
m_StreamOut.writeit("\tScreenParent screen = null;\n");
}
String screenMode = recClassFields.getField(ClassFields.CLASS_FIELD_INITIAL_VALUE).toString();
if ((screenMode == null) || (screenMode.length() == 0))
screenMode = "MAINT_MODE";
if (!screenMode.contains("."))
screenMode = "ScreenConstants." + screenMode;
String fieldName = recClassFields.getField(ClassFields.CLASS_FIELD_NAME).toString();
if (firstTime)
m_StreamOut.writeit("\t");
else
m_StreamOut.writeit("\telse ");
m_StreamOut.write("if ((iDocMode & " + screenMode + ") == " + screenMode + ")\n");
m_StreamOut.writeit("\t\tscreen = Record.makeNewScreen(" + fieldName + ", itsLocation, parentScreen, iDocMode | ScreenConstants.DONT_DISPLAY_FIELD_DESC, properties, this, true);\n");
firstTime = false;
}
}
if (!firstTime)
{
m_StreamOut.writeit("\telse\n");
m_StreamOut.writeit("\t\tscreen = super.makeScreen(itsLocation, parentScreen, iDocMode, properties);\n");
m_StreamOut.writeit("\treturn screen;\n}\n");
}
} catch (DBException e) {
e.printStackTrace();
}
}
}
|
[
"public",
"void",
"writeFileMakeViews",
"(",
")",
"{",
"if",
"(",
"this",
".",
"readThisMethod",
"(",
"\"makeScreen\"",
")",
")",
"{",
"this",
".",
"writeThisMethod",
"(",
"CodeType",
".",
"THICK",
")",
";",
"return",
";",
"// if no views specified, use default methods",
"}",
"if",
"(",
"true",
")",
"{",
"ClassInfo",
"recClassInfo",
"=",
"(",
"ClassInfo",
")",
"this",
".",
"getMainRecord",
"(",
")",
";",
"ClassFields",
"recClassFields",
"=",
"new",
"ClassFields",
"(",
"this",
")",
";",
"recClassFields",
".",
"addListener",
"(",
"new",
"SubFileFilter",
"(",
"ClassFields",
".",
"CLASS_INFO_CLASS_NAME_KEY",
",",
"recClassInfo",
".",
"getField",
"(",
"ClassInfo",
".",
"CLASS_NAME",
")",
")",
")",
";",
"// Only read through the class fields",
"recClassFields",
".",
"close",
"(",
")",
";",
"try",
"{",
"boolean",
"firstTime",
"=",
"true",
";",
"while",
"(",
"recClassFields",
".",
"hasNext",
"(",
")",
")",
"{",
"recClassFields",
".",
"next",
"(",
")",
";",
"String",
"strClassFieldType",
"=",
"recClassFields",
".",
"getField",
"(",
"ClassFields",
".",
"CLASS_FIELDS_TYPE",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"strClassFieldType",
".",
"equalsIgnoreCase",
"(",
"ClassFieldsTypeField",
".",
"SCREEN_CLASS_NAME",
")",
")",
"{",
"if",
"(",
"firstTime",
")",
"{",
"this",
".",
"writeMethodInterface",
"(",
"null",
",",
"\"makeScreen\"",
",",
"\"ScreenParent\"",
",",
"\"ScreenLoc itsLocation, ComponentParent parentScreen, int iDocMode, Map<String,Object> properties\"",
",",
"\"\"",
",",
"\"Make a default screen.\"",
",",
"null",
")",
";",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\tScreenParent screen = null;\\n\"",
")",
";",
"}",
"String",
"screenMode",
"=",
"recClassFields",
".",
"getField",
"(",
"ClassFields",
".",
"CLASS_FIELD_INITIAL_VALUE",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"(",
"screenMode",
"==",
"null",
")",
"||",
"(",
"screenMode",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"screenMode",
"=",
"\"MAINT_MODE\"",
";",
"if",
"(",
"!",
"screenMode",
".",
"contains",
"(",
"\".\"",
")",
")",
"screenMode",
"=",
"\"ScreenConstants.\"",
"+",
"screenMode",
";",
"String",
"fieldName",
"=",
"recClassFields",
".",
"getField",
"(",
"ClassFields",
".",
"CLASS_FIELD_NAME",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"firstTime",
")",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\t\"",
")",
";",
"else",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\telse \"",
")",
";",
"m_StreamOut",
".",
"write",
"(",
"\"if ((iDocMode & \"",
"+",
"screenMode",
"+",
"\") == \"",
"+",
"screenMode",
"+",
"\")\\n\"",
")",
";",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\t\\tscreen = Record.makeNewScreen(\"",
"+",
"fieldName",
"+",
"\", itsLocation, parentScreen, iDocMode | ScreenConstants.DONT_DISPLAY_FIELD_DESC, properties, this, true);\\n\"",
")",
";",
"firstTime",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"!",
"firstTime",
")",
"{",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\telse\\n\"",
")",
";",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\t\\tscreen = super.makeScreen(itsLocation, parentScreen, iDocMode, properties);\\n\"",
")",
";",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\treturn screen;\\n}\\n\"",
")",
";",
"}",
"}",
"catch",
"(",
"DBException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}"
] |
Write the TableDoc code to DoMakeViews.
|
[
"Write",
"the",
"TableDoc",
"code",
"to",
"DoMakeViews",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java#L885-L937
|
153,828
|
jbundle/jbundle
|
app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java
|
WriteRecordClass.writeFree
|
public void writeFree()
{
Record recClassInfo = this.getMainRecord();
ClassFields recClassFields = new ClassFields(this);
try {
String strFieldName;
String strFieldClass;
// Now, zero out all the class fields
recClassFields.setKeyArea(ClassFields.CLASS_INFO_CLASS_NAME_KEY);
SubFileFilter fileBehavior2 = new SubFileFilter(recClassInfo.getField(ClassInfo.CLASS_NAME), ClassFields.CLASS_INFO_CLASS_NAME, null, null, null, null);
recClassFields.addListener(fileBehavior2); // Only read through the class fields
recClassFields.close();
recClassFields.moveFirst();
this.writeMethodInterface(null, "free", "void", "", "", "Release the objects bound to this record.", null);
m_StreamOut.setTabs(+1);
m_StreamOut.writeit("super.free();\n");
while (recClassFields.hasNext())
{
recClassFields.next();
strFieldName = recClassFields.getField(ClassFields.CLASS_FIELD_NAME).getString();
String strClassFieldType = recClassFields.getField(ClassFields.CLASS_FIELDS_TYPE).toString();
if ((strClassFieldType.equalsIgnoreCase(ClassFieldsTypeField.CLASS_FIELD))
|| (strClassFieldType.equalsIgnoreCase(ClassFieldsTypeField.NATIVE_FIELD)))
if (strFieldName.length() != 0)
if (!recClassFields.getField(ClassFields.CLASS_FIELD_PROTECT).getString().equalsIgnoreCase("S")) // Not static
{
String strReference = "";
if (strClassFieldType.equalsIgnoreCase(ClassFieldsTypeField.CLASS_FIELD))
strReference = "null";
else
{
strReference = recClassFields.getField(ClassFields.CLASS_FIELD_INITIAL).getString();
if (strReference.length() == 0)
{
strReference = "0";
strFieldClass = recClassFields.getField(ClassFields.CLASS_FIELD_CLASS).getString();
if (strFieldClass.equalsIgnoreCase("String"))
strReference = "\"\"";
}
}
if (!strReference.equals("(none)"))
m_StreamOut.writeit("\t" + strFieldName + " = null;\n");
}
}
recClassFields.close();
m_StreamOut.setTabs(-1);
m_StreamOut.writeit("}\n");
} catch (DBException ex) {
ex.printStackTrace();
} finally {
if (recClassFields != null)
recClassFields.free();
}
}
|
java
|
public void writeFree()
{
Record recClassInfo = this.getMainRecord();
ClassFields recClassFields = new ClassFields(this);
try {
String strFieldName;
String strFieldClass;
// Now, zero out all the class fields
recClassFields.setKeyArea(ClassFields.CLASS_INFO_CLASS_NAME_KEY);
SubFileFilter fileBehavior2 = new SubFileFilter(recClassInfo.getField(ClassInfo.CLASS_NAME), ClassFields.CLASS_INFO_CLASS_NAME, null, null, null, null);
recClassFields.addListener(fileBehavior2); // Only read through the class fields
recClassFields.close();
recClassFields.moveFirst();
this.writeMethodInterface(null, "free", "void", "", "", "Release the objects bound to this record.", null);
m_StreamOut.setTabs(+1);
m_StreamOut.writeit("super.free();\n");
while (recClassFields.hasNext())
{
recClassFields.next();
strFieldName = recClassFields.getField(ClassFields.CLASS_FIELD_NAME).getString();
String strClassFieldType = recClassFields.getField(ClassFields.CLASS_FIELDS_TYPE).toString();
if ((strClassFieldType.equalsIgnoreCase(ClassFieldsTypeField.CLASS_FIELD))
|| (strClassFieldType.equalsIgnoreCase(ClassFieldsTypeField.NATIVE_FIELD)))
if (strFieldName.length() != 0)
if (!recClassFields.getField(ClassFields.CLASS_FIELD_PROTECT).getString().equalsIgnoreCase("S")) // Not static
{
String strReference = "";
if (strClassFieldType.equalsIgnoreCase(ClassFieldsTypeField.CLASS_FIELD))
strReference = "null";
else
{
strReference = recClassFields.getField(ClassFields.CLASS_FIELD_INITIAL).getString();
if (strReference.length() == 0)
{
strReference = "0";
strFieldClass = recClassFields.getField(ClassFields.CLASS_FIELD_CLASS).getString();
if (strFieldClass.equalsIgnoreCase("String"))
strReference = "\"\"";
}
}
if (!strReference.equals("(none)"))
m_StreamOut.writeit("\t" + strFieldName + " = null;\n");
}
}
recClassFields.close();
m_StreamOut.setTabs(-1);
m_StreamOut.writeit("}\n");
} catch (DBException ex) {
ex.printStackTrace();
} finally {
if (recClassFields != null)
recClassFields.free();
}
}
|
[
"public",
"void",
"writeFree",
"(",
")",
"{",
"Record",
"recClassInfo",
"=",
"this",
".",
"getMainRecord",
"(",
")",
";",
"ClassFields",
"recClassFields",
"=",
"new",
"ClassFields",
"(",
"this",
")",
";",
"try",
"{",
"String",
"strFieldName",
";",
"String",
"strFieldClass",
";",
"// Now, zero out all the class fields",
"recClassFields",
".",
"setKeyArea",
"(",
"ClassFields",
".",
"CLASS_INFO_CLASS_NAME_KEY",
")",
";",
"SubFileFilter",
"fileBehavior2",
"=",
"new",
"SubFileFilter",
"(",
"recClassInfo",
".",
"getField",
"(",
"ClassInfo",
".",
"CLASS_NAME",
")",
",",
"ClassFields",
".",
"CLASS_INFO_CLASS_NAME",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"recClassFields",
".",
"addListener",
"(",
"fileBehavior2",
")",
";",
"// Only read through the class fields",
"recClassFields",
".",
"close",
"(",
")",
";",
"recClassFields",
".",
"moveFirst",
"(",
")",
";",
"this",
".",
"writeMethodInterface",
"(",
"null",
",",
"\"free\"",
",",
"\"void\"",
",",
"\"\"",
",",
"\"\"",
",",
"\"Release the objects bound to this record.\"",
",",
"null",
")",
";",
"m_StreamOut",
".",
"setTabs",
"(",
"+",
"1",
")",
";",
"m_StreamOut",
".",
"writeit",
"(",
"\"super.free();\\n\"",
")",
";",
"while",
"(",
"recClassFields",
".",
"hasNext",
"(",
")",
")",
"{",
"recClassFields",
".",
"next",
"(",
")",
";",
"strFieldName",
"=",
"recClassFields",
".",
"getField",
"(",
"ClassFields",
".",
"CLASS_FIELD_NAME",
")",
".",
"getString",
"(",
")",
";",
"String",
"strClassFieldType",
"=",
"recClassFields",
".",
"getField",
"(",
"ClassFields",
".",
"CLASS_FIELDS_TYPE",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"(",
"strClassFieldType",
".",
"equalsIgnoreCase",
"(",
"ClassFieldsTypeField",
".",
"CLASS_FIELD",
")",
")",
"||",
"(",
"strClassFieldType",
".",
"equalsIgnoreCase",
"(",
"ClassFieldsTypeField",
".",
"NATIVE_FIELD",
")",
")",
")",
"if",
"(",
"strFieldName",
".",
"length",
"(",
")",
"!=",
"0",
")",
"if",
"(",
"!",
"recClassFields",
".",
"getField",
"(",
"ClassFields",
".",
"CLASS_FIELD_PROTECT",
")",
".",
"getString",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"\"S\"",
")",
")",
"// Not static",
"{",
"String",
"strReference",
"=",
"\"\"",
";",
"if",
"(",
"strClassFieldType",
".",
"equalsIgnoreCase",
"(",
"ClassFieldsTypeField",
".",
"CLASS_FIELD",
")",
")",
"strReference",
"=",
"\"null\"",
";",
"else",
"{",
"strReference",
"=",
"recClassFields",
".",
"getField",
"(",
"ClassFields",
".",
"CLASS_FIELD_INITIAL",
")",
".",
"getString",
"(",
")",
";",
"if",
"(",
"strReference",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"strReference",
"=",
"\"0\"",
";",
"strFieldClass",
"=",
"recClassFields",
".",
"getField",
"(",
"ClassFields",
".",
"CLASS_FIELD_CLASS",
")",
".",
"getString",
"(",
")",
";",
"if",
"(",
"strFieldClass",
".",
"equalsIgnoreCase",
"(",
"\"String\"",
")",
")",
"strReference",
"=",
"\"\\\"\\\"\"",
";",
"}",
"}",
"if",
"(",
"!",
"strReference",
".",
"equals",
"(",
"\"(none)\"",
")",
")",
"m_StreamOut",
".",
"writeit",
"(",
"\"\\t\"",
"+",
"strFieldName",
"+",
"\" = null;\\n\"",
")",
";",
"}",
"}",
"recClassFields",
".",
"close",
"(",
")",
";",
"m_StreamOut",
".",
"setTabs",
"(",
"-",
"1",
")",
";",
"m_StreamOut",
".",
"writeit",
"(",
"\"}\\n\"",
")",
";",
"}",
"catch",
"(",
"DBException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"recClassFields",
"!=",
"null",
")",
"recClassFields",
".",
"free",
"(",
")",
";",
"}",
"}"
] |
Free the class.
|
[
"Free",
"the",
"class",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java#L1251-L1308
|
153,829
|
jbundle/jbundle
|
app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java
|
WriteRecordClass.readRecordClass
|
public void readRecordClass(String strRecordClass)
{
String strBaseClass;
Record recClassInfo = this.getMainRecord();
if (!this.readThisClass(strRecordClass))
strBaseClass = "Record";
else
{
strBaseClass = recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).getString();
if (strBaseClass.equalsIgnoreCase("Record"))
strBaseClass = "Record";
if (strBaseClass.length() == 0)
strBaseClass = "Record";
}
recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).setString(strBaseClass);
}
|
java
|
public void readRecordClass(String strRecordClass)
{
String strBaseClass;
Record recClassInfo = this.getMainRecord();
if (!this.readThisClass(strRecordClass))
strBaseClass = "Record";
else
{
strBaseClass = recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).getString();
if (strBaseClass.equalsIgnoreCase("Record"))
strBaseClass = "Record";
if (strBaseClass.length() == 0)
strBaseClass = "Record";
}
recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).setString(strBaseClass);
}
|
[
"public",
"void",
"readRecordClass",
"(",
"String",
"strRecordClass",
")",
"{",
"String",
"strBaseClass",
";",
"Record",
"recClassInfo",
"=",
"this",
".",
"getMainRecord",
"(",
")",
";",
"if",
"(",
"!",
"this",
".",
"readThisClass",
"(",
"strRecordClass",
")",
")",
"strBaseClass",
"=",
"\"Record\"",
";",
"else",
"{",
"strBaseClass",
"=",
"recClassInfo",
".",
"getField",
"(",
"ClassInfo",
".",
"BASE_CLASS_NAME",
")",
".",
"getString",
"(",
")",
";",
"if",
"(",
"strBaseClass",
".",
"equalsIgnoreCase",
"(",
"\"Record\"",
")",
")",
"strBaseClass",
"=",
"\"Record\"",
";",
"if",
"(",
"strBaseClass",
".",
"length",
"(",
")",
"==",
"0",
")",
"strBaseClass",
"=",
"\"Record\"",
";",
"}",
"recClassInfo",
".",
"getField",
"(",
"ClassInfo",
".",
"BASE_CLASS_NAME",
")",
".",
"setString",
"(",
"strBaseClass",
")",
";",
"}"
] |
Read the Class for this record
|
[
"Read",
"the",
"Class",
"for",
"this",
"record"
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java#L1312-L1327
|
153,830
|
jbundle/jbundle
|
app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java
|
WriteRecordClass.getBaseDataClass
|
public void getBaseDataClass(FieldStuff fieldStuff)
{
Record recClassInfo2 = m_recClassInfo2;
FieldData recFieldData = (FieldData)this.getRecord(FieldData.FIELD_DATA_FILE);
String strRecordClass = recFieldData.getField(FieldData.FIELD_CLASS).getString();
fieldStuff.strBaseFieldClass = null;
try {
while (true)
{
recClassInfo2.setKeyArea(ClassInfo.CLASS_NAME_KEY);
recClassInfo2.getField(ClassInfo.CLASS_NAME).setString(strRecordClass); // Class of this record
if ((!recClassInfo2.seek("=")) || (strRecordClass == null) || (strRecordClass.length() == 0))
{
if (fieldStuff.strBaseFieldClass == null)
fieldStuff.strBaseFieldClass = recFieldData.getField(FieldData.FIELD_CLASS).getString(); // Never
return;
}
if (fieldStuff.strBaseFieldClass == null)
{
String packageName = ((ClassInfo)recClassInfo2).getPackageName(null);
if (packageName.endsWith(".base.field"))
fieldStuff.strBaseFieldClass = recClassInfo2.getField(ClassInfo.CLASS_NAME).toString();
}
if (strRecordClass.indexOf("Field") != -1)
{
String strType = strRecordClass.substring(0, strRecordClass.indexOf("Field"));
if ((strType.equals("DateTime")) || (strType.equals("Time")))
strType = "Date";
if (strType.length() > 0)
if ("Short Integer Double Float Boolean String Date".indexOf(strType) != -1)
{
if ((fieldStuff.strDataClass == null) || (fieldStuff.strDataClass.length() == 0))
fieldStuff.strDataClass = strType; // End of based records - not found
return;
}
}
strRecordClass = recClassInfo2.getField(ClassInfo.BASE_CLASS_NAME).getString();
}
} catch (DBException ex) {
ex.printStackTrace();
}
}
|
java
|
public void getBaseDataClass(FieldStuff fieldStuff)
{
Record recClassInfo2 = m_recClassInfo2;
FieldData recFieldData = (FieldData)this.getRecord(FieldData.FIELD_DATA_FILE);
String strRecordClass = recFieldData.getField(FieldData.FIELD_CLASS).getString();
fieldStuff.strBaseFieldClass = null;
try {
while (true)
{
recClassInfo2.setKeyArea(ClassInfo.CLASS_NAME_KEY);
recClassInfo2.getField(ClassInfo.CLASS_NAME).setString(strRecordClass); // Class of this record
if ((!recClassInfo2.seek("=")) || (strRecordClass == null) || (strRecordClass.length() == 0))
{
if (fieldStuff.strBaseFieldClass == null)
fieldStuff.strBaseFieldClass = recFieldData.getField(FieldData.FIELD_CLASS).getString(); // Never
return;
}
if (fieldStuff.strBaseFieldClass == null)
{
String packageName = ((ClassInfo)recClassInfo2).getPackageName(null);
if (packageName.endsWith(".base.field"))
fieldStuff.strBaseFieldClass = recClassInfo2.getField(ClassInfo.CLASS_NAME).toString();
}
if (strRecordClass.indexOf("Field") != -1)
{
String strType = strRecordClass.substring(0, strRecordClass.indexOf("Field"));
if ((strType.equals("DateTime")) || (strType.equals("Time")))
strType = "Date";
if (strType.length() > 0)
if ("Short Integer Double Float Boolean String Date".indexOf(strType) != -1)
{
if ((fieldStuff.strDataClass == null) || (fieldStuff.strDataClass.length() == 0))
fieldStuff.strDataClass = strType; // End of based records - not found
return;
}
}
strRecordClass = recClassInfo2.getField(ClassInfo.BASE_CLASS_NAME).getString();
}
} catch (DBException ex) {
ex.printStackTrace();
}
}
|
[
"public",
"void",
"getBaseDataClass",
"(",
"FieldStuff",
"fieldStuff",
")",
"{",
"Record",
"recClassInfo2",
"=",
"m_recClassInfo2",
";",
"FieldData",
"recFieldData",
"=",
"(",
"FieldData",
")",
"this",
".",
"getRecord",
"(",
"FieldData",
".",
"FIELD_DATA_FILE",
")",
";",
"String",
"strRecordClass",
"=",
"recFieldData",
".",
"getField",
"(",
"FieldData",
".",
"FIELD_CLASS",
")",
".",
"getString",
"(",
")",
";",
"fieldStuff",
".",
"strBaseFieldClass",
"=",
"null",
";",
"try",
"{",
"while",
"(",
"true",
")",
"{",
"recClassInfo2",
".",
"setKeyArea",
"(",
"ClassInfo",
".",
"CLASS_NAME_KEY",
")",
";",
"recClassInfo2",
".",
"getField",
"(",
"ClassInfo",
".",
"CLASS_NAME",
")",
".",
"setString",
"(",
"strRecordClass",
")",
";",
"// Class of this record",
"if",
"(",
"(",
"!",
"recClassInfo2",
".",
"seek",
"(",
"\"=\"",
")",
")",
"||",
"(",
"strRecordClass",
"==",
"null",
")",
"||",
"(",
"strRecordClass",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"if",
"(",
"fieldStuff",
".",
"strBaseFieldClass",
"==",
"null",
")",
"fieldStuff",
".",
"strBaseFieldClass",
"=",
"recFieldData",
".",
"getField",
"(",
"FieldData",
".",
"FIELD_CLASS",
")",
".",
"getString",
"(",
")",
";",
"// Never",
"return",
";",
"}",
"if",
"(",
"fieldStuff",
".",
"strBaseFieldClass",
"==",
"null",
")",
"{",
"String",
"packageName",
"=",
"(",
"(",
"ClassInfo",
")",
"recClassInfo2",
")",
".",
"getPackageName",
"(",
"null",
")",
";",
"if",
"(",
"packageName",
".",
"endsWith",
"(",
"\".base.field\"",
")",
")",
"fieldStuff",
".",
"strBaseFieldClass",
"=",
"recClassInfo2",
".",
"getField",
"(",
"ClassInfo",
".",
"CLASS_NAME",
")",
".",
"toString",
"(",
")",
";",
"}",
"if",
"(",
"strRecordClass",
".",
"indexOf",
"(",
"\"Field\"",
")",
"!=",
"-",
"1",
")",
"{",
"String",
"strType",
"=",
"strRecordClass",
".",
"substring",
"(",
"0",
",",
"strRecordClass",
".",
"indexOf",
"(",
"\"Field\"",
")",
")",
";",
"if",
"(",
"(",
"strType",
".",
"equals",
"(",
"\"DateTime\"",
")",
")",
"||",
"(",
"strType",
".",
"equals",
"(",
"\"Time\"",
")",
")",
")",
"strType",
"=",
"\"Date\"",
";",
"if",
"(",
"strType",
".",
"length",
"(",
")",
">",
"0",
")",
"if",
"(",
"\"Short Integer Double Float Boolean String Date\"",
".",
"indexOf",
"(",
"strType",
")",
"!=",
"-",
"1",
")",
"{",
"if",
"(",
"(",
"fieldStuff",
".",
"strDataClass",
"==",
"null",
")",
"||",
"(",
"fieldStuff",
".",
"strDataClass",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"fieldStuff",
".",
"strDataClass",
"=",
"strType",
";",
"// End of based records - not found",
"return",
";",
"}",
"}",
"strRecordClass",
"=",
"recClassInfo2",
".",
"getField",
"(",
"ClassInfo",
".",
"BASE_CLASS_NAME",
")",
".",
"getString",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"DBException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] |
Read thru the classes until you get a Physical data class.
|
[
"Read",
"thru",
"the",
"classes",
"until",
"you",
"get",
"a",
"Physical",
"data",
"class",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/util/src/main/java/org/jbundle/app/program/manual/util/WriteRecordClass.java#L1391-L1433
|
153,831
|
jbundle/jbundle
|
app/program/manual/backup/src/main/java/org/jbundle/app/program/manual/backup/BackupServerApp.java
|
BackupServerApp.actionPerformed
|
@Override
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == m_cycletimer)
this.startNextFile();
else if (e.getSource() == m_timeouttimer)
this.checkTimeout();
}
|
java
|
@Override
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == m_cycletimer)
this.startNextFile();
else if (e.getSource() == m_timeouttimer)
this.checkTimeout();
}
|
[
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"e",
")",
"{",
"if",
"(",
"e",
".",
"getSource",
"(",
")",
"==",
"m_cycletimer",
")",
"this",
".",
"startNextFile",
"(",
")",
";",
"else",
"if",
"(",
"e",
".",
"getSource",
"(",
")",
"==",
"m_timeouttimer",
")",
"this",
".",
"checkTimeout",
"(",
")",
";",
"}"
] |
Timer handling.
|
[
"Timer",
"handling",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/backup/src/main/java/org/jbundle/app/program/manual/backup/BackupServerApp.java#L291-L298
|
153,832
|
jbundle/jbundle
|
app/program/manual/backup/src/main/java/org/jbundle/app/program/manual/backup/BackupServerApp.java
|
BackupServerApp.flush
|
public synchronized void flush(boolean bSendFakeTrx)
{
try {
if (bSendFakeTrx)
this.getWriter().writeObject(FAKE_TRX);
this.getWriter().flush();
} catch (IOException e) {
e.printStackTrace();
}
}
|
java
|
public synchronized void flush(boolean bSendFakeTrx)
{
try {
if (bSendFakeTrx)
this.getWriter().writeObject(FAKE_TRX);
this.getWriter().flush();
} catch (IOException e) {
e.printStackTrace();
}
}
|
[
"public",
"synchronized",
"void",
"flush",
"(",
"boolean",
"bSendFakeTrx",
")",
"{",
"try",
"{",
"if",
"(",
"bSendFakeTrx",
")",
"this",
".",
"getWriter",
"(",
")",
".",
"writeObject",
"(",
"FAKE_TRX",
")",
";",
"this",
".",
"getWriter",
"(",
")",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] |
Flush the buffer.
@param bSendFakeTrx Send a fake trx before flushing (This guarantees activity on the stream before the flush [In case it just autoflushed the entire buffer])
|
[
"Flush",
"the",
"buffer",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/manual/backup/src/main/java/org/jbundle/app/program/manual/backup/BackupServerApp.java#L323-L332
|
153,833
|
pressgang-ccms/PressGangCCMSContentSpec
|
src/main/java/org/jboss/pressgang/ccms/contentspec/InfoTopic.java
|
InfoTopic.getIdAndOptionsString
|
protected String getIdAndOptionsString() {
final String options = getOptionsString();
if (isTopicANewTopic()) {
return id + (options.equals("") ? "" : (", " + options));
} else {
return id + (revision == null ? "" : (", rev: " + revision)) + (options.equals("") ? "" : (", " + options));
}
}
|
java
|
protected String getIdAndOptionsString() {
final String options = getOptionsString();
if (isTopicANewTopic()) {
return id + (options.equals("") ? "" : (", " + options));
} else {
return id + (revision == null ? "" : (", rev: " + revision)) + (options.equals("") ? "" : (", " + options));
}
}
|
[
"protected",
"String",
"getIdAndOptionsString",
"(",
")",
"{",
"final",
"String",
"options",
"=",
"getOptionsString",
"(",
")",
";",
"if",
"(",
"isTopicANewTopic",
"(",
")",
")",
"{",
"return",
"id",
"+",
"(",
"options",
".",
"equals",
"(",
"\"\"",
")",
"?",
"\"\"",
":",
"(",
"\", \"",
"+",
"options",
")",
")",
";",
"}",
"else",
"{",
"return",
"id",
"+",
"(",
"revision",
"==",
"null",
"?",
"\"\"",
":",
"(",
"\", rev: \"",
"+",
"revision",
")",
")",
"+",
"(",
"options",
".",
"equals",
"(",
"\"\"",
")",
"?",
"\"\"",
":",
"(",
"\", \"",
"+",
"options",
")",
")",
";",
"}",
"}"
] |
Get the ID and Options string for the topic.
@return
|
[
"Get",
"the",
"ID",
"and",
"Options",
"string",
"for",
"the",
"topic",
"."
] |
2bc02e2971e4522b47a130fb7ae5a0f5ad377df1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpec/blob/2bc02e2971e4522b47a130fb7ae5a0f5ad377df1/src/main/java/org/jboss/pressgang/ccms/contentspec/InfoTopic.java#L359-L366
|
153,834
|
jbundle/jbundle
|
main/db/src/main/java/org/jbundle/main/db/base/BaseStatus.java
|
BaseStatus.isWaiting
|
public static boolean isWaiting(int iStatusID)
{
switch (iStatusID)
{
case REQUEST_SENT:
case DATA_REQUIRED:
return true;
case NULL_STATUS:
case NO_STATUS:
case PROPOSAL:
case ACCEPTED:
case CANCELED:
case OKAY:
case NOT_USED:
case ERROR:
case MANUAL_REQUEST_REQUIRED:
case MANUAL_REQUEST_SENT:
case NOT_VALID:
case DATA_VALID:
default:
return false;
}
}
|
java
|
public static boolean isWaiting(int iStatusID)
{
switch (iStatusID)
{
case REQUEST_SENT:
case DATA_REQUIRED:
return true;
case NULL_STATUS:
case NO_STATUS:
case PROPOSAL:
case ACCEPTED:
case CANCELED:
case OKAY:
case NOT_USED:
case ERROR:
case MANUAL_REQUEST_REQUIRED:
case MANUAL_REQUEST_SENT:
case NOT_VALID:
case DATA_VALID:
default:
return false;
}
}
|
[
"public",
"static",
"boolean",
"isWaiting",
"(",
"int",
"iStatusID",
")",
"{",
"switch",
"(",
"iStatusID",
")",
"{",
"case",
"REQUEST_SENT",
":",
"case",
"DATA_REQUIRED",
":",
"return",
"true",
";",
"case",
"NULL_STATUS",
":",
"case",
"NO_STATUS",
":",
"case",
"PROPOSAL",
":",
"case",
"ACCEPTED",
":",
"case",
"CANCELED",
":",
"case",
"OKAY",
":",
"case",
"NOT_USED",
":",
"case",
"ERROR",
":",
"case",
"MANUAL_REQUEST_REQUIRED",
":",
"case",
"MANUAL_REQUEST_SENT",
":",
"case",
"NOT_VALID",
":",
"case",
"DATA_VALID",
":",
"default",
":",
"return",
"false",
";",
"}",
"}"
] |
Is this status waiting for an event to occur?.
|
[
"Is",
"this",
"status",
"waiting",
"for",
"an",
"event",
"to",
"occur?",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/main/db/src/main/java/org/jbundle/main/db/base/BaseStatus.java#L137-L159
|
153,835
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/comp/ChangePasswordDialog.java
|
ChangePasswordDialog.getNewPassword
|
public String getNewPassword()
{
char[] rgchNewPassword = newPasswordField.getPassword();
char[] rgchConfirmPassword = confirmPasswordField.getPassword();
String strNewPassword = new String(rgchNewPassword);
String strConfirmPassword = new String(rgchConfirmPassword);
if (strNewPassword != null)
if (!strNewPassword.equals(strConfirmPassword))
return null;
return strNewPassword;
}
|
java
|
public String getNewPassword()
{
char[] rgchNewPassword = newPasswordField.getPassword();
char[] rgchConfirmPassword = confirmPasswordField.getPassword();
String strNewPassword = new String(rgchNewPassword);
String strConfirmPassword = new String(rgchConfirmPassword);
if (strNewPassword != null)
if (!strNewPassword.equals(strConfirmPassword))
return null;
return strNewPassword;
}
|
[
"public",
"String",
"getNewPassword",
"(",
")",
"{",
"char",
"[",
"]",
"rgchNewPassword",
"=",
"newPasswordField",
".",
"getPassword",
"(",
")",
";",
"char",
"[",
"]",
"rgchConfirmPassword",
"=",
"confirmPasswordField",
".",
"getPassword",
"(",
")",
";",
"String",
"strNewPassword",
"=",
"new",
"String",
"(",
"rgchNewPassword",
")",
";",
"String",
"strConfirmPassword",
"=",
"new",
"String",
"(",
"rgchConfirmPassword",
")",
";",
"if",
"(",
"strNewPassword",
"!=",
"null",
")",
"if",
"(",
"!",
"strNewPassword",
".",
"equals",
"(",
"strConfirmPassword",
")",
")",
"return",
"null",
";",
"return",
"strNewPassword",
";",
"}"
] |
Compare the new and confirm password and return the new password.
|
[
"Compare",
"the",
"new",
"and",
"confirm",
"password",
"and",
"return",
"the",
"new",
"password",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/comp/ChangePasswordDialog.java#L55-L65
|
153,836
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/math/Circles.java
|
Circles.isInside
|
public static boolean isInside(Circle c1, Circle c2)
{
return distanceFromCenter(c1, c2.getX(), c2.getY())+c2.getRadius() < c1.getRadius();
}
|
java
|
public static boolean isInside(Circle c1, Circle c2)
{
return distanceFromCenter(c1, c2.getX(), c2.getY())+c2.getRadius() < c1.getRadius();
}
|
[
"public",
"static",
"boolean",
"isInside",
"(",
"Circle",
"c1",
",",
"Circle",
"c2",
")",
"{",
"return",
"distanceFromCenter",
"(",
"c1",
",",
"c2",
".",
"getX",
"(",
")",
",",
"c2",
".",
"getY",
"(",
")",
")",
"+",
"c2",
".",
"getRadius",
"(",
")",
"<",
"c1",
".",
"getRadius",
"(",
")",
";",
"}"
] |
Returns true if c2 is inside of c1
@param c1
@param c2
@return
|
[
"Returns",
"true",
"if",
"c2",
"is",
"inside",
"of",
"c1"
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/math/Circles.java#L60-L63
|
153,837
|
wigforss/Ka-Commons-Reflection
|
src/main/java/org/kasource/commons/reflection/collection/ClassMap.java
|
ClassMap.get
|
public T get(Class<?> clazz) {
if(map == null || map.isEmpty()) {
return null;
}
Class<?> classToInspect = clazz;
T object = map.get(classToInspect);
if(object == null && !excludeInterfaces) {
object = getByInterfaces(classToInspect);
}
while (object == null && classToInspect.getSuperclass() != null) {
classToInspect = classToInspect.getSuperclass();
object = map.get(classToInspect);
if(object == null && !excludeInterfaces) {
object = getByInterfaces(classToInspect);
}
}
return object;
}
|
java
|
public T get(Class<?> clazz) {
if(map == null || map.isEmpty()) {
return null;
}
Class<?> classToInspect = clazz;
T object = map.get(classToInspect);
if(object == null && !excludeInterfaces) {
object = getByInterfaces(classToInspect);
}
while (object == null && classToInspect.getSuperclass() != null) {
classToInspect = classToInspect.getSuperclass();
object = map.get(classToInspect);
if(object == null && !excludeInterfaces) {
object = getByInterfaces(classToInspect);
}
}
return object;
}
|
[
"public",
"T",
"get",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"map",
"==",
"null",
"||",
"map",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"Class",
"<",
"?",
">",
"classToInspect",
"=",
"clazz",
";",
"T",
"object",
"=",
"map",
".",
"get",
"(",
"classToInspect",
")",
";",
"if",
"(",
"object",
"==",
"null",
"&&",
"!",
"excludeInterfaces",
")",
"{",
"object",
"=",
"getByInterfaces",
"(",
"classToInspect",
")",
";",
"}",
"while",
"(",
"object",
"==",
"null",
"&&",
"classToInspect",
".",
"getSuperclass",
"(",
")",
"!=",
"null",
")",
"{",
"classToInspect",
"=",
"classToInspect",
".",
"getSuperclass",
"(",
")",
";",
"object",
"=",
"map",
".",
"get",
"(",
"classToInspect",
")",
";",
"if",
"(",
"object",
"==",
"null",
"&&",
"!",
"excludeInterfaces",
")",
"{",
"object",
"=",
"getByInterfaces",
"(",
"classToInspect",
")",
";",
"}",
"}",
"return",
"object",
";",
"}"
] |
Returns the value of a map entry which key matches the supplied class
or any of its super classes or any of its interfaces.
Values are resolved using the most specific classes and interfaces first
and then more general (base classes).
@param clazz Class to resolve value for by inspecting the class META data.
@return value found for the supplied class or null if no value could be resolved.
|
[
"Returns",
"the",
"value",
"of",
"a",
"map",
"entry",
"which",
"key",
"matches",
"the",
"supplied",
"class",
"or",
"any",
"of",
"its",
"super",
"classes",
"or",
"any",
"of",
"its",
"interfaces",
"."
] |
a80f7a164cd800089e4f4dd948ca6f0e7badcf33
|
https://github.com/wigforss/Ka-Commons-Reflection/blob/a80f7a164cd800089e4f4dd948ca6f0e7badcf33/src/main/java/org/kasource/commons/reflection/collection/ClassMap.java#L51-L68
|
153,838
|
wigforss/Ka-Commons-Reflection
|
src/main/java/org/kasource/commons/reflection/collection/ClassMap.java
|
ClassMap.getByInterfaces
|
public T getByInterfaces(Class<?> clazz) {
T object = null;
Class<?>[] interfaces = clazz.getInterfaces();
for (Class<?> interfaceClass : interfaces) {
object = map.get(interfaceClass);
if(object != null) {
break;
}
}
return object;
}
|
java
|
public T getByInterfaces(Class<?> clazz) {
T object = null;
Class<?>[] interfaces = clazz.getInterfaces();
for (Class<?> interfaceClass : interfaces) {
object = map.get(interfaceClass);
if(object != null) {
break;
}
}
return object;
}
|
[
"public",
"T",
"getByInterfaces",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"T",
"object",
"=",
"null",
";",
"Class",
"<",
"?",
">",
"[",
"]",
"interfaces",
"=",
"clazz",
".",
"getInterfaces",
"(",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"interfaceClass",
":",
"interfaces",
")",
"{",
"object",
"=",
"map",
".",
"get",
"(",
"interfaceClass",
")",
";",
"if",
"(",
"object",
"!=",
"null",
")",
"{",
"break",
";",
"}",
"}",
"return",
"object",
";",
"}"
] |
Returns the vale associated with the any
interface implemented by the supplied class.
This method will return the first match only, if
more than one value can be resolved the first is
returned.
@param clazz Class to inspect interfaces of.
@return The resolved value if found, else null.
|
[
"Returns",
"the",
"vale",
"associated",
"with",
"the",
"any",
"interface",
"implemented",
"by",
"the",
"supplied",
"class",
"."
] |
a80f7a164cd800089e4f4dd948ca6f0e7badcf33
|
https://github.com/wigforss/Ka-Commons-Reflection/blob/a80f7a164cd800089e4f4dd948ca6f0e7badcf33/src/main/java/org/kasource/commons/reflection/collection/ClassMap.java#L83-L93
|
153,839
|
jbundle/jbundle
|
base/message/core/src/main/java/org/jbundle/base/message/core/local/LocalMessageReceiver.java
|
LocalMessageReceiver.getMessageFilterList
|
public MessageReceiverFilterList getMessageFilterList()
{
if (m_filterList == null)
{
String strFilterType = null;
App app = this.getMessageQueue().getMessageManager().getApplication();
if (app != null)
strFilterType = app.getProperty(MessageConstants.MESSAGE_FILTER);
if (MessageConstants.TREE_FILTER.equals(strFilterType))
m_filterList = new TreeMessageFilterList(this);
}
return super.getMessageFilterList();
}
|
java
|
public MessageReceiverFilterList getMessageFilterList()
{
if (m_filterList == null)
{
String strFilterType = null;
App app = this.getMessageQueue().getMessageManager().getApplication();
if (app != null)
strFilterType = app.getProperty(MessageConstants.MESSAGE_FILTER);
if (MessageConstants.TREE_FILTER.equals(strFilterType))
m_filterList = new TreeMessageFilterList(this);
}
return super.getMessageFilterList();
}
|
[
"public",
"MessageReceiverFilterList",
"getMessageFilterList",
"(",
")",
"{",
"if",
"(",
"m_filterList",
"==",
"null",
")",
"{",
"String",
"strFilterType",
"=",
"null",
";",
"App",
"app",
"=",
"this",
".",
"getMessageQueue",
"(",
")",
".",
"getMessageManager",
"(",
")",
".",
"getApplication",
"(",
")",
";",
"if",
"(",
"app",
"!=",
"null",
")",
"strFilterType",
"=",
"app",
".",
"getProperty",
"(",
"MessageConstants",
".",
"MESSAGE_FILTER",
")",
";",
"if",
"(",
"MessageConstants",
".",
"TREE_FILTER",
".",
"equals",
"(",
"strFilterType",
")",
")",
"m_filterList",
"=",
"new",
"TreeMessageFilterList",
"(",
"this",
")",
";",
"}",
"return",
"super",
".",
"getMessageFilterList",
"(",
")",
";",
"}"
] |
Get the message filter list.
Create a new filter list the first time.
@return The filter list.
|
[
"Get",
"the",
"message",
"filter",
"list",
".",
"Create",
"a",
"new",
"filter",
"list",
"the",
"first",
"time",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/message/core/src/main/java/org/jbundle/base/message/core/local/LocalMessageReceiver.java#L73-L85
|
153,840
|
Multifarious/MacroManager
|
src/main/java/com/fasterxml/mama/balancing/MeteredBalancingPolicy.java
|
MeteredBalancingPolicy.claimWork
|
@Override
public void claimWork() throws InterruptedException
{
synchronized (cluster.allWorkUnits) {
for (String workUnit : getUnclaimed()) {
if (isPeggedToMe(workUnit)) {
claimWorkPeggedToMe(workUnit);
}
}
final double evenD= evenDistribution();
LinkedList<String> unclaimed = new LinkedList<String>(getUnclaimed());
while (myLoad() <= evenD && !unclaimed.isEmpty()) {
final String workUnit = unclaimed.poll();
if (config.useSoftHandoff && cluster.containsHandoffRequest(workUnit)
&& isFairGame(workUnit) && attemptToClaim(workUnit, true)) {
LOG.info(workUnit);
handoffListener.finishHandoff(workUnit);
} else if (isFairGame(workUnit)) {
attemptToClaim(workUnit);
}
}
}
}
|
java
|
@Override
public void claimWork() throws InterruptedException
{
synchronized (cluster.allWorkUnits) {
for (String workUnit : getUnclaimed()) {
if (isPeggedToMe(workUnit)) {
claimWorkPeggedToMe(workUnit);
}
}
final double evenD= evenDistribution();
LinkedList<String> unclaimed = new LinkedList<String>(getUnclaimed());
while (myLoad() <= evenD && !unclaimed.isEmpty()) {
final String workUnit = unclaimed.poll();
if (config.useSoftHandoff && cluster.containsHandoffRequest(workUnit)
&& isFairGame(workUnit) && attemptToClaim(workUnit, true)) {
LOG.info(workUnit);
handoffListener.finishHandoff(workUnit);
} else if (isFairGame(workUnit)) {
attemptToClaim(workUnit);
}
}
}
}
|
[
"@",
"Override",
"public",
"void",
"claimWork",
"(",
")",
"throws",
"InterruptedException",
"{",
"synchronized",
"(",
"cluster",
".",
"allWorkUnits",
")",
"{",
"for",
"(",
"String",
"workUnit",
":",
"getUnclaimed",
"(",
")",
")",
"{",
"if",
"(",
"isPeggedToMe",
"(",
"workUnit",
")",
")",
"{",
"claimWorkPeggedToMe",
"(",
"workUnit",
")",
";",
"}",
"}",
"final",
"double",
"evenD",
"=",
"evenDistribution",
"(",
")",
";",
"LinkedList",
"<",
"String",
">",
"unclaimed",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
"getUnclaimed",
"(",
")",
")",
";",
"while",
"(",
"myLoad",
"(",
")",
"<=",
"evenD",
"&&",
"!",
"unclaimed",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"String",
"workUnit",
"=",
"unclaimed",
".",
"poll",
"(",
")",
";",
"if",
"(",
"config",
".",
"useSoftHandoff",
"&&",
"cluster",
".",
"containsHandoffRequest",
"(",
"workUnit",
")",
"&&",
"isFairGame",
"(",
"workUnit",
")",
"&&",
"attemptToClaim",
"(",
"workUnit",
",",
"true",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"workUnit",
")",
";",
"handoffListener",
".",
"finishHandoff",
"(",
"workUnit",
")",
";",
"}",
"else",
"if",
"(",
"isFairGame",
"(",
"workUnit",
")",
")",
"{",
"attemptToClaim",
"(",
"workUnit",
")",
";",
"}",
"}",
"}",
"}"
] |
Begins by claiming all work units that are pegged to this node.
Then, continues to claim work from the available pool until we've claimed
equal to or slightly more than the total desired load.
|
[
"Begins",
"by",
"claiming",
"all",
"work",
"units",
"that",
"are",
"pegged",
"to",
"this",
"node",
".",
"Then",
"continues",
"to",
"claim",
"work",
"from",
"the",
"available",
"pool",
"until",
"we",
"ve",
"claimed",
"equal",
"to",
"or",
"slightly",
"more",
"than",
"the",
"total",
"desired",
"load",
"."
] |
559785839981f460aaeba3c3fddff7fb667d9581
|
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/balancing/MeteredBalancingPolicy.java#L77-L100
|
153,841
|
Multifarious/MacroManager
|
src/main/java/com/fasterxml/mama/balancing/MeteredBalancingPolicy.java
|
MeteredBalancingPolicy.myLoad
|
public double myLoad()
{
double load = 0d;
/*
LOG.debug(cluster.loadMap.toString);
LOG.debug(cluster.myWorkUnits.toString);
*/
for (String wu : cluster.myWorkUnits) {
Double d = cluster.getWorkUnitLoad(wu);
if (d != null) {
load += d;
}
}
return load;
}
|
java
|
public double myLoad()
{
double load = 0d;
/*
LOG.debug(cluster.loadMap.toString);
LOG.debug(cluster.myWorkUnits.toString);
*/
for (String wu : cluster.myWorkUnits) {
Double d = cluster.getWorkUnitLoad(wu);
if (d != null) {
load += d;
}
}
return load;
}
|
[
"public",
"double",
"myLoad",
"(",
")",
"{",
"double",
"load",
"=",
"0d",
";",
"/*\n LOG.debug(cluster.loadMap.toString);\n LOG.debug(cluster.myWorkUnits.toString);\n */",
"for",
"(",
"String",
"wu",
":",
"cluster",
".",
"myWorkUnits",
")",
"{",
"Double",
"d",
"=",
"cluster",
".",
"getWorkUnitLoad",
"(",
"wu",
")",
";",
"if",
"(",
"d",
"!=",
"null",
")",
"{",
"load",
"+=",
"d",
";",
"}",
"}",
"return",
"load",
";",
"}"
] |
Determines the current load on this instance when smart rebalancing is enabled.
This load is determined by the sum of all of this node's meters' one minute rate.
|
[
"Determines",
"the",
"current",
"load",
"on",
"this",
"instance",
"when",
"smart",
"rebalancing",
"is",
"enabled",
".",
"This",
"load",
"is",
"determined",
"by",
"the",
"sum",
"of",
"all",
"of",
"this",
"node",
"s",
"meters",
"one",
"minute",
"rate",
"."
] |
559785839981f460aaeba3c3fddff7fb667d9581
|
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/balancing/MeteredBalancingPolicy.java#L128-L142
|
153,842
|
Multifarious/MacroManager
|
src/main/java/com/fasterxml/mama/balancing/MeteredBalancingPolicy.java
|
MeteredBalancingPolicy.scheduleLoadTicks
|
private void scheduleLoadTicks() {
Runnable sendLoadToZookeeper = new Runnable() {
@Override
public void run() {
final List<String> loads = new ArrayList<String>();
synchronized (meters) {
for (Map.Entry<String,Meter> entry : meters.entrySet()) {
final String workUnit = entry.getKey();
loads.add(String.format("/%s/meta/workload/%s", cluster.name, workUnit));
loads.add(String.valueOf(entry.getValue().getOneMinuteRate()));
}
}
Iterator<String> it = loads.iterator();
while (it.hasNext()) {
final String path = it.next();
final String rate = it.next();
try {
ZKUtils.setOrCreate(cluster.zk, path, rate, CreateMode.PERSISTENT);
} catch (Exception e) {
// should we fail the loop too?
LOG.error("Problems trying to store load rate for {} (value {}): ({}) {}",
path, rate, e.getClass().getName(), e.getMessage());
}
}
String nodeLoadPath = String.format("/%s/nodes/%s", cluster.name, cluster.myNodeID);
try {
NodeInfo myInfo = new NodeInfo(cluster.getState().toString(), cluster.zk.get().getSessionId());
byte[] myInfoEncoded = JsonUtil.asJSONBytes(myInfo);
ZKUtils.setOrCreate(cluster.zk, nodeLoadPath, myInfoEncoded, CreateMode.EPHEMERAL);
if (LOG.isDebugEnabled()) {
// TODO: Shouldn't be evaluating methods inside of a logging statement.
LOG.debug("My load: {}", myLoad());
}
} catch (Exception e) {
LOG.error("Error reporting load info to ZooKeeper.", e);
}
}
};
loadFuture = cluster.scheduleAtFixedRate(sendLoadToZookeeper, 0, 1, TimeUnit.MINUTES);
}
|
java
|
private void scheduleLoadTicks() {
Runnable sendLoadToZookeeper = new Runnable() {
@Override
public void run() {
final List<String> loads = new ArrayList<String>();
synchronized (meters) {
for (Map.Entry<String,Meter> entry : meters.entrySet()) {
final String workUnit = entry.getKey();
loads.add(String.format("/%s/meta/workload/%s", cluster.name, workUnit));
loads.add(String.valueOf(entry.getValue().getOneMinuteRate()));
}
}
Iterator<String> it = loads.iterator();
while (it.hasNext()) {
final String path = it.next();
final String rate = it.next();
try {
ZKUtils.setOrCreate(cluster.zk, path, rate, CreateMode.PERSISTENT);
} catch (Exception e) {
// should we fail the loop too?
LOG.error("Problems trying to store load rate for {} (value {}): ({}) {}",
path, rate, e.getClass().getName(), e.getMessage());
}
}
String nodeLoadPath = String.format("/%s/nodes/%s", cluster.name, cluster.myNodeID);
try {
NodeInfo myInfo = new NodeInfo(cluster.getState().toString(), cluster.zk.get().getSessionId());
byte[] myInfoEncoded = JsonUtil.asJSONBytes(myInfo);
ZKUtils.setOrCreate(cluster.zk, nodeLoadPath, myInfoEncoded, CreateMode.EPHEMERAL);
if (LOG.isDebugEnabled()) {
// TODO: Shouldn't be evaluating methods inside of a logging statement.
LOG.debug("My load: {}", myLoad());
}
} catch (Exception e) {
LOG.error("Error reporting load info to ZooKeeper.", e);
}
}
};
loadFuture = cluster.scheduleAtFixedRate(sendLoadToZookeeper, 0, 1, TimeUnit.MINUTES);
}
|
[
"private",
"void",
"scheduleLoadTicks",
"(",
")",
"{",
"Runnable",
"sendLoadToZookeeper",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"final",
"List",
"<",
"String",
">",
"loads",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"synchronized",
"(",
"meters",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Meter",
">",
"entry",
":",
"meters",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"String",
"workUnit",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"loads",
".",
"add",
"(",
"String",
".",
"format",
"(",
"\"/%s/meta/workload/%s\"",
",",
"cluster",
".",
"name",
",",
"workUnit",
")",
")",
";",
"loads",
".",
"add",
"(",
"String",
".",
"valueOf",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"getOneMinuteRate",
"(",
")",
")",
")",
";",
"}",
"}",
"Iterator",
"<",
"String",
">",
"it",
"=",
"loads",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"String",
"path",
"=",
"it",
".",
"next",
"(",
")",
";",
"final",
"String",
"rate",
"=",
"it",
".",
"next",
"(",
")",
";",
"try",
"{",
"ZKUtils",
".",
"setOrCreate",
"(",
"cluster",
".",
"zk",
",",
"path",
",",
"rate",
",",
"CreateMode",
".",
"PERSISTENT",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// should we fail the loop too?",
"LOG",
".",
"error",
"(",
"\"Problems trying to store load rate for {} (value {}): ({}) {}\"",
",",
"path",
",",
"rate",
",",
"e",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"String",
"nodeLoadPath",
"=",
"String",
".",
"format",
"(",
"\"/%s/nodes/%s\"",
",",
"cluster",
".",
"name",
",",
"cluster",
".",
"myNodeID",
")",
";",
"try",
"{",
"NodeInfo",
"myInfo",
"=",
"new",
"NodeInfo",
"(",
"cluster",
".",
"getState",
"(",
")",
".",
"toString",
"(",
")",
",",
"cluster",
".",
"zk",
".",
"get",
"(",
")",
".",
"getSessionId",
"(",
")",
")",
";",
"byte",
"[",
"]",
"myInfoEncoded",
"=",
"JsonUtil",
".",
"asJSONBytes",
"(",
"myInfo",
")",
";",
"ZKUtils",
".",
"setOrCreate",
"(",
"cluster",
".",
"zk",
",",
"nodeLoadPath",
",",
"myInfoEncoded",
",",
"CreateMode",
".",
"EPHEMERAL",
")",
";",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"// TODO: Shouldn't be evaluating methods inside of a logging statement.",
"LOG",
".",
"debug",
"(",
"\"My load: {}\"",
",",
"myLoad",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Error reporting load info to ZooKeeper.\"",
",",
"e",
")",
";",
"}",
"}",
"}",
";",
"loadFuture",
"=",
"cluster",
".",
"scheduleAtFixedRate",
"(",
"sendLoadToZookeeper",
",",
"0",
",",
"1",
",",
"TimeUnit",
".",
"MINUTES",
")",
";",
"}"
] |
Once a minute, pass off information about the amount of load generated per
work unit off to Zookeeper for use in the claiming and rebalancing process.
|
[
"Once",
"a",
"minute",
"pass",
"off",
"information",
"about",
"the",
"amount",
"of",
"load",
"generated",
"per",
"work",
"unit",
"off",
"to",
"Zookeeper",
"for",
"use",
"in",
"the",
"claiming",
"and",
"rebalancing",
"process",
"."
] |
559785839981f460aaeba3c3fddff7fb667d9581
|
https://github.com/Multifarious/MacroManager/blob/559785839981f460aaeba3c3fddff7fb667d9581/src/main/java/com/fasterxml/mama/balancing/MeteredBalancingPolicy.java#L148-L190
|
153,843
|
Stratio/stratio-connector-commons
|
connector-commons/src/main/java/com/stratio/connector/commons/connection/ConnectionHandler.java
|
ConnectionHandler.createConnection
|
public void createConnection(ICredentials credentials, ConnectorClusterConfig config) throws ConnectionException {
logger.info("Creating new connection...");
Connection connection = createNativeConnection(credentials, config);
String connectionName = config.getName().getName();
synchronized (connections) {
if (!connections.containsKey(connectionName)) {
connections.put(connectionName, connection);
logger.info("Connected to [" + connectionName + "]");
} else {
String msg = "The connection [" + connectionName + "] already exists";
logger.error(msg);
throw new ConnectionException(msg);
}
}
}
|
java
|
public void createConnection(ICredentials credentials, ConnectorClusterConfig config) throws ConnectionException {
logger.info("Creating new connection...");
Connection connection = createNativeConnection(credentials, config);
String connectionName = config.getName().getName();
synchronized (connections) {
if (!connections.containsKey(connectionName)) {
connections.put(connectionName, connection);
logger.info("Connected to [" + connectionName + "]");
} else {
String msg = "The connection [" + connectionName + "] already exists";
logger.error(msg);
throw new ConnectionException(msg);
}
}
}
|
[
"public",
"void",
"createConnection",
"(",
"ICredentials",
"credentials",
",",
"ConnectorClusterConfig",
"config",
")",
"throws",
"ConnectionException",
"{",
"logger",
".",
"info",
"(",
"\"Creating new connection...\"",
")",
";",
"Connection",
"connection",
"=",
"createNativeConnection",
"(",
"credentials",
",",
"config",
")",
";",
"String",
"connectionName",
"=",
"config",
".",
"getName",
"(",
")",
".",
"getName",
"(",
")",
";",
"synchronized",
"(",
"connections",
")",
"{",
"if",
"(",
"!",
"connections",
".",
"containsKey",
"(",
"connectionName",
")",
")",
"{",
"connections",
".",
"put",
"(",
"connectionName",
",",
"connection",
")",
";",
"logger",
".",
"info",
"(",
"\"Connected to [\"",
"+",
"connectionName",
"+",
"\"]\"",
")",
";",
"}",
"else",
"{",
"String",
"msg",
"=",
"\"The connection [\"",
"+",
"connectionName",
"+",
"\"] already exists\"",
";",
"logger",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"new",
"ConnectionException",
"(",
"msg",
")",
";",
"}",
"}",
"}"
] |
This method create a connection.
@param credentials the cluster configuration.
@param config the connection options.
@throws ConnectionException if the connection already exists.
|
[
"This",
"method",
"create",
"a",
"connection",
"."
] |
d7cc66cb9591344a13055962e87a91f01c3707d1
|
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/connection/ConnectionHandler.java#L72-L90
|
153,844
|
Stratio/stratio-connector-commons
|
connector-commons/src/main/java/com/stratio/connector/commons/connection/ConnectionHandler.java
|
ConnectionHandler.isConnected
|
public boolean isConnected(String clusterName) {
boolean isConnected = false;
synchronized (connections) {
if (connections.containsKey(clusterName)) {
isConnected = connections.get(clusterName).isConnected();
}
}
return isConnected;
}
|
java
|
public boolean isConnected(String clusterName) {
boolean isConnected = false;
synchronized (connections) {
if (connections.containsKey(clusterName)) {
isConnected = connections.get(clusterName).isConnected();
}
}
return isConnected;
}
|
[
"public",
"boolean",
"isConnected",
"(",
"String",
"clusterName",
")",
"{",
"boolean",
"isConnected",
"=",
"false",
";",
"synchronized",
"(",
"connections",
")",
"{",
"if",
"(",
"connections",
".",
"containsKey",
"(",
"clusterName",
")",
")",
"{",
"isConnected",
"=",
"connections",
".",
"get",
"(",
"clusterName",
")",
".",
"isConnected",
"(",
")",
";",
"}",
"}",
"return",
"isConnected",
";",
"}"
] |
Return if a connection is connected.
@param clusterName the connection name.
@return true if the connection is connected. False in other case.
|
[
"Return",
"if",
"a",
"connection",
"is",
"connected",
"."
] |
d7cc66cb9591344a13055962e87a91f01c3707d1
|
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/connection/ConnectionHandler.java#L113-L121
|
153,845
|
Stratio/stratio-connector-commons
|
connector-commons/src/main/java/com/stratio/connector/commons/connection/ConnectionHandler.java
|
ConnectionHandler.getConnection
|
public Connection getConnection(String name) throws ExecutionException {
Connection connection = null;
synchronized (connections) {
if (connections.containsKey(name)) {
connection = connections.get(name);
} else {
String msg = "The connection [" + name + "] does not exist";
logger.error(msg);
throw new ExecutionException(msg);
}
}
return connection;
}
|
java
|
public Connection getConnection(String name) throws ExecutionException {
Connection connection = null;
synchronized (connections) {
if (connections.containsKey(name)) {
connection = connections.get(name);
} else {
String msg = "The connection [" + name + "] does not exist";
logger.error(msg);
throw new ExecutionException(msg);
}
}
return connection;
}
|
[
"public",
"Connection",
"getConnection",
"(",
"String",
"name",
")",
"throws",
"ExecutionException",
"{",
"Connection",
"connection",
"=",
"null",
";",
"synchronized",
"(",
"connections",
")",
"{",
"if",
"(",
"connections",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"connection",
"=",
"connections",
".",
"get",
"(",
"name",
")",
";",
"}",
"else",
"{",
"String",
"msg",
"=",
"\"The connection [\"",
"+",
"name",
"+",
"\"] does not exist\"",
";",
"logger",
".",
"error",
"(",
"msg",
")",
";",
"throw",
"new",
"ExecutionException",
"(",
"msg",
")",
";",
"}",
"}",
"return",
"connection",
";",
"}"
] |
This method return a connection.
@param name the connection name.
@return the connection.
@throws ExecutionException if the connection does not exist.
|
[
"This",
"method",
"return",
"a",
"connection",
"."
] |
d7cc66cb9591344a13055962e87a91f01c3707d1
|
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/connection/ConnectionHandler.java#L141-L154
|
153,846
|
Stratio/stratio-connector-commons
|
connector-commons/src/main/java/com/stratio/connector/commons/connection/ConnectionHandler.java
|
ConnectionHandler.startJob
|
public void startJob(String targetCluster) throws ExecutionException {
getConnection(targetCluster).setJobInProgress(true);
logger.info("a new job has been started in cluster [" + targetCluster + "]");
}
|
java
|
public void startJob(String targetCluster) throws ExecutionException {
getConnection(targetCluster).setJobInProgress(true);
logger.info("a new job has been started in cluster [" + targetCluster + "]");
}
|
[
"public",
"void",
"startJob",
"(",
"String",
"targetCluster",
")",
"throws",
"ExecutionException",
"{",
"getConnection",
"(",
"targetCluster",
")",
".",
"setJobInProgress",
"(",
"true",
")",
";",
"logger",
".",
"info",
"(",
"\"a new job has been started in cluster [\"",
"+",
"targetCluster",
"+",
"\"]\"",
")",
";",
"}"
] |
This method start a work for a connections.
@param targetCluster the connections cluster name.
@throws ExecutionException if the work can not start.
|
[
"This",
"method",
"start",
"a",
"work",
"for",
"a",
"connections",
"."
] |
d7cc66cb9591344a13055962e87a91f01c3707d1
|
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/connection/ConnectionHandler.java#L162-L165
|
153,847
|
Stratio/stratio-connector-commons
|
connector-commons/src/main/java/com/stratio/connector/commons/connection/ConnectionHandler.java
|
ConnectionHandler.endJob
|
public void endJob(String targetCluster) throws ExecutionException {
getConnection(targetCluster).setJobInProgress(false);
logger.info("a new job has been finished in cluster [" + targetCluster + "]");
}
|
java
|
public void endJob(String targetCluster) throws ExecutionException {
getConnection(targetCluster).setJobInProgress(false);
logger.info("a new job has been finished in cluster [" + targetCluster + "]");
}
|
[
"public",
"void",
"endJob",
"(",
"String",
"targetCluster",
")",
"throws",
"ExecutionException",
"{",
"getConnection",
"(",
"targetCluster",
")",
".",
"setJobInProgress",
"(",
"false",
")",
";",
"logger",
".",
"info",
"(",
"\"a new job has been finished in cluster [\"",
"+",
"targetCluster",
"+",
"\"]\"",
")",
";",
"}"
] |
This method finalize a work for a connections.
@param targetCluster the connections cluster name.
@throws ExecutionException if the work can not finish.
|
[
"This",
"method",
"finalize",
"a",
"work",
"for",
"a",
"connections",
"."
] |
d7cc66cb9591344a13055962e87a91f01c3707d1
|
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/connection/ConnectionHandler.java#L173-L176
|
153,848
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java
|
ComponentPrint.surveyComponents
|
public void surveyComponents(Component component)
{
// First, climb up and get the title from the frame.
Component frame = component;
while (frame != null)
{
if (frame instanceof Frame)
{
title = ((Frame)frame).getTitle();
break;
}
frame = frame.getParent();
}
if (title == null)
title = BLANK;
// Now go through the components and line the printable ones up.
Vector<Component> vector = new Vector<Component>();
this.addComponents(((Container)component), vector);
if (vector.size() == 0)
vector.add(component);
this.componentList = new Component[vector.size()];
for (int i = 0; i < vector.size(); i++)
{
componentList[i] = (Component)vector.get(i);
}
this.resetAll();
}
|
java
|
public void surveyComponents(Component component)
{
// First, climb up and get the title from the frame.
Component frame = component;
while (frame != null)
{
if (frame instanceof Frame)
{
title = ((Frame)frame).getTitle();
break;
}
frame = frame.getParent();
}
if (title == null)
title = BLANK;
// Now go through the components and line the printable ones up.
Vector<Component> vector = new Vector<Component>();
this.addComponents(((Container)component), vector);
if (vector.size() == 0)
vector.add(component);
this.componentList = new Component[vector.size()];
for (int i = 0; i < vector.size(); i++)
{
componentList[i] = (Component)vector.get(i);
}
this.resetAll();
}
|
[
"public",
"void",
"surveyComponents",
"(",
"Component",
"component",
")",
"{",
"// First, climb up and get the title from the frame.",
"Component",
"frame",
"=",
"component",
";",
"while",
"(",
"frame",
"!=",
"null",
")",
"{",
"if",
"(",
"frame",
"instanceof",
"Frame",
")",
"{",
"title",
"=",
"(",
"(",
"Frame",
")",
"frame",
")",
".",
"getTitle",
"(",
")",
";",
"break",
";",
"}",
"frame",
"=",
"frame",
".",
"getParent",
"(",
")",
";",
"}",
"if",
"(",
"title",
"==",
"null",
")",
"title",
"=",
"BLANK",
";",
"// Now go through the components and line the printable ones up.",
"Vector",
"<",
"Component",
">",
"vector",
"=",
"new",
"Vector",
"<",
"Component",
">",
"(",
")",
";",
"this",
".",
"addComponents",
"(",
"(",
"(",
"Container",
")",
"component",
")",
",",
"vector",
")",
";",
"if",
"(",
"vector",
".",
"size",
"(",
")",
"==",
"0",
")",
"vector",
".",
"add",
"(",
"component",
")",
";",
"this",
".",
"componentList",
"=",
"new",
"Component",
"[",
"vector",
".",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"vector",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"componentList",
"[",
"i",
"]",
"=",
"(",
"Component",
")",
"vector",
".",
"get",
"(",
"i",
")",
";",
"}",
"this",
".",
"resetAll",
"(",
")",
";",
"}"
] |
Survey the components.
@param component The top-level parent.
|
[
"Survey",
"the",
"components",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java#L82-L109
|
153,849
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java
|
ComponentPrint.addComponents
|
public void addComponents(Container container, Vector<Component> vector)
{
int components = container.getComponentCount();
int[] componentOrder = this.getComponentOrder(container);
for (int i = 0; i < components; i++)
{
Component component = container.getComponent(componentOrder[i]);
if (component instanceof JMenuBar)
continue; // Never print this
if (component instanceof JScrollPane)
{
component = ((JScrollPane)component).getViewport().getView();
if (!(component instanceof JTable))
{
vector.add(component);
component = null;
}
}
if (component instanceof JTable)
{
JComponent header = ((JTable)component).getTableHeader();
if (header != null)
vector.add(header);
vector.add(component);
component = null;
}
if (component instanceof JToolBar)
{
vector.add(component);
component = null;
}
if (component instanceof Container)
this.addComponents(((Container)component), vector);
}
}
|
java
|
public void addComponents(Container container, Vector<Component> vector)
{
int components = container.getComponentCount();
int[] componentOrder = this.getComponentOrder(container);
for (int i = 0; i < components; i++)
{
Component component = container.getComponent(componentOrder[i]);
if (component instanceof JMenuBar)
continue; // Never print this
if (component instanceof JScrollPane)
{
component = ((JScrollPane)component).getViewport().getView();
if (!(component instanceof JTable))
{
vector.add(component);
component = null;
}
}
if (component instanceof JTable)
{
JComponent header = ((JTable)component).getTableHeader();
if (header != null)
vector.add(header);
vector.add(component);
component = null;
}
if (component instanceof JToolBar)
{
vector.add(component);
component = null;
}
if (component instanceof Container)
this.addComponents(((Container)component), vector);
}
}
|
[
"public",
"void",
"addComponents",
"(",
"Container",
"container",
",",
"Vector",
"<",
"Component",
">",
"vector",
")",
"{",
"int",
"components",
"=",
"container",
".",
"getComponentCount",
"(",
")",
";",
"int",
"[",
"]",
"componentOrder",
"=",
"this",
".",
"getComponentOrder",
"(",
"container",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"components",
";",
"i",
"++",
")",
"{",
"Component",
"component",
"=",
"container",
".",
"getComponent",
"(",
"componentOrder",
"[",
"i",
"]",
")",
";",
"if",
"(",
"component",
"instanceof",
"JMenuBar",
")",
"continue",
";",
"// Never print this",
"if",
"(",
"component",
"instanceof",
"JScrollPane",
")",
"{",
"component",
"=",
"(",
"(",
"JScrollPane",
")",
"component",
")",
".",
"getViewport",
"(",
")",
".",
"getView",
"(",
")",
";",
"if",
"(",
"!",
"(",
"component",
"instanceof",
"JTable",
")",
")",
"{",
"vector",
".",
"add",
"(",
"component",
")",
";",
"component",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"component",
"instanceof",
"JTable",
")",
"{",
"JComponent",
"header",
"=",
"(",
"(",
"JTable",
")",
"component",
")",
".",
"getTableHeader",
"(",
")",
";",
"if",
"(",
"header",
"!=",
"null",
")",
"vector",
".",
"add",
"(",
"header",
")",
";",
"vector",
".",
"add",
"(",
"component",
")",
";",
"component",
"=",
"null",
";",
"}",
"if",
"(",
"component",
"instanceof",
"JToolBar",
")",
"{",
"vector",
".",
"add",
"(",
"component",
")",
";",
"component",
"=",
"null",
";",
"}",
"if",
"(",
"component",
"instanceof",
"Container",
")",
"this",
".",
"addComponents",
"(",
"(",
"(",
"Container",
")",
"component",
")",
",",
"vector",
")",
";",
"}",
"}"
] |
Go through all the components and order the ones that I need to print.
@param container The container to start at.
@param vector The vector to add the components to.
|
[
"Go",
"through",
"all",
"the",
"components",
"and",
"order",
"the",
"ones",
"that",
"I",
"need",
"to",
"print",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java#L115-L149
|
153,850
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java
|
ComponentPrint.getComponentOrder
|
public int[] getComponentOrder(Container container)
{
int components = container.getComponentCount();
int[] componentOrder = new int[components];
int[] rgY = new int[components];
// First assume order is Y order
for (int i = 0; i < components; i++)
{
componentOrder[i] = i;
rgY[i] = container.getComponent(i).getY();
}
// Now bubble sort by Y
for (int i = 0; i < components; i++)
{
for (int j = i + 1; j < components; j++)
{
if (rgY[j] < rgY[i])
{ // Make component closer to top first
int temp = rgY[i];
rgY[i] = rgY[j];
rgY[j] = temp;
temp = componentOrder[i];
componentOrder[i] = componentOrder[j];
componentOrder[j] = temp;
}
}
}
return componentOrder;
}
|
java
|
public int[] getComponentOrder(Container container)
{
int components = container.getComponentCount();
int[] componentOrder = new int[components];
int[] rgY = new int[components];
// First assume order is Y order
for (int i = 0; i < components; i++)
{
componentOrder[i] = i;
rgY[i] = container.getComponent(i).getY();
}
// Now bubble sort by Y
for (int i = 0; i < components; i++)
{
for (int j = i + 1; j < components; j++)
{
if (rgY[j] < rgY[i])
{ // Make component closer to top first
int temp = rgY[i];
rgY[i] = rgY[j];
rgY[j] = temp;
temp = componentOrder[i];
componentOrder[i] = componentOrder[j];
componentOrder[j] = temp;
}
}
}
return componentOrder;
}
|
[
"public",
"int",
"[",
"]",
"getComponentOrder",
"(",
"Container",
"container",
")",
"{",
"int",
"components",
"=",
"container",
".",
"getComponentCount",
"(",
")",
";",
"int",
"[",
"]",
"componentOrder",
"=",
"new",
"int",
"[",
"components",
"]",
";",
"int",
"[",
"]",
"rgY",
"=",
"new",
"int",
"[",
"components",
"]",
";",
"// First assume order is Y order",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"components",
";",
"i",
"++",
")",
"{",
"componentOrder",
"[",
"i",
"]",
"=",
"i",
";",
"rgY",
"[",
"i",
"]",
"=",
"container",
".",
"getComponent",
"(",
"i",
")",
".",
"getY",
"(",
")",
";",
"}",
"// Now bubble sort by Y",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"components",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"i",
"+",
"1",
";",
"j",
"<",
"components",
";",
"j",
"++",
")",
"{",
"if",
"(",
"rgY",
"[",
"j",
"]",
"<",
"rgY",
"[",
"i",
"]",
")",
"{",
"// Make component closer to top first",
"int",
"temp",
"=",
"rgY",
"[",
"i",
"]",
";",
"rgY",
"[",
"i",
"]",
"=",
"rgY",
"[",
"j",
"]",
";",
"rgY",
"[",
"j",
"]",
"=",
"temp",
";",
"temp",
"=",
"componentOrder",
"[",
"i",
"]",
";",
"componentOrder",
"[",
"i",
"]",
"=",
"componentOrder",
"[",
"j",
"]",
";",
"componentOrder",
"[",
"j",
"]",
"=",
"temp",
";",
"}",
"}",
"}",
"return",
"componentOrder",
";",
"}"
] |
Get the component order by how they are ordered vertically on the screen.
@param container The container to survey.
@return An array with the container index values by their y position on the screen.
|
[
"Get",
"the",
"component",
"order",
"by",
"how",
"they",
"are",
"ordered",
"vertically",
"on",
"the",
"screen",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java#L155-L183
|
153,851
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java
|
ComponentPrint.resetAll
|
public void resetAll()
{
currentLocationOnPage = 0;
componentIndex = 0;
currentComponent = this.getComponent(componentIndex);
componentStartYLocation = 0;
componentPageHeight = 0;
currentPageIndex = 0;
remainingComponentHeight = 0;
if (currentComponent != null)
remainingComponentHeight = currentComponent.getHeight();
remainingPageHeight = pageHeight;
}
|
java
|
public void resetAll()
{
currentLocationOnPage = 0;
componentIndex = 0;
currentComponent = this.getComponent(componentIndex);
componentStartYLocation = 0;
componentPageHeight = 0;
currentPageIndex = 0;
remainingComponentHeight = 0;
if (currentComponent != null)
remainingComponentHeight = currentComponent.getHeight();
remainingPageHeight = pageHeight;
}
|
[
"public",
"void",
"resetAll",
"(",
")",
"{",
"currentLocationOnPage",
"=",
"0",
";",
"componentIndex",
"=",
"0",
";",
"currentComponent",
"=",
"this",
".",
"getComponent",
"(",
"componentIndex",
")",
";",
"componentStartYLocation",
"=",
"0",
";",
"componentPageHeight",
"=",
"0",
";",
"currentPageIndex",
"=",
"0",
";",
"remainingComponentHeight",
"=",
"0",
";",
"if",
"(",
"currentComponent",
"!=",
"null",
")",
"remainingComponentHeight",
"=",
"currentComponent",
".",
"getHeight",
"(",
")",
";",
"remainingPageHeight",
"=",
"pageHeight",
";",
"}"
] |
Reset to the first page.
|
[
"Reset",
"to",
"the",
"first",
"page",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java#L187-L202
|
153,852
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java
|
ComponentPrint.setCurrentYLocation
|
public boolean setCurrentYLocation(int targetPageIndex, int targetLocationOnPage)
{
//? if ((targetPageIndex != currentPageIndex) || (targetLocationOnPage != currentLocationOnPage))
this.resetAll(); // If I'm not using the cached values, reset to start
boolean pageDone = false;
while (pageDone == false)
{
if (currentComponent == null)
break;
componentPageHeight = this.calcComponentPageHeight();
if (currentPageIndex > targetPageIndex)
break;
if (currentPageIndex == targetPageIndex)
if (currentLocationOnPage >= targetLocationOnPage)
break; // Target location reached. Return this current component, stats
remainingComponentHeight = remainingComponentHeight + this.checkComponentHeight();
if (remainingComponentHeight < remainingPageHeight)
{ // This component will fit on this page.
currentLocationOnPage = currentLocationOnPage + remainingComponentHeight;
remainingPageHeight = remainingPageHeight - remainingComponentHeight;
componentIndex++;
currentComponent = this.getComponent(componentIndex);
componentStartYLocation = 0;
if (currentComponent != null)
remainingComponentHeight = currentComponent.getHeight();
}
else
{ // This component goes past the end of the page
componentStartYLocation = componentStartYLocation + componentPageHeight;
if (targetPageIndex == currentPageIndex)
pageDone = true; // The target page is completely scanned
currentPageIndex++;
currentLocationOnPage = 0;
remainingComponentHeight = remainingComponentHeight - componentPageHeight;
remainingPageHeight = pageHeight;
}
}
return pageDone; // Page done
}
|
java
|
public boolean setCurrentYLocation(int targetPageIndex, int targetLocationOnPage)
{
//? if ((targetPageIndex != currentPageIndex) || (targetLocationOnPage != currentLocationOnPage))
this.resetAll(); // If I'm not using the cached values, reset to start
boolean pageDone = false;
while (pageDone == false)
{
if (currentComponent == null)
break;
componentPageHeight = this.calcComponentPageHeight();
if (currentPageIndex > targetPageIndex)
break;
if (currentPageIndex == targetPageIndex)
if (currentLocationOnPage >= targetLocationOnPage)
break; // Target location reached. Return this current component, stats
remainingComponentHeight = remainingComponentHeight + this.checkComponentHeight();
if (remainingComponentHeight < remainingPageHeight)
{ // This component will fit on this page.
currentLocationOnPage = currentLocationOnPage + remainingComponentHeight;
remainingPageHeight = remainingPageHeight - remainingComponentHeight;
componentIndex++;
currentComponent = this.getComponent(componentIndex);
componentStartYLocation = 0;
if (currentComponent != null)
remainingComponentHeight = currentComponent.getHeight();
}
else
{ // This component goes past the end of the page
componentStartYLocation = componentStartYLocation + componentPageHeight;
if (targetPageIndex == currentPageIndex)
pageDone = true; // The target page is completely scanned
currentPageIndex++;
currentLocationOnPage = 0;
remainingComponentHeight = remainingComponentHeight - componentPageHeight;
remainingPageHeight = pageHeight;
}
}
return pageDone; // Page done
}
|
[
"public",
"boolean",
"setCurrentYLocation",
"(",
"int",
"targetPageIndex",
",",
"int",
"targetLocationOnPage",
")",
"{",
"//? if ((targetPageIndex != currentPageIndex) || (targetLocationOnPage != currentLocationOnPage))",
"this",
".",
"resetAll",
"(",
")",
";",
"// If I'm not using the cached values, reset to start",
"boolean",
"pageDone",
"=",
"false",
";",
"while",
"(",
"pageDone",
"==",
"false",
")",
"{",
"if",
"(",
"currentComponent",
"==",
"null",
")",
"break",
";",
"componentPageHeight",
"=",
"this",
".",
"calcComponentPageHeight",
"(",
")",
";",
"if",
"(",
"currentPageIndex",
">",
"targetPageIndex",
")",
"break",
";",
"if",
"(",
"currentPageIndex",
"==",
"targetPageIndex",
")",
"if",
"(",
"currentLocationOnPage",
">=",
"targetLocationOnPage",
")",
"break",
";",
"// Target location reached. Return this current component, stats",
"remainingComponentHeight",
"=",
"remainingComponentHeight",
"+",
"this",
".",
"checkComponentHeight",
"(",
")",
";",
"if",
"(",
"remainingComponentHeight",
"<",
"remainingPageHeight",
")",
"{",
"// This component will fit on this page.",
"currentLocationOnPage",
"=",
"currentLocationOnPage",
"+",
"remainingComponentHeight",
";",
"remainingPageHeight",
"=",
"remainingPageHeight",
"-",
"remainingComponentHeight",
";",
"componentIndex",
"++",
";",
"currentComponent",
"=",
"this",
".",
"getComponent",
"(",
"componentIndex",
")",
";",
"componentStartYLocation",
"=",
"0",
";",
"if",
"(",
"currentComponent",
"!=",
"null",
")",
"remainingComponentHeight",
"=",
"currentComponent",
".",
"getHeight",
"(",
")",
";",
"}",
"else",
"{",
"// This component goes past the end of the page",
"componentStartYLocation",
"=",
"componentStartYLocation",
"+",
"componentPageHeight",
";",
"if",
"(",
"targetPageIndex",
"==",
"currentPageIndex",
")",
"pageDone",
"=",
"true",
";",
"// The target page is completely scanned",
"currentPageIndex",
"++",
";",
"currentLocationOnPage",
"=",
"0",
";",
"remainingComponentHeight",
"=",
"remainingComponentHeight",
"-",
"componentPageHeight",
";",
"remainingPageHeight",
"=",
"pageHeight",
";",
"}",
"}",
"return",
"pageDone",
";",
"// Page done",
"}"
] |
Set the current Y location and change the current component information to match.
@param targetPageIndex The page to position to.
@param targetLocationOnPage The location in the current page to position in.
@return True if this is the last component and it is finished on this page.
|
[
"Set",
"the",
"current",
"Y",
"location",
"and",
"change",
"the",
"current",
"component",
"information",
"to",
"match",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java#L218-L264
|
153,853
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java
|
ComponentPrint.getMaxComponentWidth
|
public int getMaxComponentWidth()
{
int maxWidth = 0;
for (int index = 0; ; index++)
{
Component component = this.getComponent(index);
if (component == null)
break;
if (component instanceof JTableHeader)
continue; // Don't use this one
if (component instanceof JPanel)
{ // Use the rightmost child for the width
for (int i = 0; i < ((JPanel)component).getComponentCount(); i++)
{
Component childComponent = ((JPanel)component).getComponent(i);
int farthestWidth = childComponent.getX() + ((JPanel)component).getComponent(i).getWidth();
maxWidth = Math.max(maxWidth, Math.min(component.getWidth(), farthestWidth));
}
}
else
maxWidth = Math.max(maxWidth, component.getWidth());
}
return maxWidth;
}
|
java
|
public int getMaxComponentWidth()
{
int maxWidth = 0;
for (int index = 0; ; index++)
{
Component component = this.getComponent(index);
if (component == null)
break;
if (component instanceof JTableHeader)
continue; // Don't use this one
if (component instanceof JPanel)
{ // Use the rightmost child for the width
for (int i = 0; i < ((JPanel)component).getComponentCount(); i++)
{
Component childComponent = ((JPanel)component).getComponent(i);
int farthestWidth = childComponent.getX() + ((JPanel)component).getComponent(i).getWidth();
maxWidth = Math.max(maxWidth, Math.min(component.getWidth(), farthestWidth));
}
}
else
maxWidth = Math.max(maxWidth, component.getWidth());
}
return maxWidth;
}
|
[
"public",
"int",
"getMaxComponentWidth",
"(",
")",
"{",
"int",
"maxWidth",
"=",
"0",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
";",
"index",
"++",
")",
"{",
"Component",
"component",
"=",
"this",
".",
"getComponent",
"(",
"index",
")",
";",
"if",
"(",
"component",
"==",
"null",
")",
"break",
";",
"if",
"(",
"component",
"instanceof",
"JTableHeader",
")",
"continue",
";",
"// Don't use this one",
"if",
"(",
"component",
"instanceof",
"JPanel",
")",
"{",
"// Use the rightmost child for the width",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"(",
"(",
"JPanel",
")",
"component",
")",
".",
"getComponentCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"Component",
"childComponent",
"=",
"(",
"(",
"JPanel",
")",
"component",
")",
".",
"getComponent",
"(",
"i",
")",
";",
"int",
"farthestWidth",
"=",
"childComponent",
".",
"getX",
"(",
")",
"+",
"(",
"(",
"JPanel",
")",
"component",
")",
".",
"getComponent",
"(",
"i",
")",
".",
"getWidth",
"(",
")",
";",
"maxWidth",
"=",
"Math",
".",
"max",
"(",
"maxWidth",
",",
"Math",
".",
"min",
"(",
"component",
".",
"getWidth",
"(",
")",
",",
"farthestWidth",
")",
")",
";",
"}",
"}",
"else",
"maxWidth",
"=",
"Math",
".",
"max",
"(",
"maxWidth",
",",
"component",
".",
"getWidth",
"(",
")",
")",
";",
"}",
"return",
"maxWidth",
";",
"}"
] |
Get the widest component.
To calculate the scale.
@return The width of the widest component.
|
[
"Get",
"the",
"widest",
"component",
".",
"To",
"calculate",
"the",
"scale",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java#L287-L310
|
153,854
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java
|
ComponentPrint.getComponent
|
public Component getComponent(int componentIndex)
{
if (componentList != null)
if (componentIndex < componentList.length)
return componentList[componentIndex];
return null;
}
|
java
|
public Component getComponent(int componentIndex)
{
if (componentList != null)
if (componentIndex < componentList.length)
return componentList[componentIndex];
return null;
}
|
[
"public",
"Component",
"getComponent",
"(",
"int",
"componentIndex",
")",
"{",
"if",
"(",
"componentList",
"!=",
"null",
")",
"if",
"(",
"componentIndex",
"<",
"componentList",
".",
"length",
")",
"return",
"componentList",
"[",
"componentIndex",
"]",
";",
"return",
"null",
";",
"}"
] |
Get the component at this index.
@param componentIndex Component index.
@return The component at this index.
|
[
"Get",
"the",
"component",
"at",
"this",
"index",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java#L316-L322
|
153,855
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java
|
ComponentPrint.checkComponentHeight
|
public int checkComponentHeight()
{
int maxHeightToCheck = componentStartYLocation - currentLocationOnPage + pageHeight;
if (currentComponent == null)
return 0;
if (currentComponent instanceof JTable)
{ // todo(don) There has to be a better way of doing this JTable code.
int beforeHeight = currentComponent.getHeight();
int rowHeight = ((JTable)currentComponent).getRowHeight();
int rowCount = ((JTable)currentComponent).getRowCount();
int maxRowCount = maxHeightToCheck / rowHeight;
for (int i = rowCount - 1; i < rowCount ; i++)
{
if (i >= maxRowCount)
break; // No need to go farther (yet)
rowCount = ((JTable)currentComponent).getRowCount();
}
int newComponentHeight = rowHeight * rowCount;
currentComponent.setSize(currentComponent.getWidth(), newComponentHeight); // Change in the height.
return newComponentHeight - beforeHeight;
}
return 0;
}
|
java
|
public int checkComponentHeight()
{
int maxHeightToCheck = componentStartYLocation - currentLocationOnPage + pageHeight;
if (currentComponent == null)
return 0;
if (currentComponent instanceof JTable)
{ // todo(don) There has to be a better way of doing this JTable code.
int beforeHeight = currentComponent.getHeight();
int rowHeight = ((JTable)currentComponent).getRowHeight();
int rowCount = ((JTable)currentComponent).getRowCount();
int maxRowCount = maxHeightToCheck / rowHeight;
for (int i = rowCount - 1; i < rowCount ; i++)
{
if (i >= maxRowCount)
break; // No need to go farther (yet)
rowCount = ((JTable)currentComponent).getRowCount();
}
int newComponentHeight = rowHeight * rowCount;
currentComponent.setSize(currentComponent.getWidth(), newComponentHeight); // Change in the height.
return newComponentHeight - beforeHeight;
}
return 0;
}
|
[
"public",
"int",
"checkComponentHeight",
"(",
")",
"{",
"int",
"maxHeightToCheck",
"=",
"componentStartYLocation",
"-",
"currentLocationOnPage",
"+",
"pageHeight",
";",
"if",
"(",
"currentComponent",
"==",
"null",
")",
"return",
"0",
";",
"if",
"(",
"currentComponent",
"instanceof",
"JTable",
")",
"{",
"// todo(don) There has to be a better way of doing this JTable code.",
"int",
"beforeHeight",
"=",
"currentComponent",
".",
"getHeight",
"(",
")",
";",
"int",
"rowHeight",
"=",
"(",
"(",
"JTable",
")",
"currentComponent",
")",
".",
"getRowHeight",
"(",
")",
";",
"int",
"rowCount",
"=",
"(",
"(",
"JTable",
")",
"currentComponent",
")",
".",
"getRowCount",
"(",
")",
";",
"int",
"maxRowCount",
"=",
"maxHeightToCheck",
"/",
"rowHeight",
";",
"for",
"(",
"int",
"i",
"=",
"rowCount",
"-",
"1",
";",
"i",
"<",
"rowCount",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
">=",
"maxRowCount",
")",
"break",
";",
"// No need to go farther (yet)",
"rowCount",
"=",
"(",
"(",
"JTable",
")",
"currentComponent",
")",
".",
"getRowCount",
"(",
")",
";",
"}",
"int",
"newComponentHeight",
"=",
"rowHeight",
"*",
"rowCount",
";",
"currentComponent",
".",
"setSize",
"(",
"currentComponent",
".",
"getWidth",
"(",
")",
",",
"newComponentHeight",
")",
";",
"// Change in the height.",
"return",
"newComponentHeight",
"-",
"beforeHeight",
";",
"}",
"return",
"0",
";",
"}"
] |
Get the height of this component.
Typically, this is just the height of the component.
Except for JTables, where I need to query to this target height to make sure the
component is at least this correct height.
@param component The component to get the height of.
@return the component's height.
|
[
"Get",
"the",
"height",
"of",
"this",
"component",
".",
"Typically",
"this",
"is",
"just",
"the",
"height",
"of",
"the",
"component",
".",
"Except",
"for",
"JTables",
"where",
"I",
"need",
"to",
"query",
"to",
"this",
"target",
"height",
"to",
"make",
"sure",
"the",
"component",
"is",
"at",
"least",
"this",
"correct",
"height",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java#L339-L361
|
153,856
|
jbundle/jbundle
|
thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java
|
ComponentPrint.calcComponentPageHeight
|
public int calcComponentPageHeight()
{
remainingComponentHeight = remainingComponentHeight + this.checkComponentHeight();
if (remainingComponentHeight <= remainingPageHeight)
return remainingComponentHeight;
if (currentComponent == null)
return 0; // Never
if (!(currentComponent instanceof Container))
return 0; // Never
if (currentComponent instanceof JTable)
{
int rowHeight = ((JTable)currentComponent).getRowHeight();
int currentComponentPageBreak = componentStartYLocation + remainingPageHeight;
int currentComponentPageRow = (int)(currentComponentPageBreak / rowHeight);
return remainingPageHeight - (currentComponentPageBreak - currentComponentPageRow * rowHeight);
}
int lastComponentPageHeight = 0;
int y = 0;
int maxLowerBreak = (int)(pageHeight * MAX_LOWER_BREAK);
Component component = null;
for (y = remainingPageHeight; y > remainingPageHeight - maxLowerBreak; y--)
{
int x = 0;
for (x = 0; x < currentComponent.getWidth(); x++)
{
component = ((Container)currentComponent).getComponentAt(x, componentStartYLocation + y);
if (component != null)
if (component != currentComponent)
if (component.getY() + component.getHeight() - 1 != y) // Don't count last line
break; // This line contains a component, don't break here (continue looking)
}
if (x == currentComponent.getWidth())
break; // White space thru this whole line, use this as a break
if (component != null)
lastComponentPageHeight = Math.max(lastComponentPageHeight, component.getY() - 1);
}
if (y == remainingPageHeight - maxLowerBreak)
{ // Did not find a break, try another way
if ((lastComponentPageHeight == 0) || (lastComponentPageHeight < pageHeight - maxLowerBreak))
y = pageHeight; // No break found, break at the end of the page (in the middle of a component)
else
y = lastComponentPageHeight; // No break found, use the start of the lowest component
}
return y;
}
|
java
|
public int calcComponentPageHeight()
{
remainingComponentHeight = remainingComponentHeight + this.checkComponentHeight();
if (remainingComponentHeight <= remainingPageHeight)
return remainingComponentHeight;
if (currentComponent == null)
return 0; // Never
if (!(currentComponent instanceof Container))
return 0; // Never
if (currentComponent instanceof JTable)
{
int rowHeight = ((JTable)currentComponent).getRowHeight();
int currentComponentPageBreak = componentStartYLocation + remainingPageHeight;
int currentComponentPageRow = (int)(currentComponentPageBreak / rowHeight);
return remainingPageHeight - (currentComponentPageBreak - currentComponentPageRow * rowHeight);
}
int lastComponentPageHeight = 0;
int y = 0;
int maxLowerBreak = (int)(pageHeight * MAX_LOWER_BREAK);
Component component = null;
for (y = remainingPageHeight; y > remainingPageHeight - maxLowerBreak; y--)
{
int x = 0;
for (x = 0; x < currentComponent.getWidth(); x++)
{
component = ((Container)currentComponent).getComponentAt(x, componentStartYLocation + y);
if (component != null)
if (component != currentComponent)
if (component.getY() + component.getHeight() - 1 != y) // Don't count last line
break; // This line contains a component, don't break here (continue looking)
}
if (x == currentComponent.getWidth())
break; // White space thru this whole line, use this as a break
if (component != null)
lastComponentPageHeight = Math.max(lastComponentPageHeight, component.getY() - 1);
}
if (y == remainingPageHeight - maxLowerBreak)
{ // Did not find a break, try another way
if ((lastComponentPageHeight == 0) || (lastComponentPageHeight < pageHeight - maxLowerBreak))
y = pageHeight; // No break found, break at the end of the page (in the middle of a component)
else
y = lastComponentPageHeight; // No break found, use the start of the lowest component
}
return y;
}
|
[
"public",
"int",
"calcComponentPageHeight",
"(",
")",
"{",
"remainingComponentHeight",
"=",
"remainingComponentHeight",
"+",
"this",
".",
"checkComponentHeight",
"(",
")",
";",
"if",
"(",
"remainingComponentHeight",
"<=",
"remainingPageHeight",
")",
"return",
"remainingComponentHeight",
";",
"if",
"(",
"currentComponent",
"==",
"null",
")",
"return",
"0",
";",
"// Never",
"if",
"(",
"!",
"(",
"currentComponent",
"instanceof",
"Container",
")",
")",
"return",
"0",
";",
"// Never",
"if",
"(",
"currentComponent",
"instanceof",
"JTable",
")",
"{",
"int",
"rowHeight",
"=",
"(",
"(",
"JTable",
")",
"currentComponent",
")",
".",
"getRowHeight",
"(",
")",
";",
"int",
"currentComponentPageBreak",
"=",
"componentStartYLocation",
"+",
"remainingPageHeight",
";",
"int",
"currentComponentPageRow",
"=",
"(",
"int",
")",
"(",
"currentComponentPageBreak",
"/",
"rowHeight",
")",
";",
"return",
"remainingPageHeight",
"-",
"(",
"currentComponentPageBreak",
"-",
"currentComponentPageRow",
"*",
"rowHeight",
")",
";",
"}",
"int",
"lastComponentPageHeight",
"=",
"0",
";",
"int",
"y",
"=",
"0",
";",
"int",
"maxLowerBreak",
"=",
"(",
"int",
")",
"(",
"pageHeight",
"*",
"MAX_LOWER_BREAK",
")",
";",
"Component",
"component",
"=",
"null",
";",
"for",
"(",
"y",
"=",
"remainingPageHeight",
";",
"y",
">",
"remainingPageHeight",
"-",
"maxLowerBreak",
";",
"y",
"--",
")",
"{",
"int",
"x",
"=",
"0",
";",
"for",
"(",
"x",
"=",
"0",
";",
"x",
"<",
"currentComponent",
".",
"getWidth",
"(",
")",
";",
"x",
"++",
")",
"{",
"component",
"=",
"(",
"(",
"Container",
")",
"currentComponent",
")",
".",
"getComponentAt",
"(",
"x",
",",
"componentStartYLocation",
"+",
"y",
")",
";",
"if",
"(",
"component",
"!=",
"null",
")",
"if",
"(",
"component",
"!=",
"currentComponent",
")",
"if",
"(",
"component",
".",
"getY",
"(",
")",
"+",
"component",
".",
"getHeight",
"(",
")",
"-",
"1",
"!=",
"y",
")",
"// Don't count last line",
"break",
";",
"// This line contains a component, don't break here (continue looking)",
"}",
"if",
"(",
"x",
"==",
"currentComponent",
".",
"getWidth",
"(",
")",
")",
"break",
";",
"// White space thru this whole line, use this as a break",
"if",
"(",
"component",
"!=",
"null",
")",
"lastComponentPageHeight",
"=",
"Math",
".",
"max",
"(",
"lastComponentPageHeight",
",",
"component",
".",
"getY",
"(",
")",
"-",
"1",
")",
";",
"}",
"if",
"(",
"y",
"==",
"remainingPageHeight",
"-",
"maxLowerBreak",
")",
"{",
"// Did not find a break, try another way",
"if",
"(",
"(",
"lastComponentPageHeight",
"==",
"0",
")",
"||",
"(",
"lastComponentPageHeight",
"<",
"pageHeight",
"-",
"maxLowerBreak",
")",
")",
"y",
"=",
"pageHeight",
";",
"// No break found, break at the end of the page (in the middle of a component)",
"else",
"y",
"=",
"lastComponentPageHeight",
";",
"// No break found, use the start of the lowest component",
"}",
"return",
"y",
";",
"}"
] |
Calculate the remaining height of this component on this page.
This is used to calculate a smart page break that does not split a control
between pages.
@return The remaining height of this component on this page.
|
[
"Calculate",
"the",
"remaining",
"height",
"of",
"this",
"component",
"on",
"this",
"page",
".",
"This",
"is",
"used",
"to",
"calculate",
"a",
"smart",
"page",
"break",
"that",
"does",
"not",
"split",
"a",
"control",
"between",
"pages",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/screen/screen/src/main/java/org/jbundle/thin/base/screen/print/ComponentPrint.java#L368-L414
|
153,857
|
Stratio/stratio-connector-commons
|
connector-commons/src/main/java/com/stratio/connector/commons/engine/SingleProjectQueryEngine.java
|
SingleProjectQueryEngine.executeWorkFlow
|
@Override
protected final QueryResult executeWorkFlow(LogicalWorkflow workflow) throws ConnectorException {
checkIsSupported(workflow);
ClusterName clusterName = ((Project) workflow.getInitialSteps().get(0)).getClusterName();
return execute((Project) workflow.getInitialSteps().get(0),
connectionHandler.getConnection(clusterName.getName()));
}
|
java
|
@Override
protected final QueryResult executeWorkFlow(LogicalWorkflow workflow) throws ConnectorException {
checkIsSupported(workflow);
ClusterName clusterName = ((Project) workflow.getInitialSteps().get(0)).getClusterName();
return execute((Project) workflow.getInitialSteps().get(0),
connectionHandler.getConnection(clusterName.getName()));
}
|
[
"@",
"Override",
"protected",
"final",
"QueryResult",
"executeWorkFlow",
"(",
"LogicalWorkflow",
"workflow",
")",
"throws",
"ConnectorException",
"{",
"checkIsSupported",
"(",
"workflow",
")",
";",
"ClusterName",
"clusterName",
"=",
"(",
"(",
"Project",
")",
"workflow",
".",
"getInitialSteps",
"(",
")",
".",
"get",
"(",
"0",
")",
")",
".",
"getClusterName",
"(",
")",
";",
"return",
"execute",
"(",
"(",
"Project",
")",
"workflow",
".",
"getInitialSteps",
"(",
")",
".",
"get",
"(",
"0",
")",
",",
"connectionHandler",
".",
"getConnection",
"(",
"clusterName",
".",
"getName",
"(",
")",
")",
")",
";",
"}"
] |
This method execute a query with only a project.
@param workflow the workflow to be executed.
@return the query result.
@throws ConnectorException if an error happens.
|
[
"This",
"method",
"execute",
"a",
"query",
"with",
"only",
"a",
"project",
"."
] |
d7cc66cb9591344a13055962e87a91f01c3707d1
|
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/engine/SingleProjectQueryEngine.java#L54-L62
|
153,858
|
Stratio/stratio-connector-commons
|
connector-commons/src/main/java/com/stratio/connector/commons/engine/SingleProjectQueryEngine.java
|
SingleProjectQueryEngine.asyncExecuteWorkFlow
|
protected final void asyncExecuteWorkFlow(String queryId, LogicalWorkflow workflow, IResultHandler
resultHandler) throws ConnectorException {
checkIsSupported(workflow);
ClusterName clusterName = ((Project) workflow.getInitialSteps().get(0)).getClusterName();
asyncExecute(queryId, (Project) workflow.getInitialSteps().get(0),
connectionHandler.getConnection(clusterName.getName()), resultHandler);
}
|
java
|
protected final void asyncExecuteWorkFlow(String queryId, LogicalWorkflow workflow, IResultHandler
resultHandler) throws ConnectorException {
checkIsSupported(workflow);
ClusterName clusterName = ((Project) workflow.getInitialSteps().get(0)).getClusterName();
asyncExecute(queryId, (Project) workflow.getInitialSteps().get(0),
connectionHandler.getConnection(clusterName.getName()), resultHandler);
}
|
[
"protected",
"final",
"void",
"asyncExecuteWorkFlow",
"(",
"String",
"queryId",
",",
"LogicalWorkflow",
"workflow",
",",
"IResultHandler",
"resultHandler",
")",
"throws",
"ConnectorException",
"{",
"checkIsSupported",
"(",
"workflow",
")",
";",
"ClusterName",
"clusterName",
"=",
"(",
"(",
"Project",
")",
"workflow",
".",
"getInitialSteps",
"(",
")",
".",
"get",
"(",
"0",
")",
")",
".",
"getClusterName",
"(",
")",
";",
"asyncExecute",
"(",
"queryId",
",",
"(",
"Project",
")",
"workflow",
".",
"getInitialSteps",
"(",
")",
".",
"get",
"(",
"0",
")",
",",
"connectionHandler",
".",
"getConnection",
"(",
"clusterName",
".",
"getName",
"(",
")",
")",
",",
"resultHandler",
")",
";",
"}"
] |
Abstract method which must be implemented by the concrete database metadataEngine to execute a async workflow.
@param queryId the queryId.
@param workflow the workflow.
@param resultHandler the result handler.
@throws ConnectorException if an error happens.
|
[
"Abstract",
"method",
"which",
"must",
"be",
"implemented",
"by",
"the",
"concrete",
"database",
"metadataEngine",
"to",
"execute",
"a",
"async",
"workflow",
"."
] |
d7cc66cb9591344a13055962e87a91f01c3707d1
|
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/engine/SingleProjectQueryEngine.java#L72-L78
|
153,859
|
Stratio/stratio-connector-commons
|
connector-commons/src/main/java/com/stratio/connector/commons/engine/SingleProjectQueryEngine.java
|
SingleProjectQueryEngine.pagedExecuteWorkFlow
|
protected final void pagedExecuteWorkFlow(String queryId, LogicalWorkflow workflow, IResultHandler resultHandler,
int pageSize) throws ConnectorException {
checkIsSupported(workflow);
ClusterName clusterName = ((Project) workflow.getInitialSteps().get(0)).getClusterName();
pagedExecute(queryId, (Project) workflow.getInitialSteps().get(0),
connectionHandler.getConnection(clusterName.getName()), resultHandler);
}
|
java
|
protected final void pagedExecuteWorkFlow(String queryId, LogicalWorkflow workflow, IResultHandler resultHandler,
int pageSize) throws ConnectorException {
checkIsSupported(workflow);
ClusterName clusterName = ((Project) workflow.getInitialSteps().get(0)).getClusterName();
pagedExecute(queryId, (Project) workflow.getInitialSteps().get(0),
connectionHandler.getConnection(clusterName.getName()), resultHandler);
}
|
[
"protected",
"final",
"void",
"pagedExecuteWorkFlow",
"(",
"String",
"queryId",
",",
"LogicalWorkflow",
"workflow",
",",
"IResultHandler",
"resultHandler",
",",
"int",
"pageSize",
")",
"throws",
"ConnectorException",
"{",
"checkIsSupported",
"(",
"workflow",
")",
";",
"ClusterName",
"clusterName",
"=",
"(",
"(",
"Project",
")",
"workflow",
".",
"getInitialSteps",
"(",
")",
".",
"get",
"(",
"0",
")",
")",
".",
"getClusterName",
"(",
")",
";",
"pagedExecute",
"(",
"queryId",
",",
"(",
"Project",
")",
"workflow",
".",
"getInitialSteps",
"(",
")",
".",
"get",
"(",
"0",
")",
",",
"connectionHandler",
".",
"getConnection",
"(",
"clusterName",
".",
"getName",
"(",
")",
")",
",",
"resultHandler",
")",
";",
"}"
] |
Abstract method which must be implemented by the concrete database metadataEngine to execute a async and paged
workflow.
@param queryId the queryId.
@param workflow the workflow.
@param resultHandler the result handler.
@param pageSize
@throws ConnectorException if an error happens.
|
[
"Abstract",
"method",
"which",
"must",
"be",
"implemented",
"by",
"the",
"concrete",
"database",
"metadataEngine",
"to",
"execute",
"a",
"async",
"and",
"paged",
"workflow",
"."
] |
d7cc66cb9591344a13055962e87a91f01c3707d1
|
https://github.com/Stratio/stratio-connector-commons/blob/d7cc66cb9591344a13055962e87a91f01c3707d1/connector-commons/src/main/java/com/stratio/connector/commons/engine/SingleProjectQueryEngine.java#L91-L98
|
153,860
|
jbundle/jbundle
|
thin/base/db/base/src/main/java/org/jbundle/thin/base/db/util/ArrayCache.java
|
ArrayCache.set
|
public Object set(int index, Object element)
{
if ((index < m_iStartIndex) || (index >= m_iStartIndex + m_iMaxSize))
{ // Out of bounds, re-adjust bounds
int iNewStart = index - m_iMaxSize / 2; // index should be right in the middle
if (iNewStart < 0)
iNewStart = 0;
int iStart = 0;
int iEnd = this.size() - 1;
int iIncrement = +1;
if (iNewStart < m_iStartIndex)
{ // Go backwards to avoid overlaying values
iStart = iEnd;
iEnd = 0;
iIncrement = -1;
}
for (int i = iStart; i * iIncrement <= iEnd; i = i + iIncrement)
{
Object obj = super.set(i, null); // Get and clear value
int iShiftedIndex = i + m_iStartIndex - iNewStart;
if ((iShiftedIndex >= 0) && (iShiftedIndex < this.size()))
super.set(iShiftedIndex, obj); // Move/set it!
else
this.freeObject(m_iStartIndex + i, obj); // Notify obj
}
m_iStartIndex = iNewStart;
}
if (index >= m_iStartIndex + this.size())
{ // Need to add empty elements inbetween
for (int i = m_iStartIndex + this.size(); i <= index; i++)
this.add(null); // Add a placeholder
}
index = index - m_iStartIndex;
return super.set(index, element);
}
|
java
|
public Object set(int index, Object element)
{
if ((index < m_iStartIndex) || (index >= m_iStartIndex + m_iMaxSize))
{ // Out of bounds, re-adjust bounds
int iNewStart = index - m_iMaxSize / 2; // index should be right in the middle
if (iNewStart < 0)
iNewStart = 0;
int iStart = 0;
int iEnd = this.size() - 1;
int iIncrement = +1;
if (iNewStart < m_iStartIndex)
{ // Go backwards to avoid overlaying values
iStart = iEnd;
iEnd = 0;
iIncrement = -1;
}
for (int i = iStart; i * iIncrement <= iEnd; i = i + iIncrement)
{
Object obj = super.set(i, null); // Get and clear value
int iShiftedIndex = i + m_iStartIndex - iNewStart;
if ((iShiftedIndex >= 0) && (iShiftedIndex < this.size()))
super.set(iShiftedIndex, obj); // Move/set it!
else
this.freeObject(m_iStartIndex + i, obj); // Notify obj
}
m_iStartIndex = iNewStart;
}
if (index >= m_iStartIndex + this.size())
{ // Need to add empty elements inbetween
for (int i = m_iStartIndex + this.size(); i <= index; i++)
this.add(null); // Add a placeholder
}
index = index - m_iStartIndex;
return super.set(index, element);
}
|
[
"public",
"Object",
"set",
"(",
"int",
"index",
",",
"Object",
"element",
")",
"{",
"if",
"(",
"(",
"index",
"<",
"m_iStartIndex",
")",
"||",
"(",
"index",
">=",
"m_iStartIndex",
"+",
"m_iMaxSize",
")",
")",
"{",
"// Out of bounds, re-adjust bounds",
"int",
"iNewStart",
"=",
"index",
"-",
"m_iMaxSize",
"/",
"2",
";",
"// index should be right in the middle",
"if",
"(",
"iNewStart",
"<",
"0",
")",
"iNewStart",
"=",
"0",
";",
"int",
"iStart",
"=",
"0",
";",
"int",
"iEnd",
"=",
"this",
".",
"size",
"(",
")",
"-",
"1",
";",
"int",
"iIncrement",
"=",
"+",
"1",
";",
"if",
"(",
"iNewStart",
"<",
"m_iStartIndex",
")",
"{",
"// Go backwards to avoid overlaying values",
"iStart",
"=",
"iEnd",
";",
"iEnd",
"=",
"0",
";",
"iIncrement",
"=",
"-",
"1",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"iStart",
";",
"i",
"*",
"iIncrement",
"<=",
"iEnd",
";",
"i",
"=",
"i",
"+",
"iIncrement",
")",
"{",
"Object",
"obj",
"=",
"super",
".",
"set",
"(",
"i",
",",
"null",
")",
";",
"// Get and clear value",
"int",
"iShiftedIndex",
"=",
"i",
"+",
"m_iStartIndex",
"-",
"iNewStart",
";",
"if",
"(",
"(",
"iShiftedIndex",
">=",
"0",
")",
"&&",
"(",
"iShiftedIndex",
"<",
"this",
".",
"size",
"(",
")",
")",
")",
"super",
".",
"set",
"(",
"iShiftedIndex",
",",
"obj",
")",
";",
"// Move/set it!",
"else",
"this",
".",
"freeObject",
"(",
"m_iStartIndex",
"+",
"i",
",",
"obj",
")",
";",
"// Notify obj",
"}",
"m_iStartIndex",
"=",
"iNewStart",
";",
"}",
"if",
"(",
"index",
">=",
"m_iStartIndex",
"+",
"this",
".",
"size",
"(",
")",
")",
"{",
"// Need to add empty elements inbetween",
"for",
"(",
"int",
"i",
"=",
"m_iStartIndex",
"+",
"this",
".",
"size",
"(",
")",
";",
"i",
"<=",
"index",
";",
"i",
"++",
")",
"this",
".",
"(",
"null",
")",
";",
"// Add a placeholder",
"}",
"index",
"=",
"index",
"-",
"m_iStartIndex",
";",
"return",
"super",
".",
"set",
"(",
"index",
",",
"element",
")",
";",
"}"
] |
Set this element to this object.
If this index is not in the current array, shift the array and add it.
@see java.util.ArrayList
@param index The index to set the value.
@param element The object to add.
@return The selelement previously at this location.
|
[
"Set",
"this",
"element",
"to",
"this",
"object",
".",
"If",
"this",
"index",
"is",
"not",
"in",
"the",
"current",
"array",
"shift",
"the",
"array",
"and",
"add",
"it",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/db/base/src/main/java/org/jbundle/thin/base/db/util/ArrayCache.java#L55-L89
|
153,861
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/util/AbstractStateMachine.java
|
AbstractStateMachine.addState
|
public void addState(String name, Runnable enter)
{
addState(name, (S) new AdhocState(name, enter, null, null));
}
|
java
|
public void addState(String name, Runnable enter)
{
addState(name, (S) new AdhocState(name, enter, null, null));
}
|
[
"public",
"void",
"addState",
"(",
"String",
"name",
",",
"Runnable",
"enter",
")",
"{",
"addState",
"(",
"name",
",",
"(",
"S",
")",
"new",
"AdhocState",
"(",
"name",
",",
"enter",
",",
"null",
",",
"null",
")",
")",
";",
"}"
] |
Creates named state with functional interface.
@param name
@param enter Called when state is entered.
|
[
"Creates",
"named",
"state",
"with",
"functional",
"interface",
"."
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/AbstractStateMachine.java#L69-L72
|
153,862
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/util/AbstractStateMachine.java
|
AbstractStateMachine.addState
|
public void addState(String name, S state)
{
AbstractState old = states.put(name, new StateWrapper(name, state));
if (old != null)
{
throw new IllegalArgumentException("state "+name+" exists already");
}
}
|
java
|
public void addState(String name, S state)
{
AbstractState old = states.put(name, new StateWrapper(name, state));
if (old != null)
{
throw new IllegalArgumentException("state "+name+" exists already");
}
}
|
[
"public",
"void",
"addState",
"(",
"String",
"name",
",",
"S",
"state",
")",
"{",
"AbstractState",
"old",
"=",
"states",
".",
"put",
"(",
"name",
",",
"new",
"StateWrapper",
"(",
"name",
",",
"state",
")",
")",
";",
"if",
"(",
"old",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"state \"",
"+",
"name",
"+",
"\" exists already\"",
")",
";",
"}",
"}"
] |
Creates named state
@param name
@param state
|
[
"Creates",
"named",
"state"
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/AbstractStateMachine.java#L99-L106
|
153,863
|
jbundle/jbundle
|
app/program/script/src/main/java/org/jbundle/app/program/script/process/PurgeRecordsProcess.java
|
PurgeRecordsProcess.initSharedRecord
|
public void initSharedRecord(Record record)
{
FieldListener listener = null;
try {
BaseField field = record.getSharedRecordTypeKey();
field.addListener(listener = new InitOnceFieldHandler(null));
field.setData(new Integer(0), true, DBConstants.INIT_MOVE);
field.setData(new Integer(0), true, DBConstants.INIT_MOVE);
if (field != null)
if (field.getDataClass() == Integer.class)
{
for (int i = 1; ; i++)
{
Integer intData = new Integer(i);
field.setData(intData);
record.addNew();
Record recShared = record.getTable().getCurrentTable().getRecord();
if (recShared == null)
break;
if (recShared == record)
break;
if (recShared.getField(field.getFieldName()).getValue() != i)
break;
this.disableAllListeners(recShared);
}
}
} catch (DBException ex) {
ex.printStackTrace();
} finally {
if (listener != null)
record.removeListener(listener, true);
}
}
|
java
|
public void initSharedRecord(Record record)
{
FieldListener listener = null;
try {
BaseField field = record.getSharedRecordTypeKey();
field.addListener(listener = new InitOnceFieldHandler(null));
field.setData(new Integer(0), true, DBConstants.INIT_MOVE);
field.setData(new Integer(0), true, DBConstants.INIT_MOVE);
if (field != null)
if (field.getDataClass() == Integer.class)
{
for (int i = 1; ; i++)
{
Integer intData = new Integer(i);
field.setData(intData);
record.addNew();
Record recShared = record.getTable().getCurrentTable().getRecord();
if (recShared == null)
break;
if (recShared == record)
break;
if (recShared.getField(field.getFieldName()).getValue() != i)
break;
this.disableAllListeners(recShared);
}
}
} catch (DBException ex) {
ex.printStackTrace();
} finally {
if (listener != null)
record.removeListener(listener, true);
}
}
|
[
"public",
"void",
"initSharedRecord",
"(",
"Record",
"record",
")",
"{",
"FieldListener",
"listener",
"=",
"null",
";",
"try",
"{",
"BaseField",
"field",
"=",
"record",
".",
"getSharedRecordTypeKey",
"(",
")",
";",
"field",
".",
"addListener",
"(",
"listener",
"=",
"new",
"InitOnceFieldHandler",
"(",
"null",
")",
")",
";",
"field",
".",
"setData",
"(",
"new",
"Integer",
"(",
"0",
")",
",",
"true",
",",
"DBConstants",
".",
"INIT_MOVE",
")",
";",
"field",
".",
"setData",
"(",
"new",
"Integer",
"(",
"0",
")",
",",
"true",
",",
"DBConstants",
".",
"INIT_MOVE",
")",
";",
"if",
"(",
"field",
"!=",
"null",
")",
"if",
"(",
"field",
".",
"getDataClass",
"(",
")",
"==",
"Integer",
".",
"class",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"1",
";",
";",
"i",
"++",
")",
"{",
"Integer",
"intData",
"=",
"new",
"Integer",
"(",
"i",
")",
";",
"field",
".",
"setData",
"(",
"intData",
")",
";",
"record",
".",
"addNew",
"(",
")",
";",
"Record",
"recShared",
"=",
"record",
".",
"getTable",
"(",
")",
".",
"getCurrentTable",
"(",
")",
".",
"getRecord",
"(",
")",
";",
"if",
"(",
"recShared",
"==",
"null",
")",
"break",
";",
"if",
"(",
"recShared",
"==",
"record",
")",
"break",
";",
"if",
"(",
"recShared",
".",
"getField",
"(",
"field",
".",
"getFieldName",
"(",
")",
")",
".",
"getValue",
"(",
")",
"!=",
"i",
")",
"break",
";",
"this",
".",
"disableAllListeners",
"(",
"recShared",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"DBException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"listener",
"!=",
"null",
")",
"record",
".",
"removeListener",
"(",
"listener",
",",
"true",
")",
";",
"}",
"}"
] |
InitSharedRecord Method.
|
[
"InitSharedRecord",
"Method",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/app/program/script/src/main/java/org/jbundle/app/program/script/process/PurgeRecordsProcess.java#L79-L111
|
153,864
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.validateContentSpec
|
public boolean validateContentSpec(final ContentSpec contentSpec, final String username) {
boolean valid = preValidateContentSpec(contentSpec);
if (!postValidateContentSpec(contentSpec, username)) {
valid = false;
}
return valid;
}
|
java
|
public boolean validateContentSpec(final ContentSpec contentSpec, final String username) {
boolean valid = preValidateContentSpec(contentSpec);
if (!postValidateContentSpec(contentSpec, username)) {
valid = false;
}
return valid;
}
|
[
"public",
"boolean",
"validateContentSpec",
"(",
"final",
"ContentSpec",
"contentSpec",
",",
"final",
"String",
"username",
")",
"{",
"boolean",
"valid",
"=",
"preValidateContentSpec",
"(",
"contentSpec",
")",
";",
"if",
"(",
"!",
"postValidateContentSpec",
"(",
"contentSpec",
",",
"username",
")",
")",
"{",
"valid",
"=",
"false",
";",
"}",
"return",
"valid",
";",
"}"
] |
Validates that a Content Specification is valid by checking the META data,
child levels and topics. This method is a
wrapper to first call PreValidate and then PostValidate.
@param contentSpec The content specification to be validated.
@param username The user who requested the content spec validation.
@return True if the content specification is valid, otherwise false.
|
[
"Validates",
"that",
"a",
"Content",
"Specification",
"is",
"valid",
"by",
"checking",
"the",
"META",
"data",
"child",
"levels",
"and",
"topics",
".",
"This",
"method",
"is",
"a",
"wrapper",
"to",
"first",
"call",
"PreValidate",
"and",
"then",
"PostValidate",
"."
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L179-L187
|
153,865
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.preValidateXML
|
private boolean preValidateXML(final KeyValueNode<String> keyValueNode, final String wrappedValue, final String format) {
Document doc = null;
String errorMsg = null;
try {
String fixedXML = DocBookUtilities.escapeForXML(wrappedValue);
if (CommonConstants.DOCBOOK_50_TITLE.equalsIgnoreCase(format)) {
fixedXML = DocBookUtilities.addDocBook50Namespace(fixedXML);
}
doc = XMLUtilities.convertStringToDocument(fixedXML);
} catch (Exception e) {
errorMsg = e.getMessage();
}
// If the doc variable is null then an error occurred somewhere
if (doc == null) {
final String line = keyValueNode.getText();
if (errorMsg != null) {
log.error(String.format(ProcessorConstants.ERROR_INVALID_METADATA_MSG, keyValueNode.getKey(), errorMsg, line));
} else {
log.error(String.format(ProcessorConstants.ERROR_INVALID_METADATA_NO_ERROR_MSG, keyValueNode.getKey(), line));
}
return false;
}
return true;
}
|
java
|
private boolean preValidateXML(final KeyValueNode<String> keyValueNode, final String wrappedValue, final String format) {
Document doc = null;
String errorMsg = null;
try {
String fixedXML = DocBookUtilities.escapeForXML(wrappedValue);
if (CommonConstants.DOCBOOK_50_TITLE.equalsIgnoreCase(format)) {
fixedXML = DocBookUtilities.addDocBook50Namespace(fixedXML);
}
doc = XMLUtilities.convertStringToDocument(fixedXML);
} catch (Exception e) {
errorMsg = e.getMessage();
}
// If the doc variable is null then an error occurred somewhere
if (doc == null) {
final String line = keyValueNode.getText();
if (errorMsg != null) {
log.error(String.format(ProcessorConstants.ERROR_INVALID_METADATA_MSG, keyValueNode.getKey(), errorMsg, line));
} else {
log.error(String.format(ProcessorConstants.ERROR_INVALID_METADATA_NO_ERROR_MSG, keyValueNode.getKey(), line));
}
return false;
}
return true;
}
|
[
"private",
"boolean",
"preValidateXML",
"(",
"final",
"KeyValueNode",
"<",
"String",
">",
"keyValueNode",
",",
"final",
"String",
"wrappedValue",
",",
"final",
"String",
"format",
")",
"{",
"Document",
"doc",
"=",
"null",
";",
"String",
"errorMsg",
"=",
"null",
";",
"try",
"{",
"String",
"fixedXML",
"=",
"DocBookUtilities",
".",
"escapeForXML",
"(",
"wrappedValue",
")",
";",
"if",
"(",
"CommonConstants",
".",
"DOCBOOK_50_TITLE",
".",
"equalsIgnoreCase",
"(",
"format",
")",
")",
"{",
"fixedXML",
"=",
"DocBookUtilities",
".",
"addDocBook50Namespace",
"(",
"fixedXML",
")",
";",
"}",
"doc",
"=",
"XMLUtilities",
".",
"convertStringToDocument",
"(",
"fixedXML",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"errorMsg",
"=",
"e",
".",
"getMessage",
"(",
")",
";",
"}",
"// If the doc variable is null then an error occurred somewhere",
"if",
"(",
"doc",
"==",
"null",
")",
"{",
"final",
"String",
"line",
"=",
"keyValueNode",
".",
"getText",
"(",
")",
";",
"if",
"(",
"errorMsg",
"!=",
"null",
")",
"{",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_INVALID_METADATA_MSG",
",",
"keyValueNode",
".",
"getKey",
"(",
")",
",",
"errorMsg",
",",
"line",
")",
")",
";",
"}",
"else",
"{",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_INVALID_METADATA_NO_ERROR_MSG",
",",
"keyValueNode",
".",
"getKey",
"(",
")",
",",
"line",
")",
")",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Performs the pre validation on keyvalue nodes that may be used as XML to ensure it is at least valid XML.
@param keyValueNode The key value node being validated.
@param wrappedValue The wrapped value, as it would appear in a build.
@param format
@return True if the content is valid otherwise false.
|
[
"Performs",
"the",
"pre",
"validation",
"on",
"keyvalue",
"nodes",
"that",
"may",
"be",
"used",
"as",
"XML",
"to",
"ensure",
"it",
"is",
"at",
"least",
"valid",
"XML",
"."
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L430-L457
|
153,866
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.doesPublicanCfgsContainValue
|
private boolean doesPublicanCfgsContainValue(final ContentSpec contentSpec, final String value) {
final Pattern pattern = Pattern.compile("^(.*\\n)?( |\\t)*" + value + ":.*", java.util.regex.Pattern.DOTALL);
if (!isNullOrEmpty(contentSpec.getPublicanCfg()) && pattern.matcher(contentSpec.getPublicanCfg()).matches()) {
return true;
} else if (!contentSpec.getAllAdditionalPublicanCfgs().isEmpty()) {
for (final Entry<String, String> entry : contentSpec.getAllAdditionalPublicanCfgs().entrySet()) {
if (!isNullOrEmpty(entry.getValue()) && pattern.matcher(entry.getValue()).matches()) {
return true;
}
}
}
return false;
}
|
java
|
private boolean doesPublicanCfgsContainValue(final ContentSpec contentSpec, final String value) {
final Pattern pattern = Pattern.compile("^(.*\\n)?( |\\t)*" + value + ":.*", java.util.regex.Pattern.DOTALL);
if (!isNullOrEmpty(contentSpec.getPublicanCfg()) && pattern.matcher(contentSpec.getPublicanCfg()).matches()) {
return true;
} else if (!contentSpec.getAllAdditionalPublicanCfgs().isEmpty()) {
for (final Entry<String, String> entry : contentSpec.getAllAdditionalPublicanCfgs().entrySet()) {
if (!isNullOrEmpty(entry.getValue()) && pattern.matcher(entry.getValue()).matches()) {
return true;
}
}
}
return false;
}
|
[
"private",
"boolean",
"doesPublicanCfgsContainValue",
"(",
"final",
"ContentSpec",
"contentSpec",
",",
"final",
"String",
"value",
")",
"{",
"final",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"\"^(.*\\\\n)?( |\\\\t)*\"",
"+",
"value",
"+",
"\":.*\"",
",",
"java",
".",
"util",
".",
"regex",
".",
"Pattern",
".",
"DOTALL",
")",
";",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"contentSpec",
".",
"getPublicanCfg",
"(",
")",
")",
"&&",
"pattern",
".",
"matcher",
"(",
"contentSpec",
".",
"getPublicanCfg",
"(",
")",
")",
".",
"matches",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"!",
"contentSpec",
".",
"getAllAdditionalPublicanCfgs",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"final",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"contentSpec",
".",
"getAllAdditionalPublicanCfgs",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
"&&",
"pattern",
".",
"matcher",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
".",
"matches",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if the default or additional publican cfg files have a specified value
@param contentSpec The content spec to check from.
@param value The value to check for. eg: mainfile
@return True if the value exists in any publican.cfg
|
[
"Check",
"if",
"the",
"default",
"or",
"additional",
"publican",
"cfg",
"files",
"have",
"a",
"specified",
"value"
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L466-L479
|
153,867
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.checkForConflictingCondition
|
protected void checkForConflictingCondition(final IOptionsNode node, final ContentSpec contentSpec) {
if (!isNullOrEmpty(node.getConditionStatement())) {
final String publicanCfg;
if (!contentSpec.getDefaultPublicanCfg().equals(CommonConstants.CS_PUBLICAN_CFG_TITLE)) {
final String name = contentSpec.getDefaultPublicanCfg();
final Matcher matcher = CSConstants.CUSTOM_PUBLICAN_CFG_PATTERN.matcher(name);
final String fixedName = matcher.find() ? matcher.group(1) : name;
publicanCfg = contentSpec.getAdditionalPublicanCfg(fixedName);
} else {
publicanCfg = contentSpec.getPublicanCfg();
}
// Make sure a publican.cfg is defined before doing any checks
if (!isNullOrEmpty(publicanCfg)) {
if (publicanCfg.contains("condition:")) {
log.warn(String.format(ProcessorConstants.WARN_CONDITION_IGNORED_MSG, node.getLineNumber(), node.getText()));
}
}
}
}
|
java
|
protected void checkForConflictingCondition(final IOptionsNode node, final ContentSpec contentSpec) {
if (!isNullOrEmpty(node.getConditionStatement())) {
final String publicanCfg;
if (!contentSpec.getDefaultPublicanCfg().equals(CommonConstants.CS_PUBLICAN_CFG_TITLE)) {
final String name = contentSpec.getDefaultPublicanCfg();
final Matcher matcher = CSConstants.CUSTOM_PUBLICAN_CFG_PATTERN.matcher(name);
final String fixedName = matcher.find() ? matcher.group(1) : name;
publicanCfg = contentSpec.getAdditionalPublicanCfg(fixedName);
} else {
publicanCfg = contentSpec.getPublicanCfg();
}
// Make sure a publican.cfg is defined before doing any checks
if (!isNullOrEmpty(publicanCfg)) {
if (publicanCfg.contains("condition:")) {
log.warn(String.format(ProcessorConstants.WARN_CONDITION_IGNORED_MSG, node.getLineNumber(), node.getText()));
}
}
}
}
|
[
"protected",
"void",
"checkForConflictingCondition",
"(",
"final",
"IOptionsNode",
"node",
",",
"final",
"ContentSpec",
"contentSpec",
")",
"{",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"node",
".",
"getConditionStatement",
"(",
")",
")",
")",
"{",
"final",
"String",
"publicanCfg",
";",
"if",
"(",
"!",
"contentSpec",
".",
"getDefaultPublicanCfg",
"(",
")",
".",
"equals",
"(",
"CommonConstants",
".",
"CS_PUBLICAN_CFG_TITLE",
")",
")",
"{",
"final",
"String",
"name",
"=",
"contentSpec",
".",
"getDefaultPublicanCfg",
"(",
")",
";",
"final",
"Matcher",
"matcher",
"=",
"CSConstants",
".",
"CUSTOM_PUBLICAN_CFG_PATTERN",
".",
"matcher",
"(",
"name",
")",
";",
"final",
"String",
"fixedName",
"=",
"matcher",
".",
"find",
"(",
")",
"?",
"matcher",
".",
"group",
"(",
"1",
")",
":",
"name",
";",
"publicanCfg",
"=",
"contentSpec",
".",
"getAdditionalPublicanCfg",
"(",
"fixedName",
")",
";",
"}",
"else",
"{",
"publicanCfg",
"=",
"contentSpec",
".",
"getPublicanCfg",
"(",
")",
";",
"}",
"// Make sure a publican.cfg is defined before doing any checks",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"publicanCfg",
")",
")",
"{",
"if",
"(",
"publicanCfg",
".",
"contains",
"(",
"\"condition:\"",
")",
")",
"{",
"log",
".",
"warn",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"WARN_CONDITION_IGNORED_MSG",
",",
"node",
".",
"getLineNumber",
"(",
")",
",",
"node",
".",
"getText",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Check if the condition on a node will conflict with a condition in the defined publican.cfg file.
@param node The node to be checked.
@param contentSpec The content spec the node belongs to.
|
[
"Check",
"if",
"the",
"condition",
"on",
"a",
"node",
"will",
"conflict",
"with",
"a",
"condition",
"in",
"the",
"defined",
"publican",
".",
"cfg",
"file",
"."
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L487-L506
|
153,868
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.validateEntities
|
protected boolean validateEntities(final ContentSpec contentSpec) {
final String entities = contentSpec.getEntities();
if (isNullOrEmpty(entities)) return true;
boolean valid = true;
// Make sure the input is valid XML.
final String wrappedEntities = "<!DOCTYPE section [" + entities + "]><section></section>";
Document doc = null;
try {
doc = XMLUtilities.convertStringToDocument(wrappedEntities);
} catch (Exception e) {
final String line = CommonConstants.CS_ENTITIES_TITLE + " = [" + entities + "]";
log.error(String.format(ProcessorConstants.ERROR_INVALID_ENTITIES_MSG, e.getMessage(), line));
valid = false;
}
// Check that no reserved entities are defined.
if (doc != null) {
final List<String> invalidEntities = new ArrayList<String>();
final NamedNodeMap entityNodes = doc.getDoctype().getEntities();
for (int i = 0; i < entityNodes.getLength(); i++) {
final org.w3c.dom.Node entityNode = entityNodes.item(i);
if (ProcessorConstants.RESERVED_ENTITIES.contains(entityNode.getNodeName())) {
invalidEntities.add(entityNode.getNodeName());
}
}
if (!invalidEntities.isEmpty()) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < invalidEntities.size(); i++) {
if (i != 0) {
if (i == invalidEntities.size() - 1) {
builder.append(" and ");
} else {
builder.append(", ");
}
}
builder.append(invalidEntities.get(i));
}
final String line = CommonConstants.CS_ENTITIES_TITLE + " = [" + entities + "]";
if (invalidEntities.size() == 1) {
log.error(String.format(ProcessorConstants.ERROR_RESERVED_ENTITIES_SINGLE_DEFINED_MSG, builder.toString(), line));
} else {
log.error(String.format(ProcessorConstants.ERROR_RESERVED_ENTITIES_DEFINED_MSG, builder.toString(), line));
}
valid = false;
}
}
return valid;
}
|
java
|
protected boolean validateEntities(final ContentSpec contentSpec) {
final String entities = contentSpec.getEntities();
if (isNullOrEmpty(entities)) return true;
boolean valid = true;
// Make sure the input is valid XML.
final String wrappedEntities = "<!DOCTYPE section [" + entities + "]><section></section>";
Document doc = null;
try {
doc = XMLUtilities.convertStringToDocument(wrappedEntities);
} catch (Exception e) {
final String line = CommonConstants.CS_ENTITIES_TITLE + " = [" + entities + "]";
log.error(String.format(ProcessorConstants.ERROR_INVALID_ENTITIES_MSG, e.getMessage(), line));
valid = false;
}
// Check that no reserved entities are defined.
if (doc != null) {
final List<String> invalidEntities = new ArrayList<String>();
final NamedNodeMap entityNodes = doc.getDoctype().getEntities();
for (int i = 0; i < entityNodes.getLength(); i++) {
final org.w3c.dom.Node entityNode = entityNodes.item(i);
if (ProcessorConstants.RESERVED_ENTITIES.contains(entityNode.getNodeName())) {
invalidEntities.add(entityNode.getNodeName());
}
}
if (!invalidEntities.isEmpty()) {
final StringBuilder builder = new StringBuilder();
for (int i = 0; i < invalidEntities.size(); i++) {
if (i != 0) {
if (i == invalidEntities.size() - 1) {
builder.append(" and ");
} else {
builder.append(", ");
}
}
builder.append(invalidEntities.get(i));
}
final String line = CommonConstants.CS_ENTITIES_TITLE + " = [" + entities + "]";
if (invalidEntities.size() == 1) {
log.error(String.format(ProcessorConstants.ERROR_RESERVED_ENTITIES_SINGLE_DEFINED_MSG, builder.toString(), line));
} else {
log.error(String.format(ProcessorConstants.ERROR_RESERVED_ENTITIES_DEFINED_MSG, builder.toString(), line));
}
valid = false;
}
}
return valid;
}
|
[
"protected",
"boolean",
"validateEntities",
"(",
"final",
"ContentSpec",
"contentSpec",
")",
"{",
"final",
"String",
"entities",
"=",
"contentSpec",
".",
"getEntities",
"(",
")",
";",
"if",
"(",
"isNullOrEmpty",
"(",
"entities",
")",
")",
"return",
"true",
";",
"boolean",
"valid",
"=",
"true",
";",
"// Make sure the input is valid XML.",
"final",
"String",
"wrappedEntities",
"=",
"\"<!DOCTYPE section [\"",
"+",
"entities",
"+",
"\"]><section></section>\"",
";",
"Document",
"doc",
"=",
"null",
";",
"try",
"{",
"doc",
"=",
"XMLUtilities",
".",
"convertStringToDocument",
"(",
"wrappedEntities",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"final",
"String",
"line",
"=",
"CommonConstants",
".",
"CS_ENTITIES_TITLE",
"+",
"\" = [\"",
"+",
"entities",
"+",
"\"]\"",
";",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_INVALID_ENTITIES_MSG",
",",
"e",
".",
"getMessage",
"(",
")",
",",
"line",
")",
")",
";",
"valid",
"=",
"false",
";",
"}",
"// Check that no reserved entities are defined.",
"if",
"(",
"doc",
"!=",
"null",
")",
"{",
"final",
"List",
"<",
"String",
">",
"invalidEntities",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"final",
"NamedNodeMap",
"entityNodes",
"=",
"doc",
".",
"getDoctype",
"(",
")",
".",
"getEntities",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"entityNodes",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"org",
".",
"w3c",
".",
"dom",
".",
"Node",
"entityNode",
"=",
"entityNodes",
".",
"item",
"(",
"i",
")",
";",
"if",
"(",
"ProcessorConstants",
".",
"RESERVED_ENTITIES",
".",
"contains",
"(",
"entityNode",
".",
"getNodeName",
"(",
")",
")",
")",
"{",
"invalidEntities",
".",
"add",
"(",
"entityNode",
".",
"getNodeName",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"invalidEntities",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"invalidEntities",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"!=",
"0",
")",
"{",
"if",
"(",
"i",
"==",
"invalidEntities",
".",
"size",
"(",
")",
"-",
"1",
")",
"{",
"builder",
".",
"append",
"(",
"\" and \"",
")",
";",
"}",
"else",
"{",
"builder",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"}",
"builder",
".",
"append",
"(",
"invalidEntities",
".",
"get",
"(",
"i",
")",
")",
";",
"}",
"final",
"String",
"line",
"=",
"CommonConstants",
".",
"CS_ENTITIES_TITLE",
"+",
"\" = [\"",
"+",
"entities",
"+",
"\"]\"",
";",
"if",
"(",
"invalidEntities",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_RESERVED_ENTITIES_SINGLE_DEFINED_MSG",
",",
"builder",
".",
"toString",
"(",
")",
",",
"line",
")",
")",
";",
"}",
"else",
"{",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_RESERVED_ENTITIES_DEFINED_MSG",
",",
"builder",
".",
"toString",
"(",
")",
",",
"line",
")",
")",
";",
"}",
"valid",
"=",
"false",
";",
"}",
"}",
"return",
"valid",
";",
"}"
] |
Validates the custom entities to ensure that only the defaults are overridden and that the content is valid XML.
@param contentSpec The content spec that contains the custom entities to be validated.
@return True if the custom entities are valid and don't contain additional custom values, otherwise false.
|
[
"Validates",
"the",
"custom",
"entities",
"to",
"ensure",
"that",
"only",
"the",
"defaults",
"are",
"overridden",
"and",
"that",
"the",
"content",
"is",
"valid",
"XML",
"."
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L514-L566
|
153,869
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.postValidateXML
|
protected boolean postValidateXML(final ContentSpec contentSpec, final KeyValueNode<String> keyValueNode,
final String wrappedElement, String parentElement) {
String fixedWrappedElement = DocBookUtilities.escapeForXML(wrappedElement);
// Get the docbook DTD
final String docbookFileName;
final XMLValidator.ValidationMethod validationMethod;
final byte[] docbookSchema;
if (contentSpec.getFormat().equalsIgnoreCase(CommonConstants.DOCBOOK_50_TITLE)) {
final BlobConstantWrapper docbookRng = blobConstantProvider.getBlobConstant(serverEntities.getDocBook50RNGBlobConstantId());
docbookFileName = docbookRng.getName();
validationMethod = XMLValidator.ValidationMethod.RELAXNG;
docbookSchema = docbookRng.getValue();
// Further wrap the element for docbook 5.0
if (CommonConstants.CS_TITLE_TITLE.equalsIgnoreCase(keyValueNode.getKey())) {
fixedWrappedElement = DocBookUtilities.addDocBook50Namespace("<book><info>" + fixedWrappedElement + "</info></book>");
} else {
fixedWrappedElement = DocBookUtilities.addDocBook50Namespace("<book><info><title />" + fixedWrappedElement + "</info></book>");
}
parentElement = "book";
} else {
final BlobConstantWrapper rocbookDtd = blobConstantProvider.getBlobConstant(serverEntities.getRocBook45DTDBlobConstantId());
docbookFileName = rocbookDtd.getName();
validationMethod = XMLValidator.ValidationMethod.DTD;
docbookSchema = rocbookDtd.getValue();
}
// Create the dummy XML entities file
final StringBuilder xmlEntities = new StringBuilder(DocBookUtilities.DOCBOOK_ENTITIES_STRING);
xmlEntities.append("\n").append(CSConstants.DUMMY_CS_NAME_ENT_FILE);
if (!isNullOrEmpty(contentSpec.getEntities())) {
xmlEntities.append(contentSpec.getEntities());
}
// Validate the XML content against the dtd
final XMLValidator validator = new XMLValidator(false);
if (!validator.validate(validationMethod, fixedWrappedElement, docbookFileName, docbookSchema, xmlEntities.toString(),
parentElement)) {
final String line = keyValueNode.getText();
log.error(String.format(ProcessorConstants.ERROR_INVALID_METADATA_MSG, keyValueNode.getKey(), validator.getErrorText(), line));
return false;
}
return true;
}
|
java
|
protected boolean postValidateXML(final ContentSpec contentSpec, final KeyValueNode<String> keyValueNode,
final String wrappedElement, String parentElement) {
String fixedWrappedElement = DocBookUtilities.escapeForXML(wrappedElement);
// Get the docbook DTD
final String docbookFileName;
final XMLValidator.ValidationMethod validationMethod;
final byte[] docbookSchema;
if (contentSpec.getFormat().equalsIgnoreCase(CommonConstants.DOCBOOK_50_TITLE)) {
final BlobConstantWrapper docbookRng = blobConstantProvider.getBlobConstant(serverEntities.getDocBook50RNGBlobConstantId());
docbookFileName = docbookRng.getName();
validationMethod = XMLValidator.ValidationMethod.RELAXNG;
docbookSchema = docbookRng.getValue();
// Further wrap the element for docbook 5.0
if (CommonConstants.CS_TITLE_TITLE.equalsIgnoreCase(keyValueNode.getKey())) {
fixedWrappedElement = DocBookUtilities.addDocBook50Namespace("<book><info>" + fixedWrappedElement + "</info></book>");
} else {
fixedWrappedElement = DocBookUtilities.addDocBook50Namespace("<book><info><title />" + fixedWrappedElement + "</info></book>");
}
parentElement = "book";
} else {
final BlobConstantWrapper rocbookDtd = blobConstantProvider.getBlobConstant(serverEntities.getRocBook45DTDBlobConstantId());
docbookFileName = rocbookDtd.getName();
validationMethod = XMLValidator.ValidationMethod.DTD;
docbookSchema = rocbookDtd.getValue();
}
// Create the dummy XML entities file
final StringBuilder xmlEntities = new StringBuilder(DocBookUtilities.DOCBOOK_ENTITIES_STRING);
xmlEntities.append("\n").append(CSConstants.DUMMY_CS_NAME_ENT_FILE);
if (!isNullOrEmpty(contentSpec.getEntities())) {
xmlEntities.append(contentSpec.getEntities());
}
// Validate the XML content against the dtd
final XMLValidator validator = new XMLValidator(false);
if (!validator.validate(validationMethod, fixedWrappedElement, docbookFileName, docbookSchema, xmlEntities.toString(),
parentElement)) {
final String line = keyValueNode.getText();
log.error(String.format(ProcessorConstants.ERROR_INVALID_METADATA_MSG, keyValueNode.getKey(), validator.getErrorText(), line));
return false;
}
return true;
}
|
[
"protected",
"boolean",
"postValidateXML",
"(",
"final",
"ContentSpec",
"contentSpec",
",",
"final",
"KeyValueNode",
"<",
"String",
">",
"keyValueNode",
",",
"final",
"String",
"wrappedElement",
",",
"String",
"parentElement",
")",
"{",
"String",
"fixedWrappedElement",
"=",
"DocBookUtilities",
".",
"escapeForXML",
"(",
"wrappedElement",
")",
";",
"// Get the docbook DTD",
"final",
"String",
"docbookFileName",
";",
"final",
"XMLValidator",
".",
"ValidationMethod",
"validationMethod",
";",
"final",
"byte",
"[",
"]",
"docbookSchema",
";",
"if",
"(",
"contentSpec",
".",
"getFormat",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"CommonConstants",
".",
"DOCBOOK_50_TITLE",
")",
")",
"{",
"final",
"BlobConstantWrapper",
"docbookRng",
"=",
"blobConstantProvider",
".",
"getBlobConstant",
"(",
"serverEntities",
".",
"getDocBook50RNGBlobConstantId",
"(",
")",
")",
";",
"docbookFileName",
"=",
"docbookRng",
".",
"getName",
"(",
")",
";",
"validationMethod",
"=",
"XMLValidator",
".",
"ValidationMethod",
".",
"RELAXNG",
";",
"docbookSchema",
"=",
"docbookRng",
".",
"getValue",
"(",
")",
";",
"// Further wrap the element for docbook 5.0",
"if",
"(",
"CommonConstants",
".",
"CS_TITLE_TITLE",
".",
"equalsIgnoreCase",
"(",
"keyValueNode",
".",
"getKey",
"(",
")",
")",
")",
"{",
"fixedWrappedElement",
"=",
"DocBookUtilities",
".",
"addDocBook50Namespace",
"(",
"\"<book><info>\"",
"+",
"fixedWrappedElement",
"+",
"\"</info></book>\"",
")",
";",
"}",
"else",
"{",
"fixedWrappedElement",
"=",
"DocBookUtilities",
".",
"addDocBook50Namespace",
"(",
"\"<book><info><title />\"",
"+",
"fixedWrappedElement",
"+",
"\"</info></book>\"",
")",
";",
"}",
"parentElement",
"=",
"\"book\"",
";",
"}",
"else",
"{",
"final",
"BlobConstantWrapper",
"rocbookDtd",
"=",
"blobConstantProvider",
".",
"getBlobConstant",
"(",
"serverEntities",
".",
"getRocBook45DTDBlobConstantId",
"(",
")",
")",
";",
"docbookFileName",
"=",
"rocbookDtd",
".",
"getName",
"(",
")",
";",
"validationMethod",
"=",
"XMLValidator",
".",
"ValidationMethod",
".",
"DTD",
";",
"docbookSchema",
"=",
"rocbookDtd",
".",
"getValue",
"(",
")",
";",
"}",
"// Create the dummy XML entities file",
"final",
"StringBuilder",
"xmlEntities",
"=",
"new",
"StringBuilder",
"(",
"DocBookUtilities",
".",
"DOCBOOK_ENTITIES_STRING",
")",
";",
"xmlEntities",
".",
"append",
"(",
"\"\\n\"",
")",
".",
"append",
"(",
"CSConstants",
".",
"DUMMY_CS_NAME_ENT_FILE",
")",
";",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"contentSpec",
".",
"getEntities",
"(",
")",
")",
")",
"{",
"xmlEntities",
".",
"append",
"(",
"contentSpec",
".",
"getEntities",
"(",
")",
")",
";",
"}",
"// Validate the XML content against the dtd",
"final",
"XMLValidator",
"validator",
"=",
"new",
"XMLValidator",
"(",
"false",
")",
";",
"if",
"(",
"!",
"validator",
".",
"validate",
"(",
"validationMethod",
",",
"fixedWrappedElement",
",",
"docbookFileName",
",",
"docbookSchema",
",",
"xmlEntities",
".",
"toString",
"(",
")",
",",
"parentElement",
")",
")",
"{",
"final",
"String",
"line",
"=",
"keyValueNode",
".",
"getText",
"(",
")",
";",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_INVALID_METADATA_MSG",
",",
"keyValueNode",
".",
"getKey",
"(",
")",
",",
"validator",
".",
"getErrorText",
"(",
")",
",",
"line",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks that the XML for a keyvalue node is valid DocBook XML.
@param contentSpec
@param keyValueNode
@param wrappedElement
@param parentElement
@return
|
[
"Checks",
"that",
"the",
"XML",
"for",
"a",
"keyvalue",
"node",
"is",
"valid",
"DocBook",
"XML",
"."
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L831-L876
|
153,870
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.validateFiles
|
protected boolean validateFiles(final ContentSpec contentSpec) {
final FileList fileList = contentSpec.getFileList();
boolean valid = true;
if (fileList != null && !fileList.getValue().isEmpty()) {
for (final File file : fileList.getValue()) {
FileWrapper fileWrapper = null;
try {
fileWrapper = fileProvider.getFile(file.getId(), file.getRevision());
} catch (NotFoundException e) {
log.debug("Could not find file for id " + file.getId());
}
if (fileWrapper == null) {
log.error(String.format(ProcessorConstants.ERROR_FILE_ID_NONEXIST_MSG, fileList.getLineNumber(), file.getText()));
valid = false;
} else if (file.getTitle() != null) {
// Make sure the titles sync up, as a title was specified.
if (!fileWrapper.getFilename().equals(file.getTitle())) {
final String errorMsg = String.format(ProcessorConstants.ERROR_FILE_TITLE_NO_MATCH_MSG, fileList.getLineNumber(),
file.getTitle(), fileWrapper.getFilename());
if (processingOptions.isStrictTitles()) {
log.error(errorMsg);
valid = false;
} else {
log.warn(errorMsg);
file.setTitle(fileWrapper.getFilename());
}
}
} else {
// The short format was used if the title is null, so add it
file.setTitle(fileWrapper.getFilename());
}
}
}
return valid;
}
|
java
|
protected boolean validateFiles(final ContentSpec contentSpec) {
final FileList fileList = contentSpec.getFileList();
boolean valid = true;
if (fileList != null && !fileList.getValue().isEmpty()) {
for (final File file : fileList.getValue()) {
FileWrapper fileWrapper = null;
try {
fileWrapper = fileProvider.getFile(file.getId(), file.getRevision());
} catch (NotFoundException e) {
log.debug("Could not find file for id " + file.getId());
}
if (fileWrapper == null) {
log.error(String.format(ProcessorConstants.ERROR_FILE_ID_NONEXIST_MSG, fileList.getLineNumber(), file.getText()));
valid = false;
} else if (file.getTitle() != null) {
// Make sure the titles sync up, as a title was specified.
if (!fileWrapper.getFilename().equals(file.getTitle())) {
final String errorMsg = String.format(ProcessorConstants.ERROR_FILE_TITLE_NO_MATCH_MSG, fileList.getLineNumber(),
file.getTitle(), fileWrapper.getFilename());
if (processingOptions.isStrictTitles()) {
log.error(errorMsg);
valid = false;
} else {
log.warn(errorMsg);
file.setTitle(fileWrapper.getFilename());
}
}
} else {
// The short format was used if the title is null, so add it
file.setTitle(fileWrapper.getFilename());
}
}
}
return valid;
}
|
[
"protected",
"boolean",
"validateFiles",
"(",
"final",
"ContentSpec",
"contentSpec",
")",
"{",
"final",
"FileList",
"fileList",
"=",
"contentSpec",
".",
"getFileList",
"(",
")",
";",
"boolean",
"valid",
"=",
"true",
";",
"if",
"(",
"fileList",
"!=",
"null",
"&&",
"!",
"fileList",
".",
"getValue",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"final",
"File",
"file",
":",
"fileList",
".",
"getValue",
"(",
")",
")",
"{",
"FileWrapper",
"fileWrapper",
"=",
"null",
";",
"try",
"{",
"fileWrapper",
"=",
"fileProvider",
".",
"getFile",
"(",
"file",
".",
"getId",
"(",
")",
",",
"file",
".",
"getRevision",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"e",
")",
"{",
"log",
".",
"debug",
"(",
"\"Could not find file for id \"",
"+",
"file",
".",
"getId",
"(",
")",
")",
";",
"}",
"if",
"(",
"fileWrapper",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_FILE_ID_NONEXIST_MSG",
",",
"fileList",
".",
"getLineNumber",
"(",
")",
",",
"file",
".",
"getText",
"(",
")",
")",
")",
";",
"valid",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"file",
".",
"getTitle",
"(",
")",
"!=",
"null",
")",
"{",
"// Make sure the titles sync up, as a title was specified.",
"if",
"(",
"!",
"fileWrapper",
".",
"getFilename",
"(",
")",
".",
"equals",
"(",
"file",
".",
"getTitle",
"(",
")",
")",
")",
"{",
"final",
"String",
"errorMsg",
"=",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_FILE_TITLE_NO_MATCH_MSG",
",",
"fileList",
".",
"getLineNumber",
"(",
")",
",",
"file",
".",
"getTitle",
"(",
")",
",",
"fileWrapper",
".",
"getFilename",
"(",
")",
")",
";",
"if",
"(",
"processingOptions",
".",
"isStrictTitles",
"(",
")",
")",
"{",
"log",
".",
"error",
"(",
"errorMsg",
")",
";",
"valid",
"=",
"false",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"errorMsg",
")",
";",
"file",
".",
"setTitle",
"(",
"fileWrapper",
".",
"getFilename",
"(",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"// The short format was used if the title is null, so add it",
"file",
".",
"setTitle",
"(",
"fileWrapper",
".",
"getFilename",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"valid",
";",
"}"
] |
Checks to make sure that the files specified in a content spec are valid and exist.
@param contentSpec The content spec to check.
@return True if all the files are valid, otherwise false.
|
[
"Checks",
"to",
"make",
"sure",
"that",
"the",
"files",
"specified",
"in",
"a",
"content",
"spec",
"are",
"valid",
"and",
"exist",
"."
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L884-L921
|
153,871
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.preValidateRelationships
|
public boolean preValidateRelationships(final ContentSpec contentSpec) {
boolean error = false;
// Create the map of unique ids to spec topics
final Map<String, List<ITopicNode>> specTopicMap = ContentSpecUtilities.getIdTopicNodeMap(contentSpec);
final Map<SpecNodeWithRelationships, List<Relationship>> relationships = contentSpec.getRelationships();
for (final Entry<SpecNodeWithRelationships, List<Relationship>> relationshipEntry : relationships.entrySet()) {
final SpecNodeWithRelationships specNode = relationshipEntry.getKey();
// Check if the app should be shutdown
if (isShuttingDown.get()) {
shutdown.set(true);
return false;
}
for (final Relationship relationship : relationshipEntry.getValue()) {
// Check if the app should be shutdown
if (isShuttingDown.get()) {
shutdown.set(true);
return false;
}
final String relatedId = relationship.getSecondaryRelationshipId();
// The relationship points to a target so it must be a level or topic
if (relationship instanceof TargetRelationship) {
final SpecNode node = ((TargetRelationship) relationship).getSecondaryRelationship();
if (node instanceof SpecTopic) {
final SpecTopic targetTopic = (SpecTopic) node;
if (!validateRelationshipToTopic(relationship, specNode, relatedId, targetTopic, specTopicMap)) {
error = true;
}
} else if (node instanceof Level) {
final Level targetLevel = (Level) node;
if (!validateRelationshipToLevel(relationship, specNode, targetLevel)) {
error = true;
}
}
} else if (relationship instanceof TopicRelationship) {
final SpecTopic relatedTopic = ((TopicRelationship) relationship).getSecondaryRelationship();
if (!validateRelationshipToTopic(relationship, specNode, relatedId, relatedTopic, specTopicMap)) {
error = true;
}
}
}
}
return !error;
}
|
java
|
public boolean preValidateRelationships(final ContentSpec contentSpec) {
boolean error = false;
// Create the map of unique ids to spec topics
final Map<String, List<ITopicNode>> specTopicMap = ContentSpecUtilities.getIdTopicNodeMap(contentSpec);
final Map<SpecNodeWithRelationships, List<Relationship>> relationships = contentSpec.getRelationships();
for (final Entry<SpecNodeWithRelationships, List<Relationship>> relationshipEntry : relationships.entrySet()) {
final SpecNodeWithRelationships specNode = relationshipEntry.getKey();
// Check if the app should be shutdown
if (isShuttingDown.get()) {
shutdown.set(true);
return false;
}
for (final Relationship relationship : relationshipEntry.getValue()) {
// Check if the app should be shutdown
if (isShuttingDown.get()) {
shutdown.set(true);
return false;
}
final String relatedId = relationship.getSecondaryRelationshipId();
// The relationship points to a target so it must be a level or topic
if (relationship instanceof TargetRelationship) {
final SpecNode node = ((TargetRelationship) relationship).getSecondaryRelationship();
if (node instanceof SpecTopic) {
final SpecTopic targetTopic = (SpecTopic) node;
if (!validateRelationshipToTopic(relationship, specNode, relatedId, targetTopic, specTopicMap)) {
error = true;
}
} else if (node instanceof Level) {
final Level targetLevel = (Level) node;
if (!validateRelationshipToLevel(relationship, specNode, targetLevel)) {
error = true;
}
}
} else if (relationship instanceof TopicRelationship) {
final SpecTopic relatedTopic = ((TopicRelationship) relationship).getSecondaryRelationship();
if (!validateRelationshipToTopic(relationship, specNode, relatedId, relatedTopic, specTopicMap)) {
error = true;
}
}
}
}
return !error;
}
|
[
"public",
"boolean",
"preValidateRelationships",
"(",
"final",
"ContentSpec",
"contentSpec",
")",
"{",
"boolean",
"error",
"=",
"false",
";",
"// Create the map of unique ids to spec topics",
"final",
"Map",
"<",
"String",
",",
"List",
"<",
"ITopicNode",
">",
">",
"specTopicMap",
"=",
"ContentSpecUtilities",
".",
"getIdTopicNodeMap",
"(",
"contentSpec",
")",
";",
"final",
"Map",
"<",
"SpecNodeWithRelationships",
",",
"List",
"<",
"Relationship",
">",
">",
"relationships",
"=",
"contentSpec",
".",
"getRelationships",
"(",
")",
";",
"for",
"(",
"final",
"Entry",
"<",
"SpecNodeWithRelationships",
",",
"List",
"<",
"Relationship",
">",
">",
"relationshipEntry",
":",
"relationships",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"SpecNodeWithRelationships",
"specNode",
"=",
"relationshipEntry",
".",
"getKey",
"(",
")",
";",
"// Check if the app should be shutdown",
"if",
"(",
"isShuttingDown",
".",
"get",
"(",
")",
")",
"{",
"shutdown",
".",
"set",
"(",
"true",
")",
";",
"return",
"false",
";",
"}",
"for",
"(",
"final",
"Relationship",
"relationship",
":",
"relationshipEntry",
".",
"getValue",
"(",
")",
")",
"{",
"// Check if the app should be shutdown",
"if",
"(",
"isShuttingDown",
".",
"get",
"(",
")",
")",
"{",
"shutdown",
".",
"set",
"(",
"true",
")",
";",
"return",
"false",
";",
"}",
"final",
"String",
"relatedId",
"=",
"relationship",
".",
"getSecondaryRelationshipId",
"(",
")",
";",
"// The relationship points to a target so it must be a level or topic",
"if",
"(",
"relationship",
"instanceof",
"TargetRelationship",
")",
"{",
"final",
"SpecNode",
"node",
"=",
"(",
"(",
"TargetRelationship",
")",
"relationship",
")",
".",
"getSecondaryRelationship",
"(",
")",
";",
"if",
"(",
"node",
"instanceof",
"SpecTopic",
")",
"{",
"final",
"SpecTopic",
"targetTopic",
"=",
"(",
"SpecTopic",
")",
"node",
";",
"if",
"(",
"!",
"validateRelationshipToTopic",
"(",
"relationship",
",",
"specNode",
",",
"relatedId",
",",
"targetTopic",
",",
"specTopicMap",
")",
")",
"{",
"error",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"node",
"instanceof",
"Level",
")",
"{",
"final",
"Level",
"targetLevel",
"=",
"(",
"Level",
")",
"node",
";",
"if",
"(",
"!",
"validateRelationshipToLevel",
"(",
"relationship",
",",
"specNode",
",",
"targetLevel",
")",
")",
"{",
"error",
"=",
"true",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"relationship",
"instanceof",
"TopicRelationship",
")",
"{",
"final",
"SpecTopic",
"relatedTopic",
"=",
"(",
"(",
"TopicRelationship",
")",
"relationship",
")",
".",
"getSecondaryRelationship",
"(",
")",
";",
"if",
"(",
"!",
"validateRelationshipToTopic",
"(",
"relationship",
",",
"specNode",
",",
"relatedId",
",",
"relatedTopic",
",",
"specTopicMap",
")",
")",
"{",
"error",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"return",
"!",
"error",
";",
"}"
] |
Validate a set of relationships created when parsing.
@param contentSpec The content spec to be validated.
@return True if the relationships are valid, otherwise false.
|
[
"Validate",
"a",
"set",
"of",
"relationships",
"created",
"when",
"parsing",
"."
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L929-L976
|
153,872
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.validateFixedUrl
|
protected boolean validateFixedUrl(final SpecNode specNode, final Set<String> processedFixedUrls) {
boolean valid = true;
if (!ProcessorConstants.VALID_FIXED_URL_PATTERN.matcher(specNode.getFixedUrl()).matches()) {
log.error(format(ProcessorConstants.ERROR_FIXED_URL_NOT_VALID, specNode.getLineNumber(), specNode.getText()));
valid = false;
} else if (processedFixedUrls.contains(specNode.getFixedUrl())) {
log.error(format(ProcessorConstants.ERROR_FIXED_URL_NOT_UNIQUE, specNode.getLineNumber(), specNode.getFixedUrl(),
specNode.getText()));
valid = false;
}
return valid;
}
|
java
|
protected boolean validateFixedUrl(final SpecNode specNode, final Set<String> processedFixedUrls) {
boolean valid = true;
if (!ProcessorConstants.VALID_FIXED_URL_PATTERN.matcher(specNode.getFixedUrl()).matches()) {
log.error(format(ProcessorConstants.ERROR_FIXED_URL_NOT_VALID, specNode.getLineNumber(), specNode.getText()));
valid = false;
} else if (processedFixedUrls.contains(specNode.getFixedUrl())) {
log.error(format(ProcessorConstants.ERROR_FIXED_URL_NOT_UNIQUE, specNode.getLineNumber(), specNode.getFixedUrl(),
specNode.getText()));
valid = false;
}
return valid;
}
|
[
"protected",
"boolean",
"validateFixedUrl",
"(",
"final",
"SpecNode",
"specNode",
",",
"final",
"Set",
"<",
"String",
">",
"processedFixedUrls",
")",
"{",
"boolean",
"valid",
"=",
"true",
";",
"if",
"(",
"!",
"ProcessorConstants",
".",
"VALID_FIXED_URL_PATTERN",
".",
"matcher",
"(",
"specNode",
".",
"getFixedUrl",
"(",
")",
")",
".",
"matches",
"(",
")",
")",
"{",
"log",
".",
"error",
"(",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_FIXED_URL_NOT_VALID",
",",
"specNode",
".",
"getLineNumber",
"(",
")",
",",
"specNode",
".",
"getText",
"(",
")",
")",
")",
";",
"valid",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"processedFixedUrls",
".",
"contains",
"(",
"specNode",
".",
"getFixedUrl",
"(",
")",
")",
")",
"{",
"log",
".",
"error",
"(",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_FIXED_URL_NOT_UNIQUE",
",",
"specNode",
".",
"getLineNumber",
"(",
")",
",",
"specNode",
".",
"getFixedUrl",
"(",
")",
",",
"specNode",
".",
"getText",
"(",
")",
")",
")",
";",
"valid",
"=",
"false",
";",
"}",
"return",
"valid",
";",
"}"
] |
Checks to make sure that a user defined fixed url is valid
@param specNode
@param processedFixedUrls
@return
|
[
"Checks",
"to",
"make",
"sure",
"that",
"a",
"user",
"defined",
"fixed",
"url",
"is",
"valid"
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L1585-L1598
|
153,873
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.preValidateCommonContent
|
protected boolean preValidateCommonContent(final CommonContent commonContent, final BookType bookType) {
boolean valid = true;
// Check if the app should be shutdown
if (isShuttingDown.get()) {
shutdown.set(true);
return false;
}
// Check that the title exists
if (isNullOrEmpty(commonContent.getTitle())) {
log.error(String.format(ProcessorConstants.ERROR_COMMON_CONTENT_NO_TITLE_MSG, commonContent.getLineNumber(), commonContent.getText()));
valid = false;
}
if ((bookType == BookType.BOOK || bookType == BookType.BOOK_DRAFT)) {
final Level parent = commonContent.getParent();
// Check that the common content is inside a chapter/section/process/appendix/part/preface
final LevelType parentLevelType = parent.getLevelType();
if (parent == null || parentLevelType == LevelType.BASE) {
log.error(format(ProcessorConstants.ERROR_COMMON_CONTENT_OUTSIDE_CHAPTER_MSG, commonContent.getLineNumber(),
commonContent.getText()));
valid = false;
}
// Check that there are no levels in the parent part (ie the common content is in the intro)
if (parent != null && parentLevelType == LevelType.PART) {
final List<Node> parentChildren = parent.getChildNodes();
final int index = parentChildren.indexOf(commonContent);
for (int i = 0; i < index; i++) {
final Node node = parentChildren.get(i);
if (node instanceof Level && ((Level) node).getLevelType() != LevelType.INITIAL_CONTENT) {
log.error(String.format(ProcessorConstants.ERROR_COMMON_CONTENT_NOT_IN_PART_INTRO_MSG,
commonContent.getLineNumber(), commonContent.getText()));
valid = false;
break;
}
}
}
}
// Check that the common content doesn't ahve a fixed url and if it does then print a warning
if (!isNullOrEmpty(commonContent.getFixedUrl())) {
log.warn(format(ProcessorConstants.WARN_FIXED_URL_WILL_BE_IGNORED_MSG, commonContent.getLineNumber(), commonContent.getText()));
commonContent.setFixedUrl(null);
}
// Check for known common content and warn the user if it's not known
if (!ProcessorConstants.KNOWN_COMMON_CONTENT.contains(commonContent.getFixedTitle())) {
log.warn(format(ProcessorConstants.WARN_UNRECOGNISED_COMMON_CONTENT_MSG, commonContent.getLineNumber(), commonContent.getText()));
}
return valid;
}
|
java
|
protected boolean preValidateCommonContent(final CommonContent commonContent, final BookType bookType) {
boolean valid = true;
// Check if the app should be shutdown
if (isShuttingDown.get()) {
shutdown.set(true);
return false;
}
// Check that the title exists
if (isNullOrEmpty(commonContent.getTitle())) {
log.error(String.format(ProcessorConstants.ERROR_COMMON_CONTENT_NO_TITLE_MSG, commonContent.getLineNumber(), commonContent.getText()));
valid = false;
}
if ((bookType == BookType.BOOK || bookType == BookType.BOOK_DRAFT)) {
final Level parent = commonContent.getParent();
// Check that the common content is inside a chapter/section/process/appendix/part/preface
final LevelType parentLevelType = parent.getLevelType();
if (parent == null || parentLevelType == LevelType.BASE) {
log.error(format(ProcessorConstants.ERROR_COMMON_CONTENT_OUTSIDE_CHAPTER_MSG, commonContent.getLineNumber(),
commonContent.getText()));
valid = false;
}
// Check that there are no levels in the parent part (ie the common content is in the intro)
if (parent != null && parentLevelType == LevelType.PART) {
final List<Node> parentChildren = parent.getChildNodes();
final int index = parentChildren.indexOf(commonContent);
for (int i = 0; i < index; i++) {
final Node node = parentChildren.get(i);
if (node instanceof Level && ((Level) node).getLevelType() != LevelType.INITIAL_CONTENT) {
log.error(String.format(ProcessorConstants.ERROR_COMMON_CONTENT_NOT_IN_PART_INTRO_MSG,
commonContent.getLineNumber(), commonContent.getText()));
valid = false;
break;
}
}
}
}
// Check that the common content doesn't ahve a fixed url and if it does then print a warning
if (!isNullOrEmpty(commonContent.getFixedUrl())) {
log.warn(format(ProcessorConstants.WARN_FIXED_URL_WILL_BE_IGNORED_MSG, commonContent.getLineNumber(), commonContent.getText()));
commonContent.setFixedUrl(null);
}
// Check for known common content and warn the user if it's not known
if (!ProcessorConstants.KNOWN_COMMON_CONTENT.contains(commonContent.getFixedTitle())) {
log.warn(format(ProcessorConstants.WARN_UNRECOGNISED_COMMON_CONTENT_MSG, commonContent.getLineNumber(), commonContent.getText()));
}
return valid;
}
|
[
"protected",
"boolean",
"preValidateCommonContent",
"(",
"final",
"CommonContent",
"commonContent",
",",
"final",
"BookType",
"bookType",
")",
"{",
"boolean",
"valid",
"=",
"true",
";",
"// Check if the app should be shutdown",
"if",
"(",
"isShuttingDown",
".",
"get",
"(",
")",
")",
"{",
"shutdown",
".",
"set",
"(",
"true",
")",
";",
"return",
"false",
";",
"}",
"// Check that the title exists",
"if",
"(",
"isNullOrEmpty",
"(",
"commonContent",
".",
"getTitle",
"(",
")",
")",
")",
"{",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_COMMON_CONTENT_NO_TITLE_MSG",
",",
"commonContent",
".",
"getLineNumber",
"(",
")",
",",
"commonContent",
".",
"getText",
"(",
")",
")",
")",
";",
"valid",
"=",
"false",
";",
"}",
"if",
"(",
"(",
"bookType",
"==",
"BookType",
".",
"BOOK",
"||",
"bookType",
"==",
"BookType",
".",
"BOOK_DRAFT",
")",
")",
"{",
"final",
"Level",
"parent",
"=",
"commonContent",
".",
"getParent",
"(",
")",
";",
"// Check that the common content is inside a chapter/section/process/appendix/part/preface",
"final",
"LevelType",
"parentLevelType",
"=",
"parent",
".",
"getLevelType",
"(",
")",
";",
"if",
"(",
"parent",
"==",
"null",
"||",
"parentLevelType",
"==",
"LevelType",
".",
"BASE",
")",
"{",
"log",
".",
"error",
"(",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_COMMON_CONTENT_OUTSIDE_CHAPTER_MSG",
",",
"commonContent",
".",
"getLineNumber",
"(",
")",
",",
"commonContent",
".",
"getText",
"(",
")",
")",
")",
";",
"valid",
"=",
"false",
";",
"}",
"// Check that there are no levels in the parent part (ie the common content is in the intro)",
"if",
"(",
"parent",
"!=",
"null",
"&&",
"parentLevelType",
"==",
"LevelType",
".",
"PART",
")",
"{",
"final",
"List",
"<",
"Node",
">",
"parentChildren",
"=",
"parent",
".",
"getChildNodes",
"(",
")",
";",
"final",
"int",
"index",
"=",
"parentChildren",
".",
"indexOf",
"(",
"commonContent",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"index",
";",
"i",
"++",
")",
"{",
"final",
"Node",
"node",
"=",
"parentChildren",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"node",
"instanceof",
"Level",
"&&",
"(",
"(",
"Level",
")",
"node",
")",
".",
"getLevelType",
"(",
")",
"!=",
"LevelType",
".",
"INITIAL_CONTENT",
")",
"{",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_COMMON_CONTENT_NOT_IN_PART_INTRO_MSG",
",",
"commonContent",
".",
"getLineNumber",
"(",
")",
",",
"commonContent",
".",
"getText",
"(",
")",
")",
")",
";",
"valid",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"}",
"// Check that the common content doesn't ahve a fixed url and if it does then print a warning",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"commonContent",
".",
"getFixedUrl",
"(",
")",
")",
")",
"{",
"log",
".",
"warn",
"(",
"format",
"(",
"ProcessorConstants",
".",
"WARN_FIXED_URL_WILL_BE_IGNORED_MSG",
",",
"commonContent",
".",
"getLineNumber",
"(",
")",
",",
"commonContent",
".",
"getText",
"(",
")",
")",
")",
";",
"commonContent",
".",
"setFixedUrl",
"(",
"null",
")",
";",
"}",
"// Check for known common content and warn the user if it's not known",
"if",
"(",
"!",
"ProcessorConstants",
".",
"KNOWN_COMMON_CONTENT",
".",
"contains",
"(",
"commonContent",
".",
"getFixedTitle",
"(",
")",
")",
")",
"{",
"log",
".",
"warn",
"(",
"format",
"(",
"ProcessorConstants",
".",
"WARN_UNRECOGNISED_COMMON_CONTENT_MSG",
",",
"commonContent",
".",
"getLineNumber",
"(",
")",
",",
"commonContent",
".",
"getText",
"(",
")",
")",
")",
";",
"}",
"return",
"valid",
";",
"}"
] |
Validates a Common Content node for formatting issues.
@param commonContent The common content to be validated.
@param bookType The type of book the common content is to be validated against.
@return True if the common content is valid otherwise false.
|
[
"Validates",
"a",
"Common",
"Content",
"node",
"for",
"formatting",
"issues",
"."
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L1725-L1779
|
153,874
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.validateExistingTopicTags
|
private boolean validateExistingTopicTags(final ITopicNode topicNode, final BaseTopicWrapper<?> topic) {
// Ignore validating revision topics
if (topicNode.getRevision() != null) {
return true;
}
boolean valid = true;
final List<String> tagNames = topicNode.getTags(true);
if (!tagNames.isEmpty()) {
final Set<TagWrapper> tags = new HashSet<TagWrapper>();
for (final String tagName : tagNames) {
// Check if the app should be shutdown
if (isShuttingDown.get()) {
shutdown.set(true);
return false;
}
// Get the tag from the database
TagWrapper tag = null;
try {
tag = tagProvider.getTagByName(tagName);
} catch (NotFoundException e) {
}
// Check that it exists
if (tag != null) {
tags.add(tag);
}
}
// Add all the existing tags
if (topic.getTags() != null) {
tags.addAll(topic.getTags().getItems());
}
// Check that the mutex value entered is correct
final Map<Integer, List<TagWrapper>> mapping = EntityUtilities.getCategoryMappingFromTagList(tags);
for (final Entry<Integer, List<TagWrapper>> catEntry : mapping.entrySet()) {
final CategoryWrapper cat = categoryProvider.getCategory(catEntry.getKey());
final List<TagWrapper> catTags = catEntry.getValue();
// Check if the app should be shutdown
if (isShuttingDown.get()) {
shutdown.set(true);
return false;
}
// Check that only one tag has been set if the category is mutually exclusive
if (cat.isMutuallyExclusive() && catTags.size() > 1) {
log.error(String.format(ProcessorConstants.ERROR_TOPIC_TOO_MANY_CATS_MSG, topicNode.getLineNumber(), cat.getName(),
topicNode.getText()));
valid = false;
}
}
}
return valid;
}
|
java
|
private boolean validateExistingTopicTags(final ITopicNode topicNode, final BaseTopicWrapper<?> topic) {
// Ignore validating revision topics
if (topicNode.getRevision() != null) {
return true;
}
boolean valid = true;
final List<String> tagNames = topicNode.getTags(true);
if (!tagNames.isEmpty()) {
final Set<TagWrapper> tags = new HashSet<TagWrapper>();
for (final String tagName : tagNames) {
// Check if the app should be shutdown
if (isShuttingDown.get()) {
shutdown.set(true);
return false;
}
// Get the tag from the database
TagWrapper tag = null;
try {
tag = tagProvider.getTagByName(tagName);
} catch (NotFoundException e) {
}
// Check that it exists
if (tag != null) {
tags.add(tag);
}
}
// Add all the existing tags
if (topic.getTags() != null) {
tags.addAll(topic.getTags().getItems());
}
// Check that the mutex value entered is correct
final Map<Integer, List<TagWrapper>> mapping = EntityUtilities.getCategoryMappingFromTagList(tags);
for (final Entry<Integer, List<TagWrapper>> catEntry : mapping.entrySet()) {
final CategoryWrapper cat = categoryProvider.getCategory(catEntry.getKey());
final List<TagWrapper> catTags = catEntry.getValue();
// Check if the app should be shutdown
if (isShuttingDown.get()) {
shutdown.set(true);
return false;
}
// Check that only one tag has been set if the category is mutually exclusive
if (cat.isMutuallyExclusive() && catTags.size() > 1) {
log.error(String.format(ProcessorConstants.ERROR_TOPIC_TOO_MANY_CATS_MSG, topicNode.getLineNumber(), cat.getName(),
topicNode.getText()));
valid = false;
}
}
}
return valid;
}
|
[
"private",
"boolean",
"validateExistingTopicTags",
"(",
"final",
"ITopicNode",
"topicNode",
",",
"final",
"BaseTopicWrapper",
"<",
"?",
">",
"topic",
")",
"{",
"// Ignore validating revision topics",
"if",
"(",
"topicNode",
".",
"getRevision",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"true",
";",
"}",
"boolean",
"valid",
"=",
"true",
";",
"final",
"List",
"<",
"String",
">",
"tagNames",
"=",
"topicNode",
".",
"getTags",
"(",
"true",
")",
";",
"if",
"(",
"!",
"tagNames",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"Set",
"<",
"TagWrapper",
">",
"tags",
"=",
"new",
"HashSet",
"<",
"TagWrapper",
">",
"(",
")",
";",
"for",
"(",
"final",
"String",
"tagName",
":",
"tagNames",
")",
"{",
"// Check if the app should be shutdown",
"if",
"(",
"isShuttingDown",
".",
"get",
"(",
")",
")",
"{",
"shutdown",
".",
"set",
"(",
"true",
")",
";",
"return",
"false",
";",
"}",
"// Get the tag from the database",
"TagWrapper",
"tag",
"=",
"null",
";",
"try",
"{",
"tag",
"=",
"tagProvider",
".",
"getTagByName",
"(",
"tagName",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"e",
")",
"{",
"}",
"// Check that it exists",
"if",
"(",
"tag",
"!=",
"null",
")",
"{",
"tags",
".",
"add",
"(",
"tag",
")",
";",
"}",
"}",
"// Add all the existing tags",
"if",
"(",
"topic",
".",
"getTags",
"(",
")",
"!=",
"null",
")",
"{",
"tags",
".",
"addAll",
"(",
"topic",
".",
"getTags",
"(",
")",
".",
"getItems",
"(",
")",
")",
";",
"}",
"// Check that the mutex value entered is correct",
"final",
"Map",
"<",
"Integer",
",",
"List",
"<",
"TagWrapper",
">",
">",
"mapping",
"=",
"EntityUtilities",
".",
"getCategoryMappingFromTagList",
"(",
"tags",
")",
";",
"for",
"(",
"final",
"Entry",
"<",
"Integer",
",",
"List",
"<",
"TagWrapper",
">",
">",
"catEntry",
":",
"mapping",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"CategoryWrapper",
"cat",
"=",
"categoryProvider",
".",
"getCategory",
"(",
"catEntry",
".",
"getKey",
"(",
")",
")",
";",
"final",
"List",
"<",
"TagWrapper",
">",
"catTags",
"=",
"catEntry",
".",
"getValue",
"(",
")",
";",
"// Check if the app should be shutdown",
"if",
"(",
"isShuttingDown",
".",
"get",
"(",
")",
")",
"{",
"shutdown",
".",
"set",
"(",
"true",
")",
";",
"return",
"false",
";",
"}",
"// Check that only one tag has been set if the category is mutually exclusive",
"if",
"(",
"cat",
".",
"isMutuallyExclusive",
"(",
")",
"&&",
"catTags",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"log",
".",
"error",
"(",
"String",
".",
"format",
"(",
"ProcessorConstants",
".",
"ERROR_TOPIC_TOO_MANY_CATS_MSG",
",",
"topicNode",
".",
"getLineNumber",
"(",
")",
",",
"cat",
".",
"getName",
"(",
")",
",",
"topicNode",
".",
"getText",
"(",
")",
")",
")",
";",
"valid",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"valid",
";",
"}"
] |
Checks that adding tags to existing topic won't cause problems
@param topicNode The topic the tags below to.
@return True if the tags are valid otherwise false.
|
[
"Checks",
"that",
"adding",
"tags",
"to",
"existing",
"topic",
"won",
"t",
"cause",
"problems"
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L2278-L2334
|
153,875
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.preValidateBugLinks
|
public boolean preValidateBugLinks(final ContentSpec contentSpec) {
// If Bug Links are turned off then there isn't any need to validate them.
if (!contentSpec.isInjectBugLinks()) {
return true;
}
final BugLinkOptions bugOptions;
final BugLinkType type;
if (contentSpec.getBugLinks().equals(BugLinkType.JIRA)) {
type = BugLinkType.JIRA;
bugOptions = contentSpec.getJIRABugLinkOptions();
} else {
type = BugLinkType.BUGZILLA;
bugOptions = contentSpec.getBugzillaBugLinkOptions();
}
final BaseBugLinkStrategy bugLinkStrategy = BugLinkStrategyFactory.getInstance().create(type, bugOptions.getBaseUrl());
// Validate the content in the bug options using the appropriate bug link strategy
try {
bugLinkStrategy.checkValidValues(bugOptions);
} catch (ValidationException e) {
final Throwable cause = ExceptionUtilities.getRootCause(e);
log.error(cause.getMessage());
return false;
}
return true;
}
|
java
|
public boolean preValidateBugLinks(final ContentSpec contentSpec) {
// If Bug Links are turned off then there isn't any need to validate them.
if (!contentSpec.isInjectBugLinks()) {
return true;
}
final BugLinkOptions bugOptions;
final BugLinkType type;
if (contentSpec.getBugLinks().equals(BugLinkType.JIRA)) {
type = BugLinkType.JIRA;
bugOptions = contentSpec.getJIRABugLinkOptions();
} else {
type = BugLinkType.BUGZILLA;
bugOptions = contentSpec.getBugzillaBugLinkOptions();
}
final BaseBugLinkStrategy bugLinkStrategy = BugLinkStrategyFactory.getInstance().create(type, bugOptions.getBaseUrl());
// Validate the content in the bug options using the appropriate bug link strategy
try {
bugLinkStrategy.checkValidValues(bugOptions);
} catch (ValidationException e) {
final Throwable cause = ExceptionUtilities.getRootCause(e);
log.error(cause.getMessage());
return false;
}
return true;
}
|
[
"public",
"boolean",
"preValidateBugLinks",
"(",
"final",
"ContentSpec",
"contentSpec",
")",
"{",
"// If Bug Links are turned off then there isn't any need to validate them.",
"if",
"(",
"!",
"contentSpec",
".",
"isInjectBugLinks",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"final",
"BugLinkOptions",
"bugOptions",
";",
"final",
"BugLinkType",
"type",
";",
"if",
"(",
"contentSpec",
".",
"getBugLinks",
"(",
")",
".",
"equals",
"(",
"BugLinkType",
".",
"JIRA",
")",
")",
"{",
"type",
"=",
"BugLinkType",
".",
"JIRA",
";",
"bugOptions",
"=",
"contentSpec",
".",
"getJIRABugLinkOptions",
"(",
")",
";",
"}",
"else",
"{",
"type",
"=",
"BugLinkType",
".",
"BUGZILLA",
";",
"bugOptions",
"=",
"contentSpec",
".",
"getBugzillaBugLinkOptions",
"(",
")",
";",
"}",
"final",
"BaseBugLinkStrategy",
"bugLinkStrategy",
"=",
"BugLinkStrategyFactory",
".",
"getInstance",
"(",
")",
".",
"create",
"(",
"type",
",",
"bugOptions",
".",
"getBaseUrl",
"(",
")",
")",
";",
"// Validate the content in the bug options using the appropriate bug link strategy",
"try",
"{",
"bugLinkStrategy",
".",
"checkValidValues",
"(",
"bugOptions",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"e",
")",
"{",
"final",
"Throwable",
"cause",
"=",
"ExceptionUtilities",
".",
"getRootCause",
"(",
"e",
")",
";",
"log",
".",
"error",
"(",
"cause",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Validate the Bug Links MetaData for a Content Specification without doing any external calls.
@param contentSpec The Content Spec to validate.
@return True if the links values are valid, otherwise false.
|
[
"Validate",
"the",
"Bug",
"Links",
"MetaData",
"for",
"a",
"Content",
"Specification",
"without",
"doing",
"any",
"external",
"calls",
"."
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L2342-L2369
|
153,876
|
pressgang-ccms/PressGangCCMSContentSpecProcessor
|
src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java
|
ContentSpecValidator.postValidateBugLinks
|
public boolean postValidateBugLinks(final ContentSpec contentSpec, boolean strict) {
// If Bug Links are turned off then there isn't any need to validate them.
if (!contentSpec.isInjectBugLinks()) {
return true;
}
try {
final BugLinkOptions bugOptions;
final BugLinkType type;
if (contentSpec.getBugLinks().equals(BugLinkType.JIRA)) {
type = BugLinkType.JIRA;
bugOptions = contentSpec.getJIRABugLinkOptions();
} else {
type = BugLinkType.BUGZILLA;
bugOptions = contentSpec.getBugzillaBugLinkOptions();
}
final BaseBugLinkStrategy bugLinkStrategy = BugLinkStrategyFactory.getInstance().create(type, bugOptions.getBaseUrl());
// This step should have been performed by the preValidate method, so just make sure incase it hasn't been called.
try {
bugLinkStrategy.checkValidValues(bugOptions);
} catch (ValidationException e) {
return false;
}
// Validate the content in the bug options against the external service using the appropriate bug link strategy
try {
bugLinkStrategy.validate(bugOptions);
} catch (ValidationException e) {
final Throwable cause = ExceptionUtilities.getRootCause(e);
if (strict) {
log.error(cause.getMessage());
return false;
} else {
log.warn(cause.getMessage());
}
}
return true;
} catch (Exception e) {
if (e instanceof ConnectException || e instanceof MalformedURLException) {
if (strict) {
log.error(ProcessorConstants.ERROR_BUG_LINKS_UNABLE_TO_CONNECT);
return false;
} else {
log.warn(ProcessorConstants.ERROR_BUG_LINKS_UNABLE_TO_CONNECT);
}
} else if (e.getCause() instanceof ConnectionException) {
if (strict) {
log.error(ProcessorConstants.ERROR_BUGZILLA_UNABLE_TO_CONNECT);
return false;
} else {
log.warn(ProcessorConstants.ERROR_BUGZILLA_UNABLE_TO_CONNECT);
}
} else {
if (strict) {
log.error(ProcessorConstants.ERROR_BUG_LINKS_UNABLE_TO_VALIDATE);
log.error(e.toString());
return false;
} else {
log.warn(ProcessorConstants.ERROR_BUG_LINKS_UNABLE_TO_VALIDATE);
log.warn(e.toString());
}
}
}
return true;
}
|
java
|
public boolean postValidateBugLinks(final ContentSpec contentSpec, boolean strict) {
// If Bug Links are turned off then there isn't any need to validate them.
if (!contentSpec.isInjectBugLinks()) {
return true;
}
try {
final BugLinkOptions bugOptions;
final BugLinkType type;
if (contentSpec.getBugLinks().equals(BugLinkType.JIRA)) {
type = BugLinkType.JIRA;
bugOptions = contentSpec.getJIRABugLinkOptions();
} else {
type = BugLinkType.BUGZILLA;
bugOptions = contentSpec.getBugzillaBugLinkOptions();
}
final BaseBugLinkStrategy bugLinkStrategy = BugLinkStrategyFactory.getInstance().create(type, bugOptions.getBaseUrl());
// This step should have been performed by the preValidate method, so just make sure incase it hasn't been called.
try {
bugLinkStrategy.checkValidValues(bugOptions);
} catch (ValidationException e) {
return false;
}
// Validate the content in the bug options against the external service using the appropriate bug link strategy
try {
bugLinkStrategy.validate(bugOptions);
} catch (ValidationException e) {
final Throwable cause = ExceptionUtilities.getRootCause(e);
if (strict) {
log.error(cause.getMessage());
return false;
} else {
log.warn(cause.getMessage());
}
}
return true;
} catch (Exception e) {
if (e instanceof ConnectException || e instanceof MalformedURLException) {
if (strict) {
log.error(ProcessorConstants.ERROR_BUG_LINKS_UNABLE_TO_CONNECT);
return false;
} else {
log.warn(ProcessorConstants.ERROR_BUG_LINKS_UNABLE_TO_CONNECT);
}
} else if (e.getCause() instanceof ConnectionException) {
if (strict) {
log.error(ProcessorConstants.ERROR_BUGZILLA_UNABLE_TO_CONNECT);
return false;
} else {
log.warn(ProcessorConstants.ERROR_BUGZILLA_UNABLE_TO_CONNECT);
}
} else {
if (strict) {
log.error(ProcessorConstants.ERROR_BUG_LINKS_UNABLE_TO_VALIDATE);
log.error(e.toString());
return false;
} else {
log.warn(ProcessorConstants.ERROR_BUG_LINKS_UNABLE_TO_VALIDATE);
log.warn(e.toString());
}
}
}
return true;
}
|
[
"public",
"boolean",
"postValidateBugLinks",
"(",
"final",
"ContentSpec",
"contentSpec",
",",
"boolean",
"strict",
")",
"{",
"// If Bug Links are turned off then there isn't any need to validate them.",
"if",
"(",
"!",
"contentSpec",
".",
"isInjectBugLinks",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"final",
"BugLinkOptions",
"bugOptions",
";",
"final",
"BugLinkType",
"type",
";",
"if",
"(",
"contentSpec",
".",
"getBugLinks",
"(",
")",
".",
"equals",
"(",
"BugLinkType",
".",
"JIRA",
")",
")",
"{",
"type",
"=",
"BugLinkType",
".",
"JIRA",
";",
"bugOptions",
"=",
"contentSpec",
".",
"getJIRABugLinkOptions",
"(",
")",
";",
"}",
"else",
"{",
"type",
"=",
"BugLinkType",
".",
"BUGZILLA",
";",
"bugOptions",
"=",
"contentSpec",
".",
"getBugzillaBugLinkOptions",
"(",
")",
";",
"}",
"final",
"BaseBugLinkStrategy",
"bugLinkStrategy",
"=",
"BugLinkStrategyFactory",
".",
"getInstance",
"(",
")",
".",
"create",
"(",
"type",
",",
"bugOptions",
".",
"getBaseUrl",
"(",
")",
")",
";",
"// This step should have been performed by the preValidate method, so just make sure incase it hasn't been called.",
"try",
"{",
"bugLinkStrategy",
".",
"checkValidValues",
"(",
"bugOptions",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"// Validate the content in the bug options against the external service using the appropriate bug link strategy",
"try",
"{",
"bugLinkStrategy",
".",
"validate",
"(",
"bugOptions",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"e",
")",
"{",
"final",
"Throwable",
"cause",
"=",
"ExceptionUtilities",
".",
"getRootCause",
"(",
"e",
")",
";",
"if",
"(",
"strict",
")",
"{",
"log",
".",
"error",
"(",
"cause",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"cause",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"ConnectException",
"||",
"e",
"instanceof",
"MalformedURLException",
")",
"{",
"if",
"(",
"strict",
")",
"{",
"log",
".",
"error",
"(",
"ProcessorConstants",
".",
"ERROR_BUG_LINKS_UNABLE_TO_CONNECT",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"ProcessorConstants",
".",
"ERROR_BUG_LINKS_UNABLE_TO_CONNECT",
")",
";",
"}",
"}",
"else",
"if",
"(",
"e",
".",
"getCause",
"(",
")",
"instanceof",
"ConnectionException",
")",
"{",
"if",
"(",
"strict",
")",
"{",
"log",
".",
"error",
"(",
"ProcessorConstants",
".",
"ERROR_BUGZILLA_UNABLE_TO_CONNECT",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"ProcessorConstants",
".",
"ERROR_BUGZILLA_UNABLE_TO_CONNECT",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"strict",
")",
"{",
"log",
".",
"error",
"(",
"ProcessorConstants",
".",
"ERROR_BUG_LINKS_UNABLE_TO_VALIDATE",
")",
";",
"log",
".",
"error",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"log",
".",
"warn",
"(",
"ProcessorConstants",
".",
"ERROR_BUG_LINKS_UNABLE_TO_VALIDATE",
")",
";",
"log",
".",
"warn",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] |
Validate the Bug Links MetaData for a Content Specification.
@param contentSpec The Content Spec to validate.
@param strict If strict validation should be performed (invalid matches throws an error instead of a warning)
@return True if the links are valid, otherwise false.
|
[
"Validate",
"the",
"Bug",
"Links",
"MetaData",
"for",
"a",
"Content",
"Specification",
"."
] |
85ffac047c4ede0f972364ab1f03f7d61a4de5f1
|
https://github.com/pressgang-ccms/PressGangCCMSContentSpecProcessor/blob/85ffac047c4ede0f972364ab1f03f7d61a4de5f1/src/main/java/org/jboss/pressgang/ccms/contentspec/processor/ContentSpecValidator.java#L2378-L2445
|
153,877
|
attribyte/wpdb
|
src/main/java/org/attribyte/wp/model/BlockParser.java
|
BlockParser.removeEmptyBlocks
|
public static List<Block> removeEmptyBlocks(final Collection<Block> blocks) {
List<Block> cleanBlocks = Lists.newArrayListWithExpectedSize(blocks.size());
for(Block block : blocks) {
if(block.content.isEmpty()) {
continue;
}
if(isWhitespace(block.content)) {
continue;
}
cleanBlocks.add(block);
}
return cleanBlocks;
}
|
java
|
public static List<Block> removeEmptyBlocks(final Collection<Block> blocks) {
List<Block> cleanBlocks = Lists.newArrayListWithExpectedSize(blocks.size());
for(Block block : blocks) {
if(block.content.isEmpty()) {
continue;
}
if(isWhitespace(block.content)) {
continue;
}
cleanBlocks.add(block);
}
return cleanBlocks;
}
|
[
"public",
"static",
"List",
"<",
"Block",
">",
"removeEmptyBlocks",
"(",
"final",
"Collection",
"<",
"Block",
">",
"blocks",
")",
"{",
"List",
"<",
"Block",
">",
"cleanBlocks",
"=",
"Lists",
".",
"newArrayListWithExpectedSize",
"(",
"blocks",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Block",
"block",
":",
"blocks",
")",
"{",
"if",
"(",
"block",
".",
"content",
".",
"isEmpty",
"(",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"isWhitespace",
"(",
"block",
".",
"content",
")",
")",
"{",
"continue",
";",
"}",
"cleanBlocks",
".",
"add",
"(",
"block",
")",
";",
"}",
"return",
"cleanBlocks",
";",
"}"
] |
Removes empty blocks from a collection of blocks.
@param blocks The collection of blocks.
@return A list of blocks with empty blocks removed.
|
[
"Removes",
"empty",
"blocks",
"from",
"a",
"collection",
"of",
"blocks",
"."
] |
b9adf6131dfb67899ebff770c9bfeb001cc42f30
|
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/model/BlockParser.java#L133-L147
|
153,878
|
attribyte/wpdb
|
src/main/java/org/attribyte/wp/model/BlockParser.java
|
BlockParser.block
|
private static Block block(final String comment, final int nameStart) {
int attrIndex = comment.indexOf('{');
if(attrIndex != -1) {
return new Block(comment.substring(nameStart, attrIndex).trim(),
comment.substring(attrIndex).trim());
} else {
return new Block(comment.substring(nameStart).trim());
}
}
|
java
|
private static Block block(final String comment, final int nameStart) {
int attrIndex = comment.indexOf('{');
if(attrIndex != -1) {
return new Block(comment.substring(nameStart, attrIndex).trim(),
comment.substring(attrIndex).trim());
} else {
return new Block(comment.substring(nameStart).trim());
}
}
|
[
"private",
"static",
"Block",
"block",
"(",
"final",
"String",
"comment",
",",
"final",
"int",
"nameStart",
")",
"{",
"int",
"attrIndex",
"=",
"comment",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"attrIndex",
"!=",
"-",
"1",
")",
"{",
"return",
"new",
"Block",
"(",
"comment",
".",
"substring",
"(",
"nameStart",
",",
"attrIndex",
")",
".",
"trim",
"(",
")",
",",
"comment",
".",
"substring",
"(",
"attrIndex",
")",
".",
"trim",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Block",
"(",
"comment",
".",
"substring",
"(",
"nameStart",
")",
".",
"trim",
"(",
")",
")",
";",
"}",
"}"
] |
Creates an empty block from a comment string.
@param comment The comment string.
@param nameStart The start index for the name.
@return The block.
|
[
"Creates",
"an",
"empty",
"block",
"from",
"a",
"comment",
"string",
"."
] |
b9adf6131dfb67899ebff770c9bfeb001cc42f30
|
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/model/BlockParser.java#L183-L191
|
153,879
|
jeroenvanmaanen/bridge-pattern
|
src/main/java/org/leialearns/bridge/Static.java
|
Static.getFarObject
|
public static <FT extends FarObject<NT>, NT> FT getFarObject(NT nearObject, Class<FT> farType) {
return nearObject == null ? null : farType.cast(getFarObject(nearObject));
}
|
java
|
public static <FT extends FarObject<NT>, NT> FT getFarObject(NT nearObject, Class<FT> farType) {
return nearObject == null ? null : farType.cast(getFarObject(nearObject));
}
|
[
"public",
"static",
"<",
"FT",
"extends",
"FarObject",
"<",
"NT",
">",
",",
"NT",
">",
"FT",
"getFarObject",
"(",
"NT",
"nearObject",
",",
"Class",
"<",
"FT",
">",
"farType",
")",
"{",
"return",
"nearObject",
"==",
"null",
"?",
"null",
":",
"farType",
".",
"cast",
"(",
"getFarObject",
"(",
"nearObject",
")",
")",
";",
"}"
] |
Returns the far object that corresponds to the given near object in a type safe way.
@param nearObject The near object
@param farType The class that represents the type of the far object
@param <FT> The type of the far object
@param <NT> The type of the near object
@return The far object that corresponds to the given near object
@see BridgeFacets#getFarObject()
|
[
"Returns",
"the",
"far",
"object",
"that",
"corresponds",
"to",
"the",
"given",
"near",
"object",
"in",
"a",
"type",
"safe",
"way",
"."
] |
55bd2de8cff800a1a97e26e97d3600e6dfb00b59
|
https://github.com/jeroenvanmaanen/bridge-pattern/blob/55bd2de8cff800a1a97e26e97d3600e6dfb00b59/src/main/java/org/leialearns/bridge/Static.java#L30-L32
|
153,880
|
jeroenvanmaanen/bridge-pattern
|
src/main/java/org/leialearns/bridge/Static.java
|
Static.getFarObject
|
public static FarObject<?> getFarObject(Object nearObject) {
return nearObject == null ? null : getFacets(nearObject).getFarObject();
}
|
java
|
public static FarObject<?> getFarObject(Object nearObject) {
return nearObject == null ? null : getFacets(nearObject).getFarObject();
}
|
[
"public",
"static",
"FarObject",
"<",
"?",
">",
"getFarObject",
"(",
"Object",
"nearObject",
")",
"{",
"return",
"nearObject",
"==",
"null",
"?",
"null",
":",
"getFacets",
"(",
"nearObject",
")",
".",
"getFarObject",
"(",
")",
";",
"}"
] |
Returns the far object that corresponds to the given near object.
@param nearObject The near object
@return The far object that corresponds to the given near object
@see BridgeFacets#getFarObject()
|
[
"Returns",
"the",
"far",
"object",
"that",
"corresponds",
"to",
"the",
"given",
"near",
"object",
"."
] |
55bd2de8cff800a1a97e26e97d3600e6dfb00b59
|
https://github.com/jeroenvanmaanen/bridge-pattern/blob/55bd2de8cff800a1a97e26e97d3600e6dfb00b59/src/main/java/org/leialearns/bridge/Static.java#L40-L42
|
153,881
|
opendatatrentino/smatch-webapi-client
|
src/main/java/it/unitn/disi/smatch/webapi/client/WebApiClient.java
|
WebApiClient.getInstance
|
public static WebApiClient getInstance(Locale locale) {
if (null == webApiClient) {
webApiClient = new WebApiClient(locale);
}
return webApiClient;
}
|
java
|
public static WebApiClient getInstance(Locale locale) {
if (null == webApiClient) {
webApiClient = new WebApiClient(locale);
}
return webApiClient;
}
|
[
"public",
"static",
"WebApiClient",
"getInstance",
"(",
"Locale",
"locale",
")",
"{",
"if",
"(",
"null",
"==",
"webApiClient",
")",
"{",
"webApiClient",
"=",
"new",
"WebApiClient",
"(",
"locale",
")",
";",
"}",
"return",
"webApiClient",
";",
"}"
] |
Returns instance of web API client for given locale. This method use
default connection parameters from property configuration file.
@param locale language.
@return instance of web API client for given locale.
|
[
"Returns",
"instance",
"of",
"web",
"API",
"client",
"for",
"given",
"locale",
".",
"This",
"method",
"use",
"default",
"connection",
"parameters",
"from",
"property",
"configuration",
"file",
"."
] |
d74fc41ab5bdc29afafd11c9001ac25dff20f965
|
https://github.com/opendatatrentino/smatch-webapi-client/blob/d74fc41ab5bdc29afafd11c9001ac25dff20f965/src/main/java/it/unitn/disi/smatch/webapi/client/WebApiClient.java#L110-L115
|
153,882
|
opendatatrentino/smatch-webapi-client
|
src/main/java/it/unitn/disi/smatch/webapi/client/WebApiClient.java
|
WebApiClient.getInstance
|
public static WebApiClient getInstance(Locale locale, String host, int port) {
if (null == webApiClient) {
webApiClient = new WebApiClient(locale, host, "" + port);
}
return webApiClient;
}
|
java
|
public static WebApiClient getInstance(Locale locale, String host, int port) {
if (null == webApiClient) {
webApiClient = new WebApiClient(locale, host, "" + port);
}
return webApiClient;
}
|
[
"public",
"static",
"WebApiClient",
"getInstance",
"(",
"Locale",
"locale",
",",
"String",
"host",
",",
"int",
"port",
")",
"{",
"if",
"(",
"null",
"==",
"webApiClient",
")",
"{",
"webApiClient",
"=",
"new",
"WebApiClient",
"(",
"locale",
",",
"host",
",",
"\"\"",
"+",
"port",
")",
";",
"}",
"return",
"webApiClient",
";",
"}"
] |
Returns instance of web API client for given locale and connection
properties.
@param locale language.
@param host Sweb web API server host.
@param port Sweb web API server port.
@return instance of web API client for given locale and connection
properties.
|
[
"Returns",
"instance",
"of",
"web",
"API",
"client",
"for",
"given",
"locale",
"and",
"connection",
"properties",
"."
] |
d74fc41ab5bdc29afafd11c9001ac25dff20f965
|
https://github.com/opendatatrentino/smatch-webapi-client/blob/d74fc41ab5bdc29afafd11c9001ac25dff20f965/src/main/java/it/unitn/disi/smatch/webapi/client/WebApiClient.java#L127-L132
|
153,883
|
opendatatrentino/smatch-webapi-client
|
src/main/java/it/unitn/disi/smatch/webapi/client/WebApiClient.java
|
WebApiClient.match
|
@Override
public Correspondence match(String sourceName, List<String> sourceNodes,
String targetName, List<String> targetNodes) {
MatchMethods method = new MatchMethods(httpClient, locale, serverPath);
Correspondence correspondace = null;
try {
correspondace = method.match(sourceName, sourceNodes, targetName, targetNodes);
} catch (WebApiException ex) {
java.util.logging.Logger.getLogger(WebApiClient.class.getName()).log(Level.SEVERE, null, ex);
}
return correspondace;
}
|
java
|
@Override
public Correspondence match(String sourceName, List<String> sourceNodes,
String targetName, List<String> targetNodes) {
MatchMethods method = new MatchMethods(httpClient, locale, serverPath);
Correspondence correspondace = null;
try {
correspondace = method.match(sourceName, sourceNodes, targetName, targetNodes);
} catch (WebApiException ex) {
java.util.logging.Logger.getLogger(WebApiClient.class.getName()).log(Level.SEVERE, null, ex);
}
return correspondace;
}
|
[
"@",
"Override",
"public",
"Correspondence",
"match",
"(",
"String",
"sourceName",
",",
"List",
"<",
"String",
">",
"sourceNodes",
",",
"String",
"targetName",
",",
"List",
"<",
"String",
">",
"targetNodes",
")",
"{",
"MatchMethods",
"method",
"=",
"new",
"MatchMethods",
"(",
"httpClient",
",",
"locale",
",",
"serverPath",
")",
";",
"Correspondence",
"correspondace",
"=",
"null",
";",
"try",
"{",
"correspondace",
"=",
"method",
".",
"match",
"(",
"sourceName",
",",
"sourceNodes",
",",
"targetName",
",",
"targetNodes",
")",
";",
"}",
"catch",
"(",
"WebApiException",
"ex",
")",
"{",
"java",
".",
"util",
".",
"logging",
".",
"Logger",
".",
"getLogger",
"(",
"WebApiClient",
".",
"class",
".",
"getName",
"(",
")",
")",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"null",
",",
"ex",
")",
";",
"}",
"return",
"correspondace",
";",
"}"
] |
Returns the correspondence between the source and the target contexts
@param sourceName - The name of the root node in the source tree
@param sourceNodes - Names of the source nodes under the source root node
@param targetName - The name of the root node in the target tree
@param targetNodes -Names of the target nodes under the target root node
@return - the correspondence
|
[
"Returns",
"the",
"correspondence",
"between",
"the",
"source",
"and",
"the",
"target",
"contexts"
] |
d74fc41ab5bdc29afafd11c9001ac25dff20f965
|
https://github.com/opendatatrentino/smatch-webapi-client/blob/d74fc41ab5bdc29afafd11c9001ac25dff20f965/src/main/java/it/unitn/disi/smatch/webapi/client/WebApiClient.java#L173-L187
|
153,884
|
attribyte/wpdb
|
src/main/java/org/attribyte/wp/model/ShortcodeParser.java
|
ShortcodeParser.parseAttributes
|
private static Map<String, String> parseAttributes(String attrString) throws ParseException {
AttributeString str = new AttributeString(attrString);
Map<String, String> attributes = Maps.newLinkedHashMapWithExpectedSize(4); //Preserve order...
AttrState state = AttrState.NAME;
String currName = "";
String currString = "";
int currPos = 0;
while((currString = str.nextString()) != null) {
switch(state) {
case NAME:
if(str.ch == '=') {
currName = currString;
state = AttrState.VALUE;
} else {
attributes.put(String.format("$%d", currPos++), currString);
}
break;
case VALUE:
attributes.put(currName.toLowerCase(), currString);
state = AttrState.NAME;
break;
}
}
return attributes;
}
|
java
|
private static Map<String, String> parseAttributes(String attrString) throws ParseException {
AttributeString str = new AttributeString(attrString);
Map<String, String> attributes = Maps.newLinkedHashMapWithExpectedSize(4); //Preserve order...
AttrState state = AttrState.NAME;
String currName = "";
String currString = "";
int currPos = 0;
while((currString = str.nextString()) != null) {
switch(state) {
case NAME:
if(str.ch == '=') {
currName = currString;
state = AttrState.VALUE;
} else {
attributes.put(String.format("$%d", currPos++), currString);
}
break;
case VALUE:
attributes.put(currName.toLowerCase(), currString);
state = AttrState.NAME;
break;
}
}
return attributes;
}
|
[
"private",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"parseAttributes",
"(",
"String",
"attrString",
")",
"throws",
"ParseException",
"{",
"AttributeString",
"str",
"=",
"new",
"AttributeString",
"(",
"attrString",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"attributes",
"=",
"Maps",
".",
"newLinkedHashMapWithExpectedSize",
"(",
"4",
")",
";",
"//Preserve order...",
"AttrState",
"state",
"=",
"AttrState",
".",
"NAME",
";",
"String",
"currName",
"=",
"\"\"",
";",
"String",
"currString",
"=",
"\"\"",
";",
"int",
"currPos",
"=",
"0",
";",
"while",
"(",
"(",
"currString",
"=",
"str",
".",
"nextString",
"(",
")",
")",
"!=",
"null",
")",
"{",
"switch",
"(",
"state",
")",
"{",
"case",
"NAME",
":",
"if",
"(",
"str",
".",
"ch",
"==",
"'",
"'",
")",
"{",
"currName",
"=",
"currString",
";",
"state",
"=",
"AttrState",
".",
"VALUE",
";",
"}",
"else",
"{",
"attributes",
".",
"put",
"(",
"String",
".",
"format",
"(",
"\"$%d\"",
",",
"currPos",
"++",
")",
",",
"currString",
")",
";",
"}",
"break",
";",
"case",
"VALUE",
":",
"attributes",
".",
"put",
"(",
"currName",
".",
"toLowerCase",
"(",
")",
",",
"currString",
")",
";",
"state",
"=",
"AttrState",
".",
"NAME",
";",
"break",
";",
"}",
"}",
"return",
"attributes",
";",
"}"
] |
Parse attributes in a shortcode.
@param attrString The attribute string.
@return The map of attributes. Keys are <em>lower-case</em>.
@throws ParseException on invalid shortcode.
|
[
"Parse",
"attributes",
"in",
"a",
"shortcode",
"."
] |
b9adf6131dfb67899ebff770c9bfeb001cc42f30
|
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/model/ShortcodeParser.java#L258-L283
|
153,885
|
attribyte/wpdb
|
src/main/java/org/attribyte/wp/model/ShortcodeParser.java
|
ShortcodeParser.scanForName
|
private static String scanForName(int pos, final char[] chars) {
StringBuilder buf = new StringBuilder();
while(pos < chars.length) {
char ch = chars[pos++];
switch(ch) {
case ' ':
case ']':
return buf.toString();
case '[':
case '<':
case '>':
case '&':
case '/':
return "";
default:
if(ch < 0x20 || Character.isWhitespace(ch)) {
return "";
} else {
buf.append(ch);
}
}
}
return "";
}
|
java
|
private static String scanForName(int pos, final char[] chars) {
StringBuilder buf = new StringBuilder();
while(pos < chars.length) {
char ch = chars[pos++];
switch(ch) {
case ' ':
case ']':
return buf.toString();
case '[':
case '<':
case '>':
case '&':
case '/':
return "";
default:
if(ch < 0x20 || Character.isWhitespace(ch)) {
return "";
} else {
buf.append(ch);
}
}
}
return "";
}
|
[
"private",
"static",
"String",
"scanForName",
"(",
"int",
"pos",
",",
"final",
"char",
"[",
"]",
"chars",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"while",
"(",
"pos",
"<",
"chars",
".",
"length",
")",
"{",
"char",
"ch",
"=",
"chars",
"[",
"pos",
"++",
"]",
";",
"switch",
"(",
"ch",
")",
"{",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"return",
"\"\"",
";",
"default",
":",
"if",
"(",
"ch",
"<",
"0x20",
"||",
"Character",
".",
"isWhitespace",
"(",
"ch",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"else",
"{",
"buf",
".",
"append",
"(",
"ch",
")",
";",
"}",
"}",
"}",
"return",
"\"\"",
";",
"}"
] |
Scans for a valid shortcode name.
@param pos The starting position.
@param chars The character array to scan.
@return The shortcode name or an empty string if none found or invalid character is encountered.
|
[
"Scans",
"for",
"a",
"valid",
"shortcode",
"name",
"."
] |
b9adf6131dfb67899ebff770c9bfeb001cc42f30
|
https://github.com/attribyte/wpdb/blob/b9adf6131dfb67899ebff770c9bfeb001cc42f30/src/main/java/org/attribyte/wp/model/ShortcodeParser.java#L318-L341
|
153,886
|
jbundle/jbundle
|
thin/base/util/util/src/main/java/org/jbundle/thin/base/util/ThinUtil.java
|
ThinUtil.fixDisplayURL
|
public static String fixDisplayURL(String strURL, boolean bHelp, boolean bNoNav, boolean bLanguage, PropertyOwner propertyOwner)
{
if ((strURL == null) || (strURL.length() == 0))
return strURL;
Map<String,Object> properties = UrlUtil.parseArgs(null, strURL);
if (bHelp)
properties.put(Params.HELP, Constants.BLANK);
if (bNoNav)
{
properties.put(Params.MENUBARS, "No");
properties.put(Params.NAVMENUS, "No");
properties.put(Params.LOGOS, "No");
properties.put(Params.TRAILERS, "No"); // Don't need outside frame stuff in a window
}
if (bLanguage)
{
String strLanguage = null;
if (propertyOwner != null)
strLanguage = propertyOwner.getProperty("helplanguage");
if ((strLanguage == null) || (strLanguage.length() == 0))
if (propertyOwner != null)
strLanguage = propertyOwner.getProperty(Params.LANGUAGE);
if ((strLanguage != null) && (strLanguage.length() > 0))
properties.put(Params.LANGUAGE, strLanguage);
}
return UrlUtil.propertiesToUrl(properties);
}
|
java
|
public static String fixDisplayURL(String strURL, boolean bHelp, boolean bNoNav, boolean bLanguage, PropertyOwner propertyOwner)
{
if ((strURL == null) || (strURL.length() == 0))
return strURL;
Map<String,Object> properties = UrlUtil.parseArgs(null, strURL);
if (bHelp)
properties.put(Params.HELP, Constants.BLANK);
if (bNoNav)
{
properties.put(Params.MENUBARS, "No");
properties.put(Params.NAVMENUS, "No");
properties.put(Params.LOGOS, "No");
properties.put(Params.TRAILERS, "No"); // Don't need outside frame stuff in a window
}
if (bLanguage)
{
String strLanguage = null;
if (propertyOwner != null)
strLanguage = propertyOwner.getProperty("helplanguage");
if ((strLanguage == null) || (strLanguage.length() == 0))
if (propertyOwner != null)
strLanguage = propertyOwner.getProperty(Params.LANGUAGE);
if ((strLanguage != null) && (strLanguage.length() > 0))
properties.put(Params.LANGUAGE, strLanguage);
}
return UrlUtil.propertiesToUrl(properties);
}
|
[
"public",
"static",
"String",
"fixDisplayURL",
"(",
"String",
"strURL",
",",
"boolean",
"bHelp",
",",
"boolean",
"bNoNav",
",",
"boolean",
"bLanguage",
",",
"PropertyOwner",
"propertyOwner",
")",
"{",
"if",
"(",
"(",
"strURL",
"==",
"null",
")",
"||",
"(",
"strURL",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"return",
"strURL",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"properties",
"=",
"UrlUtil",
".",
"parseArgs",
"(",
"null",
",",
"strURL",
")",
";",
"if",
"(",
"bHelp",
")",
"properties",
".",
"put",
"(",
"Params",
".",
"HELP",
",",
"Constants",
".",
"BLANK",
")",
";",
"if",
"(",
"bNoNav",
")",
"{",
"properties",
".",
"put",
"(",
"Params",
".",
"MENUBARS",
",",
"\"No\"",
")",
";",
"properties",
".",
"put",
"(",
"Params",
".",
"NAVMENUS",
",",
"\"No\"",
")",
";",
"properties",
".",
"put",
"(",
"Params",
".",
"LOGOS",
",",
"\"No\"",
")",
";",
"properties",
".",
"put",
"(",
"Params",
".",
"TRAILERS",
",",
"\"No\"",
")",
";",
"// Don't need outside frame stuff in a window",
"}",
"if",
"(",
"bLanguage",
")",
"{",
"String",
"strLanguage",
"=",
"null",
";",
"if",
"(",
"propertyOwner",
"!=",
"null",
")",
"strLanguage",
"=",
"propertyOwner",
".",
"getProperty",
"(",
"\"helplanguage\"",
")",
";",
"if",
"(",
"(",
"strLanguage",
"==",
"null",
")",
"||",
"(",
"strLanguage",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"if",
"(",
"propertyOwner",
"!=",
"null",
")",
"strLanguage",
"=",
"propertyOwner",
".",
"getProperty",
"(",
"Params",
".",
"LANGUAGE",
")",
";",
"if",
"(",
"(",
"strLanguage",
"!=",
"null",
")",
"&&",
"(",
"strLanguage",
".",
"length",
"(",
")",
">",
"0",
")",
")",
"properties",
".",
"put",
"(",
"Params",
".",
"LANGUAGE",
",",
"strLanguage",
")",
";",
"}",
"return",
"UrlUtil",
".",
"propertiesToUrl",
"(",
"properties",
")",
";",
"}"
] |
Get this URL minus the nav bars
@param strURL
@param bHelp Add help param
@param bNoNav Add no nav bars params
@param bLanguage Add language param
@return
|
[
"Get",
"this",
"URL",
"minus",
"the",
"nav",
"bars"
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/thin/base/util/util/src/main/java/org/jbundle/thin/base/util/ThinUtil.java#L30-L56
|
153,887
|
carewebframework/carewebframework-vista
|
org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigFilter.java
|
ESigFilter.matches
|
public boolean matches(ESigItem item) {
if (selected != null && item.isSelected() != selected) {
return false;
}
if (eSigType != null && !item.getESigType().equals(eSigType)) {
return false;
}
if (session != null && !item.getSession().equals(session)) {
return false;
}
if (ids != null && !ids.contains(item.getId())) {
return false;
}
return true;
}
|
java
|
public boolean matches(ESigItem item) {
if (selected != null && item.isSelected() != selected) {
return false;
}
if (eSigType != null && !item.getESigType().equals(eSigType)) {
return false;
}
if (session != null && !item.getSession().equals(session)) {
return false;
}
if (ids != null && !ids.contains(item.getId())) {
return false;
}
return true;
}
|
[
"public",
"boolean",
"matches",
"(",
"ESigItem",
"item",
")",
"{",
"if",
"(",
"selected",
"!=",
"null",
"&&",
"item",
".",
"isSelected",
"(",
")",
"!=",
"selected",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"eSigType",
"!=",
"null",
"&&",
"!",
"item",
".",
"getESigType",
"(",
")",
".",
"equals",
"(",
"eSigType",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"session",
"!=",
"null",
"&&",
"!",
"item",
".",
"getSession",
"(",
")",
".",
"equals",
"(",
"session",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"ids",
"!=",
"null",
"&&",
"!",
"ids",
".",
"contains",
"(",
"item",
".",
"getId",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Returns true if the item matches the selection filter.
@param item The esignature item.
@return True if the item matches the selection filter.
|
[
"Returns",
"true",
"if",
"the",
"item",
"matches",
"the",
"selection",
"filter",
"."
] |
883b2cbe395d9e8a21cd19db820f0876bda6b1c6
|
https://github.com/carewebframework/carewebframework-vista/blob/883b2cbe395d9e8a21cd19db820f0876bda6b1c6/org.carewebframework.vista.api-parent/org.carewebframework.vista.api.esig/src/main/java/org/carewebframework/vista/esig/ESigFilter.java#L64-L82
|
153,888
|
jbundle/jbundle
|
base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XPopupBox.java
|
XPopupBox.scanTableItems
|
public void scanTableItems()
{
m_vDisplays = new Vector<String>();
m_vValues = new Vector<String>();
String strField = null;
Convert converter = this.getScreenField().getConverter();
Object data = converter.getData();
BaseField field = (BaseField)converter.getField();
boolean bModifiedState = false;
boolean[] states = null;
if (field != null)
{
bModifiedState = field.isModified();
states = field.setEnableListeners(false);
}
for (int index = 0; index < SPopupBox.MAX_POPUP_ITEMS; index++)
{
String strDisplay = converter.convertIndexToDisStr(index);
boolean bModified = false;
if (field != null)
bModified = field.isModified();
converter.convertIndexToField(index, DBConstants.DONT_DISPLAY, DBConstants.READ_MOVE); // Don't change
if (field != null)
field.setModified(bModified);
if (converter.getField() != null)
strField = converter.getField().getString();
else
strField = Integer.toString(index);
if (index > 0)
if ((strDisplay == null) || (strDisplay.length() == 0))
break; // Far Enough
m_vDisplays.add(strDisplay);
m_vValues.add(strField);
}
converter.setData(data, DBConstants.DONT_DISPLAY, DBConstants.READ_MOVE); // Restore to original value
if (field != null)
{
field.setModified(bModifiedState);
field.setEnableListeners(states);
}
}
|
java
|
public void scanTableItems()
{
m_vDisplays = new Vector<String>();
m_vValues = new Vector<String>();
String strField = null;
Convert converter = this.getScreenField().getConverter();
Object data = converter.getData();
BaseField field = (BaseField)converter.getField();
boolean bModifiedState = false;
boolean[] states = null;
if (field != null)
{
bModifiedState = field.isModified();
states = field.setEnableListeners(false);
}
for (int index = 0; index < SPopupBox.MAX_POPUP_ITEMS; index++)
{
String strDisplay = converter.convertIndexToDisStr(index);
boolean bModified = false;
if (field != null)
bModified = field.isModified();
converter.convertIndexToField(index, DBConstants.DONT_DISPLAY, DBConstants.READ_MOVE); // Don't change
if (field != null)
field.setModified(bModified);
if (converter.getField() != null)
strField = converter.getField().getString();
else
strField = Integer.toString(index);
if (index > 0)
if ((strDisplay == null) || (strDisplay.length() == 0))
break; // Far Enough
m_vDisplays.add(strDisplay);
m_vValues.add(strField);
}
converter.setData(data, DBConstants.DONT_DISPLAY, DBConstants.READ_MOVE); // Restore to original value
if (field != null)
{
field.setModified(bModifiedState);
field.setEnableListeners(states);
}
}
|
[
"public",
"void",
"scanTableItems",
"(",
")",
"{",
"m_vDisplays",
"=",
"new",
"Vector",
"<",
"String",
">",
"(",
")",
";",
"m_vValues",
"=",
"new",
"Vector",
"<",
"String",
">",
"(",
")",
";",
"String",
"strField",
"=",
"null",
";",
"Convert",
"converter",
"=",
"this",
".",
"getScreenField",
"(",
")",
".",
"getConverter",
"(",
")",
";",
"Object",
"data",
"=",
"converter",
".",
"getData",
"(",
")",
";",
"BaseField",
"field",
"=",
"(",
"BaseField",
")",
"converter",
".",
"getField",
"(",
")",
";",
"boolean",
"bModifiedState",
"=",
"false",
";",
"boolean",
"[",
"]",
"states",
"=",
"null",
";",
"if",
"(",
"field",
"!=",
"null",
")",
"{",
"bModifiedState",
"=",
"field",
".",
"isModified",
"(",
")",
";",
"states",
"=",
"field",
".",
"setEnableListeners",
"(",
"false",
")",
";",
"}",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"SPopupBox",
".",
"MAX_POPUP_ITEMS",
";",
"index",
"++",
")",
"{",
"String",
"strDisplay",
"=",
"converter",
".",
"convertIndexToDisStr",
"(",
"index",
")",
";",
"boolean",
"bModified",
"=",
"false",
";",
"if",
"(",
"field",
"!=",
"null",
")",
"bModified",
"=",
"field",
".",
"isModified",
"(",
")",
";",
"converter",
".",
"convertIndexToField",
"(",
"index",
",",
"DBConstants",
".",
"DONT_DISPLAY",
",",
"DBConstants",
".",
"READ_MOVE",
")",
";",
"// Don't change",
"if",
"(",
"field",
"!=",
"null",
")",
"field",
".",
"setModified",
"(",
"bModified",
")",
";",
"if",
"(",
"converter",
".",
"getField",
"(",
")",
"!=",
"null",
")",
"strField",
"=",
"converter",
".",
"getField",
"(",
")",
".",
"getString",
"(",
")",
";",
"else",
"strField",
"=",
"Integer",
".",
"toString",
"(",
"index",
")",
";",
"if",
"(",
"index",
">",
"0",
")",
"if",
"(",
"(",
"strDisplay",
"==",
"null",
")",
"||",
"(",
"strDisplay",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"break",
";",
"// Far Enough",
"m_vDisplays",
".",
"add",
"(",
"strDisplay",
")",
";",
"m_vValues",
".",
"add",
"(",
"strField",
")",
";",
"}",
"converter",
".",
"setData",
"(",
"data",
",",
"DBConstants",
".",
"DONT_DISPLAY",
",",
"DBConstants",
".",
"READ_MOVE",
")",
";",
"// Restore to original value",
"if",
"(",
"field",
"!=",
"null",
")",
"{",
"field",
".",
"setModified",
"(",
"bModifiedState",
")",
";",
"field",
".",
"setEnableListeners",
"(",
"states",
")",
";",
"}",
"}"
] |
Scan through the items and cache the values and display strings.
|
[
"Scan",
"through",
"the",
"items",
"and",
"cache",
"the",
"values",
"and",
"display",
"strings",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XPopupBox.java#L75-L116
|
153,889
|
jbundle/jbundle
|
base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XPopupBox.java
|
XPopupBox.getSFieldProperty
|
public String getSFieldProperty(String strFieldName)
{
String strValue = super.getSFieldProperty(strFieldName);
// Hack - For some weird reason DOJO returns the display value instead of the 'option' value. Need to look up the field value.
Convert converter = this.getScreenField().getConverter();
String strConverter = converter.toString();
if (((strValue != null) && (strValue.equals(strConverter)))
|| ((strValue == null) && (strConverter == null)))
{ // The value has not changed, return it!
if (converter.getField() != null) // Always
return converter.getField().toString();
}
for (int index = 0; index < SPopupBox.MAX_POPUP_ITEMS; index++)
{
String strDisplay = converter.convertIndexToDisStr(index);
if (((strValue != null) && (strValue.equals(strDisplay)))
|| ((strValue == null) && (strDisplay == null)))
{
if (converter.convertIndexToField(index, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE) == DBConstants.NORMAL_RETURN)
return converter.getField().toString();
}
if (index > 0)
if ((strDisplay == null) || (strDisplay.length() == 0))
break; // Far Enough
}
return strValue;
}
|
java
|
public String getSFieldProperty(String strFieldName)
{
String strValue = super.getSFieldProperty(strFieldName);
// Hack - For some weird reason DOJO returns the display value instead of the 'option' value. Need to look up the field value.
Convert converter = this.getScreenField().getConverter();
String strConverter = converter.toString();
if (((strValue != null) && (strValue.equals(strConverter)))
|| ((strValue == null) && (strConverter == null)))
{ // The value has not changed, return it!
if (converter.getField() != null) // Always
return converter.getField().toString();
}
for (int index = 0; index < SPopupBox.MAX_POPUP_ITEMS; index++)
{
String strDisplay = converter.convertIndexToDisStr(index);
if (((strValue != null) && (strValue.equals(strDisplay)))
|| ((strValue == null) && (strDisplay == null)))
{
if (converter.convertIndexToField(index, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE) == DBConstants.NORMAL_RETURN)
return converter.getField().toString();
}
if (index > 0)
if ((strDisplay == null) || (strDisplay.length() == 0))
break; // Far Enough
}
return strValue;
}
|
[
"public",
"String",
"getSFieldProperty",
"(",
"String",
"strFieldName",
")",
"{",
"String",
"strValue",
"=",
"super",
".",
"getSFieldProperty",
"(",
"strFieldName",
")",
";",
"// Hack - For some weird reason DOJO returns the display value instead of the 'option' value. Need to look up the field value.",
"Convert",
"converter",
"=",
"this",
".",
"getScreenField",
"(",
")",
".",
"getConverter",
"(",
")",
";",
"String",
"strConverter",
"=",
"converter",
".",
"toString",
"(",
")",
";",
"if",
"(",
"(",
"(",
"strValue",
"!=",
"null",
")",
"&&",
"(",
"strValue",
".",
"equals",
"(",
"strConverter",
")",
")",
")",
"||",
"(",
"(",
"strValue",
"==",
"null",
")",
"&&",
"(",
"strConverter",
"==",
"null",
")",
")",
")",
"{",
"// The value has not changed, return it!",
"if",
"(",
"converter",
".",
"getField",
"(",
")",
"!=",
"null",
")",
"// Always",
"return",
"converter",
".",
"getField",
"(",
")",
".",
"toString",
"(",
")",
";",
"}",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"SPopupBox",
".",
"MAX_POPUP_ITEMS",
";",
"index",
"++",
")",
"{",
"String",
"strDisplay",
"=",
"converter",
".",
"convertIndexToDisStr",
"(",
"index",
")",
";",
"if",
"(",
"(",
"(",
"strValue",
"!=",
"null",
")",
"&&",
"(",
"strValue",
".",
"equals",
"(",
"strDisplay",
")",
")",
")",
"||",
"(",
"(",
"strValue",
"==",
"null",
")",
"&&",
"(",
"strDisplay",
"==",
"null",
")",
")",
")",
"{",
"if",
"(",
"converter",
".",
"convertIndexToField",
"(",
"index",
",",
"DBConstants",
".",
"DISPLAY",
",",
"DBConstants",
".",
"SCREEN_MOVE",
")",
"==",
"DBConstants",
".",
"NORMAL_RETURN",
")",
"return",
"converter",
".",
"getField",
"(",
")",
".",
"toString",
"(",
")",
";",
"}",
"if",
"(",
"index",
">",
"0",
")",
"if",
"(",
"(",
"strDisplay",
"==",
"null",
")",
"||",
"(",
"strDisplay",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"break",
";",
"// Far Enough",
"}",
"return",
"strValue",
";",
"}"
] |
Get this control's value as it was submitted by the HTML post operation.
@return The value the field was set to.
|
[
"Get",
"this",
"control",
"s",
"value",
"as",
"it",
"was",
"submitted",
"by",
"the",
"HTML",
"post",
"operation",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/screen/view/xml/src/main/java/org/jbundle/base/screen/view/xml/XPopupBox.java#L212-L238
|
153,890
|
yestech/yesepisodic
|
src/main/java/org/yestech/episodic/util/EpisodicUtil.java
|
EpisodicUtil.unmarshall
|
public static Object unmarshall(HttpResponse response) throws JAXBException, IOException {
String xml = EntityUtils.toString(response.getEntity());
Unmarshaller unmarshaller = ctx.createUnmarshaller();
return unmarshaller.unmarshal(new StringReader(xml));
}
|
java
|
public static Object unmarshall(HttpResponse response) throws JAXBException, IOException {
String xml = EntityUtils.toString(response.getEntity());
Unmarshaller unmarshaller = ctx.createUnmarshaller();
return unmarshaller.unmarshal(new StringReader(xml));
}
|
[
"public",
"static",
"Object",
"unmarshall",
"(",
"HttpResponse",
"response",
")",
"throws",
"JAXBException",
",",
"IOException",
"{",
"String",
"xml",
"=",
"EntityUtils",
".",
"toString",
"(",
"response",
".",
"getEntity",
"(",
")",
")",
";",
"Unmarshaller",
"unmarshaller",
"=",
"ctx",
".",
"createUnmarshaller",
"(",
")",
";",
"return",
"unmarshaller",
".",
"unmarshal",
"(",
"new",
"StringReader",
"(",
"xml",
")",
")",
";",
"}"
] |
Unmarshalls the input stream into an object from org.yestech.episodic.objectmodel.
@param response the response
@return The unmarshalled object.
@throws javax.xml.bind.JAXBException Thrown if there are issues with the xml stream passed in.
|
[
"Unmarshalls",
"the",
"input",
"stream",
"into",
"an",
"object",
"from",
"org",
".",
"yestech",
".",
"episodic",
".",
"objectmodel",
"."
] |
ed9699443871a44d51e149f32769b4d84cded63d
|
https://github.com/yestech/yesepisodic/blob/ed9699443871a44d51e149f32769b4d84cded63d/src/main/java/org/yestech/episodic/util/EpisodicUtil.java#L56-L60
|
153,891
|
yestech/yesepisodic
|
src/main/java/org/yestech/episodic/util/EpisodicUtil.java
|
EpisodicUtil.join
|
public static String join(String[] strings) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < strings.length; i++) {
builder.append(strings[i]);
if (i + 1 < strings.length) builder.append(",");
}
return builder.toString();
}
|
java
|
public static String join(String[] strings) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < strings.length; i++) {
builder.append(strings[i]);
if (i + 1 < strings.length) builder.append(",");
}
return builder.toString();
}
|
[
"public",
"static",
"String",
"join",
"(",
"String",
"[",
"]",
"strings",
")",
"{",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"strings",
".",
"length",
";",
"i",
"++",
")",
"{",
"builder",
".",
"append",
"(",
"strings",
"[",
"i",
"]",
")",
";",
"if",
"(",
"i",
"+",
"1",
"<",
"strings",
".",
"length",
")",
"builder",
".",
"append",
"(",
"\",\"",
")",
";",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
A simple method for joining an array of strings to a comma seperated string.
@param strings An array of strings.
@return The array as single string joined by commas
|
[
"A",
"simple",
"method",
"for",
"joining",
"an",
"array",
"of",
"strings",
"to",
"a",
"comma",
"seperated",
"string",
"."
] |
ed9699443871a44d51e149f32769b4d84cded63d
|
https://github.com/yestech/yesepisodic/blob/ed9699443871a44d51e149f32769b4d84cded63d/src/main/java/org/yestech/episodic/util/EpisodicUtil.java#L68-L75
|
153,892
|
jbundle/jbundle
|
base/base/src/main/java/org/jbundle/base/db/event/RemoveFromQueryRecordOnCloseHandler.java
|
RemoveFromQueryRecordOnCloseHandler.removeIt
|
public void removeIt()
{
if (m_queryRecord != null)
if (this.getOwner() != null)
m_queryRecord.removeRecord(this.getOwner());
m_queryRecord = null;
}
|
java
|
public void removeIt()
{
if (m_queryRecord != null)
if (this.getOwner() != null)
m_queryRecord.removeRecord(this.getOwner());
m_queryRecord = null;
}
|
[
"public",
"void",
"removeIt",
"(",
")",
"{",
"if",
"(",
"m_queryRecord",
"!=",
"null",
")",
"if",
"(",
"this",
".",
"getOwner",
"(",
")",
"!=",
"null",
")",
"m_queryRecord",
".",
"removeRecord",
"(",
"this",
".",
"getOwner",
"(",
")",
")",
";",
"m_queryRecord",
"=",
"null",
";",
"}"
] |
Remove this record from the query record.
|
[
"Remove",
"this",
"record",
"from",
"the",
"query",
"record",
"."
] |
4037fcfa85f60c7d0096c453c1a3cd573c2b0abc
|
https://github.com/jbundle/jbundle/blob/4037fcfa85f60c7d0096c453c1a3cd573c2b0abc/base/base/src/main/java/org/jbundle/base/db/event/RemoveFromQueryRecordOnCloseHandler.java#L79-L85
|
153,893
|
lshift/jamume
|
src/main/java/net/lshift/java/dispatch/ImplementsOnlyDirectSuperclasses.java
|
ImplementsOnlyDirectSuperclasses.directSuperclasses
|
public List<Class<?>> directSuperclasses(Class<?> c)
{
if(c.isPrimitive()) {
return primitiveSuperclasses(c);
}
else if(c.isArray()) {
return arrayDirectSuperclasses(0, c);
}
else {
Class<?> [] interfaces = c.getInterfaces();
Class<?> superclass = c.getSuperclass();
List<Class<?>> classes = new LinkedList<Class<?>>();
classes.addAll(Arrays.asList(interfaces));
if(superclass == null) {
if(interfaces.length == 0 &&
c != Object.class)
classes.add(Object.class);
}
else {
classes.add(superclass);
}
return classes;
}
}
|
java
|
public List<Class<?>> directSuperclasses(Class<?> c)
{
if(c.isPrimitive()) {
return primitiveSuperclasses(c);
}
else if(c.isArray()) {
return arrayDirectSuperclasses(0, c);
}
else {
Class<?> [] interfaces = c.getInterfaces();
Class<?> superclass = c.getSuperclass();
List<Class<?>> classes = new LinkedList<Class<?>>();
classes.addAll(Arrays.asList(interfaces));
if(superclass == null) {
if(interfaces.length == 0 &&
c != Object.class)
classes.add(Object.class);
}
else {
classes.add(superclass);
}
return classes;
}
}
|
[
"public",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"directSuperclasses",
"(",
"Class",
"<",
"?",
">",
"c",
")",
"{",
"if",
"(",
"c",
".",
"isPrimitive",
"(",
")",
")",
"{",
"return",
"primitiveSuperclasses",
"(",
"c",
")",
";",
"}",
"else",
"if",
"(",
"c",
".",
"isArray",
"(",
")",
")",
"{",
"return",
"arrayDirectSuperclasses",
"(",
"0",
",",
"c",
")",
";",
"}",
"else",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"interfaces",
"=",
"c",
".",
"getInterfaces",
"(",
")",
";",
"Class",
"<",
"?",
">",
"superclass",
"=",
"c",
".",
"getSuperclass",
"(",
")",
";",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"classes",
"=",
"new",
"LinkedList",
"<",
"Class",
"<",
"?",
">",
">",
"(",
")",
";",
"classes",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"interfaces",
")",
")",
";",
"if",
"(",
"superclass",
"==",
"null",
")",
"{",
"if",
"(",
"interfaces",
".",
"length",
"==",
"0",
"&&",
"c",
"!=",
"Object",
".",
"class",
")",
"classes",
".",
"add",
"(",
"Object",
".",
"class",
")",
";",
"}",
"else",
"{",
"classes",
".",
"add",
"(",
"superclass",
")",
";",
"}",
"return",
"classes",
";",
"}",
"}"
] |
Get the direct superclasses of a class.
Interfaces, followed by the superclasses. Interfaces with
no super interfaces extend Object.
|
[
"Get",
"the",
"direct",
"superclasses",
"of",
"a",
"class",
".",
"Interfaces",
"followed",
"by",
"the",
"superclasses",
".",
"Interfaces",
"with",
"no",
"super",
"interfaces",
"extend",
"Object",
"."
] |
754d9ab29311601328a2f39928775e4e010305b7
|
https://github.com/lshift/jamume/blob/754d9ab29311601328a2f39928775e4e010305b7/src/main/java/net/lshift/java/dispatch/ImplementsOnlyDirectSuperclasses.java#L23-L48
|
153,894
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/util/CmdArgs.java
|
CmdArgs.getValue
|
@Override
public Object getValue(String name)
{
if (arguments == null)
{
throw new IllegalStateException("setArgs not called");
}
Object ob = options.get(name);
if (ob != null)
{
return ob;
}
return arguments.get(name);
}
|
java
|
@Override
public Object getValue(String name)
{
if (arguments == null)
{
throw new IllegalStateException("setArgs not called");
}
Object ob = options.get(name);
if (ob != null)
{
return ob;
}
return arguments.get(name);
}
|
[
"@",
"Override",
"public",
"Object",
"getValue",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"arguments",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"setArgs not called\"",
")",
";",
"}",
"Object",
"ob",
"=",
"options",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"ob",
"!=",
"null",
")",
"{",
"return",
"ob",
";",
"}",
"return",
"arguments",
".",
"get",
"(",
"name",
")",
";",
"}"
] |
Returns named option or argument value
@param name
@return
|
[
"Returns",
"named",
"option",
"or",
"argument",
"value"
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CmdArgs.java#L77-L90
|
153,895
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/util/CmdArgs.java
|
CmdArgs.command
|
public void command(String... args)
{
try
{
setArgs(args);
}
catch (CmdArgsException ex)
{
ex.printStackTrace();
Logger logger = Logger.getLogger(CmdArgs.class.getName());
logger.log(Level.SEVERE, Arrays.toString(args));
logger.log(Level.SEVERE, ex.getMessage(), ex);
logger.log(Level.SEVERE, ex.usage());
System.exit(-1);
}
}
|
java
|
public void command(String... args)
{
try
{
setArgs(args);
}
catch (CmdArgsException ex)
{
ex.printStackTrace();
Logger logger = Logger.getLogger(CmdArgs.class.getName());
logger.log(Level.SEVERE, Arrays.toString(args));
logger.log(Level.SEVERE, ex.getMessage(), ex);
logger.log(Level.SEVERE, ex.usage());
System.exit(-1);
}
}
|
[
"public",
"void",
"command",
"(",
"String",
"...",
"args",
")",
"{",
"try",
"{",
"setArgs",
"(",
"args",
")",
";",
"}",
"catch",
"(",
"CmdArgsException",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"Logger",
"logger",
"=",
"Logger",
".",
"getLogger",
"(",
"CmdArgs",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"logger",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"Arrays",
".",
"toString",
"(",
"args",
")",
")",
";",
"logger",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"logger",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"ex",
".",
"usage",
"(",
")",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
"}"
] |
Initializes options and arguments. Reports error and exits on error.
Called usually from main method.
@param args
|
[
"Initializes",
"options",
"and",
"arguments",
".",
"Reports",
"error",
"and",
"exits",
"on",
"error",
".",
"Called",
"usually",
"from",
"main",
"method",
"."
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CmdArgs.java#L96-L111
|
153,896
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/util/CmdArgs.java
|
CmdArgs.getArgument
|
public final <T> T getArgument(String name)
{
if (arguments == null)
{
throw new IllegalStateException("setArgs not called");
}
return (T) arguments.get(name);
}
|
java
|
public final <T> T getArgument(String name)
{
if (arguments == null)
{
throw new IllegalStateException("setArgs not called");
}
return (T) arguments.get(name);
}
|
[
"public",
"final",
"<",
"T",
">",
"T",
"getArgument",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"arguments",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"setArgs not called\"",
")",
";",
"}",
"return",
"(",
"T",
")",
"arguments",
".",
"get",
"(",
"name",
")",
";",
"}"
] |
Returns named argument value
@param <T>
@param name
@return
|
[
"Returns",
"named",
"argument",
"value"
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CmdArgs.java#L243-L250
|
153,897
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/util/CmdArgs.java
|
CmdArgs.getOption
|
public final <T> T getOption(String name)
{
if (arguments == null)
{
throw new IllegalStateException("setArgs not called");
}
Object value = options.get(name);
if (value == null)
{
Option opt = map.get(name);
if (opt == null)
{
throw new IllegalArgumentException("option "+name+" not found");
}
if (opt.defValue != null)
{
return (T) opt.defValue;
}
if (!opt.mandatory)
{
return null;
}
throw new IllegalArgumentException(name+" not found");
}
return (T) value;
}
|
java
|
public final <T> T getOption(String name)
{
if (arguments == null)
{
throw new IllegalStateException("setArgs not called");
}
Object value = options.get(name);
if (value == null)
{
Option opt = map.get(name);
if (opt == null)
{
throw new IllegalArgumentException("option "+name+" not found");
}
if (opt.defValue != null)
{
return (T) opt.defValue;
}
if (!opt.mandatory)
{
return null;
}
throw new IllegalArgumentException(name+" not found");
}
return (T) value;
}
|
[
"public",
"final",
"<",
"T",
">",
"T",
"getOption",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"arguments",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"setArgs not called\"",
")",
";",
"}",
"Object",
"value",
"=",
"options",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"Option",
"opt",
"=",
"map",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"opt",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"option \"",
"+",
"name",
"+",
"\" not found\"",
")",
";",
"}",
"if",
"(",
"opt",
".",
"defValue",
"!=",
"null",
")",
"{",
"return",
"(",
"T",
")",
"opt",
".",
"defValue",
";",
"}",
"if",
"(",
"!",
"opt",
".",
"mandatory",
")",
"{",
"return",
"null",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
"name",
"+",
"\" not found\"",
")",
";",
"}",
"return",
"(",
"T",
")",
"value",
";",
"}"
] |
Return named option value.
@param <T>
@param name
@return
|
[
"Return",
"named",
"option",
"value",
"."
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CmdArgs.java#L257-L282
|
153,898
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/util/CmdArgs.java
|
CmdArgs.addArgument
|
public final <T> void addArgument(Class<T> cls, String name)
{
if (map.containsKey(name))
{
throw new IllegalArgumentException(name+" is already added as option");
}
if (hasArrayArgument)
{
throw new IllegalArgumentException("no argument allowed after array argument");
}
types.add(cls);
names.add(name);
if (cls.isArray())
{
hasArrayArgument = true;
}
}
|
java
|
public final <T> void addArgument(Class<T> cls, String name)
{
if (map.containsKey(name))
{
throw new IllegalArgumentException(name+" is already added as option");
}
if (hasArrayArgument)
{
throw new IllegalArgumentException("no argument allowed after array argument");
}
types.add(cls);
names.add(name);
if (cls.isArray())
{
hasArrayArgument = true;
}
}
|
[
"public",
"final",
"<",
"T",
">",
"void",
"addArgument",
"(",
"Class",
"<",
"T",
">",
"cls",
",",
"String",
"name",
")",
"{",
"if",
"(",
"map",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"name",
"+",
"\" is already added as option\"",
")",
";",
"}",
"if",
"(",
"hasArrayArgument",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"no argument allowed after array argument\"",
")",
";",
"}",
"types",
".",
"add",
"(",
"cls",
")",
";",
"names",
".",
"add",
"(",
"name",
")",
";",
"if",
"(",
"cls",
".",
"isArray",
"(",
")",
")",
"{",
"hasArrayArgument",
"=",
"true",
";",
"}",
"}"
] |
Add typed argument
@param <T>
@param cls
@param name
|
[
"Add",
"typed",
"argument"
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CmdArgs.java#L297-L313
|
153,899
|
tvesalainen/util
|
util/src/main/java/org/vesalainen/util/CmdArgs.java
|
CmdArgs.addOption
|
public final <T> void addOption(String name, String description)
{
addOption(String.class, name, description, null);
}
|
java
|
public final <T> void addOption(String name, String description)
{
addOption(String.class, name, description, null);
}
|
[
"public",
"final",
"<",
"T",
">",
"void",
"addOption",
"(",
"String",
"name",
",",
"String",
"description",
")",
"{",
"addOption",
"(",
"String",
".",
"class",
",",
"name",
",",
"description",
",",
"null",
")",
";",
"}"
] |
Add a mandatory string option
@param <T> Type of option
@param name Option name Option name without
@param description Option description
|
[
"Add",
"a",
"mandatory",
"string",
"option"
] |
bba7a44689f638ffabc8be40a75bdc9a33676433
|
https://github.com/tvesalainen/util/blob/bba7a44689f638ffabc8be40a75bdc9a33676433/util/src/main/java/org/vesalainen/util/CmdArgs.java#L320-L323
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.