id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
2,400 | josesamuel/remoter | remoter/src/main/java/remoter/compiler/builder/RemoteBuilder.java | RemoteBuilder.processRemoterElements | private int processRemoterElements(TypeSpec.Builder classBuilder, Element element, int methodIndex, ElementVisitor elementVisitor, MethodSpec.Builder methodBuilder) {
if (element instanceof TypeElement) {
for (TypeMirror typeMirror : ((TypeElement) element).getInterfaces()) {
if (typeMirror instanceof DeclaredType) {
Element superElement = ((DeclaredType) typeMirror).asElement();
methodIndex = processRemoterElements(classBuilder, superElement, methodIndex, elementVisitor, methodBuilder);
}
}
for (Element member : element.getEnclosedElements()) {
if (member.getKind() == ElementKind.METHOD) {
elementVisitor.visitElement(classBuilder, member, methodIndex, methodBuilder);
methodIndex++;
}
}
}
return methodIndex;
} | java | private int processRemoterElements(TypeSpec.Builder classBuilder, Element element, int methodIndex, ElementVisitor elementVisitor, MethodSpec.Builder methodBuilder) {
if (element instanceof TypeElement) {
for (TypeMirror typeMirror : ((TypeElement) element).getInterfaces()) {
if (typeMirror instanceof DeclaredType) {
Element superElement = ((DeclaredType) typeMirror).asElement();
methodIndex = processRemoterElements(classBuilder, superElement, methodIndex, elementVisitor, methodBuilder);
}
}
for (Element member : element.getEnclosedElements()) {
if (member.getKind() == ElementKind.METHOD) {
elementVisitor.visitElement(classBuilder, member, methodIndex, methodBuilder);
methodIndex++;
}
}
}
return methodIndex;
} | [
"private",
"int",
"processRemoterElements",
"(",
"TypeSpec",
".",
"Builder",
"classBuilder",
",",
"Element",
"element",
",",
"int",
"methodIndex",
",",
"ElementVisitor",
"elementVisitor",
",",
"MethodSpec",
".",
"Builder",
"methodBuilder",
")",
"{",
"if",
"(",
"element",
"instanceof",
"TypeElement",
")",
"{",
"for",
"(",
"TypeMirror",
"typeMirror",
":",
"(",
"(",
"TypeElement",
")",
"element",
")",
".",
"getInterfaces",
"(",
")",
")",
"{",
"if",
"(",
"typeMirror",
"instanceof",
"DeclaredType",
")",
"{",
"Element",
"superElement",
"=",
"(",
"(",
"DeclaredType",
")",
"typeMirror",
")",
".",
"asElement",
"(",
")",
";",
"methodIndex",
"=",
"processRemoterElements",
"(",
"classBuilder",
",",
"superElement",
",",
"methodIndex",
",",
"elementVisitor",
",",
"methodBuilder",
")",
";",
"}",
"}",
"for",
"(",
"Element",
"member",
":",
"element",
".",
"getEnclosedElements",
"(",
")",
")",
"{",
"if",
"(",
"member",
".",
"getKind",
"(",
")",
"==",
"ElementKind",
".",
"METHOD",
")",
"{",
"elementVisitor",
".",
"visitElement",
"(",
"classBuilder",
",",
"member",
",",
"methodIndex",
",",
"methodBuilder",
")",
";",
"methodIndex",
"++",
";",
"}",
"}",
"}",
"return",
"methodIndex",
";",
"}"
] | Recursevely Visit extended elements | [
"Recursevely",
"Visit",
"extended",
"elements"
] | 007401868c319740d40134ebc07c3406988f9a86 | https://github.com/josesamuel/remoter/blob/007401868c319740d40134ebc07c3406988f9a86/remoter/src/main/java/remoter/compiler/builder/RemoteBuilder.java#L108-L124 |
2,401 | shamanland/xdroid | lib-viewholder/src/main/java/xdroid/viewholder/ViewHolder.java | ViewHolder.get | public <V extends View> V get(int id) {
Object result = mViews.get(id);
if (result == NULL) {
return null;
}
if (result != null) {
return cast(result);
}
result = mView.findViewById(id);
if (result == null) {
mViews.put(id, NULL);
} else {
mViews.put(id, result);
}
return cast(result);
} | java | public <V extends View> V get(int id) {
Object result = mViews.get(id);
if (result == NULL) {
return null;
}
if (result != null) {
return cast(result);
}
result = mView.findViewById(id);
if (result == null) {
mViews.put(id, NULL);
} else {
mViews.put(id, result);
}
return cast(result);
} | [
"public",
"<",
"V",
"extends",
"View",
">",
"V",
"get",
"(",
"int",
"id",
")",
"{",
"Object",
"result",
"=",
"mViews",
".",
"get",
"(",
"id",
")",
";",
"if",
"(",
"result",
"==",
"NULL",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"cast",
"(",
"result",
")",
";",
"}",
"result",
"=",
"mView",
".",
"findViewById",
"(",
"id",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"{",
"mViews",
".",
"put",
"(",
"id",
",",
"NULL",
")",
";",
"}",
"else",
"{",
"mViews",
".",
"put",
"(",
"id",
",",
"result",
")",
";",
"}",
"return",
"cast",
"(",
"result",
")",
";",
"}"
] | Gets the child view by id.
@param id view id
@param <V> any type return value to be casted to
@return cached instance of <code>View</code> or <code>null</code> if not found | [
"Gets",
"the",
"child",
"view",
"by",
"id",
"."
] | 5330811114afaf6a7b8f9a10f3bbe19d37995d89 | https://github.com/shamanland/xdroid/blob/5330811114afaf6a7b8f9a10f3bbe19d37995d89/lib-viewholder/src/main/java/xdroid/viewholder/ViewHolder.java#L85-L105 |
2,402 | akarnokd/ixjava | src/main/java/ix/IxSourceQueuedIterator.java | IxSourceQueuedIterator.fromObject | @SuppressWarnings("unchecked")
protected final U fromObject(Object value) {
return value == NULL ? null : (U)value;
} | java | @SuppressWarnings("unchecked")
protected final U fromObject(Object value) {
return value == NULL ? null : (U)value;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"final",
"U",
"fromObject",
"(",
"Object",
"value",
")",
"{",
"return",
"value",
"==",
"NULL",
"?",
"null",
":",
"(",
"U",
")",
"value",
";",
"}"
] | Cast the object back to a typed value.
@param value the value to cast back
@return the typed value, maybe null | [
"Cast",
"the",
"object",
"back",
"to",
"a",
"typed",
"value",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/IxSourceQueuedIterator.java#L60-L63 |
2,403 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.as | public final <R> R as(IxFunction<? super Ix<T>, R> transformer) {
return transformer.apply(this);
} | java | public final <R> R as(IxFunction<? super Ix<T>, R> transformer) {
return transformer.apply(this);
} | [
"public",
"final",
"<",
"R",
">",
"R",
"as",
"(",
"IxFunction",
"<",
"?",
"super",
"Ix",
"<",
"T",
">",
",",
"R",
">",
"transformer",
")",
"{",
"return",
"transformer",
".",
"apply",
"(",
"this",
")",
";",
"}"
] | Calls the given transformers with this and returns its value allowing
fluent conversions to non-Ix types.
@param <R> the result type
@param transformer the function receiving this Ix instance and returns a value
@return the value returned by the transformer function
@throws NullPointerException if transformer is null
@since 1.0 | [
"Calls",
"the",
"given",
"transformers",
"with",
"this",
"and",
"returns",
"its",
"value",
"allowing",
"fluent",
"conversions",
"to",
"non",
"-",
"Ix",
"types",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L759-L761 |
2,404 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.first | @SuppressWarnings("unchecked")
public final T first(T defaultValue) {
if (this instanceof Callable) {
return checkedCall((Callable<T>) this);
}
Iterator<T> it = iterator();
if (it.hasNext()) {
return it.next();
}
return defaultValue;
} | java | @SuppressWarnings("unchecked")
public final T first(T defaultValue) {
if (this instanceof Callable) {
return checkedCall((Callable<T>) this);
}
Iterator<T> it = iterator();
if (it.hasNext()) {
return it.next();
}
return defaultValue;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"T",
"first",
"(",
"T",
"defaultValue",
")",
"{",
"if",
"(",
"this",
"instanceof",
"Callable",
")",
"{",
"return",
"checkedCall",
"(",
"(",
"Callable",
"<",
"T",
">",
")",
"this",
")",
";",
"}",
"Iterator",
"<",
"T",
">",
"it",
"=",
"iterator",
"(",
")",
";",
"if",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"return",
"it",
".",
"next",
"(",
")",
";",
"}",
"return",
"defaultValue",
";",
"}"
] | Returns the first element of this sequence or the defaultValue
if this sequence is empty.
@param defaultValue the value to return if this sequence is empty
@return the first element or the default value
@since 1.0
@see #first()
@see #last() | [
"Returns",
"the",
"first",
"element",
"of",
"this",
"sequence",
"or",
"the",
"defaultValue",
"if",
"this",
"sequence",
"is",
"empty",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L2271-L2281 |
2,405 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.into | public final <U extends Collection<? super T>> U into(U collection) {
for (T v : this) {
collection.add(v);
}
return collection;
} | java | public final <U extends Collection<? super T>> U into(U collection) {
for (T v : this) {
collection.add(v);
}
return collection;
} | [
"public",
"final",
"<",
"U",
"extends",
"Collection",
"<",
"?",
"super",
"T",
">",
">",
"U",
"into",
"(",
"U",
"collection",
")",
"{",
"for",
"(",
"T",
"v",
":",
"this",
")",
"{",
"collection",
".",
"add",
"(",
"v",
")",
";",
"}",
"return",
"collection",
";",
"}"
] | Consumes the entire sequence and adds each element into the given collection
that is also returned.
@param <U> the collection of type accepting a (super)type of this element type
@param collection the collection to collect into
@return the collection itself
@throws NullPointerException if collection is null
@since 1.0 | [
"Consumes",
"the",
"entire",
"sequence",
"and",
"adds",
"each",
"element",
"into",
"the",
"given",
"collection",
"that",
"is",
"also",
"returned",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L2322-L2327 |
2,406 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.last | @SuppressWarnings("unchecked")
public final T last() {
if (this instanceof Callable) {
return checkedCall((Callable<T>) this);
}
Iterator<T> it = iterator();
if (!it.hasNext()) {
throw new NoSuchElementException();
}
for (;;) {
T t = it.next();
if (!it.hasNext()) {
return t;
}
}
} | java | @SuppressWarnings("unchecked")
public final T last() {
if (this instanceof Callable) {
return checkedCall((Callable<T>) this);
}
Iterator<T> it = iterator();
if (!it.hasNext()) {
throw new NoSuchElementException();
}
for (;;) {
T t = it.next();
if (!it.hasNext()) {
return t;
}
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"final",
"T",
"last",
"(",
")",
"{",
"if",
"(",
"this",
"instanceof",
"Callable",
")",
"{",
"return",
"checkedCall",
"(",
"(",
"Callable",
"<",
"T",
">",
")",
"this",
")",
";",
"}",
"Iterator",
"<",
"T",
">",
"it",
"=",
"iterator",
"(",
")",
";",
"if",
"(",
"!",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"}",
"for",
"(",
";",
";",
")",
"{",
"T",
"t",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"!",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"return",
"t",
";",
"}",
"}",
"}"
] | Returns the last element of this sequence.
@return the last element of this sequence
@throws NoSuchElementException if the sequence is empty
@since 1.0
@see #last(Object) | [
"Returns",
"the",
"last",
"element",
"of",
"this",
"sequence",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L2336-L2352 |
2,407 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.print | public final void print(CharSequence separator, int charsPerLine) {
boolean first = true;
int len = 0;
for (T v : this) {
String s = String.valueOf(v);
if (first) {
System.out.print(s);
len += s.length();
first = false;
} else {
System.out.print(separator);
len += separator.length();
if (len > charsPerLine) {
System.out.println();
System.out.print(s);
len = s.length();
} else {
System.out.print(s);
len += s.length();
}
}
}
} | java | public final void print(CharSequence separator, int charsPerLine) {
boolean first = true;
int len = 0;
for (T v : this) {
String s = String.valueOf(v);
if (first) {
System.out.print(s);
len += s.length();
first = false;
} else {
System.out.print(separator);
len += separator.length();
if (len > charsPerLine) {
System.out.println();
System.out.print(s);
len = s.length();
} else {
System.out.print(s);
len += s.length();
}
}
}
} | [
"public",
"final",
"void",
"print",
"(",
"CharSequence",
"separator",
",",
"int",
"charsPerLine",
")",
"{",
"boolean",
"first",
"=",
"true",
";",
"int",
"len",
"=",
"0",
";",
"for",
"(",
"T",
"v",
":",
"this",
")",
"{",
"String",
"s",
"=",
"String",
".",
"valueOf",
"(",
"v",
")",
";",
"if",
"(",
"first",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"s",
")",
";",
"len",
"+=",
"s",
".",
"length",
"(",
")",
";",
"first",
"=",
"false",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"print",
"(",
"separator",
")",
";",
"len",
"+=",
"separator",
".",
"length",
"(",
")",
";",
"if",
"(",
"len",
">",
"charsPerLine",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"System",
".",
"out",
".",
"print",
"(",
"s",
")",
";",
"len",
"=",
"s",
".",
"length",
"(",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"print",
"(",
"s",
")",
";",
"len",
"+=",
"s",
".",
"length",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Prints the elements of this sequence to the console, separated
by the given separator and with a line break after roughly the
given charsPerLine amount.
@param separator the characters to separate the elements
@param charsPerLine indicates how long a line should be | [
"Prints",
"the",
"elements",
"of",
"this",
"sequence",
"to",
"the",
"console",
"separated",
"by",
"the",
"given",
"separator",
"and",
"with",
"a",
"line",
"break",
"after",
"roughly",
"the",
"given",
"charsPerLine",
"amount",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L2397-L2423 |
2,408 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.println | public final void println(CharSequence prefix) {
for (T v : this) {
System.out.print(prefix);
System.out.println(v);
}
} | java | public final void println(CharSequence prefix) {
for (T v : this) {
System.out.print(prefix);
System.out.println(v);
}
} | [
"public",
"final",
"void",
"println",
"(",
"CharSequence",
"prefix",
")",
"{",
"for",
"(",
"T",
"v",
":",
"this",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"prefix",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"v",
")",
";",
"}",
"}"
] | Prints each element of this sequence into a new line on the console, prefixed
by the given character sequence.
@param prefix the prefix before each line | [
"Prints",
"each",
"element",
"of",
"this",
"sequence",
"into",
"a",
"new",
"line",
"on",
"the",
"console",
"prefixed",
"by",
"the",
"given",
"character",
"sequence",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L2440-L2445 |
2,409 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.removeAll | public final void removeAll(IxPredicate<? super T> predicate) {
Iterator<T> it = iterator();
while (it.hasNext()) {
T v = it.next();
if (predicate.test(v)) {
it.remove();
}
}
} | java | public final void removeAll(IxPredicate<? super T> predicate) {
Iterator<T> it = iterator();
while (it.hasNext()) {
T v = it.next();
if (predicate.test(v)) {
it.remove();
}
}
} | [
"public",
"final",
"void",
"removeAll",
"(",
"IxPredicate",
"<",
"?",
"super",
"T",
">",
"predicate",
")",
"{",
"Iterator",
"<",
"T",
">",
"it",
"=",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"T",
"v",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"predicate",
".",
"test",
"(",
"v",
")",
")",
"{",
"it",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}"
] | Consumes this Iterable and removes all elements for
which the predicate returns true; in other words,
remove those elements of a mutable source that match
the predicate.
@param predicate the predicate called with the current
element and should return true for elements to remove, false
for elements to keep.
@throws UnsupportedOperationException if the this Iterable
doesn't allow removing elements.
@see #retainAll(IxPredicate)
@see #removeAll()
@since 1.0 | [
"Consumes",
"this",
"Iterable",
"and",
"removes",
"all",
"elements",
"for",
"which",
"the",
"predicate",
"returns",
"true",
";",
"in",
"other",
"words",
"remove",
"those",
"elements",
"of",
"a",
"mutable",
"source",
"that",
"match",
"the",
"predicate",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L2471-L2479 |
2,410 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.single | public final T single() {
Iterator<T> it = iterator();
if (it.hasNext()) {
T v = it.next();
if (it.hasNext()) {
throw new IndexOutOfBoundsException("The source has more than one element.");
}
return v;
}
throw new NoSuchElementException("The source is empty.");
} | java | public final T single() {
Iterator<T> it = iterator();
if (it.hasNext()) {
T v = it.next();
if (it.hasNext()) {
throw new IndexOutOfBoundsException("The source has more than one element.");
}
return v;
}
throw new NoSuchElementException("The source is empty.");
} | [
"public",
"final",
"T",
"single",
"(",
")",
"{",
"Iterator",
"<",
"T",
">",
"it",
"=",
"iterator",
"(",
")",
";",
"if",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"T",
"v",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"The source has more than one element.\"",
")",
";",
"}",
"return",
"v",
";",
"}",
"throw",
"new",
"NoSuchElementException",
"(",
"\"The source is empty.\"",
")",
";",
"}"
] | Returns the single element of this sequence or throws a NoSuchElementException
if this sequence is empty or IndexOutOfBoundsException if this sequence has more
than on element
@return the single element of the sequence
@throws IndexOutOfBoundsException if the sequence has more than one element
@throws NoSuchElementException if the sequence is empty
@since 1.0
@see #single(Object) | [
"Returns",
"the",
"single",
"element",
"of",
"this",
"sequence",
"or",
"throws",
"a",
"NoSuchElementException",
"if",
"this",
"sequence",
"is",
"empty",
"or",
"IndexOutOfBoundsException",
"if",
"this",
"sequence",
"has",
"more",
"than",
"on",
"element"
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L2524-L2534 |
2,411 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.subscribe | public final void subscribe(IxConsumer<? super T> onNext, IxConsumer<Throwable> onError) {
try {
for (T v : this) {
onNext.accept(v);
}
} catch (Throwable ex) {
onError.accept(ex);
}
} | java | public final void subscribe(IxConsumer<? super T> onNext, IxConsumer<Throwable> onError) {
try {
for (T v : this) {
onNext.accept(v);
}
} catch (Throwable ex) {
onError.accept(ex);
}
} | [
"public",
"final",
"void",
"subscribe",
"(",
"IxConsumer",
"<",
"?",
"super",
"T",
">",
"onNext",
",",
"IxConsumer",
"<",
"Throwable",
">",
"onError",
")",
"{",
"try",
"{",
"for",
"(",
"T",
"v",
":",
"this",
")",
"{",
"onNext",
".",
"accept",
"(",
"v",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"ex",
")",
"{",
"onError",
".",
"accept",
"(",
"ex",
")",
";",
"}",
"}"
] | Iterates over this sequence and calls the given onNext action with
each element and calls the onError with any exception thrown by the iteration
or the onNext action.
@param onNext the consumer to call with each element
@param onError the consumer to call with the exception thrown
@throws NullPointerException if onError is null
@since 1.0 | [
"Iterates",
"over",
"this",
"sequence",
"and",
"calls",
"the",
"given",
"onNext",
"action",
"with",
"each",
"element",
"and",
"calls",
"the",
"onError",
"with",
"any",
"exception",
"thrown",
"by",
"the",
"iteration",
"or",
"the",
"onNext",
"action",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L2589-L2597 |
2,412 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.subscribe | public final void subscribe(IxConsumer<? super T> onNext, IxConsumer<Throwable> onError, Runnable onCompleted) {
try {
for (T v : this) {
onNext.accept(v);
}
} catch (Throwable ex) {
onError.accept(ex);
return;
}
onCompleted.run();
} | java | public final void subscribe(IxConsumer<? super T> onNext, IxConsumer<Throwable> onError, Runnable onCompleted) {
try {
for (T v : this) {
onNext.accept(v);
}
} catch (Throwable ex) {
onError.accept(ex);
return;
}
onCompleted.run();
} | [
"public",
"final",
"void",
"subscribe",
"(",
"IxConsumer",
"<",
"?",
"super",
"T",
">",
"onNext",
",",
"IxConsumer",
"<",
"Throwable",
">",
"onError",
",",
"Runnable",
"onCompleted",
")",
"{",
"try",
"{",
"for",
"(",
"T",
"v",
":",
"this",
")",
"{",
"onNext",
".",
"accept",
"(",
"v",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"ex",
")",
"{",
"onError",
".",
"accept",
"(",
"ex",
")",
";",
"return",
";",
"}",
"onCompleted",
".",
"run",
"(",
")",
";",
"}"
] | Iterates over this sequence and calls the given onNext action with
each element and calls the onError with any exception thrown by the iteration
or the onNext action; otherwise calls the onCompleted action when the sequence completes
without exception.
@param onNext the consumer to call with each element
@param onError the consumer to call with the exception thrown
@param onCompleted the action called after the sequence has been consumed
@throws NullPointerException if onError or onCompleted is null
@since 1.0 | [
"Iterates",
"over",
"this",
"sequence",
"and",
"calls",
"the",
"given",
"onNext",
"action",
"with",
"each",
"element",
"and",
"calls",
"the",
"onError",
"with",
"any",
"exception",
"thrown",
"by",
"the",
"iteration",
"or",
"the",
"onNext",
"action",
";",
"otherwise",
"calls",
"the",
"onCompleted",
"action",
"when",
"the",
"sequence",
"completes",
"without",
"exception",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L2610-L2620 |
2,413 | akarnokd/ixjava | src/main/java/ix/Ix.java | Ix.nullCheck | protected static <U> U nullCheck(U value, String message) {
if (value == null) {
throw new NullPointerException(message);
}
return value;
} | java | protected static <U> U nullCheck(U value, String message) {
if (value == null) {
throw new NullPointerException(message);
}
return value;
} | [
"protected",
"static",
"<",
"U",
">",
"U",
"nullCheck",
"(",
"U",
"value",
",",
"String",
"message",
")",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"message",
")",
";",
"}",
"return",
"value",
";",
"}"
] | Checks if the value is null and if so, throws
a NullPointerException with the given message.
@param <U> the value type
@param value the value to check for null
@param message the message to report in the exception
@return the value | [
"Checks",
"if",
"the",
"value",
"is",
"null",
"and",
"if",
"so",
"throws",
"a",
"NullPointerException",
"with",
"the",
"given",
"message",
"."
] | add721bba550c36541faa450e40a975bb65e78d7 | https://github.com/akarnokd/ixjava/blob/add721bba550c36541faa450e40a975bb65e78d7/src/main/java/ix/Ix.java#L2749-L2754 |
2,414 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/Outcome.java | Outcome.encode | public static Stream<Statement> encode(final Stream<? extends Outcome> stream) {
Preconditions.checkNotNull(stream);
return Record.encode(stream.transform(new Function<Outcome, Record>() {
@Override
public Record apply(final Outcome outcome) {
return outcome.toRecord();
}
}, 0), ImmutableSet.of(KSR.INVOCATION));
} | java | public static Stream<Statement> encode(final Stream<? extends Outcome> stream) {
Preconditions.checkNotNull(stream);
return Record.encode(stream.transform(new Function<Outcome, Record>() {
@Override
public Record apply(final Outcome outcome) {
return outcome.toRecord();
}
}, 0), ImmutableSet.of(KSR.INVOCATION));
} | [
"public",
"static",
"Stream",
"<",
"Statement",
">",
"encode",
"(",
"final",
"Stream",
"<",
"?",
"extends",
"Outcome",
">",
"stream",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"stream",
")",
";",
"return",
"Record",
".",
"encode",
"(",
"stream",
".",
"transform",
"(",
"new",
"Function",
"<",
"Outcome",
",",
"Record",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Record",
"apply",
"(",
"final",
"Outcome",
"outcome",
")",
"{",
"return",
"outcome",
".",
"toRecord",
"(",
")",
";",
"}",
"}",
",",
"0",
")",
",",
"ImmutableSet",
".",
"of",
"(",
"KSR",
".",
"INVOCATION",
")",
")",
";",
"}"
] | Performs outcome-to-RDF encoding by converting a stream of outcomes in a stream of RDF
statements.
@param stream
the stream of outcomes to encode.
@return the resulting stream of statements | [
"Performs",
"outcome",
"-",
"to",
"-",
"RDF",
"encoding",
"by",
"converting",
"a",
"stream",
"of",
"outcomes",
"in",
"a",
"stream",
"of",
"RDF",
"statements",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/Outcome.java#L254-L264 |
2,415 | dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/AbstractHBaseUtils.java | AbstractHBaseUtils.createConfiguration | public void createConfiguration(final Properties properties) {
setHbcfg(HBaseConfiguration.create());
getHbcfg().set(HBASE_ZOOKEEPER_QUORUM,
properties.getProperty(HBASE_ZOOKEEPER_QUORUM, "hlt-services4"));
getHbcfg().set(HBASE_ZOOKEEPER_CLIENT_PORT,
properties.getProperty(HBASE_ZOOKEEPER_CLIENT_PORT, "2181"));
getHbcfg().set(HADOOP_FS_DEFAULT_NAME,
properties.getProperty(HADOOP_FS_DEFAULT_NAME, "hdfs://hlt-services4:9000"));
// getHbcfg().set("hbase.client.retries.number", "1");
} | java | public void createConfiguration(final Properties properties) {
setHbcfg(HBaseConfiguration.create());
getHbcfg().set(HBASE_ZOOKEEPER_QUORUM,
properties.getProperty(HBASE_ZOOKEEPER_QUORUM, "hlt-services4"));
getHbcfg().set(HBASE_ZOOKEEPER_CLIENT_PORT,
properties.getProperty(HBASE_ZOOKEEPER_CLIENT_PORT, "2181"));
getHbcfg().set(HADOOP_FS_DEFAULT_NAME,
properties.getProperty(HADOOP_FS_DEFAULT_NAME, "hdfs://hlt-services4:9000"));
// getHbcfg().set("hbase.client.retries.number", "1");
} | [
"public",
"void",
"createConfiguration",
"(",
"final",
"Properties",
"properties",
")",
"{",
"setHbcfg",
"(",
"HBaseConfiguration",
".",
"create",
"(",
")",
")",
";",
"getHbcfg",
"(",
")",
".",
"set",
"(",
"HBASE_ZOOKEEPER_QUORUM",
",",
"properties",
".",
"getProperty",
"(",
"HBASE_ZOOKEEPER_QUORUM",
",",
"\"hlt-services4\"",
")",
")",
";",
"getHbcfg",
"(",
")",
".",
"set",
"(",
"HBASE_ZOOKEEPER_CLIENT_PORT",
",",
"properties",
".",
"getProperty",
"(",
"HBASE_ZOOKEEPER_CLIENT_PORT",
",",
"\"2181\"",
")",
")",
";",
"getHbcfg",
"(",
")",
".",
"set",
"(",
"HADOOP_FS_DEFAULT_NAME",
",",
"properties",
".",
"getProperty",
"(",
"HADOOP_FS_DEFAULT_NAME",
",",
"\"hdfs://hlt-services4:9000\"",
")",
")",
";",
"// getHbcfg().set(\"hbase.client.retries.number\", \"1\");",
"}"
] | Creates an HBase configuration object.
@param properties the configuration properties | [
"Creates",
"an",
"HBase",
"configuration",
"object",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/AbstractHBaseUtils.java#L178-L192 |
2,416 | dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/AbstractHBaseUtils.java | AbstractHBaseUtils.getFilter | public FilterList getFilter(XPath condition, boolean passAll,
String []famNames, String []qualNames, String []params) {
FilterList list = new FilterList((passAll)?FilterList.Operator.MUST_PASS_ALL:
FilterList.Operator.MUST_PASS_ONE);
for (int iCont = 0; iCont < famNames.length; iCont ++) {
SingleColumnValueFilter filterTmp = new SingleColumnValueFilter(
Bytes.toBytes(famNames[iCont]),
Bytes.toBytes(qualNames[iCont]),
CompareOp.EQUAL,
Bytes.toBytes(params[iCont])
);
list.addFilter(filterTmp);
}
return list;
} | java | public FilterList getFilter(XPath condition, boolean passAll,
String []famNames, String []qualNames, String []params) {
FilterList list = new FilterList((passAll)?FilterList.Operator.MUST_PASS_ALL:
FilterList.Operator.MUST_PASS_ONE);
for (int iCont = 0; iCont < famNames.length; iCont ++) {
SingleColumnValueFilter filterTmp = new SingleColumnValueFilter(
Bytes.toBytes(famNames[iCont]),
Bytes.toBytes(qualNames[iCont]),
CompareOp.EQUAL,
Bytes.toBytes(params[iCont])
);
list.addFilter(filterTmp);
}
return list;
} | [
"public",
"FilterList",
"getFilter",
"(",
"XPath",
"condition",
",",
"boolean",
"passAll",
",",
"String",
"[",
"]",
"famNames",
",",
"String",
"[",
"]",
"qualNames",
",",
"String",
"[",
"]",
"params",
")",
"{",
"FilterList",
"list",
"=",
"new",
"FilterList",
"(",
"(",
"passAll",
")",
"?",
"FilterList",
".",
"Operator",
".",
"MUST_PASS_ALL",
":",
"FilterList",
".",
"Operator",
".",
"MUST_PASS_ONE",
")",
";",
"for",
"(",
"int",
"iCont",
"=",
"0",
";",
"iCont",
"<",
"famNames",
".",
"length",
";",
"iCont",
"++",
")",
"{",
"SingleColumnValueFilter",
"filterTmp",
"=",
"new",
"SingleColumnValueFilter",
"(",
"Bytes",
".",
"toBytes",
"(",
"famNames",
"[",
"iCont",
"]",
")",
",",
"Bytes",
".",
"toBytes",
"(",
"qualNames",
"[",
"iCont",
"]",
")",
",",
"CompareOp",
".",
"EQUAL",
",",
"Bytes",
".",
"toBytes",
"(",
"params",
"[",
"iCont",
"]",
")",
")",
";",
"list",
".",
"addFilter",
"(",
"filterTmp",
")",
";",
"}",
"return",
"list",
";",
"}"
] | Gets filter based on the condition to be performed
@param condition To be applied server sided
@param passAll boolean if all elements have to pass the test
@param famNames to be checked
@param qualNames to be checked
@param params that could be needed
@return FilterList containing all filters needed | [
"Gets",
"filter",
"based",
"on",
"the",
"condition",
"to",
"be",
"performed"
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/AbstractHBaseUtils.java#L203-L217 |
2,417 | dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/AbstractHBaseUtils.java | AbstractHBaseUtils.getResultScan | public Scan getResultScan(String tableName, String famName,
ByteBuffer startKey, ByteBuffer endKey) throws IOException {
logger.debug("AbstractHBaseUtils Begin of getResultScan(" + tableName + ", " + famName + ")");
Scan scan = new Scan();
scan.addFamily(Bytes.toBytes(famName));
// For a range scan, set start / stop id or just start.
if (startKey != null)
scan.setStartRow(Bytes.toBytes(startKey));
if (endKey != null)
scan.setStopRow(Bytes.toBytes(endKey));
return scan;
} | java | public Scan getResultScan(String tableName, String famName,
ByteBuffer startKey, ByteBuffer endKey) throws IOException {
logger.debug("AbstractHBaseUtils Begin of getResultScan(" + tableName + ", " + famName + ")");
Scan scan = new Scan();
scan.addFamily(Bytes.toBytes(famName));
// For a range scan, set start / stop id or just start.
if (startKey != null)
scan.setStartRow(Bytes.toBytes(startKey));
if (endKey != null)
scan.setStopRow(Bytes.toBytes(endKey));
return scan;
} | [
"public",
"Scan",
"getResultScan",
"(",
"String",
"tableName",
",",
"String",
"famName",
",",
"ByteBuffer",
"startKey",
",",
"ByteBuffer",
"endKey",
")",
"throws",
"IOException",
"{",
"logger",
".",
"debug",
"(",
"\"AbstractHBaseUtils Begin of getResultScan(\"",
"+",
"tableName",
"+",
"\", \"",
"+",
"famName",
"+",
"\")\"",
")",
";",
"Scan",
"scan",
"=",
"new",
"Scan",
"(",
")",
";",
"scan",
".",
"addFamily",
"(",
"Bytes",
".",
"toBytes",
"(",
"famName",
")",
")",
";",
"// For a range scan, set start / stop id or just start.",
"if",
"(",
"startKey",
"!=",
"null",
")",
"scan",
".",
"setStartRow",
"(",
"Bytes",
".",
"toBytes",
"(",
"startKey",
")",
")",
";",
"if",
"(",
"endKey",
"!=",
"null",
")",
"scan",
".",
"setStopRow",
"(",
"Bytes",
".",
"toBytes",
"(",
"endKey",
")",
")",
";",
"return",
"scan",
";",
"}"
] | Creates a scan
@param tableName to be scan
@param famName to be checked
@param startKey to query the table
@param endKey to query the table
@param conf
@return Scan inside the table
@throws IOException | [
"Creates",
"a",
"scan"
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/AbstractHBaseUtils.java#L229-L240 |
2,418 | dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/AbstractHBaseUtils.java | AbstractHBaseUtils.getScan | public Scan getScan(String tableName,
String famName) throws IOException {
return getResultScan(tableName, famName, null, null);
} | java | public Scan getScan(String tableName,
String famName) throws IOException {
return getResultScan(tableName, famName, null, null);
} | [
"public",
"Scan",
"getScan",
"(",
"String",
"tableName",
",",
"String",
"famName",
")",
"throws",
"IOException",
"{",
"return",
"getResultScan",
"(",
"tableName",
",",
"famName",
",",
"null",
",",
"null",
")",
";",
"}"
] | Creates a result scanner
@param tableName
@param famName
@param conf
@return
@throws IOException | [
"Creates",
"a",
"result",
"scanner"
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/AbstractHBaseUtils.java#L250-L253 |
2,419 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Smaz.java | Smaz.decompress | public static String decompress(final byte[] strBytes) {
if (strBytes[0] == UNCOMPRESSED_FLAG) {
return new String(strBytes, 1, strBytes.length, Charsets.UTF_8);
}
final StringBuilder out = new StringBuilder();
for (int i = 0; i < strBytes.length; i++) {
final char b = (char) (0xFF & strBytes[i]);
if (b == 254) {
out.append((char) strBytes[++i]);
} else if (b == 255) {
final int length = 0xFF & strBytes[++i];
for (int j = 1; j <= length; j++) {
out.append((char) strBytes[i + j]);
}
i += length;
} else {
final int loc = 0xFF & b;
out.append(REVERSE_CODEBOOK[loc]);
}
}
return out.toString();
} | java | public static String decompress(final byte[] strBytes) {
if (strBytes[0] == UNCOMPRESSED_FLAG) {
return new String(strBytes, 1, strBytes.length, Charsets.UTF_8);
}
final StringBuilder out = new StringBuilder();
for (int i = 0; i < strBytes.length; i++) {
final char b = (char) (0xFF & strBytes[i]);
if (b == 254) {
out.append((char) strBytes[++i]);
} else if (b == 255) {
final int length = 0xFF & strBytes[++i];
for (int j = 1; j <= length; j++) {
out.append((char) strBytes[i + j]);
}
i += length;
} else {
final int loc = 0xFF & b;
out.append(REVERSE_CODEBOOK[loc]);
}
}
return out.toString();
} | [
"public",
"static",
"String",
"decompress",
"(",
"final",
"byte",
"[",
"]",
"strBytes",
")",
"{",
"if",
"(",
"strBytes",
"[",
"0",
"]",
"==",
"UNCOMPRESSED_FLAG",
")",
"{",
"return",
"new",
"String",
"(",
"strBytes",
",",
"1",
",",
"strBytes",
".",
"length",
",",
"Charsets",
".",
"UTF_8",
")",
";",
"}",
"final",
"StringBuilder",
"out",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"strBytes",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"char",
"b",
"=",
"(",
"char",
")",
"(",
"0xFF",
"&",
"strBytes",
"[",
"i",
"]",
")",
";",
"if",
"(",
"b",
"==",
"254",
")",
"{",
"out",
".",
"append",
"(",
"(",
"char",
")",
"strBytes",
"[",
"++",
"i",
"]",
")",
";",
"}",
"else",
"if",
"(",
"b",
"==",
"255",
")",
"{",
"final",
"int",
"length",
"=",
"0xFF",
"&",
"strBytes",
"[",
"++",
"i",
"]",
";",
"for",
"(",
"int",
"j",
"=",
"1",
";",
"j",
"<=",
"length",
";",
"j",
"++",
")",
"{",
"out",
".",
"append",
"(",
"(",
"char",
")",
"strBytes",
"[",
"i",
"+",
"j",
"]",
")",
";",
"}",
"i",
"+=",
"length",
";",
"}",
"else",
"{",
"final",
"int",
"loc",
"=",
"0xFF",
"&",
"b",
";",
"out",
".",
"append",
"(",
"REVERSE_CODEBOOK",
"[",
"loc",
"]",
")",
";",
"}",
"}",
"return",
"out",
".",
"toString",
"(",
")",
";",
"}"
] | Decompress byte array from compress back into String
@param strBytes
@return decompressed String
@see Smaz#compress(String) | [
"Decompress",
"byte",
"array",
"from",
"compress",
"back",
"into",
"String"
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Smaz.java#L217-L241 |
2,420 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Smaz.java | Smaz.outputVerb | private static void outputVerb(final ByteArrayOutputStream baos, final String str) {
if (str.length() == 1) {
baos.write(254);
baos.write(str.toCharArray()[0]);
} else {
final byte[] bytes = str.getBytes(Charsets.UTF_8);
baos.write(255);
baos.write(str.length());
baos.write(bytes, 0, bytes.length);
}
} | java | private static void outputVerb(final ByteArrayOutputStream baos, final String str) {
if (str.length() == 1) {
baos.write(254);
baos.write(str.toCharArray()[0]);
} else {
final byte[] bytes = str.getBytes(Charsets.UTF_8);
baos.write(255);
baos.write(str.length());
baos.write(bytes, 0, bytes.length);
}
} | [
"private",
"static",
"void",
"outputVerb",
"(",
"final",
"ByteArrayOutputStream",
"baos",
",",
"final",
"String",
"str",
")",
"{",
"if",
"(",
"str",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"baos",
".",
"write",
"(",
"254",
")",
";",
"baos",
".",
"write",
"(",
"str",
".",
"toCharArray",
"(",
")",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"final",
"byte",
"[",
"]",
"bytes",
"=",
"str",
".",
"getBytes",
"(",
"Charsets",
".",
"UTF_8",
")",
";",
"baos",
".",
"write",
"(",
"255",
")",
";",
"baos",
".",
"write",
"(",
"str",
".",
"length",
"(",
")",
")",
";",
"baos",
".",
"write",
"(",
"bytes",
",",
"0",
",",
"bytes",
".",
"length",
")",
";",
"}",
"}"
] | Outputs the verbatim string to the output stream
@param baos
@param str | [
"Outputs",
"the",
"verbatim",
"string",
"to",
"the",
"output",
"stream"
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Smaz.java#L262-L272 |
2,421 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java | Stream.create | public static <T> Stream<T> create(final Iterator<? extends T> iterator) {
if (iterator.hasNext()) {
return new IteratorStream<T>(iterator);
} else {
return new EmptyStream<T>();
}
} | java | public static <T> Stream<T> create(final Iterator<? extends T> iterator) {
if (iterator.hasNext()) {
return new IteratorStream<T>(iterator);
} else {
return new EmptyStream<T>();
}
} | [
"public",
"static",
"<",
"T",
">",
"Stream",
"<",
"T",
">",
"create",
"(",
"final",
"Iterator",
"<",
"?",
"extends",
"T",
">",
"iterator",
")",
"{",
"if",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"return",
"new",
"IteratorStream",
"<",
"T",
">",
"(",
"iterator",
")",
";",
"}",
"else",
"{",
"return",
"new",
"EmptyStream",
"<",
"T",
">",
"(",
")",
";",
"}",
"}"
] | Creates a new Stream over the elements returned by the supplied Iterator.
@param iterator
an Iterator returning non-null elements
@param <T>
the type of elements
@return a Stream over the elements returned by the supplied Iterator | [
"Creates",
"a",
"new",
"Stream",
"over",
"the",
"elements",
"returned",
"by",
"the",
"supplied",
"Iterator",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java#L228-L234 |
2,422 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java | Stream.create | public static <T> Stream<T> create(final Iteration<? extends T, ?> iteration) {
return new IterationStream<T>(iteration);
} | java | public static <T> Stream<T> create(final Iteration<? extends T, ?> iteration) {
return new IterationStream<T>(iteration);
} | [
"public",
"static",
"<",
"T",
">",
"Stream",
"<",
"T",
">",
"create",
"(",
"final",
"Iteration",
"<",
"?",
"extends",
"T",
",",
"?",
">",
"iteration",
")",
"{",
"return",
"new",
"IterationStream",
"<",
"T",
">",
"(",
"iteration",
")",
";",
"}"
] | Creates a new Stream over the elements returned by the supplied Sesame Iteration.
@param iteration
the Iteration
@param <T>
the type of elements
@return a Stream over the elements returned by the supplied Iteration | [
"Creates",
"a",
"new",
"Stream",
"over",
"the",
"elements",
"returned",
"by",
"the",
"supplied",
"Sesame",
"Iteration",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java#L245-L247 |
2,423 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java | Stream.create | public static <T> Stream<T> create(final Enumeration<? extends T> enumeration) {
if (enumeration.hasMoreElements()) {
return new IteratorStream<T>(Iterators.forEnumeration(enumeration));
} else {
return new EmptyStream<T>();
}
} | java | public static <T> Stream<T> create(final Enumeration<? extends T> enumeration) {
if (enumeration.hasMoreElements()) {
return new IteratorStream<T>(Iterators.forEnumeration(enumeration));
} else {
return new EmptyStream<T>();
}
} | [
"public",
"static",
"<",
"T",
">",
"Stream",
"<",
"T",
">",
"create",
"(",
"final",
"Enumeration",
"<",
"?",
"extends",
"T",
">",
"enumeration",
")",
"{",
"if",
"(",
"enumeration",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"return",
"new",
"IteratorStream",
"<",
"T",
">",
"(",
"Iterators",
".",
"forEnumeration",
"(",
"enumeration",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"EmptyStream",
"<",
"T",
">",
"(",
")",
";",
"}",
"}"
] | Creates a new Stream over the elements returned by the supplied Enumeration.
@param enumeration
an Enumeration of non-null elements
@param <T>
the type of elements
@return a Stream over the elements returned by the supplied Enumeration | [
"Creates",
"a",
"new",
"Stream",
"over",
"the",
"elements",
"returned",
"by",
"the",
"supplied",
"Enumeration",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java#L258-L264 |
2,424 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java | Stream.concat | public static <T> Stream<T> concat(final Iterable<? extends Iterable<? extends T>> iterables) {
return new ConcatStream<Iterable<? extends T>, T>(create(iterables));
} | java | public static <T> Stream<T> concat(final Iterable<? extends Iterable<? extends T>> iterables) {
return new ConcatStream<Iterable<? extends T>, T>(create(iterables));
} | [
"public",
"static",
"<",
"T",
">",
"Stream",
"<",
"T",
">",
"concat",
"(",
"final",
"Iterable",
"<",
"?",
"extends",
"Iterable",
"<",
"?",
"extends",
"T",
">",
">",
"iterables",
")",
"{",
"return",
"new",
"ConcatStream",
"<",
"Iterable",
"<",
"?",
"extends",
"T",
">",
",",
"T",
">",
"(",
"create",
"(",
"iterables",
")",
")",
";",
"}"
] | Returns a Stream concatenating zero or more Iterables. If an input Iterable is a Stream, it
is closed as soon as exhausted or as iteration completes.
@param iterables
an Iterable with the Iterables or Streams to concatenate
@param <T>
the type of elements
@return the resulting concatenated Stream | [
"Returns",
"a",
"Stream",
"concatenating",
"zero",
"or",
"more",
"Iterables",
".",
"If",
"an",
"input",
"Iterable",
"is",
"a",
"Stream",
"it",
"is",
"closed",
"as",
"soon",
"as",
"exhausted",
"or",
"as",
"iteration",
"completes",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java#L276-L278 |
2,425 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java | Stream.count | public final long count() {
final AtomicLong result = new AtomicLong();
toHandler(new Handler<T>() {
private long count;
@Override
public void handle(final T element) {
if (element != null) {
++this.count;
} else {
result.set(this.count);
}
}
});
return result.get();
} | java | public final long count() {
final AtomicLong result = new AtomicLong();
toHandler(new Handler<T>() {
private long count;
@Override
public void handle(final T element) {
if (element != null) {
++this.count;
} else {
result.set(this.count);
}
}
});
return result.get();
} | [
"public",
"final",
"long",
"count",
"(",
")",
"{",
"final",
"AtomicLong",
"result",
"=",
"new",
"AtomicLong",
"(",
")",
";",
"toHandler",
"(",
"new",
"Handler",
"<",
"T",
">",
"(",
")",
"{",
"private",
"long",
"count",
";",
"@",
"Override",
"public",
"void",
"handle",
"(",
"final",
"T",
"element",
")",
"{",
"if",
"(",
"element",
"!=",
"null",
")",
"{",
"++",
"this",
".",
"count",
";",
"}",
"else",
"{",
"result",
".",
"set",
"(",
"this",
".",
"count",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"result",
".",
"get",
"(",
")",
";",
"}"
] | Terminal operation returning the number of elements in this Stream. Note that only few
elements are materialized at any time, so it is safe to use this method with arbitrarily
large Streams.
@return the number of elements in this Stream | [
"Terminal",
"operation",
"returning",
"the",
"number",
"of",
"elements",
"in",
"this",
"Stream",
".",
"Note",
"that",
"only",
"few",
"elements",
"are",
"materialized",
"at",
"any",
"time",
"so",
"it",
"is",
"safe",
"to",
"use",
"this",
"method",
"with",
"arbitrarily",
"large",
"Streams",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java#L477-L495 |
2,426 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java | Stream.toArray | public final T[] toArray(final Class<T> elementClass) {
return Iterables.toArray(toCollection(Lists.<T>newArrayListWithCapacity(256)),
elementClass);
} | java | public final T[] toArray(final Class<T> elementClass) {
return Iterables.toArray(toCollection(Lists.<T>newArrayListWithCapacity(256)),
elementClass);
} | [
"public",
"final",
"T",
"[",
"]",
"toArray",
"(",
"final",
"Class",
"<",
"T",
">",
"elementClass",
")",
"{",
"return",
"Iterables",
".",
"toArray",
"(",
"toCollection",
"(",
"Lists",
".",
"<",
"T",
">",
"newArrayListWithCapacity",
"(",
"256",
")",
")",
",",
"elementClass",
")",
";",
"}"
] | Terminal operation returning an array of the specified type with all the elements of this
Stream. Call this method only if there is enough memory to hold the resulting array.
@param elementClass
the type of element to be stored in the array (necessary for the array creation)
@return the resulting array | [
"Terminal",
"operation",
"returning",
"an",
"array",
"of",
"the",
"specified",
"type",
"with",
"all",
"the",
"elements",
"of",
"this",
"Stream",
".",
"Call",
"this",
"method",
"only",
"if",
"there",
"is",
"enough",
"memory",
"to",
"hold",
"the",
"resulting",
"array",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java#L557-L560 |
2,427 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java | Stream.toCollection | public final <C extends Collection<? super T>> C toCollection(final C collection) {
Preconditions.checkNotNull(collection);
toHandler(new Handler<T>() {
@Override
public void handle(final T element) {
if (element != null) {
collection.add(element);
}
}
});
return collection;
} | java | public final <C extends Collection<? super T>> C toCollection(final C collection) {
Preconditions.checkNotNull(collection);
toHandler(new Handler<T>() {
@Override
public void handle(final T element) {
if (element != null) {
collection.add(element);
}
}
});
return collection;
} | [
"public",
"final",
"<",
"C",
"extends",
"Collection",
"<",
"?",
"super",
"T",
">",
">",
"C",
"toCollection",
"(",
"final",
"C",
"collection",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"collection",
")",
";",
"toHandler",
"(",
"new",
"Handler",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"handle",
"(",
"final",
"T",
"element",
")",
"{",
"if",
"(",
"element",
"!=",
"null",
")",
"{",
"collection",
".",
"add",
"(",
"element",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"collection",
";",
"}"
] | Terminal operation storing all the elements of this Stream in the supplied Collection. Call
this method only if the target Collection can hold all the remaining elements.
@param collection
the Collection where to store elements, not null
@param <C>
the type of Collection
@return the supplied Collection | [
"Terminal",
"operation",
"storing",
"all",
"the",
"elements",
"of",
"this",
"Stream",
"in",
"the",
"supplied",
"Collection",
".",
"Call",
"this",
"method",
"only",
"if",
"the",
"target",
"Collection",
"can",
"hold",
"all",
"the",
"remaining",
"elements",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java#L649-L661 |
2,428 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java | Stream.getUnique | public final T getUnique(final T defaultValue) {
try {
final T result = getUnique();
if (result != null) {
return result;
}
} catch (final Throwable ex) {
// ignore
}
return defaultValue;
} | java | public final T getUnique(final T defaultValue) {
try {
final T result = getUnique();
if (result != null) {
return result;
}
} catch (final Throwable ex) {
// ignore
}
return defaultValue;
} | [
"public",
"final",
"T",
"getUnique",
"(",
"final",
"T",
"defaultValue",
")",
"{",
"try",
"{",
"final",
"T",
"result",
"=",
"getUnique",
"(",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"catch",
"(",
"final",
"Throwable",
"ex",
")",
"{",
"// ignore",
"}",
"return",
"defaultValue",
";",
"}"
] | Terminal operation returning the only element in this Stream, or the default value
specified if there are no elements, multiple elements or an Exception occurs.
@param defaultValue
the default value to return if a unique value cannot be extracted
@return the only element in this Stream, or the default value in case that element does not
exist, there are multiple elements or an Exception occurs | [
"Terminal",
"operation",
"returning",
"the",
"only",
"element",
"in",
"this",
"Stream",
"or",
"the",
"default",
"value",
"specified",
"if",
"there",
"are",
"no",
"elements",
"multiple",
"elements",
"or",
"an",
"Exception",
"occurs",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Stream.java#L811-L821 |
2,429 | yoojia/NextInputs-Android | inputs/src/main/java/com/github/yoojia/inputs/Texts.java | Texts.regexMatch | public static boolean regexMatch(String input, String regex) {
return Pattern.compile(regex).matcher(input).matches();
} | java | public static boolean regexMatch(String input, String regex) {
return Pattern.compile(regex).matcher(input).matches();
} | [
"public",
"static",
"boolean",
"regexMatch",
"(",
"String",
"input",
",",
"String",
"regex",
")",
"{",
"return",
"Pattern",
".",
"compile",
"(",
"regex",
")",
".",
"matcher",
"(",
"input",
")",
".",
"matches",
"(",
")",
";",
"}"
] | If input matched regex
@param input Input String
@param regex Regex
@return is matched | [
"If",
"input",
"matched",
"regex"
] | 9ca90cf47e84c41ac226d04694194334d2923252 | https://github.com/yoojia/NextInputs-Android/blob/9ca90cf47e84c41ac226d04694194334d2923252/inputs/src/main/java/com/github/yoojia/inputs/Texts.java#L27-L29 |
2,430 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/Operation.java | Operation.timeout | public synchronized Operation timeout(@Nullable final Long timeout) {
this.timeout = timeout == null || timeout > 0 ? timeout : null;
return this;
} | java | public synchronized Operation timeout(@Nullable final Long timeout) {
this.timeout = timeout == null || timeout > 0 ? timeout : null;
return this;
} | [
"public",
"synchronized",
"Operation",
"timeout",
"(",
"@",
"Nullable",
"final",
"Long",
"timeout",
")",
"{",
"this",
".",
"timeout",
"=",
"timeout",
"==",
"null",
"||",
"timeout",
">",
"0",
"?",
"timeout",
":",
"null",
";",
"return",
"this",
";",
"}"
] | Sets the optional timeout for this operation in milliseconds. Passing null or a
non-positive value will remove any timeout previously set.
@param timeout
the timeout; null or non-positive to reset
@return this operation object for call chaining | [
"Sets",
"the",
"optional",
"timeout",
"for",
"this",
"operation",
"in",
"milliseconds",
".",
"Passing",
"null",
"or",
"a",
"non",
"-",
"positive",
"value",
"will",
"remove",
"any",
"timeout",
"previously",
"set",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/Operation.java#L69-L72 |
2,431 | dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/HBaseDataStore.java | HBaseDataStore.checkAndCreateTable | private void checkAndCreateTable(final String tabName, final String colFamName)
throws IOException
{
hbaseUtils.checkAndCreateTable(tabName, colFamName);
} | java | private void checkAndCreateTable(final String tabName, final String colFamName)
throws IOException
{
hbaseUtils.checkAndCreateTable(tabName, colFamName);
} | [
"private",
"void",
"checkAndCreateTable",
"(",
"final",
"String",
"tabName",
",",
"final",
"String",
"colFamName",
")",
"throws",
"IOException",
"{",
"hbaseUtils",
".",
"checkAndCreateTable",
"(",
"tabName",
",",
"colFamName",
")",
";",
"}"
] | Verifies the existence of tables.
@param tableName to be verified
@param columnFamilyName of the table
@throws IOException | [
"Verifies",
"the",
"existence",
"of",
"tables",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/HBaseDataStore.java#L132-L136 |
2,432 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Criteria.java | Criteria.merge | public final void merge(final Record oldRecord, final Record newRecord) {
Preconditions.checkNotNull(oldRecord);
for (final URI property : newRecord.getProperties()) {
if (appliesTo(property)) {
oldRecord.set(property,
merge(property, oldRecord.get(property), newRecord.get(property)));
}
}
} | java | public final void merge(final Record oldRecord, final Record newRecord) {
Preconditions.checkNotNull(oldRecord);
for (final URI property : newRecord.getProperties()) {
if (appliesTo(property)) {
oldRecord.set(property,
merge(property, oldRecord.get(property), newRecord.get(property)));
}
}
} | [
"public",
"final",
"void",
"merge",
"(",
"final",
"Record",
"oldRecord",
",",
"final",
"Record",
"newRecord",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"oldRecord",
")",
";",
"for",
"(",
"final",
"URI",
"property",
":",
"newRecord",
".",
"getProperties",
"(",
")",
")",
"{",
"if",
"(",
"appliesTo",
"(",
"property",
")",
")",
"{",
"oldRecord",
".",
"set",
"(",
"property",
",",
"merge",
"(",
"property",
",",
"oldRecord",
".",
"get",
"(",
"property",
")",
",",
"newRecord",
".",
"get",
"(",
"property",
")",
")",
")",
";",
"}",
"}",
"}"
] | Merges all supported properties in common to the old and new record specified, storing the
results in the old record.
@param oldRecord
the record containing old property values, not null; results of the merging
operation are stored in this record, possibly replacing old values of affected
properties (if this behavious is not desired, clone the old record in advance)
@param newRecord
the record containing new property values, not null | [
"Merges",
"all",
"supported",
"properties",
"in",
"common",
"to",
"the",
"old",
"and",
"new",
"record",
"specified",
"storing",
"the",
"results",
"in",
"the",
"old",
"record",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Criteria.java#L331-L341 |
2,433 | dkmfbk/knowledgestore | ks-server/src/main/java/eu/fbk/knowledgestore/runtime/Launcher.java | Launcher.main | public static void main(final String... args) {
// Configure command line options
final Options options = new Options();
options.addOption("c", "config", true, "use service configuration file / classpath "
+ "resource (default '" + DEFAULT_CONFIG + "')");
options.addOption("v", "version", false,
"display version and copyright information, then exit");
options.addOption("h", "help", false, "display usage information, then exit");
// Initialize exit status
int status = EX_OK;
try {
// Parse command line and handle different commands
final CommandLine cmd = new GnuParser().parse(options, args);
if (cmd.hasOption("v")) {
// Show version and copyright (http://www.gnu.org/prep/standards/standards.html)
System.out.println(String.format(
"%s (FBK KnowledgeStore) %s\njava %s bit (%s) %s\n%s", PROGRAM_EXECUTABLE,
PROGRAM_VERSION, System.getProperty("sun.arch.data.model"),
System.getProperty("java.vendor"), System.getProperty("java.version"),
PROGRAM_DISCLAIMER));
} else if (cmd.hasOption("h")) {
// Show usage (done later) and terminate
status = EX_USAGE;
} else {
// Run the service. Retrieve the configuration
final String configLocation = cmd.getOptionValue('c', DEFAULT_CONFIG);
// Differentiate between normal run, commons-daemon start, commons-daemon stop
if (cmd.getArgList().contains("__start")) {
start(configLocation); // commons-daemon start
} else if (cmd.getArgList().contains("__stop")) {
stop(); // commons-deamon stop
} else {
run(configLocation); // normal execution
}
}
} catch (final ParseException ex) {
// Display error message and then usage on syntax error
System.err.println("SYNTAX ERROR: " + ex.getMessage());
status = EX_USAGE;
} catch (final ServiceConfigurationError ex) {
// Display error message and stack trace and terminate on configuration error
System.err.println("INVALID CONFIGURATION: " + ex.getMessage());
Throwables.getRootCause(ex).printStackTrace();
status = EX_CONFIG;
} catch (final Throwable ex) {
// Display error message and stack trace on generic error
System.err.print("EXECUTION FAILED: ");
ex.printStackTrace();
status = ex instanceof IOException ? EX_IOERR : EX_UNAVAILABLE;
}
// Display usage information if necessary
if (status == EX_USAGE) {
final PrintWriter out = new PrintWriter(System.out);
final HelpFormatter formatter = new HelpFormatter();
formatter.printUsage(out, WIDTH, PROGRAM_EXECUTABLE, options);
if (PROGRAM_DESCRIPTION != null) {
formatter.printWrapped(out, WIDTH, "\n" + PROGRAM_DESCRIPTION.trim());
}
out.println("\nOptions");
formatter.printOptions(out, WIDTH, options, 2, 2);
out.flush();
}
// Display exit status for convenience
if (status != EX_OK) {
System.err.println("[exit status: " + status + "]");
} else {
System.out.println("[exit status: " + status + "]");
}
// Flush STDIN and STDOUT before exiting (we noted truncated outputs otherwise)
System.out.flush();
System.err.flush();
// Force exiting (in case there are threads still running)
System.exit(status);
} | java | public static void main(final String... args) {
// Configure command line options
final Options options = new Options();
options.addOption("c", "config", true, "use service configuration file / classpath "
+ "resource (default '" + DEFAULT_CONFIG + "')");
options.addOption("v", "version", false,
"display version and copyright information, then exit");
options.addOption("h", "help", false, "display usage information, then exit");
// Initialize exit status
int status = EX_OK;
try {
// Parse command line and handle different commands
final CommandLine cmd = new GnuParser().parse(options, args);
if (cmd.hasOption("v")) {
// Show version and copyright (http://www.gnu.org/prep/standards/standards.html)
System.out.println(String.format(
"%s (FBK KnowledgeStore) %s\njava %s bit (%s) %s\n%s", PROGRAM_EXECUTABLE,
PROGRAM_VERSION, System.getProperty("sun.arch.data.model"),
System.getProperty("java.vendor"), System.getProperty("java.version"),
PROGRAM_DISCLAIMER));
} else if (cmd.hasOption("h")) {
// Show usage (done later) and terminate
status = EX_USAGE;
} else {
// Run the service. Retrieve the configuration
final String configLocation = cmd.getOptionValue('c', DEFAULT_CONFIG);
// Differentiate between normal run, commons-daemon start, commons-daemon stop
if (cmd.getArgList().contains("__start")) {
start(configLocation); // commons-daemon start
} else if (cmd.getArgList().contains("__stop")) {
stop(); // commons-deamon stop
} else {
run(configLocation); // normal execution
}
}
} catch (final ParseException ex) {
// Display error message and then usage on syntax error
System.err.println("SYNTAX ERROR: " + ex.getMessage());
status = EX_USAGE;
} catch (final ServiceConfigurationError ex) {
// Display error message and stack trace and terminate on configuration error
System.err.println("INVALID CONFIGURATION: " + ex.getMessage());
Throwables.getRootCause(ex).printStackTrace();
status = EX_CONFIG;
} catch (final Throwable ex) {
// Display error message and stack trace on generic error
System.err.print("EXECUTION FAILED: ");
ex.printStackTrace();
status = ex instanceof IOException ? EX_IOERR : EX_UNAVAILABLE;
}
// Display usage information if necessary
if (status == EX_USAGE) {
final PrintWriter out = new PrintWriter(System.out);
final HelpFormatter formatter = new HelpFormatter();
formatter.printUsage(out, WIDTH, PROGRAM_EXECUTABLE, options);
if (PROGRAM_DESCRIPTION != null) {
formatter.printWrapped(out, WIDTH, "\n" + PROGRAM_DESCRIPTION.trim());
}
out.println("\nOptions");
formatter.printOptions(out, WIDTH, options, 2, 2);
out.flush();
}
// Display exit status for convenience
if (status != EX_OK) {
System.err.println("[exit status: " + status + "]");
} else {
System.out.println("[exit status: " + status + "]");
}
// Flush STDIN and STDOUT before exiting (we noted truncated outputs otherwise)
System.out.flush();
System.err.flush();
// Force exiting (in case there are threads still running)
System.exit(status);
} | [
"public",
"static",
"void",
"main",
"(",
"final",
"String",
"...",
"args",
")",
"{",
"// Configure command line options",
"final",
"Options",
"options",
"=",
"new",
"Options",
"(",
")",
";",
"options",
".",
"addOption",
"(",
"\"c\"",
",",
"\"config\"",
",",
"true",
",",
"\"use service configuration file / classpath \"",
"+",
"\"resource (default '\"",
"+",
"DEFAULT_CONFIG",
"+",
"\"')\"",
")",
";",
"options",
".",
"addOption",
"(",
"\"v\"",
",",
"\"version\"",
",",
"false",
",",
"\"display version and copyright information, then exit\"",
")",
";",
"options",
".",
"addOption",
"(",
"\"h\"",
",",
"\"help\"",
",",
"false",
",",
"\"display usage information, then exit\"",
")",
";",
"// Initialize exit status",
"int",
"status",
"=",
"EX_OK",
";",
"try",
"{",
"// Parse command line and handle different commands",
"final",
"CommandLine",
"cmd",
"=",
"new",
"GnuParser",
"(",
")",
".",
"parse",
"(",
"options",
",",
"args",
")",
";",
"if",
"(",
"cmd",
".",
"hasOption",
"(",
"\"v\"",
")",
")",
"{",
"// Show version and copyright (http://www.gnu.org/prep/standards/standards.html)",
"System",
".",
"out",
".",
"println",
"(",
"String",
".",
"format",
"(",
"\"%s (FBK KnowledgeStore) %s\\njava %s bit (%s) %s\\n%s\"",
",",
"PROGRAM_EXECUTABLE",
",",
"PROGRAM_VERSION",
",",
"System",
".",
"getProperty",
"(",
"\"sun.arch.data.model\"",
")",
",",
"System",
".",
"getProperty",
"(",
"\"java.vendor\"",
")",
",",
"System",
".",
"getProperty",
"(",
"\"java.version\"",
")",
",",
"PROGRAM_DISCLAIMER",
")",
")",
";",
"}",
"else",
"if",
"(",
"cmd",
".",
"hasOption",
"(",
"\"h\"",
")",
")",
"{",
"// Show usage (done later) and terminate",
"status",
"=",
"EX_USAGE",
";",
"}",
"else",
"{",
"// Run the service. Retrieve the configuration",
"final",
"String",
"configLocation",
"=",
"cmd",
".",
"getOptionValue",
"(",
"'",
"'",
",",
"DEFAULT_CONFIG",
")",
";",
"// Differentiate between normal run, commons-daemon start, commons-daemon stop",
"if",
"(",
"cmd",
".",
"getArgList",
"(",
")",
".",
"contains",
"(",
"\"__start\"",
")",
")",
"{",
"start",
"(",
"configLocation",
")",
";",
"// commons-daemon start",
"}",
"else",
"if",
"(",
"cmd",
".",
"getArgList",
"(",
")",
".",
"contains",
"(",
"\"__stop\"",
")",
")",
"{",
"stop",
"(",
")",
";",
"// commons-deamon stop",
"}",
"else",
"{",
"run",
"(",
"configLocation",
")",
";",
"// normal execution",
"}",
"}",
"}",
"catch",
"(",
"final",
"ParseException",
"ex",
")",
"{",
"// Display error message and then usage on syntax error",
"System",
".",
"err",
".",
"println",
"(",
"\"SYNTAX ERROR: \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"status",
"=",
"EX_USAGE",
";",
"}",
"catch",
"(",
"final",
"ServiceConfigurationError",
"ex",
")",
"{",
"// Display error message and stack trace and terminate on configuration error",
"System",
".",
"err",
".",
"println",
"(",
"\"INVALID CONFIGURATION: \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"Throwables",
".",
"getRootCause",
"(",
"ex",
")",
".",
"printStackTrace",
"(",
")",
";",
"status",
"=",
"EX_CONFIG",
";",
"}",
"catch",
"(",
"final",
"Throwable",
"ex",
")",
"{",
"// Display error message and stack trace on generic error",
"System",
".",
"err",
".",
"print",
"(",
"\"EXECUTION FAILED: \"",
")",
";",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"status",
"=",
"ex",
"instanceof",
"IOException",
"?",
"EX_IOERR",
":",
"EX_UNAVAILABLE",
";",
"}",
"// Display usage information if necessary",
"if",
"(",
"status",
"==",
"EX_USAGE",
")",
"{",
"final",
"PrintWriter",
"out",
"=",
"new",
"PrintWriter",
"(",
"System",
".",
"out",
")",
";",
"final",
"HelpFormatter",
"formatter",
"=",
"new",
"HelpFormatter",
"(",
")",
";",
"formatter",
".",
"printUsage",
"(",
"out",
",",
"WIDTH",
",",
"PROGRAM_EXECUTABLE",
",",
"options",
")",
";",
"if",
"(",
"PROGRAM_DESCRIPTION",
"!=",
"null",
")",
"{",
"formatter",
".",
"printWrapped",
"(",
"out",
",",
"WIDTH",
",",
"\"\\n\"",
"+",
"PROGRAM_DESCRIPTION",
".",
"trim",
"(",
")",
")",
";",
"}",
"out",
".",
"println",
"(",
"\"\\nOptions\"",
")",
";",
"formatter",
".",
"printOptions",
"(",
"out",
",",
"WIDTH",
",",
"options",
",",
"2",
",",
"2",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"}",
"// Display exit status for convenience",
"if",
"(",
"status",
"!=",
"EX_OK",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"[exit status: \"",
"+",
"status",
"+",
"\"]\"",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"[exit status: \"",
"+",
"status",
"+",
"\"]\"",
")",
";",
"}",
"// Flush STDIN and STDOUT before exiting (we noted truncated outputs otherwise)",
"System",
".",
"out",
".",
"flush",
"(",
")",
";",
"System",
".",
"err",
".",
"flush",
"(",
")",
";",
"// Force exiting (in case there are threads still running)",
"System",
".",
"exit",
"(",
"status",
")",
";",
"}"
] | Program entry point. See class documentation for the supported features.
@param args
command line arguments | [
"Program",
"entry",
"point",
".",
"See",
"class",
"documentation",
"for",
"the",
"supported",
"features",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server/src/main/java/eu/fbk/knowledgestore/runtime/Launcher.java#L204-L290 |
2,434 | dkmfbk/knowledgestore | ks-server-virtuoso/src/main/java/eu/fbk/knowledgestore/triplestore/virtuoso/VirtuosoTripleTransaction.java | VirtuosoTripleTransaction.add | public void add(final Statement statement) throws DataCorruptedException, IOException {
Preconditions.checkNotNull(statement);
checkWritable();
try {
this.connection.add(statement);
} catch (final RepositoryException ex) {
throw new IOException("Failed to add statement: " + statement, ex);
}
} | java | public void add(final Statement statement) throws DataCorruptedException, IOException {
Preconditions.checkNotNull(statement);
checkWritable();
try {
this.connection.add(statement);
} catch (final RepositoryException ex) {
throw new IOException("Failed to add statement: " + statement, ex);
}
} | [
"public",
"void",
"add",
"(",
"final",
"Statement",
"statement",
")",
"throws",
"DataCorruptedException",
",",
"IOException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"statement",
")",
";",
"checkWritable",
"(",
")",
";",
"try",
"{",
"this",
".",
"connection",
".",
"add",
"(",
"statement",
")",
";",
"}",
"catch",
"(",
"final",
"RepositoryException",
"ex",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Failed to add statement: \"",
"+",
"statement",
",",
"ex",
")",
";",
"}",
"}"
] | Adds the specified RDF statement to the triple store. Virtuoso may buffer the operation,
performing it when more opportune and in any case ensuring that the same effects are
produced as obtainable by directly executing the operation.
@param statement
the RDF statement to add
@throws DataCorruptedException
in case a non-recoverable data corruption situation is detected
@throws IOException
in case another IO error occurs not implying data corruption
@throws IllegalStateException
in case the transaction is read-only | [
"Adds",
"the",
"specified",
"RDF",
"statement",
"to",
"the",
"triple",
"store",
".",
"Virtuoso",
"may",
"buffer",
"the",
"operation",
"performing",
"it",
"when",
"more",
"opportune",
"and",
"in",
"any",
"case",
"ensuring",
"that",
"the",
"same",
"effects",
"are",
"produced",
"as",
"obtainable",
"by",
"directly",
"executing",
"the",
"operation",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-virtuoso/src/main/java/eu/fbk/knowledgestore/triplestore/virtuoso/VirtuosoTripleTransaction.java#L264-L274 |
2,435 | dkmfbk/knowledgestore | ks-server-virtuoso/src/main/java/eu/fbk/knowledgestore/triplestore/virtuoso/VirtuosoTripleTransaction.java | VirtuosoTripleTransaction.remove | public void remove(final Statement statement) throws DataCorruptedException, IOException {
Preconditions.checkState(!this.readOnly);
checkWritable();
try {
this.connection.remove(statement);
} catch (final RepositoryException ex) {
throw new IOException("Failed to remove statement: " + statement, ex);
}
} | java | public void remove(final Statement statement) throws DataCorruptedException, IOException {
Preconditions.checkState(!this.readOnly);
checkWritable();
try {
this.connection.remove(statement);
} catch (final RepositoryException ex) {
throw new IOException("Failed to remove statement: " + statement, ex);
}
} | [
"public",
"void",
"remove",
"(",
"final",
"Statement",
"statement",
")",
"throws",
"DataCorruptedException",
",",
"IOException",
"{",
"Preconditions",
".",
"checkState",
"(",
"!",
"this",
".",
"readOnly",
")",
";",
"checkWritable",
"(",
")",
";",
"try",
"{",
"this",
".",
"connection",
".",
"remove",
"(",
"statement",
")",
";",
"}",
"catch",
"(",
"final",
"RepositoryException",
"ex",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Failed to remove statement: \"",
"+",
"statement",
",",
"ex",
")",
";",
"}",
"}"
] | Removes the specified RDF statement from the triple store. Virtuoso may buffer the
operation, performing it when more opportune and in any case ensuring that the same effects
are produced as obtainable by directly executing the operation.
@param statement
the RDF statement to remove
@throws DataCorruptedException
in case a non-recoverable data corruption situation is detected
@throws IOException
in case another IO error occurs not implying data corruption
@throws IllegalStateException
in case the transaction is read-only | [
"Removes",
"the",
"specified",
"RDF",
"statement",
"from",
"the",
"triple",
"store",
".",
"Virtuoso",
"may",
"buffer",
"the",
"operation",
"performing",
"it",
"when",
"more",
"opportune",
"and",
"in",
"any",
"case",
"ensuring",
"that",
"the",
"same",
"effects",
"are",
"produced",
"as",
"obtainable",
"by",
"directly",
"executing",
"the",
"operation",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-virtuoso/src/main/java/eu/fbk/knowledgestore/triplestore/virtuoso/VirtuosoTripleTransaction.java#L331-L341 |
2,436 | dkmfbk/knowledgestore | ks-server-virtuoso/src/main/java/eu/fbk/knowledgestore/triplestore/virtuoso/VirtuosoTripleTransaction.java | VirtuosoTripleTransaction.removeBulk | public void removeBulk(final Iterable<? extends Statement> statements,
final boolean transaction) throws DataCorruptedException, IOException {
Preconditions.checkNotNull(statements);
checkWritable();
try {
if (!transaction && !this.store.existsTransactionMarker()) {
this.store.addTransactionMarker();
// log_enable affects only the current transaction.
this.connection.getQuadStoreConnection().prepareCall("log_enable(2)").execute();
}
this.connection.remove(statements);
this.connection.commit();
} catch (final SQLException sqle) {
throw new IllegalStateException("Invalid internal operation.", sqle);
} catch (final RepositoryException e) {
throw new DataCorruptedException("Error while adding bulk data.", e);
}
} | java | public void removeBulk(final Iterable<? extends Statement> statements,
final boolean transaction) throws DataCorruptedException, IOException {
Preconditions.checkNotNull(statements);
checkWritable();
try {
if (!transaction && !this.store.existsTransactionMarker()) {
this.store.addTransactionMarker();
// log_enable affects only the current transaction.
this.connection.getQuadStoreConnection().prepareCall("log_enable(2)").execute();
}
this.connection.remove(statements);
this.connection.commit();
} catch (final SQLException sqle) {
throw new IllegalStateException("Invalid internal operation.", sqle);
} catch (final RepositoryException e) {
throw new DataCorruptedException("Error while adding bulk data.", e);
}
} | [
"public",
"void",
"removeBulk",
"(",
"final",
"Iterable",
"<",
"?",
"extends",
"Statement",
">",
"statements",
",",
"final",
"boolean",
"transaction",
")",
"throws",
"DataCorruptedException",
",",
"IOException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"statements",
")",
";",
"checkWritable",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"transaction",
"&&",
"!",
"this",
".",
"store",
".",
"existsTransactionMarker",
"(",
")",
")",
"{",
"this",
".",
"store",
".",
"addTransactionMarker",
"(",
")",
";",
"// log_enable affects only the current transaction.",
"this",
".",
"connection",
".",
"getQuadStoreConnection",
"(",
")",
".",
"prepareCall",
"(",
"\"log_enable(2)\"",
")",
".",
"execute",
"(",
")",
";",
"}",
"this",
".",
"connection",
".",
"remove",
"(",
"statements",
")",
";",
"this",
".",
"connection",
".",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"SQLException",
"sqle",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Invalid internal operation.\"",
",",
"sqle",
")",
";",
"}",
"catch",
"(",
"final",
"RepositoryException",
"e",
")",
"{",
"throw",
"new",
"DataCorruptedException",
"(",
"\"Error while adding bulk data.\"",
",",
"e",
")",
";",
"}",
"}"
] | Removes the specified RDF statements from the triple store. Implementations are designed to
perform high throughput insertion.
@param statements
the RDF statements to add
@throws DataCorruptedException
in case a non-recoverable data corruption situation is detected
@throws IOException
in case another IO error occurs not implying data corruption
@throws IllegalStateException
in case the transaction is read-only | [
"Removes",
"the",
"specified",
"RDF",
"statements",
"from",
"the",
"triple",
"store",
".",
"Implementations",
"are",
"designed",
"to",
"perform",
"high",
"throughput",
"insertion",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-virtuoso/src/main/java/eu/fbk/knowledgestore/triplestore/virtuoso/VirtuosoTripleTransaction.java#L362-L383 |
2,437 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Record.java | Record.getUnique | @Nullable
public <T> T getUnique(final URI property, final Class<T> valueClass,
@Nullable final T defaultValue) {
try {
final T value = getUnique(property, valueClass);
return value == null ? defaultValue : value;
} catch (final IllegalStateException ex) {
return defaultValue;
} catch (final IllegalArgumentException ex) {
return defaultValue;
}
} | java | @Nullable
public <T> T getUnique(final URI property, final Class<T> valueClass,
@Nullable final T defaultValue) {
try {
final T value = getUnique(property, valueClass);
return value == null ? defaultValue : value;
} catch (final IllegalStateException ex) {
return defaultValue;
} catch (final IllegalArgumentException ex) {
return defaultValue;
}
} | [
"@",
"Nullable",
"public",
"<",
"T",
">",
"T",
"getUnique",
"(",
"final",
"URI",
"property",
",",
"final",
"Class",
"<",
"T",
">",
"valueClass",
",",
"@",
"Nullable",
"final",
"T",
"defaultValue",
")",
"{",
"try",
"{",
"final",
"T",
"value",
"=",
"getUnique",
"(",
"property",
",",
"valueClass",
")",
";",
"return",
"value",
"==",
"null",
"?",
"defaultValue",
":",
"value",
";",
"}",
"catch",
"(",
"final",
"IllegalStateException",
"ex",
")",
"{",
"return",
"defaultValue",
";",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"ex",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] | Returns the unique value of the property converted to an instance of a certain class, or
the default value supplied in case of failure.
@param property
the property to read
@param valueClass
the class to convert the value to
@param defaultValue
the default value to return in case the property has no value
@param <T>
the type of result
@return the unique value of the property converted to the class specified, on success; the
default value supplied in case the property has no value, has multiple values or
its unique value cannot be converted to the class specified | [
"Returns",
"the",
"unique",
"value",
"of",
"the",
"property",
"converted",
"to",
"an",
"instance",
"of",
"a",
"certain",
"class",
"or",
"the",
"default",
"value",
"supplied",
"in",
"case",
"of",
"failure",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Record.java#L554-L565 |
2,438 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Record.java | Record.get | public <T> List<T> get(final URI property, final Class<T> valueClass,
final List<T> defaultValue) {
try {
final List<T> values = get(property, valueClass);
return values.isEmpty() ? defaultValue : values;
} catch (final IllegalArgumentException ex) {
return defaultValue;
}
} | java | public <T> List<T> get(final URI property, final Class<T> valueClass,
final List<T> defaultValue) {
try {
final List<T> values = get(property, valueClass);
return values.isEmpty() ? defaultValue : values;
} catch (final IllegalArgumentException ex) {
return defaultValue;
}
} | [
"public",
"<",
"T",
">",
"List",
"<",
"T",
">",
"get",
"(",
"final",
"URI",
"property",
",",
"final",
"Class",
"<",
"T",
">",
"valueClass",
",",
"final",
"List",
"<",
"T",
">",
"defaultValue",
")",
"{",
"try",
"{",
"final",
"List",
"<",
"T",
">",
"values",
"=",
"get",
"(",
"property",
",",
"valueClass",
")",
";",
"return",
"values",
".",
"isEmpty",
"(",
")",
"?",
"defaultValue",
":",
"values",
";",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"ex",
")",
"{",
"return",
"defaultValue",
";",
"}",
"}"
] | Returns the values of the property converted to instances of a certain class, or the
default value supplied in case of failure or if the property has no values.
@param property
the property to read
@param valueClass
the class values have to be converted to
@param defaultValue
the default value to return in case conversion fails
@param <T>
the type of property values
@return an immutable list with the values of the property, converted to the class specified
and possibly empty, on success; the default value supplied in case the property has
no value or conversion fails for some value | [
"Returns",
"the",
"values",
"of",
"the",
"property",
"converted",
"to",
"instances",
"of",
"a",
"certain",
"class",
"or",
"the",
"default",
"value",
"supplied",
"in",
"case",
"of",
"failure",
"or",
"if",
"the",
"property",
"has",
"no",
"values",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Record.java#L628-L636 |
2,439 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Record.java | Record.retain | public synchronized Record retain(final URI... properties) {
for (final URI property : doGetProperties()) {
boolean retain = false;
for (int i = 0; i < properties.length; ++i) {
if (property.equals(properties[i])) {
retain = true;
break;
}
}
if (!retain) {
doSet(property, ImmutableSet.<Object>of());
}
}
return this;
} | java | public synchronized Record retain(final URI... properties) {
for (final URI property : doGetProperties()) {
boolean retain = false;
for (int i = 0; i < properties.length; ++i) {
if (property.equals(properties[i])) {
retain = true;
break;
}
}
if (!retain) {
doSet(property, ImmutableSet.<Object>of());
}
}
return this;
} | [
"public",
"synchronized",
"Record",
"retain",
"(",
"final",
"URI",
"...",
"properties",
")",
"{",
"for",
"(",
"final",
"URI",
"property",
":",
"doGetProperties",
"(",
")",
")",
"{",
"boolean",
"retain",
"=",
"false",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"properties",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"property",
".",
"equals",
"(",
"properties",
"[",
"i",
"]",
")",
")",
"{",
"retain",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"retain",
")",
"{",
"doSet",
"(",
"property",
",",
"ImmutableSet",
".",
"<",
"Object",
">",
"of",
"(",
")",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Retains only the properties specified, clearing the remaining ones. Note that the ID is not
affected.
@param properties
an array with the properties to retain, possibly empty (in which case all the
stored properties will be cleared)
@return this record object, for call chaining | [
"Retains",
"only",
"the",
"properties",
"specified",
"clearing",
"the",
"remaining",
"ones",
".",
"Note",
"that",
"the",
"ID",
"is",
"not",
"affected",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Record.java#L746-L760 |
2,440 | dkmfbk/knowledgestore | ks-core/src/main/java/eu/fbk/knowledgestore/data/Record.java | Record.clear | public synchronized Record clear(final URI... properties) {
final List<URI> propertiesToClear;
if (properties == null || properties.length == 0) {
propertiesToClear = doGetProperties();
} else {
propertiesToClear = Arrays.asList(properties);
}
for (final URI property : propertiesToClear) {
doSet(property, ImmutableSet.<Object>of());
}
return this;
} | java | public synchronized Record clear(final URI... properties) {
final List<URI> propertiesToClear;
if (properties == null || properties.length == 0) {
propertiesToClear = doGetProperties();
} else {
propertiesToClear = Arrays.asList(properties);
}
for (final URI property : propertiesToClear) {
doSet(property, ImmutableSet.<Object>of());
}
return this;
} | [
"public",
"synchronized",
"Record",
"clear",
"(",
"final",
"URI",
"...",
"properties",
")",
"{",
"final",
"List",
"<",
"URI",
">",
"propertiesToClear",
";",
"if",
"(",
"properties",
"==",
"null",
"||",
"properties",
".",
"length",
"==",
"0",
")",
"{",
"propertiesToClear",
"=",
"doGetProperties",
"(",
")",
";",
"}",
"else",
"{",
"propertiesToClear",
"=",
"Arrays",
".",
"asList",
"(",
"properties",
")",
";",
"}",
"for",
"(",
"final",
"URI",
"property",
":",
"propertiesToClear",
")",
"{",
"doSet",
"(",
"property",
",",
"ImmutableSet",
".",
"<",
"Object",
">",
"of",
"(",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Clears the properties specified, or all the stored properties if no property is specified.
Note that the ID is not affected.
@param properties
an array with the properties to retain, possibly empty (in which case all the
stored properties will be cleared)
@return this record object, for call chaining | [
"Clears",
"the",
"properties",
"specified",
"or",
"all",
"the",
"stored",
"properties",
"if",
"no",
"property",
"is",
"specified",
".",
"Note",
"that",
"the",
"ID",
"is",
"not",
"affected",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-core/src/main/java/eu/fbk/knowledgestore/data/Record.java#L771-L782 |
2,441 | dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/TephraHBaseUtils.java | TephraHBaseUtils.get | @Override
public Record get(final String tableName, final URI id) throws IOException
{
logger.debug("TEPHRA Begin of get(" + tableName + ", " + id + ")");
final TransactionAwareHTable txTable = (TransactionAwareHTable) getTable(tableName);
Record resGotten = null;
if (txTable != null) {
// Resource's Key
final Get get = new Get(Bytes.toBytes(id.toString())).setMaxVersions(1);
final Result rs = txTable.get(get);
logger.debug("Value obtained: " + new String(rs.value()));
final AvroSerializer serializer = getSerializer();
resGotten = (Record) serializer.fromBytes(rs.value());
}
return resGotten;
} | java | @Override
public Record get(final String tableName, final URI id) throws IOException
{
logger.debug("TEPHRA Begin of get(" + tableName + ", " + id + ")");
final TransactionAwareHTable txTable = (TransactionAwareHTable) getTable(tableName);
Record resGotten = null;
if (txTable != null) {
// Resource's Key
final Get get = new Get(Bytes.toBytes(id.toString())).setMaxVersions(1);
final Result rs = txTable.get(get);
logger.debug("Value obtained: " + new String(rs.value()));
final AvroSerializer serializer = getSerializer();
resGotten = (Record) serializer.fromBytes(rs.value());
}
return resGotten;
} | [
"@",
"Override",
"public",
"Record",
"get",
"(",
"final",
"String",
"tableName",
",",
"final",
"URI",
"id",
")",
"throws",
"IOException",
"{",
"logger",
".",
"debug",
"(",
"\"TEPHRA Begin of get(\"",
"+",
"tableName",
"+",
"\", \"",
"+",
"id",
"+",
"\")\"",
")",
";",
"final",
"TransactionAwareHTable",
"txTable",
"=",
"(",
"TransactionAwareHTable",
")",
"getTable",
"(",
"tableName",
")",
";",
"Record",
"resGotten",
"=",
"null",
";",
"if",
"(",
"txTable",
"!=",
"null",
")",
"{",
"// Resource's Key",
"final",
"Get",
"get",
"=",
"new",
"Get",
"(",
"Bytes",
".",
"toBytes",
"(",
"id",
".",
"toString",
"(",
")",
")",
")",
".",
"setMaxVersions",
"(",
"1",
")",
";",
"final",
"Result",
"rs",
"=",
"txTable",
".",
"get",
"(",
"get",
")",
";",
"logger",
".",
"debug",
"(",
"\"Value obtained: \"",
"+",
"new",
"String",
"(",
"rs",
".",
"value",
"(",
")",
")",
")",
";",
"final",
"AvroSerializer",
"serializer",
"=",
"getSerializer",
"(",
")",
";",
"resGotten",
"=",
"(",
"Record",
")",
"serializer",
".",
"fromBytes",
"(",
"rs",
".",
"value",
"(",
")",
")",
";",
"}",
"return",
"resGotten",
";",
"}"
] | Gets a Record based on information passed.
@param tableName
to do the get.
@param id
of the Record needed
@throws IOException | [
"Gets",
"a",
"Record",
"based",
"on",
"information",
"passed",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/TephraHBaseUtils.java#L215-L230 |
2,442 | dkmfbk/knowledgestore | ks-server-http/src/main/java/eu/fbk/knowledgestore/server/http/jaxrs/Root.java | Root.getRecord | @Nullable
private Record getRecord(final URI layer, @Nullable final URI id) throws Throwable {
final Record record = id == null ? null : getSession().retrieve(layer).ids(id).exec()
.getUnique();
if (record != null && layer.equals(KS.MENTION)) {
final String template = "SELECT ?e WHERE { ?e $$ $$ "
+ (getUIConfig().isDenotedByAllowsGraphs() ? ""
: "FILTER NOT EXISTS { GRAPH ?e { ?s ?p ?o } } ") + "}";
for (final URI entityID : getSession()
.sparql(template, getUIConfig().getDenotedByProperty(), id).execTuples()
.transform(URI.class, true, "e")) {
record.add(KS.REFERS_TO, entityID);
}
}
return record;
} | java | @Nullable
private Record getRecord(final URI layer, @Nullable final URI id) throws Throwable {
final Record record = id == null ? null : getSession().retrieve(layer).ids(id).exec()
.getUnique();
if (record != null && layer.equals(KS.MENTION)) {
final String template = "SELECT ?e WHERE { ?e $$ $$ "
+ (getUIConfig().isDenotedByAllowsGraphs() ? ""
: "FILTER NOT EXISTS { GRAPH ?e { ?s ?p ?o } } ") + "}";
for (final URI entityID : getSession()
.sparql(template, getUIConfig().getDenotedByProperty(), id).execTuples()
.transform(URI.class, true, "e")) {
record.add(KS.REFERS_TO, entityID);
}
}
return record;
} | [
"@",
"Nullable",
"private",
"Record",
"getRecord",
"(",
"final",
"URI",
"layer",
",",
"@",
"Nullable",
"final",
"URI",
"id",
")",
"throws",
"Throwable",
"{",
"final",
"Record",
"record",
"=",
"id",
"==",
"null",
"?",
"null",
":",
"getSession",
"(",
")",
".",
"retrieve",
"(",
"layer",
")",
".",
"ids",
"(",
"id",
")",
".",
"exec",
"(",
")",
".",
"getUnique",
"(",
")",
";",
"if",
"(",
"record",
"!=",
"null",
"&&",
"layer",
".",
"equals",
"(",
"KS",
".",
"MENTION",
")",
")",
"{",
"final",
"String",
"template",
"=",
"\"SELECT ?e WHERE { ?e $$ $$ \"",
"+",
"(",
"getUIConfig",
"(",
")",
".",
"isDenotedByAllowsGraphs",
"(",
")",
"?",
"\"\"",
":",
"\"FILTER NOT EXISTS { GRAPH ?e { ?s ?p ?o } } \"",
")",
"+",
"\"}\"",
";",
"for",
"(",
"final",
"URI",
"entityID",
":",
"getSession",
"(",
")",
".",
"sparql",
"(",
"template",
",",
"getUIConfig",
"(",
")",
".",
"getDenotedByProperty",
"(",
")",
",",
"id",
")",
".",
"execTuples",
"(",
")",
".",
"transform",
"(",
"URI",
".",
"class",
",",
"true",
",",
"\"e\"",
")",
")",
"{",
"record",
".",
"add",
"(",
"KS",
".",
"REFERS_TO",
",",
"entityID",
")",
";",
"}",
"}",
"return",
"record",
";",
"}"
] | DATA ACCESS METHODS | [
"DATA",
"ACCESS",
"METHODS"
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-http/src/main/java/eu/fbk/knowledgestore/server/http/jaxrs/Root.java#L681-L696 |
2,443 | dkmfbk/knowledgestore | ks-server-http/src/main/java/eu/fbk/knowledgestore/server/http/jaxrs/RenderUtils.java | RenderUtils.renderSolutionTable | public static Iterable<String> renderSolutionTable(final List<String> variables,
final Iterable<? extends BindingSet> solutions) {
final List<String> actualVariables;
if (variables != null) {
actualVariables = ImmutableList.copyOf(variables);
} else {
final Set<String> variableSet = Sets.newHashSet();
for (final BindingSet solution : solutions) {
variableSet.addAll(solution.getBindingNames());
}
actualVariables = Ordering.natural().sortedCopy(variableSet);
}
final int width = 75 / actualVariables.size();
final StringBuilder builder = new StringBuilder();
builder.append("<table class=\"sparql table table-condensed tablesorter\"><thead>\n<tr>");
for (final String variable : actualVariables) {
builder.append("<th style=\"width: ").append(width).append("%\">")
.append(escapeHtml(variable)).append("</th>");
}
final Iterable<String> header = ImmutableList.of(builder.toString());
final Iterable<String> footer = ImmutableList.of("</tbody></table>");
final Function<BindingSet, String> renderer = new Function<BindingSet, String>() {
@Override
public String apply(final BindingSet bindings) {
if (Thread.interrupted()) {
throw new IllegalStateException("Interrupted");
}
final StringBuilder builder = new StringBuilder();
builder.append("<tr>");
for (final String variable : actualVariables) {
builder.append("<td>");
try {
render(bindings.getValue(variable), builder);
} catch (final IOException ex) {
throw new Error(ex);
}
builder.append("</td>");
}
builder.append("</tr>\n");
return builder.toString();
}
};
return Iterables.concat(header, Iterables.transform(solutions, renderer), footer);
} | java | public static Iterable<String> renderSolutionTable(final List<String> variables,
final Iterable<? extends BindingSet> solutions) {
final List<String> actualVariables;
if (variables != null) {
actualVariables = ImmutableList.copyOf(variables);
} else {
final Set<String> variableSet = Sets.newHashSet();
for (final BindingSet solution : solutions) {
variableSet.addAll(solution.getBindingNames());
}
actualVariables = Ordering.natural().sortedCopy(variableSet);
}
final int width = 75 / actualVariables.size();
final StringBuilder builder = new StringBuilder();
builder.append("<table class=\"sparql table table-condensed tablesorter\"><thead>\n<tr>");
for (final String variable : actualVariables) {
builder.append("<th style=\"width: ").append(width).append("%\">")
.append(escapeHtml(variable)).append("</th>");
}
final Iterable<String> header = ImmutableList.of(builder.toString());
final Iterable<String> footer = ImmutableList.of("</tbody></table>");
final Function<BindingSet, String> renderer = new Function<BindingSet, String>() {
@Override
public String apply(final BindingSet bindings) {
if (Thread.interrupted()) {
throw new IllegalStateException("Interrupted");
}
final StringBuilder builder = new StringBuilder();
builder.append("<tr>");
for (final String variable : actualVariables) {
builder.append("<td>");
try {
render(bindings.getValue(variable), builder);
} catch (final IOException ex) {
throw new Error(ex);
}
builder.append("</td>");
}
builder.append("</tr>\n");
return builder.toString();
}
};
return Iterables.concat(header, Iterables.transform(solutions, renderer), footer);
} | [
"public",
"static",
"Iterable",
"<",
"String",
">",
"renderSolutionTable",
"(",
"final",
"List",
"<",
"String",
">",
"variables",
",",
"final",
"Iterable",
"<",
"?",
"extends",
"BindingSet",
">",
"solutions",
")",
"{",
"final",
"List",
"<",
"String",
">",
"actualVariables",
";",
"if",
"(",
"variables",
"!=",
"null",
")",
"{",
"actualVariables",
"=",
"ImmutableList",
".",
"copyOf",
"(",
"variables",
")",
";",
"}",
"else",
"{",
"final",
"Set",
"<",
"String",
">",
"variableSet",
"=",
"Sets",
".",
"newHashSet",
"(",
")",
";",
"for",
"(",
"final",
"BindingSet",
"solution",
":",
"solutions",
")",
"{",
"variableSet",
".",
"addAll",
"(",
"solution",
".",
"getBindingNames",
"(",
")",
")",
";",
"}",
"actualVariables",
"=",
"Ordering",
".",
"natural",
"(",
")",
".",
"sortedCopy",
"(",
"variableSet",
")",
";",
"}",
"final",
"int",
"width",
"=",
"75",
"/",
"actualVariables",
".",
"size",
"(",
")",
";",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"\"<table class=\\\"sparql table table-condensed tablesorter\\\"><thead>\\n<tr>\"",
")",
";",
"for",
"(",
"final",
"String",
"variable",
":",
"actualVariables",
")",
"{",
"builder",
".",
"append",
"(",
"\"<th style=\\\"width: \"",
")",
".",
"append",
"(",
"width",
")",
".",
"append",
"(",
"\"%\\\">\"",
")",
".",
"append",
"(",
"escapeHtml",
"(",
"variable",
")",
")",
".",
"append",
"(",
"\"</th>\"",
")",
";",
"}",
"final",
"Iterable",
"<",
"String",
">",
"header",
"=",
"ImmutableList",
".",
"of",
"(",
"builder",
".",
"toString",
"(",
")",
")",
";",
"final",
"Iterable",
"<",
"String",
">",
"footer",
"=",
"ImmutableList",
".",
"of",
"(",
"\"</tbody></table>\"",
")",
";",
"final",
"Function",
"<",
"BindingSet",
",",
"String",
">",
"renderer",
"=",
"new",
"Function",
"<",
"BindingSet",
",",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"apply",
"(",
"final",
"BindingSet",
"bindings",
")",
"{",
"if",
"(",
"Thread",
".",
"interrupted",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Interrupted\"",
")",
";",
"}",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"\"<tr>\"",
")",
";",
"for",
"(",
"final",
"String",
"variable",
":",
"actualVariables",
")",
"{",
"builder",
".",
"append",
"(",
"\"<td>\"",
")",
";",
"try",
"{",
"render",
"(",
"bindings",
".",
"getValue",
"(",
"variable",
")",
",",
"builder",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"Error",
"(",
"ex",
")",
";",
"}",
"builder",
".",
"append",
"(",
"\"</td>\"",
")",
";",
"}",
"builder",
".",
"append",
"(",
"\"</tr>\\n\"",
")",
";",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}",
"}",
";",
"return",
"Iterables",
".",
"concat",
"(",
"header",
",",
"Iterables",
".",
"transform",
"(",
"solutions",
",",
"renderer",
")",
",",
"footer",
")",
";",
"}"
] | Render in a streaming-way the solutions of a SPARQL SELECT query to an HTML table, emitting
an iterable with of HTML fragments.
@param variables
the variables to render in the table, in the order they should be rendered; if
null, variables will be automatically extracted from the solutions and all the
variables in alphanumeric order will be emitted
@param solutions
the solutions to render | [
"Render",
"in",
"a",
"streaming",
"-",
"way",
"the",
"solutions",
"of",
"a",
"SPARQL",
"SELECT",
"query",
"to",
"an",
"HTML",
"table",
"emitting",
"an",
"iterable",
"with",
"of",
"HTML",
"fragments",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-http/src/main/java/eu/fbk/knowledgestore/server/http/jaxrs/RenderUtils.java#L299-L346 |
2,444 | dkmfbk/knowledgestore | ks-server-http/src/main/java/eu/fbk/knowledgestore/server/http/jaxrs/RenderUtils.java | RenderUtils.escapeHtml | @Nullable
public static String escapeHtml(@Nullable final Object object) {
return object == null ? null : HtmlEscapers.htmlEscaper().escape(object.toString());
} | java | @Nullable
public static String escapeHtml(@Nullable final Object object) {
return object == null ? null : HtmlEscapers.htmlEscaper().escape(object.toString());
} | [
"@",
"Nullable",
"public",
"static",
"String",
"escapeHtml",
"(",
"@",
"Nullable",
"final",
"Object",
"object",
")",
"{",
"return",
"object",
"==",
"null",
"?",
"null",
":",
"HtmlEscapers",
".",
"htmlEscaper",
"(",
")",
".",
"escape",
"(",
"object",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Transforms the supplied object to an escaped HTML string.
@param object
the object
@return the escaped HTML string | [
"Transforms",
"the",
"supplied",
"object",
"to",
"an",
"escaped",
"HTML",
"string",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-http/src/main/java/eu/fbk/knowledgestore/server/http/jaxrs/RenderUtils.java#L513-L516 |
2,445 | dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/HBaseUtils.java | HBaseUtils.processPut | @Override
public void processPut(Record record, String tabName,
String famName, String quaName) {
logger.debug("NATIVE Begin processPut(" + record + ", " + tabName + ")");
HTable hTable = getTable(tabName);
try {
Put op = createPut(record, tabName, famName, quaName);
hTable.put(op);
} catch (IOException e) {
logger.error("Error while attempting to perform operations at HBaseDataTransactions.");
logger.error(e.getMessage());
}
} | java | @Override
public void processPut(Record record, String tabName,
String famName, String quaName) {
logger.debug("NATIVE Begin processPut(" + record + ", " + tabName + ")");
HTable hTable = getTable(tabName);
try {
Put op = createPut(record, tabName, famName, quaName);
hTable.put(op);
} catch (IOException e) {
logger.error("Error while attempting to perform operations at HBaseDataTransactions.");
logger.error(e.getMessage());
}
} | [
"@",
"Override",
"public",
"void",
"processPut",
"(",
"Record",
"record",
",",
"String",
"tabName",
",",
"String",
"famName",
",",
"String",
"quaName",
")",
"{",
"logger",
".",
"debug",
"(",
"\"NATIVE Begin processPut(\"",
"+",
"record",
"+",
"\", \"",
"+",
"tabName",
"+",
"\")\"",
")",
";",
"HTable",
"hTable",
"=",
"getTable",
"(",
"tabName",
")",
";",
"try",
"{",
"Put",
"op",
"=",
"createPut",
"(",
"record",
",",
"tabName",
",",
"famName",
",",
"quaName",
")",
";",
"hTable",
".",
"put",
"(",
"op",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error while attempting to perform operations at HBaseDataTransactions.\"",
")",
";",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Process put operations on an HBase table. | [
"Process",
"put",
"operations",
"on",
"an",
"HBase",
"table",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/HBaseUtils.java#L103-L115 |
2,446 | dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/HBaseUtils.java | HBaseUtils.processDelete | @Override
public void processDelete(URI id, String tabName,
String famName, String quaName) {
logger.debug("NATIVE Begin processDelete(" + id + ", " + tabName + ")");
HTable hTable = getTable(tabName);
try {
Delete op = createDelete(id, tabName);
hTable.delete(op);
} catch (IOException e) {
logger.error("Error while attempting to perform operations at HBaseDataTransactions.");
logger.error(e.getMessage());
}
} | java | @Override
public void processDelete(URI id, String tabName,
String famName, String quaName) {
logger.debug("NATIVE Begin processDelete(" + id + ", " + tabName + ")");
HTable hTable = getTable(tabName);
try {
Delete op = createDelete(id, tabName);
hTable.delete(op);
} catch (IOException e) {
logger.error("Error while attempting to perform operations at HBaseDataTransactions.");
logger.error(e.getMessage());
}
} | [
"@",
"Override",
"public",
"void",
"processDelete",
"(",
"URI",
"id",
",",
"String",
"tabName",
",",
"String",
"famName",
",",
"String",
"quaName",
")",
"{",
"logger",
".",
"debug",
"(",
"\"NATIVE Begin processDelete(\"",
"+",
"id",
"+",
"\", \"",
"+",
"tabName",
"+",
"\")\"",
")",
";",
"HTable",
"hTable",
"=",
"getTable",
"(",
"tabName",
")",
";",
"try",
"{",
"Delete",
"op",
"=",
"createDelete",
"(",
"id",
",",
"tabName",
")",
";",
"hTable",
".",
"delete",
"(",
"op",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error while attempting to perform operations at HBaseDataTransactions.\"",
")",
";",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Process delete operations on an HBase table. | [
"Process",
"delete",
"operations",
"on",
"an",
"HBase",
"table",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/HBaseUtils.java#L120-L132 |
2,447 | dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/HBaseUtils.java | HBaseUtils.createPut | @Override
public Put createPut(Record record, String tableName,
String famName, String quaName) throws IOException {
HTable hTable = getTable(tableName);
Put put = null;
if (hTable != null) {
// Transforming data model record into an Avro record
AvroSerializer serializer = getSerializer();
final byte[] bytes = serializer.toBytes(record);
// Resource's Key
put = new Put(Bytes.toBytes(record.getID().toString()));
// Resource's Value
put.add(Bytes.toBytes(famName), Bytes.toBytes(quaName), bytes);
}
return put;
} | java | @Override
public Put createPut(Record record, String tableName,
String famName, String quaName) throws IOException {
HTable hTable = getTable(tableName);
Put put = null;
if (hTable != null) {
// Transforming data model record into an Avro record
AvroSerializer serializer = getSerializer();
final byte[] bytes = serializer.toBytes(record);
// Resource's Key
put = new Put(Bytes.toBytes(record.getID().toString()));
// Resource's Value
put.add(Bytes.toBytes(famName), Bytes.toBytes(quaName), bytes);
}
return put;
} | [
"@",
"Override",
"public",
"Put",
"createPut",
"(",
"Record",
"record",
",",
"String",
"tableName",
",",
"String",
"famName",
",",
"String",
"quaName",
")",
"throws",
"IOException",
"{",
"HTable",
"hTable",
"=",
"getTable",
"(",
"tableName",
")",
";",
"Put",
"put",
"=",
"null",
";",
"if",
"(",
"hTable",
"!=",
"null",
")",
"{",
"// Transforming data model record into an Avro record",
"AvroSerializer",
"serializer",
"=",
"getSerializer",
"(",
")",
";",
"final",
"byte",
"[",
"]",
"bytes",
"=",
"serializer",
".",
"toBytes",
"(",
"record",
")",
";",
"// Resource's Key",
"put",
"=",
"new",
"Put",
"(",
"Bytes",
".",
"toBytes",
"(",
"record",
".",
"getID",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
";",
"// Resource's Value",
"put",
".",
"add",
"(",
"Bytes",
".",
"toBytes",
"(",
"famName",
")",
",",
"Bytes",
".",
"toBytes",
"(",
"quaName",
")",
",",
"bytes",
")",
";",
"}",
"return",
"put",
";",
"}"
] | Creates puts for HBase
@param record
@throws IOException | [
"Creates",
"puts",
"for",
"HBase"
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/HBaseUtils.java#L185-L200 |
2,448 | dkmfbk/knowledgestore | ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/HBaseUtils.java | HBaseUtils.checkForErrors | @Override
public List<Object> checkForErrors(Object[] objs) {
List<Object> errors = new ArrayList<Object>();
if (objs != null) {
for (int cont = 0; cont < objs.length; cont ++) {
if (objs[cont] == null) {
logger.debug("A operation could not be performed.");
errors.add(objs[cont]);
}
}
}
return errors;
} | java | @Override
public List<Object> checkForErrors(Object[] objs) {
List<Object> errors = new ArrayList<Object>();
if (objs != null) {
for (int cont = 0; cont < objs.length; cont ++) {
if (objs[cont] == null) {
logger.debug("A operation could not be performed.");
errors.add(objs[cont]);
}
}
}
return errors;
} | [
"@",
"Override",
"public",
"List",
"<",
"Object",
">",
"checkForErrors",
"(",
"Object",
"[",
"]",
"objs",
")",
"{",
"List",
"<",
"Object",
">",
"errors",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"if",
"(",
"objs",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"cont",
"=",
"0",
";",
"cont",
"<",
"objs",
".",
"length",
";",
"cont",
"++",
")",
"{",
"if",
"(",
"objs",
"[",
"cont",
"]",
"==",
"null",
")",
"{",
"logger",
".",
"debug",
"(",
"\"A operation could not be performed.\"",
")",
";",
"errors",
".",
"add",
"(",
"objs",
"[",
"cont",
"]",
")",
";",
"}",
"}",
"}",
"return",
"errors",
";",
"}"
] | Checking for errors after operations have been processed.
@param objs
@return | [
"Checking",
"for",
"errors",
"after",
"operations",
"have",
"been",
"processed",
"."
] | a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a | https://github.com/dkmfbk/knowledgestore/blob/a548101b1dd67fcf72a1ec6f838ea7539bdbbe7a/ks-server-hbase/src/main/java/eu/fbk/knowledgestore/datastore/hbase/utils/HBaseUtils.java#L225-L237 |
2,449 | maxschuster/DataUrl | src/main/java/eu/maxschuster/dataurl/DataUrlSerializer.java | DataUrlSerializer.getAppliedEncoder | protected IEncoder getAppliedEncoder(DataUrlEncoding encoding) {
switch (encoding) {
case BASE64:
return base64Encoder;
case URL:
return urlEncodedEncoder;
}
throw new IllegalArgumentException();
} | java | protected IEncoder getAppliedEncoder(DataUrlEncoding encoding) {
switch (encoding) {
case BASE64:
return base64Encoder;
case URL:
return urlEncodedEncoder;
}
throw new IllegalArgumentException();
} | [
"protected",
"IEncoder",
"getAppliedEncoder",
"(",
"DataUrlEncoding",
"encoding",
")",
"{",
"switch",
"(",
"encoding",
")",
"{",
"case",
"BASE64",
":",
"return",
"base64Encoder",
";",
"case",
"URL",
":",
"return",
"urlEncodedEncoder",
";",
"}",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}"
] | Get the matching encoder for the given encoding
@param encoding Encoding
@return Matching encoder | [
"Get",
"the",
"matching",
"encoder",
"for",
"the",
"given",
"encoding"
] | 6b2e2c54e50bb8ee5a7d8b30c8c2b3b24ddcb628 | https://github.com/maxschuster/DataUrl/blob/6b2e2c54e50bb8ee5a7d8b30c8c2b3b24ddcb628/src/main/java/eu/maxschuster/dataurl/DataUrlSerializer.java#L205-L213 |
2,450 | cryptomator/siv-mode | src/main/java/org/cryptomator/siv/SivMode.java | SivMode.pad | private static byte[] pad(byte[] in) {
final byte[] result = Arrays.copyOf(in, 16);
new ISO7816d4Padding().addPadding(result, in.length);
return result;
} | java | private static byte[] pad(byte[] in) {
final byte[] result = Arrays.copyOf(in, 16);
new ISO7816d4Padding().addPadding(result, in.length);
return result;
} | [
"private",
"static",
"byte",
"[",
"]",
"pad",
"(",
"byte",
"[",
"]",
"in",
")",
"{",
"final",
"byte",
"[",
"]",
"result",
"=",
"Arrays",
".",
"copyOf",
"(",
"in",
",",
"16",
")",
";",
"new",
"ISO7816d4Padding",
"(",
")",
".",
"addPadding",
"(",
"result",
",",
"in",
".",
"length",
")",
";",
"return",
"result",
";",
"}"
] | First bit 1, following bits 0. | [
"First",
"bit",
"1",
"following",
"bits",
"0",
"."
] | aa21286cc5a840c42ec3bf6d4c945ab6acaad568 | https://github.com/cryptomator/siv-mode/blob/aa21286cc5a840c42ec3bf6d4c945ab6acaad568/src/main/java/org/cryptomator/siv/SivMode.java#L259-L263 |
2,451 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/springsrc/utils/ReflectionUtils.java | ReflectionUtils.shallowCopyFieldState | public static void shallowCopyFieldState(final Object src, final Object dest) {
if (src == null) {
throw new IllegalArgumentException("Source for field copy cannot be null");
}
if (dest == null) {
throw new IllegalArgumentException("Destination for field copy cannot be null");
}
if (!src.getClass().isAssignableFrom(dest.getClass())) {
throw new IllegalArgumentException("Destination class [" + dest.getClass().getName() +
"] must be same or subclass as source class [" + src.getClass().getName() + "]");
}
doWithFields(src.getClass(), new FieldCallback() {
@Override
public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
makeAccessible(field);
Object srcValue = field.get(src);
field.set(dest, srcValue);
}
}, COPYABLE_FIELDS);
} | java | public static void shallowCopyFieldState(final Object src, final Object dest) {
if (src == null) {
throw new IllegalArgumentException("Source for field copy cannot be null");
}
if (dest == null) {
throw new IllegalArgumentException("Destination for field copy cannot be null");
}
if (!src.getClass().isAssignableFrom(dest.getClass())) {
throw new IllegalArgumentException("Destination class [" + dest.getClass().getName() +
"] must be same or subclass as source class [" + src.getClass().getName() + "]");
}
doWithFields(src.getClass(), new FieldCallback() {
@Override
public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
makeAccessible(field);
Object srcValue = field.get(src);
field.set(dest, srcValue);
}
}, COPYABLE_FIELDS);
} | [
"public",
"static",
"void",
"shallowCopyFieldState",
"(",
"final",
"Object",
"src",
",",
"final",
"Object",
"dest",
")",
"{",
"if",
"(",
"src",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Source for field copy cannot be null\"",
")",
";",
"}",
"if",
"(",
"dest",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Destination for field copy cannot be null\"",
")",
";",
"}",
"if",
"(",
"!",
"src",
".",
"getClass",
"(",
")",
".",
"isAssignableFrom",
"(",
"dest",
".",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Destination class [\"",
"+",
"dest",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"] must be same or subclass as source class [\"",
"+",
"src",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"]\"",
")",
";",
"}",
"doWithFields",
"(",
"src",
".",
"getClass",
"(",
")",
",",
"new",
"FieldCallback",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"doWith",
"(",
"Field",
"field",
")",
"throws",
"IllegalArgumentException",
",",
"IllegalAccessException",
"{",
"makeAccessible",
"(",
"field",
")",
";",
"Object",
"srcValue",
"=",
"field",
".",
"get",
"(",
"src",
")",
";",
"field",
".",
"set",
"(",
"dest",
",",
"srcValue",
")",
";",
"}",
"}",
",",
"COPYABLE_FIELDS",
")",
";",
"}"
] | Given the source object and the destination, which must be the same class
or a subclass, copy all fields, including inherited fields. Designed to
work on objects with public no-arg constructors. | [
"Given",
"the",
"source",
"object",
"and",
"the",
"destination",
"which",
"must",
"be",
"the",
"same",
"class",
"or",
"a",
"subclass",
"copy",
"all",
"fields",
"including",
"inherited",
"fields",
".",
"Designed",
"to",
"work",
"on",
"objects",
"with",
"public",
"no",
"-",
"arg",
"constructors",
"."
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/springsrc/utils/ReflectionUtils.java#L727-L746 |
2,452 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ArrayUtils.java | ArrayUtils.insertArray | public static Object[] insertArray(Object obj, Object[] arr) {
Object[] newArr = new Object[arr.length + 1];
System.arraycopy(arr, 0, newArr, 1, arr.length);
newArr[0] = obj;
return newArr;
} | java | public static Object[] insertArray(Object obj, Object[] arr) {
Object[] newArr = new Object[arr.length + 1];
System.arraycopy(arr, 0, newArr, 1, arr.length);
newArr[0] = obj;
return newArr;
} | [
"public",
"static",
"Object",
"[",
"]",
"insertArray",
"(",
"Object",
"obj",
",",
"Object",
"[",
"]",
"arr",
")",
"{",
"Object",
"[",
"]",
"newArr",
"=",
"new",
"Object",
"[",
"arr",
".",
"length",
"+",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"arr",
",",
"0",
",",
"newArr",
",",
"1",
",",
"arr",
".",
"length",
")",
";",
"newArr",
"[",
"0",
"]",
"=",
"obj",
";",
"return",
"newArr",
";",
"}"
] | Insert an Object at front of array | [
"Insert",
"an",
"Object",
"at",
"front",
"of",
"array"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ArrayUtils.java#L26-L31 |
2,453 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ArrayUtils.java | ArrayUtils.appendArray | public static Object[] appendArray(Object[] arr, Object obj) {
Object[] newArr = new Object[arr.length + 1];
System.arraycopy(arr, 0, newArr, 0, arr.length);
newArr[arr.length] = obj;
return newArr;
} | java | public static Object[] appendArray(Object[] arr, Object obj) {
Object[] newArr = new Object[arr.length + 1];
System.arraycopy(arr, 0, newArr, 0, arr.length);
newArr[arr.length] = obj;
return newArr;
} | [
"public",
"static",
"Object",
"[",
"]",
"appendArray",
"(",
"Object",
"[",
"]",
"arr",
",",
"Object",
"obj",
")",
"{",
"Object",
"[",
"]",
"newArr",
"=",
"new",
"Object",
"[",
"arr",
".",
"length",
"+",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"arr",
",",
"0",
",",
"newArr",
",",
"0",
",",
"arr",
".",
"length",
")",
";",
"newArr",
"[",
"arr",
".",
"length",
"]",
"=",
"obj",
";",
"return",
"newArr",
";",
"}"
] | Append an Object at end of array | [
"Append",
"an",
"Object",
"at",
"end",
"of",
"array"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ArrayUtils.java#L34-L39 |
2,454 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ArrayUtils.java | ArrayUtils.appendStrArray | public static String[] appendStrArray(String[] arr, String str) {
String[] newArr = new String[arr.length + 1];
System.arraycopy(arr, 0, newArr, 0, arr.length);
newArr[arr.length] = str;
return newArr;
} | java | public static String[] appendStrArray(String[] arr, String str) {
String[] newArr = new String[arr.length + 1];
System.arraycopy(arr, 0, newArr, 0, arr.length);
newArr[arr.length] = str;
return newArr;
} | [
"public",
"static",
"String",
"[",
"]",
"appendStrArray",
"(",
"String",
"[",
"]",
"arr",
",",
"String",
"str",
")",
"{",
"String",
"[",
"]",
"newArr",
"=",
"new",
"String",
"[",
"arr",
".",
"length",
"+",
"1",
"]",
";",
"System",
".",
"arraycopy",
"(",
"arr",
",",
"0",
",",
"newArr",
",",
"0",
",",
"arr",
".",
"length",
")",
";",
"newArr",
"[",
"arr",
".",
"length",
"]",
"=",
"str",
";",
"return",
"newArr",
";",
"}"
] | Append a String at end of String array | [
"Append",
"a",
"String",
"at",
"end",
"of",
"String",
"array"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ArrayUtils.java#L42-L47 |
2,455 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ArrayUtils.java | ArrayUtils.strArrayToList | public static List<String> strArrayToList(String[] arr) {
List<String> result = new ArrayList<String>();
if (arr == null || arr.length == 0)
return result;
for (String str : arr)
result.add(str);
return result;
} | java | public static List<String> strArrayToList(String[] arr) {
List<String> result = new ArrayList<String>();
if (arr == null || arr.length == 0)
return result;
for (String str : arr)
result.add(str);
return result;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"strArrayToList",
"(",
"String",
"[",
"]",
"arr",
")",
"{",
"List",
"<",
"String",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"arr",
"==",
"null",
"||",
"arr",
".",
"length",
"==",
"0",
")",
"return",
"result",
";",
"for",
"(",
"String",
"str",
":",
"arr",
")",
"result",
".",
"(",
"str",
")",
";",
"return",
"result",
";",
"}"
] | Transfer a String array to String List | [
"Transfer",
"a",
"String",
"array",
"to",
"String",
"List"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ArrayUtils.java#L50-L57 |
2,456 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ArrayUtils.java | ArrayUtils.strListToArray | public static String[] strListToArray(List<String> list) {
if (list == null)
return new String[0];
return list.toArray(new String[list.size()]);
} | java | public static String[] strListToArray(List<String> list) {
if (list == null)
return new String[0];
return list.toArray(new String[list.size()]);
} | [
"public",
"static",
"String",
"[",
"]",
"strListToArray",
"(",
"List",
"<",
"String",
">",
"list",
")",
"{",
"if",
"(",
"list",
"==",
"null",
")",
"return",
"new",
"String",
"[",
"0",
"]",
";",
"return",
"list",
".",
"toArray",
"(",
"new",
"String",
"[",
"list",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] | Transfer a String List to String array | [
"Transfer",
"a",
"String",
"List",
"to",
"String",
"array"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ArrayUtils.java#L60-L64 |
2,457 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ReservedDBWords.java | ReservedDBWords.isReservedWord | public static boolean isReservedWord(Dialect dialect, String word) {
if (!isReservedWord(word))
return false;
String fitDatabases = RESERVED_WORDS.get(word.toUpperCase()).toUpperCase();
if (fitDatabases.contains("ANSI"))
return true;
String dia = dialect.toString().replace("Dialect", "").toUpperCase();
if (dia.length() >= 4)
dia = dia.substring(0, 4);// only compare first 4 letters
return (fitDatabases.contains(dia));
} | java | public static boolean isReservedWord(Dialect dialect, String word) {
if (!isReservedWord(word))
return false;
String fitDatabases = RESERVED_WORDS.get(word.toUpperCase()).toUpperCase();
if (fitDatabases.contains("ANSI"))
return true;
String dia = dialect.toString().replace("Dialect", "").toUpperCase();
if (dia.length() >= 4)
dia = dia.substring(0, 4);// only compare first 4 letters
return (fitDatabases.contains(dia));
} | [
"public",
"static",
"boolean",
"isReservedWord",
"(",
"Dialect",
"dialect",
",",
"String",
"word",
")",
"{",
"if",
"(",
"!",
"isReservedWord",
"(",
"word",
")",
")",
"return",
"false",
";",
"String",
"fitDatabases",
"=",
"RESERVED_WORDS",
".",
"get",
"(",
"word",
".",
"toUpperCase",
"(",
")",
")",
".",
"toUpperCase",
"(",
")",
";",
"if",
"(",
"fitDatabases",
".",
"contains",
"(",
"\"ANSI\"",
")",
")",
"return",
"true",
";",
"String",
"dia",
"=",
"dialect",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"\"Dialect\"",
",",
"\"\"",
")",
".",
"toUpperCase",
"(",
")",
";",
"if",
"(",
"dia",
".",
"length",
"(",
")",
">=",
"4",
")",
"dia",
"=",
"dia",
".",
"substring",
"(",
"0",
",",
"4",
")",
";",
"// only compare first 4 letters",
"return",
"(",
"fitDatabases",
".",
"contains",
"(",
"dia",
")",
")",
";",
"}"
] | Check if is a dialect reserved word of ANSI-SQL reserved word
@return false:not reserved word. true:reserved by dialect or ANSI-SQL | [
"Check",
"if",
"is",
"a",
"dialect",
"reserved",
"word",
"of",
"ANSI",
"-",
"SQL",
"reserved",
"word"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ReservedDBWords.java#L306-L316 |
2,458 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ReservedDBWords.java | ReservedDBWords.isReservedWord | public static boolean isReservedWord(String word) {
return !StrUtils.isEmpty(word) && RESERVED_WORDS.containsKey(word.toUpperCase());
} | java | public static boolean isReservedWord(String word) {
return !StrUtils.isEmpty(word) && RESERVED_WORDS.containsKey(word.toUpperCase());
} | [
"public",
"static",
"boolean",
"isReservedWord",
"(",
"String",
"word",
")",
"{",
"return",
"!",
"StrUtils",
".",
"isEmpty",
"(",
"word",
")",
"&&",
"RESERVED_WORDS",
".",
"containsKey",
"(",
"word",
".",
"toUpperCase",
"(",
")",
")",
";",
"}"
] | Check if is a reserved word of any database | [
"Check",
"if",
"is",
"a",
"reserved",
"word",
"of",
"any",
"database"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ReservedDBWords.java#L321-L323 |
2,459 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/GuessDialectUtils.java | GuessDialectUtils.guessDialect | public static Dialect guessDialect(DataSource dataSource) {
Dialect result = dataSourceDialectCache.get(dataSource);
if (result != null)
return result;
Connection con = null;
try {
con = dataSource.getConnection();
result = guessDialect(con);
if (result == null)
return (Dialect) DialectException
.throwEX("Can not get dialect from DataSource, please submit this bug.");
dataSourceDialectCache.put(dataSource, result);
return result;
} catch (SQLException e) {
return (Dialect) DialectException.throwEX(e);
} finally {
try {
if (con != null && !con.isClosed()) {
try {// NOSONAR
con.close();
} catch (SQLException e) {
DialectException.throwEX(e);
}
}
} catch (SQLException e) {
DialectException.throwEX(e);
}
}
} | java | public static Dialect guessDialect(DataSource dataSource) {
Dialect result = dataSourceDialectCache.get(dataSource);
if (result != null)
return result;
Connection con = null;
try {
con = dataSource.getConnection();
result = guessDialect(con);
if (result == null)
return (Dialect) DialectException
.throwEX("Can not get dialect from DataSource, please submit this bug.");
dataSourceDialectCache.put(dataSource, result);
return result;
} catch (SQLException e) {
return (Dialect) DialectException.throwEX(e);
} finally {
try {
if (con != null && !con.isClosed()) {
try {// NOSONAR
con.close();
} catch (SQLException e) {
DialectException.throwEX(e);
}
}
} catch (SQLException e) {
DialectException.throwEX(e);
}
}
} | [
"public",
"static",
"Dialect",
"guessDialect",
"(",
"DataSource",
"dataSource",
")",
"{",
"Dialect",
"result",
"=",
"dataSourceDialectCache",
".",
"get",
"(",
"dataSource",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"return",
"result",
";",
"Connection",
"con",
"=",
"null",
";",
"try",
"{",
"con",
"=",
"dataSource",
".",
"getConnection",
"(",
")",
";",
"result",
"=",
"guessDialect",
"(",
"con",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"return",
"(",
"Dialect",
")",
"DialectException",
".",
"throwEX",
"(",
"\"Can not get dialect from DataSource, please submit this bug.\"",
")",
";",
"dataSourceDialectCache",
".",
"put",
"(",
"dataSource",
",",
"result",
")",
";",
"return",
"result",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"return",
"(",
"Dialect",
")",
"DialectException",
".",
"throwEX",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"con",
"!=",
"null",
"&&",
"!",
"con",
".",
"isClosed",
"(",
")",
")",
"{",
"try",
"{",
"// NOSONAR",
"con",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"DialectException",
".",
"throwEX",
"(",
"e",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"SQLException",
"e",
")",
"{",
"DialectException",
".",
"throwEX",
"(",
"e",
")",
";",
"}",
"}",
"}"
] | Guess dialect based on given dataSource
@param datasource
The dataSource
@return dialect or null if can not guess out which dialect | [
"Guess",
"dialect",
"based",
"on",
"given",
"dataSource"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/GuessDialectUtils.java#L64-L92 |
2,460 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java | StrUtils.indexOfIgnoreCase | public static int indexOfIgnoreCase(final String str, final String searchStr) {// NOSONAR
if (searchStr.isEmpty() || str.isEmpty()) {
return str.indexOf(searchStr);
}
for (int i = 0; i < str.length(); ++i) {
if (i + searchStr.length() > str.length()) {
return -1;
}
int j = 0;
int ii = i;
while (ii < str.length() && j < searchStr.length()) {
char c = Character.toLowerCase(str.charAt(ii));
char c2 = Character.toLowerCase(searchStr.charAt(j));
if (c != c2) {
break;
}
j++;
ii++;
}
if (j == searchStr.length()) {
return i;
}
}
return -1;
} | java | public static int indexOfIgnoreCase(final String str, final String searchStr) {// NOSONAR
if (searchStr.isEmpty() || str.isEmpty()) {
return str.indexOf(searchStr);
}
for (int i = 0; i < str.length(); ++i) {
if (i + searchStr.length() > str.length()) {
return -1;
}
int j = 0;
int ii = i;
while (ii < str.length() && j < searchStr.length()) {
char c = Character.toLowerCase(str.charAt(ii));
char c2 = Character.toLowerCase(searchStr.charAt(j));
if (c != c2) {
break;
}
j++;
ii++;
}
if (j == searchStr.length()) {
return i;
}
}
return -1;
} | [
"public",
"static",
"int",
"indexOfIgnoreCase",
"(",
"final",
"String",
"str",
",",
"final",
"String",
"searchStr",
")",
"{",
"// NOSONAR",
"if",
"(",
"searchStr",
".",
"isEmpty",
"(",
")",
"||",
"str",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"str",
".",
"indexOf",
"(",
"searchStr",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"str",
".",
"length",
"(",
")",
";",
"++",
"i",
")",
"{",
"if",
"(",
"i",
"+",
"searchStr",
".",
"length",
"(",
")",
">",
"str",
".",
"length",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"int",
"j",
"=",
"0",
";",
"int",
"ii",
"=",
"i",
";",
"while",
"(",
"ii",
"<",
"str",
".",
"length",
"(",
")",
"&&",
"j",
"<",
"searchStr",
".",
"length",
"(",
")",
")",
"{",
"char",
"c",
"=",
"Character",
".",
"toLowerCase",
"(",
"str",
".",
"charAt",
"(",
"ii",
")",
")",
";",
"char",
"c2",
"=",
"Character",
".",
"toLowerCase",
"(",
"searchStr",
".",
"charAt",
"(",
"j",
")",
")",
";",
"if",
"(",
"c",
"!=",
"c2",
")",
"{",
"break",
";",
"}",
"j",
"++",
";",
"ii",
"++",
";",
"}",
"if",
"(",
"j",
"==",
"searchStr",
".",
"length",
"(",
")",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | Return first postion ignore case, return -1 if not found | [
"Return",
"first",
"postion",
"ignore",
"case",
"return",
"-",
"1",
"if",
"not",
"found"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java#L365-L389 |
2,461 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java | StrUtils.lastIndexOfIgnoreCase | public static int lastIndexOfIgnoreCase(String str, String searchStr) {
if (searchStr.isEmpty() || str.isEmpty())
return -1;
return str.toLowerCase().lastIndexOf(searchStr.toLowerCase());
} | java | public static int lastIndexOfIgnoreCase(String str, String searchStr) {
if (searchStr.isEmpty() || str.isEmpty())
return -1;
return str.toLowerCase().lastIndexOf(searchStr.toLowerCase());
} | [
"public",
"static",
"int",
"lastIndexOfIgnoreCase",
"(",
"String",
"str",
",",
"String",
"searchStr",
")",
"{",
"if",
"(",
"searchStr",
".",
"isEmpty",
"(",
")",
"||",
"str",
".",
"isEmpty",
"(",
")",
")",
"return",
"-",
"1",
";",
"return",
"str",
".",
"toLowerCase",
"(",
")",
".",
"lastIndexOf",
"(",
"searchStr",
".",
"toLowerCase",
"(",
")",
")",
";",
"}"
] | Return last sub-String position ignore case, return -1 if not found | [
"Return",
"last",
"sub",
"-",
"String",
"position",
"ignore",
"case",
"return",
"-",
"1",
"if",
"not",
"found"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java#L394-L398 |
2,462 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java | StrUtils.arraysEqual | public static boolean arraysEqual(Object[] array1, Object[] array2) {
if (array1 == null || array1.length == 0 || array2 == null || array2.length == 0)
DialectException.throwEX("StrUtils arraysEqual() method can not compare empty arrays");
for (int i = 0; array1 != null && array2 != null && i < array1.length; i++)
if (!array1[i].equals(array2[i]))
return false;
return true;
} | java | public static boolean arraysEqual(Object[] array1, Object[] array2) {
if (array1 == null || array1.length == 0 || array2 == null || array2.length == 0)
DialectException.throwEX("StrUtils arraysEqual() method can not compare empty arrays");
for (int i = 0; array1 != null && array2 != null && i < array1.length; i++)
if (!array1[i].equals(array2[i]))
return false;
return true;
} | [
"public",
"static",
"boolean",
"arraysEqual",
"(",
"Object",
"[",
"]",
"array1",
",",
"Object",
"[",
"]",
"array2",
")",
"{",
"if",
"(",
"array1",
"==",
"null",
"||",
"array1",
".",
"length",
"==",
"0",
"||",
"array2",
"==",
"null",
"||",
"array2",
".",
"length",
"==",
"0",
")",
"DialectException",
".",
"throwEX",
"(",
"\"StrUtils arraysEqual() method can not compare empty arrays\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"array1",
"!=",
"null",
"&&",
"array2",
"!=",
"null",
"&&",
"i",
"<",
"array1",
".",
"length",
";",
"i",
"++",
")",
"if",
"(",
"!",
"array1",
"[",
"i",
"]",
".",
"equals",
"(",
"array2",
"[",
"i",
"]",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | Compare 2 array
@return true if each item equal | [
"Compare",
"2",
"array"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java#L852-L859 |
2,463 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java | StrUtils.toLowerCaseFirstOne | public static String toLowerCaseFirstOne(String s) {
if (Character.isLowerCase(s.charAt(0)))
return s;
else
return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
} | java | public static String toLowerCaseFirstOne(String s) {
if (Character.isLowerCase(s.charAt(0)))
return s;
else
return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
} | [
"public",
"static",
"String",
"toLowerCaseFirstOne",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"Character",
".",
"isLowerCase",
"(",
"s",
".",
"charAt",
"(",
"0",
")",
")",
")",
"return",
"s",
";",
"else",
"return",
"(",
"new",
"StringBuilder",
"(",
")",
")",
".",
"append",
"(",
"Character",
".",
"toLowerCase",
"(",
"s",
".",
"charAt",
"(",
"0",
")",
")",
")",
".",
"append",
"(",
"s",
".",
"substring",
"(",
"1",
")",
")",
".",
"toString",
"(",
")",
";",
"}"
] | First letter change to lower | [
"First",
"letter",
"change",
"to",
"lower"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java#L944-L949 |
2,464 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java | StrUtils.toUpperCaseFirstOne | public static String toUpperCaseFirstOne(String s) {
if (Character.isUpperCase(s.charAt(0)))
return s;
else
return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
} | java | public static String toUpperCaseFirstOne(String s) {
if (Character.isUpperCase(s.charAt(0)))
return s;
else
return (new StringBuilder()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
} | [
"public",
"static",
"String",
"toUpperCaseFirstOne",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"Character",
".",
"isUpperCase",
"(",
"s",
".",
"charAt",
"(",
"0",
")",
")",
")",
"return",
"s",
";",
"else",
"return",
"(",
"new",
"StringBuilder",
"(",
")",
")",
".",
"append",
"(",
"Character",
".",
"toUpperCase",
"(",
"s",
".",
"charAt",
"(",
"0",
")",
")",
")",
".",
"append",
"(",
"s",
".",
"substring",
"(",
"1",
")",
")",
".",
"toString",
"(",
")",
";",
"}"
] | First letter change to capitalised | [
"First",
"letter",
"change",
"to",
"capitalised"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java#L954-L959 |
2,465 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java | StrUtils.formatSQL | public static String formatSQL(String sql) {
if (sql == null || sql.length() == 0)
return sql;
StringBuilder sb = new StringBuilder();
char[] chars = sql.toCharArray();
boolean addedSpace = false;
for (char c : chars) {
if (isInvisibleChar(c)) {
if (!addedSpace) {
sb.append(" ");
addedSpace = true;
}
} else {
sb.append(c);
addedSpace = false;
}
}
sb.append(" ");
return sb.toString();
} | java | public static String formatSQL(String sql) {
if (sql == null || sql.length() == 0)
return sql;
StringBuilder sb = new StringBuilder();
char[] chars = sql.toCharArray();
boolean addedSpace = false;
for (char c : chars) {
if (isInvisibleChar(c)) {
if (!addedSpace) {
sb.append(" ");
addedSpace = true;
}
} else {
sb.append(c);
addedSpace = false;
}
}
sb.append(" ");
return sb.toString();
} | [
"public",
"static",
"String",
"formatSQL",
"(",
"String",
"sql",
")",
"{",
"if",
"(",
"sql",
"==",
"null",
"||",
"sql",
".",
"length",
"(",
")",
"==",
"0",
")",
"return",
"sql",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"char",
"[",
"]",
"chars",
"=",
"sql",
".",
"toCharArray",
"(",
")",
";",
"boolean",
"addedSpace",
"=",
"false",
";",
"for",
"(",
"char",
"c",
":",
"chars",
")",
"{",
"if",
"(",
"isInvisibleChar",
"(",
"c",
")",
")",
"{",
"if",
"(",
"!",
"addedSpace",
")",
"{",
"sb",
".",
"append",
"(",
"\" \"",
")",
";",
"addedSpace",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"sb",
".",
"append",
"(",
"c",
")",
";",
"addedSpace",
"=",
"false",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"\" \"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Format all " ", \t, \r... , to " ", | [
"Format",
"all",
"\\",
"t",
"\\",
"r",
"...",
"to"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/StrUtils.java#L978-L997 |
2,466 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/id/TableIdGenerator.java | TableIdGenerator.getNextID | @Override
public Object getNextID(NormalJdbcTool jdbc, Dialect dialect, Type dataType) {
int countOfRec = ((Number) jdbc // NOSONAR
.nQueryForObject("select count(*) from " + table + " where " + pkColumnName + "=?", pkColumnValue))
.intValue();
if (countOfRec == 0) {
jdbc.nUpdate("insert into " + table + "( " + pkColumnName + "," + valueColumnName + " ) values(?,?)",
pkColumnValue, initialValue);
return initialValue;
} else {
jdbc.nUpdate("update " + table + " set " + valueColumnName + "=" + valueColumnName + "+" + allocationSize
+ " where " + pkColumnName + " =?", pkColumnValue);
int last = ((Number) jdbc.nQueryForObject( // NOSONAR
"select " + valueColumnName + " from " + table + " where " + pkColumnName + "=?", pkColumnValue))
.intValue();
return last;
}
} | java | @Override
public Object getNextID(NormalJdbcTool jdbc, Dialect dialect, Type dataType) {
int countOfRec = ((Number) jdbc // NOSONAR
.nQueryForObject("select count(*) from " + table + " where " + pkColumnName + "=?", pkColumnValue))
.intValue();
if (countOfRec == 0) {
jdbc.nUpdate("insert into " + table + "( " + pkColumnName + "," + valueColumnName + " ) values(?,?)",
pkColumnValue, initialValue);
return initialValue;
} else {
jdbc.nUpdate("update " + table + " set " + valueColumnName + "=" + valueColumnName + "+" + allocationSize
+ " where " + pkColumnName + " =?", pkColumnValue);
int last = ((Number) jdbc.nQueryForObject( // NOSONAR
"select " + valueColumnName + " from " + table + " where " + pkColumnName + "=?", pkColumnValue))
.intValue();
return last;
}
} | [
"@",
"Override",
"public",
"Object",
"getNextID",
"(",
"NormalJdbcTool",
"jdbc",
",",
"Dialect",
"dialect",
",",
"Type",
"dataType",
")",
"{",
"int",
"countOfRec",
"=",
"(",
"(",
"Number",
")",
"jdbc",
"// NOSONAR",
".",
"nQueryForObject",
"(",
"\"select count(*) from \"",
"+",
"table",
"+",
"\" where \"",
"+",
"pkColumnName",
"+",
"\"=?\"",
",",
"pkColumnValue",
")",
")",
".",
"intValue",
"(",
")",
";",
"if",
"(",
"countOfRec",
"==",
"0",
")",
"{",
"jdbc",
".",
"nUpdate",
"(",
"\"insert into \"",
"+",
"table",
"+",
"\"( \"",
"+",
"pkColumnName",
"+",
"\",\"",
"+",
"valueColumnName",
"+",
"\" ) values(?,?)\"",
",",
"pkColumnValue",
",",
"initialValue",
")",
";",
"return",
"initialValue",
";",
"}",
"else",
"{",
"jdbc",
".",
"nUpdate",
"(",
"\"update \"",
"+",
"table",
"+",
"\" set \"",
"+",
"valueColumnName",
"+",
"\"=\"",
"+",
"valueColumnName",
"+",
"\"+\"",
"+",
"allocationSize",
"+",
"\" where \"",
"+",
"pkColumnName",
"+",
"\" =?\"",
",",
"pkColumnValue",
")",
";",
"int",
"last",
"=",
"(",
"(",
"Number",
")",
"jdbc",
".",
"nQueryForObject",
"(",
"// NOSONAR",
"\"select \"",
"+",
"valueColumnName",
"+",
"\" from \"",
"+",
"table",
"+",
"\" where \"",
"+",
"pkColumnName",
"+",
"\"=?\"",
",",
"pkColumnValue",
")",
")",
".",
"intValue",
"(",
")",
";",
"return",
"last",
";",
"}",
"}"
] | Get the next Table Generator ID | [
"Get",
"the",
"next",
"Table",
"Generator",
"ID"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/id/TableIdGenerator.java#L103-L121 |
2,467 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtilsOfEntity.java | TableModelUtilsOfEntity.getEntityAnnos | private static List<Map<String, Object>> getEntityAnnos(Object targetClass, String annotationName) {
Annotation[] anno = null;
if (targetClass instanceof Field)
anno = ((Field) targetClass).getAnnotations();
else
anno = ((Class<?>) targetClass).getAnnotations();
List<Map<String, Object>> l = new ArrayList<Map<String, Object>>();
for (Annotation annotation : anno) {
Class<? extends Annotation> type = annotation.annotationType();
String cName = type.getName();
if (matchNameCheck(annotationName, cName)) {
l.add(changeAnnotationValuesToMap(annotation, type));
}
}
return l;
} | java | private static List<Map<String, Object>> getEntityAnnos(Object targetClass, String annotationName) {
Annotation[] anno = null;
if (targetClass instanceof Field)
anno = ((Field) targetClass).getAnnotations();
else
anno = ((Class<?>) targetClass).getAnnotations();
List<Map<String, Object>> l = new ArrayList<Map<String, Object>>();
for (Annotation annotation : anno) {
Class<? extends Annotation> type = annotation.annotationType();
String cName = type.getName();
if (matchNameCheck(annotationName, cName)) {
l.add(changeAnnotationValuesToMap(annotation, type));
}
}
return l;
} | [
"private",
"static",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"getEntityAnnos",
"(",
"Object",
"targetClass",
",",
"String",
"annotationName",
")",
"{",
"Annotation",
"[",
"]",
"anno",
"=",
"null",
";",
"if",
"(",
"targetClass",
"instanceof",
"Field",
")",
"anno",
"=",
"(",
"(",
"Field",
")",
"targetClass",
")",
".",
"getAnnotations",
"(",
")",
";",
"else",
"anno",
"=",
"(",
"(",
"Class",
"<",
"?",
">",
")",
"targetClass",
")",
".",
"getAnnotations",
"(",
")",
";",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"l",
"=",
"new",
"ArrayList",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
";",
"for",
"(",
"Annotation",
"annotation",
":",
"anno",
")",
"{",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"type",
"=",
"annotation",
".",
"annotationType",
"(",
")",
";",
"String",
"cName",
"=",
"type",
".",
"getName",
"(",
")",
";",
"if",
"(",
"matchNameCheck",
"(",
"annotationName",
",",
"cName",
")",
")",
"{",
"l",
".",
"add",
"(",
"changeAnnotationValuesToMap",
"(",
"annotation",
",",
"type",
")",
")",
";",
"}",
"}",
"return",
"l",
";",
"}"
] | Get all entity annotations started with annotationName | [
"Get",
"all",
"entity",
"annotations",
"started",
"with",
"annotationName"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtilsOfEntity.java#L56-L71 |
2,468 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtilsOfEntity.java | TableModelUtilsOfEntity.changeAnnotationValuesToMap | private static Map<String, Object> changeAnnotationValuesToMap(Annotation annotation,
Class<? extends Annotation> type) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("AnnotationExist", true);
for (Method method : type.getDeclaredMethods())
try {
result.put(method.getName(), method.invoke(annotation, (Object[]) null));
} catch (Exception e) {// NOSONAR
}
return result;
} | java | private static Map<String, Object> changeAnnotationValuesToMap(Annotation annotation,
Class<? extends Annotation> type) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("AnnotationExist", true);
for (Method method : type.getDeclaredMethods())
try {
result.put(method.getName(), method.invoke(annotation, (Object[]) null));
} catch (Exception e) {// NOSONAR
}
return result;
} | [
"private",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"changeAnnotationValuesToMap",
"(",
"Annotation",
"annotation",
",",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"type",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"result",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"result",
".",
"put",
"(",
"\"AnnotationExist\"",
",",
"true",
")",
";",
"for",
"(",
"Method",
"method",
":",
"type",
".",
"getDeclaredMethods",
"(",
")",
")",
"try",
"{",
"result",
".",
"put",
"(",
"method",
".",
"getName",
"(",
")",
",",
"method",
".",
"invoke",
"(",
"annotation",
",",
"(",
"Object",
"[",
"]",
")",
"null",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// NOSONAR",
"}",
"return",
"result",
";",
"}"
] | Change Annotation fields values into a Map | [
"Change",
"Annotation",
"fields",
"values",
"into",
"a",
"Map"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtilsOfEntity.java#L94-L104 |
2,469 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtilsOfEntity.java | TableModelUtilsOfEntity.entity2ReadOnlyModel | public static TableModel entity2ReadOnlyModel(Class<?> entityClass) {
DialectException.assureNotNull(entityClass, "Entity class can not be null");
TableModel model = globalTableModelCache.get(entityClass);
if (model != null)
return model;
model = entity2ModelWithConfig(entityClass);
model.setReadOnly(true);
globalTableModelCache.put(entityClass, model);
return model;
} | java | public static TableModel entity2ReadOnlyModel(Class<?> entityClass) {
DialectException.assureNotNull(entityClass, "Entity class can not be null");
TableModel model = globalTableModelCache.get(entityClass);
if (model != null)
return model;
model = entity2ModelWithConfig(entityClass);
model.setReadOnly(true);
globalTableModelCache.put(entityClass, model);
return model;
} | [
"public",
"static",
"TableModel",
"entity2ReadOnlyModel",
"(",
"Class",
"<",
"?",
">",
"entityClass",
")",
"{",
"DialectException",
".",
"assureNotNull",
"(",
"entityClass",
",",
"\"Entity class can not be null\"",
")",
";",
"TableModel",
"model",
"=",
"globalTableModelCache",
".",
"get",
"(",
"entityClass",
")",
";",
"if",
"(",
"model",
"!=",
"null",
")",
"return",
"model",
";",
"model",
"=",
"entity2ModelWithConfig",
"(",
"entityClass",
")",
";",
"model",
".",
"setReadOnly",
"(",
"true",
")",
";",
"globalTableModelCache",
".",
"put",
"(",
"entityClass",
",",
"model",
")",
";",
"return",
"model",
";",
"}"
] | Convert entity class to a read-only TableModel instance | [
"Convert",
"entity",
"class",
"to",
"a",
"read",
"-",
"only",
"TableModel",
"instance"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtilsOfEntity.java#L109-L118 |
2,470 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtilsOfEntity.java | TableModelUtilsOfEntity.entity2ReadOnlyModel | public static TableModel[] entity2ReadOnlyModel(Class<?>... entityClasses) {
List<TableModel> l = new ArrayList<TableModel>();
for (Class<?> clazz : entityClasses) {
l.add(entity2ReadOnlyModel(clazz));
}
return l.toArray(new TableModel[l.size()]);
} | java | public static TableModel[] entity2ReadOnlyModel(Class<?>... entityClasses) {
List<TableModel> l = new ArrayList<TableModel>();
for (Class<?> clazz : entityClasses) {
l.add(entity2ReadOnlyModel(clazz));
}
return l.toArray(new TableModel[l.size()]);
} | [
"public",
"static",
"TableModel",
"[",
"]",
"entity2ReadOnlyModel",
"(",
"Class",
"<",
"?",
">",
"...",
"entityClasses",
")",
"{",
"List",
"<",
"TableModel",
">",
"l",
"=",
"new",
"ArrayList",
"<",
"TableModel",
">",
"(",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"clazz",
":",
"entityClasses",
")",
"{",
"l",
".",
"add",
"(",
"entity2ReadOnlyModel",
"(",
"clazz",
")",
")",
";",
"}",
"return",
"l",
".",
"toArray",
"(",
"new",
"TableModel",
"[",
"l",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] | Convert entity classes to a read-only TableModel instances | [
"Convert",
"entity",
"classes",
"to",
"a",
"read",
"-",
"only",
"TableModel",
"instances"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtilsOfEntity.java#L121-L127 |
2,471 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtilsOfEntity.java | TableModelUtilsOfEntity.entity2EditableModels | public static TableModel[] entity2EditableModels(Class<?>... entityClasses) {
List<TableModel> l = new ArrayList<TableModel>();
for (Class<?> clazz : entityClasses) {
l.add(entity2EditableModel(clazz));
}
return l.toArray(new TableModel[l.size()]);
} | java | public static TableModel[] entity2EditableModels(Class<?>... entityClasses) {
List<TableModel> l = new ArrayList<TableModel>();
for (Class<?> clazz : entityClasses) {
l.add(entity2EditableModel(clazz));
}
return l.toArray(new TableModel[l.size()]);
} | [
"public",
"static",
"TableModel",
"[",
"]",
"entity2EditableModels",
"(",
"Class",
"<",
"?",
">",
"...",
"entityClasses",
")",
"{",
"List",
"<",
"TableModel",
">",
"l",
"=",
"new",
"ArrayList",
"<",
"TableModel",
">",
"(",
")",
";",
"for",
"(",
"Class",
"<",
"?",
">",
"clazz",
":",
"entityClasses",
")",
"{",
"l",
".",
"add",
"(",
"entity2EditableModel",
"(",
"clazz",
")",
")",
";",
"}",
"return",
"l",
".",
"toArray",
"(",
"new",
"TableModel",
"[",
"l",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] | Convert entity classes to a editable TableModel instances | [
"Convert",
"entity",
"classes",
"to",
"a",
"editable",
"TableModel",
"instances"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtilsOfEntity.java#L144-L150 |
2,472 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java | ClassCacheUtils.checkMethodExist | public static Method checkMethodExist(Class<?> clazz, String uniqueMethodName) {
if (clazz == null || StrUtils.isEmpty(uniqueMethodName))
return null;
Map<String, Object> methodMap = uniqueMethodCache.get(clazz);
if (methodMap != null && !methodMap.isEmpty()) {
Object result = methodMap.get(uniqueMethodName);
if (result != null) {
if (ClassOrMethodNotExist.class.equals(result))
return null;
else
return (Method) result;
}
}
if (methodMap == null) {
methodMap = new HashMap<String, Object>();
uniqueMethodCache.put(clazz, methodMap);
}
Method[] methods = clazz.getMethods();
for (Method method : methods)
if (uniqueMethodName != null && uniqueMethodName.equals(method.getName())) {
methodMap.put(uniqueMethodName, method);
return method;
}
methodMap.put(uniqueMethodName, ClassOrMethodNotExist.class);
return null;
} | java | public static Method checkMethodExist(Class<?> clazz, String uniqueMethodName) {
if (clazz == null || StrUtils.isEmpty(uniqueMethodName))
return null;
Map<String, Object> methodMap = uniqueMethodCache.get(clazz);
if (methodMap != null && !methodMap.isEmpty()) {
Object result = methodMap.get(uniqueMethodName);
if (result != null) {
if (ClassOrMethodNotExist.class.equals(result))
return null;
else
return (Method) result;
}
}
if (methodMap == null) {
methodMap = new HashMap<String, Object>();
uniqueMethodCache.put(clazz, methodMap);
}
Method[] methods = clazz.getMethods();
for (Method method : methods)
if (uniqueMethodName != null && uniqueMethodName.equals(method.getName())) {
methodMap.put(uniqueMethodName, method);
return method;
}
methodMap.put(uniqueMethodName, ClassOrMethodNotExist.class);
return null;
} | [
"public",
"static",
"Method",
"checkMethodExist",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"uniqueMethodName",
")",
"{",
"if",
"(",
"clazz",
"==",
"null",
"||",
"StrUtils",
".",
"isEmpty",
"(",
"uniqueMethodName",
")",
")",
"return",
"null",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"methodMap",
"=",
"uniqueMethodCache",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"methodMap",
"!=",
"null",
"&&",
"!",
"methodMap",
".",
"isEmpty",
"(",
")",
")",
"{",
"Object",
"result",
"=",
"methodMap",
".",
"get",
"(",
"uniqueMethodName",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"if",
"(",
"ClassOrMethodNotExist",
".",
"class",
".",
"equals",
"(",
"result",
")",
")",
"return",
"null",
";",
"else",
"return",
"(",
"Method",
")",
"result",
";",
"}",
"}",
"if",
"(",
"methodMap",
"==",
"null",
")",
"{",
"methodMap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"uniqueMethodCache",
".",
"put",
"(",
"clazz",
",",
"methodMap",
")",
";",
"}",
"Method",
"[",
"]",
"methods",
"=",
"clazz",
".",
"getMethods",
"(",
")",
";",
"for",
"(",
"Method",
"method",
":",
"methods",
")",
"if",
"(",
"uniqueMethodName",
"!=",
"null",
"&&",
"uniqueMethodName",
".",
"equals",
"(",
"method",
".",
"getName",
"(",
")",
")",
")",
"{",
"methodMap",
".",
"put",
"(",
"uniqueMethodName",
",",
"method",
")",
";",
"return",
"method",
";",
"}",
"methodMap",
".",
"put",
"(",
"uniqueMethodName",
",",
"ClassOrMethodNotExist",
".",
"class",
")",
";",
"return",
"null",
";",
"}"
] | Check if a unique method name exists in class, if exist return the method,
otherwise return null | [
"Check",
"if",
"a",
"unique",
"method",
"name",
"exists",
"in",
"class",
"if",
"exist",
"return",
"the",
"method",
"otherwise",
"return",
"null"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java#L80-L105 |
2,473 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java | ClassCacheUtils.getClassReadMethods | public static Map<String, Method> getClassReadMethods(Class<?> clazz) {
Map<String, Method> readMethods = classReadMethods.get(clazz);
if (readMethods == null) {
cacheReadWriteMethodsAndBoxField(clazz);
return classReadMethods.get(clazz);
} else
return readMethods;
} | java | public static Map<String, Method> getClassReadMethods(Class<?> clazz) {
Map<String, Method> readMethods = classReadMethods.get(clazz);
if (readMethods == null) {
cacheReadWriteMethodsAndBoxField(clazz);
return classReadMethods.get(clazz);
} else
return readMethods;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Method",
">",
"getClassReadMethods",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"Map",
"<",
"String",
",",
"Method",
">",
"readMethods",
"=",
"classReadMethods",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"readMethods",
"==",
"null",
")",
"{",
"cacheReadWriteMethodsAndBoxField",
"(",
"clazz",
")",
";",
"return",
"classReadMethods",
".",
"get",
"(",
"clazz",
")",
";",
"}",
"else",
"return",
"readMethods",
";",
"}"
] | Return cached class read methods to avoid each time use reflect | [
"Return",
"cached",
"class",
"read",
"methods",
"to",
"avoid",
"each",
"time",
"use",
"reflect"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java#L152-L159 |
2,474 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java | ClassCacheUtils.getClassFieldReadMethod | public static Method getClassFieldReadMethod(Class<?> clazz, String fieldName) {
return getClassReadMethods(clazz).get(fieldName);
} | java | public static Method getClassFieldReadMethod(Class<?> clazz, String fieldName) {
return getClassReadMethods(clazz).get(fieldName);
} | [
"public",
"static",
"Method",
"getClassFieldReadMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"fieldName",
")",
"{",
"return",
"getClassReadMethods",
"(",
"clazz",
")",
".",
"get",
"(",
"fieldName",
")",
";",
"}"
] | Return cached class field read method to avoid each time use reflect | [
"Return",
"cached",
"class",
"field",
"read",
"method",
"to",
"avoid",
"each",
"time",
"use",
"reflect"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java#L162-L164 |
2,475 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java | ClassCacheUtils.getClassWriteMethods | public static Map<String, Method> getClassWriteMethods(Class<?> clazz) {
Map<String, Method> writeMethods = classWriteMethods.get(clazz);
if (writeMethods == null) {
cacheReadWriteMethodsAndBoxField(clazz);
return classWriteMethods.get(clazz);
} else
return writeMethods;
} | java | public static Map<String, Method> getClassWriteMethods(Class<?> clazz) {
Map<String, Method> writeMethods = classWriteMethods.get(clazz);
if (writeMethods == null) {
cacheReadWriteMethodsAndBoxField(clazz);
return classWriteMethods.get(clazz);
} else
return writeMethods;
} | [
"public",
"static",
"Map",
"<",
"String",
",",
"Method",
">",
"getClassWriteMethods",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"Map",
"<",
"String",
",",
"Method",
">",
"writeMethods",
"=",
"classWriteMethods",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"writeMethods",
"==",
"null",
")",
"{",
"cacheReadWriteMethodsAndBoxField",
"(",
"clazz",
")",
";",
"return",
"classWriteMethods",
".",
"get",
"(",
"clazz",
")",
";",
"}",
"else",
"return",
"writeMethods",
";",
"}"
] | Return cached class write methods to avoid each time use reflect | [
"Return",
"cached",
"class",
"write",
"methods",
"to",
"avoid",
"each",
"time",
"use",
"reflect"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java#L167-L174 |
2,476 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java | ClassCacheUtils.getClassFieldWriteMethod | public static Method getClassFieldWriteMethod(Class<?> clazz, String fieldName) {
return getClassWriteMethods(clazz).get(fieldName);
} | java | public static Method getClassFieldWriteMethod(Class<?> clazz, String fieldName) {
return getClassWriteMethods(clazz).get(fieldName);
} | [
"public",
"static",
"Method",
"getClassFieldWriteMethod",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"fieldName",
")",
"{",
"return",
"getClassWriteMethods",
"(",
"clazz",
")",
".",
"get",
"(",
"fieldName",
")",
";",
"}"
] | Return cached class field write method to avoid each time use reflect | [
"Return",
"cached",
"class",
"field",
"write",
"method",
"to",
"avoid",
"each",
"time",
"use",
"reflect"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java#L177-L179 |
2,477 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java | ClassCacheUtils.readValueFromBeanField | public static Object readValueFromBeanField(Object entityBean, String fieldName) {
Method readMethod = ClassCacheUtils.getClassFieldReadMethod(entityBean.getClass(), fieldName);
if (readMethod == null) {
throw new DialectException(
"No mapping found for field '" + fieldName + "' in '" + entityBean.getClass() + "'");
} else
try {
return readMethod.invoke(entityBean);
} catch (Exception e) {
throw new DialectException(e);
}
} | java | public static Object readValueFromBeanField(Object entityBean, String fieldName) {
Method readMethod = ClassCacheUtils.getClassFieldReadMethod(entityBean.getClass(), fieldName);
if (readMethod == null) {
throw new DialectException(
"No mapping found for field '" + fieldName + "' in '" + entityBean.getClass() + "'");
} else
try {
return readMethod.invoke(entityBean);
} catch (Exception e) {
throw new DialectException(e);
}
} | [
"public",
"static",
"Object",
"readValueFromBeanField",
"(",
"Object",
"entityBean",
",",
"String",
"fieldName",
")",
"{",
"Method",
"readMethod",
"=",
"ClassCacheUtils",
".",
"getClassFieldReadMethod",
"(",
"entityBean",
".",
"getClass",
"(",
")",
",",
"fieldName",
")",
";",
"if",
"(",
"readMethod",
"==",
"null",
")",
"{",
"throw",
"new",
"DialectException",
"(",
"\"No mapping found for field '\"",
"+",
"fieldName",
"+",
"\"' in '\"",
"+",
"entityBean",
".",
"getClass",
"(",
")",
"+",
"\"'\"",
")",
";",
"}",
"else",
"try",
"{",
"return",
"readMethod",
".",
"invoke",
"(",
"entityBean",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"DialectException",
"(",
"e",
")",
";",
"}",
"}"
] | Read value from entityBean field | [
"Read",
"value",
"from",
"entityBean",
"field"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java#L182-L193 |
2,478 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java | ClassCacheUtils.writeValueToBeanField | public static void writeValueToBeanField(Object entityBean, String fieldName, Object value) {
Method writeMethod = ClassCacheUtils.getClassFieldWriteMethod(entityBean.getClass(), fieldName);
if (writeMethod == null) {
throw new DialectException("Can not find Java bean read method '" + fieldName + "'");
} else
try {
writeMethod.invoke(entityBean, value);
} catch (Exception e) {
throw new DialectException("FieldName '" + fieldName + "' can not write with value '" + value + "'", e);
}
} | java | public static void writeValueToBeanField(Object entityBean, String fieldName, Object value) {
Method writeMethod = ClassCacheUtils.getClassFieldWriteMethod(entityBean.getClass(), fieldName);
if (writeMethod == null) {
throw new DialectException("Can not find Java bean read method '" + fieldName + "'");
} else
try {
writeMethod.invoke(entityBean, value);
} catch (Exception e) {
throw new DialectException("FieldName '" + fieldName + "' can not write with value '" + value + "'", e);
}
} | [
"public",
"static",
"void",
"writeValueToBeanField",
"(",
"Object",
"entityBean",
",",
"String",
"fieldName",
",",
"Object",
"value",
")",
"{",
"Method",
"writeMethod",
"=",
"ClassCacheUtils",
".",
"getClassFieldWriteMethod",
"(",
"entityBean",
".",
"getClass",
"(",
")",
",",
"fieldName",
")",
";",
"if",
"(",
"writeMethod",
"==",
"null",
")",
"{",
"throw",
"new",
"DialectException",
"(",
"\"Can not find Java bean read method '\"",
"+",
"fieldName",
"+",
"\"'\"",
")",
";",
"}",
"else",
"try",
"{",
"writeMethod",
".",
"invoke",
"(",
"entityBean",
",",
"value",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"DialectException",
"(",
"\"FieldName '\"",
"+",
"fieldName",
"+",
"\"' can not write with value '\"",
"+",
"value",
"+",
"\"'\"",
",",
"e",
")",
";",
"}",
"}"
] | write value to entityBean field | [
"write",
"value",
"to",
"entityBean",
"field"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/ClassCacheUtils.java#L196-L206 |
2,479 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/DialectFunctionTranslator.java | DialectFunctionTranslator.seperateCharsToItems | DialectSqlItem[] seperateCharsToItems(char[] chars, int start, int end) {
List<DialectSqlItem> items = new ArrayList<DialectSqlItem>();
SearchResult result = findFirstResult(chars, start, end);
while (result != null) {
items.add(result.item);
result = findFirstResult(chars, result.leftStart, result.leftEnd);
}
return items.toArray(new DialectSqlItem[items.size()]);
} | java | DialectSqlItem[] seperateCharsToItems(char[] chars, int start, int end) {
List<DialectSqlItem> items = new ArrayList<DialectSqlItem>();
SearchResult result = findFirstResult(chars, start, end);
while (result != null) {
items.add(result.item);
result = findFirstResult(chars, result.leftStart, result.leftEnd);
}
return items.toArray(new DialectSqlItem[items.size()]);
} | [
"DialectSqlItem",
"[",
"]",
"seperateCharsToItems",
"(",
"char",
"[",
"]",
"chars",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"List",
"<",
"DialectSqlItem",
">",
"items",
"=",
"new",
"ArrayList",
"<",
"DialectSqlItem",
">",
"(",
")",
";",
"SearchResult",
"result",
"=",
"findFirstResult",
"(",
"chars",
",",
"start",
",",
"end",
")",
";",
"while",
"(",
"result",
"!=",
"null",
")",
"{",
"items",
".",
"add",
"(",
"result",
".",
"item",
")",
";",
"result",
"=",
"findFirstResult",
"(",
"chars",
",",
"result",
".",
"leftStart",
",",
"result",
".",
"leftEnd",
")",
";",
"}",
"return",
"items",
".",
"toArray",
"(",
"new",
"DialectSqlItem",
"[",
"items",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] | Separate chars to Items list | [
"Separate",
"chars",
"to",
"Items",
"list"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/DialectFunctionTranslator.java#L303-L311 |
2,480 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/DialectFunctionTranslator.java | DialectFunctionTranslator.correctType | void correctType(DialectSqlItem item) {//NOSONAR
if (item.type == 'U') {// correct Unknown type to other type
String valueStr = (String) item.value;
String valueUpcase = valueStr.toUpperCase();
// check is function
String funPrefix = Dialect.getGlobalSqlFunctionPrefix();
if (!StrUtils.isEmpty(valueUpcase)) {
if (!StrUtils.isEmpty(funPrefix) && StrUtils.startsWithIgnoreCase(valueUpcase, funPrefix)
&& functionMap.containsKey(valueUpcase.substring(funPrefix.length()))) {
item.type = 'F';
item.value = valueStr.substring(funPrefix.length());
}
if ((StrUtils.isEmpty(funPrefix) && functionMap.containsKey(valueUpcase))) {
item.type = 'F';
item.value = valueStr;
}
}
if (item.type == 'U')// still not found
if (",".equals(valueStr))
// is Long able?
item.setTypeAndValue(',', valueStr);
else
item.setTypeAndValue('S', valueStr);
}
if (item.subItems != null)
for (DialectSqlItem t : item.subItems)
correctType(t);
} | java | void correctType(DialectSqlItem item) {//NOSONAR
if (item.type == 'U') {// correct Unknown type to other type
String valueStr = (String) item.value;
String valueUpcase = valueStr.toUpperCase();
// check is function
String funPrefix = Dialect.getGlobalSqlFunctionPrefix();
if (!StrUtils.isEmpty(valueUpcase)) {
if (!StrUtils.isEmpty(funPrefix) && StrUtils.startsWithIgnoreCase(valueUpcase, funPrefix)
&& functionMap.containsKey(valueUpcase.substring(funPrefix.length()))) {
item.type = 'F';
item.value = valueStr.substring(funPrefix.length());
}
if ((StrUtils.isEmpty(funPrefix) && functionMap.containsKey(valueUpcase))) {
item.type = 'F';
item.value = valueStr;
}
}
if (item.type == 'U')// still not found
if (",".equals(valueStr))
// is Long able?
item.setTypeAndValue(',', valueStr);
else
item.setTypeAndValue('S', valueStr);
}
if (item.subItems != null)
for (DialectSqlItem t : item.subItems)
correctType(t);
} | [
"void",
"correctType",
"(",
"DialectSqlItem",
"item",
")",
"{",
"//NOSONAR",
"if",
"(",
"item",
".",
"type",
"==",
"'",
"'",
")",
"{",
"// correct Unknown type to other type",
"String",
"valueStr",
"=",
"(",
"String",
")",
"item",
".",
"value",
";",
"String",
"valueUpcase",
"=",
"valueStr",
".",
"toUpperCase",
"(",
")",
";",
"// check is function",
"String",
"funPrefix",
"=",
"Dialect",
".",
"getGlobalSqlFunctionPrefix",
"(",
")",
";",
"if",
"(",
"!",
"StrUtils",
".",
"isEmpty",
"(",
"valueUpcase",
")",
")",
"{",
"if",
"(",
"!",
"StrUtils",
".",
"isEmpty",
"(",
"funPrefix",
")",
"&&",
"StrUtils",
".",
"startsWithIgnoreCase",
"(",
"valueUpcase",
",",
"funPrefix",
")",
"&&",
"functionMap",
".",
"containsKey",
"(",
"valueUpcase",
".",
"substring",
"(",
"funPrefix",
".",
"length",
"(",
")",
")",
")",
")",
"{",
"item",
".",
"type",
"=",
"'",
"'",
";",
"item",
".",
"value",
"=",
"valueStr",
".",
"substring",
"(",
"funPrefix",
".",
"length",
"(",
")",
")",
";",
"}",
"if",
"(",
"(",
"StrUtils",
".",
"isEmpty",
"(",
"funPrefix",
")",
"&&",
"functionMap",
".",
"containsKey",
"(",
"valueUpcase",
")",
")",
")",
"{",
"item",
".",
"type",
"=",
"'",
"'",
";",
"item",
".",
"value",
"=",
"valueStr",
";",
"}",
"}",
"if",
"(",
"item",
".",
"type",
"==",
"'",
"'",
")",
"// still not found",
"if",
"(",
"\",\"",
".",
"equals",
"(",
"valueStr",
")",
")",
"// is Long able?",
"item",
".",
"setTypeAndValue",
"(",
"'",
"'",
",",
"valueStr",
")",
";",
"else",
"item",
".",
"setTypeAndValue",
"(",
"'",
"'",
",",
"valueStr",
")",
";",
"}",
"if",
"(",
"item",
".",
"subItems",
"!=",
"null",
")",
"for",
"(",
"DialectSqlItem",
"t",
":",
"item",
".",
"subItems",
")",
"correctType",
"(",
"t",
")",
";",
"}"
] | if is U type, use this method to correct type | [
"if",
"is",
"U",
"type",
"use",
"this",
"method",
"to",
"correct",
"type"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/DialectFunctionTranslator.java#L314-L342 |
2,481 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/DialectFunctionTranslator.java | DialectFunctionTranslator.join | String join(Dialect d, boolean isTopLevel, DialectSqlItem function, DialectSqlItem[] items) {//NOSONAR
int pos = 0;
for (DialectSqlItem item : items) {
if (item.subItems != null) {
String value;
if (pos > 0 && items[pos - 1] != null && items[pos - 1].type == 'F')
// join as parameters
value = join(d, false, items[pos - 1], item.subItems);
else
value = join(d, false, null, item.subItems); // join as
// string
item.type = 'S';
item.value = value;
item.subItems = null;
}
pos++;
} // now there is no subItems
if (function != null) {
List<String> l = new ArrayList<String>();
for (DialectSqlItem item : items) {
if (item.type != '0')
l.add((String) item.value);
}
return renderFunction(d, function, l.toArray(new String[l.size()]));
}
StringBuilder sb = new StringBuilder();
if (!isTopLevel)
sb.append("(");
for (DialectSqlItem item : items)
if (item.type != '0') {
sb.append(item.value);
}
if (!isTopLevel)
sb.append(")");
return sb.toString();
} | java | String join(Dialect d, boolean isTopLevel, DialectSqlItem function, DialectSqlItem[] items) {//NOSONAR
int pos = 0;
for (DialectSqlItem item : items) {
if (item.subItems != null) {
String value;
if (pos > 0 && items[pos - 1] != null && items[pos - 1].type == 'F')
// join as parameters
value = join(d, false, items[pos - 1], item.subItems);
else
value = join(d, false, null, item.subItems); // join as
// string
item.type = 'S';
item.value = value;
item.subItems = null;
}
pos++;
} // now there is no subItems
if (function != null) {
List<String> l = new ArrayList<String>();
for (DialectSqlItem item : items) {
if (item.type != '0')
l.add((String) item.value);
}
return renderFunction(d, function, l.toArray(new String[l.size()]));
}
StringBuilder sb = new StringBuilder();
if (!isTopLevel)
sb.append("(");
for (DialectSqlItem item : items)
if (item.type != '0') {
sb.append(item.value);
}
if (!isTopLevel)
sb.append(")");
return sb.toString();
} | [
"String",
"join",
"(",
"Dialect",
"d",
",",
"boolean",
"isTopLevel",
",",
"DialectSqlItem",
"function",
",",
"DialectSqlItem",
"[",
"]",
"items",
")",
"{",
"//NOSONAR",
"int",
"pos",
"=",
"0",
";",
"for",
"(",
"DialectSqlItem",
"item",
":",
"items",
")",
"{",
"if",
"(",
"item",
".",
"subItems",
"!=",
"null",
")",
"{",
"String",
"value",
";",
"if",
"(",
"pos",
">",
"0",
"&&",
"items",
"[",
"pos",
"-",
"1",
"]",
"!=",
"null",
"&&",
"items",
"[",
"pos",
"-",
"1",
"]",
".",
"type",
"==",
"'",
"'",
")",
"// join as parameters",
"value",
"=",
"join",
"(",
"d",
",",
"false",
",",
"items",
"[",
"pos",
"-",
"1",
"]",
",",
"item",
".",
"subItems",
")",
";",
"else",
"value",
"=",
"join",
"(",
"d",
",",
"false",
",",
"null",
",",
"item",
".",
"subItems",
")",
";",
"// join as",
"// string",
"item",
".",
"type",
"=",
"'",
"'",
";",
"item",
".",
"value",
"=",
"value",
";",
"item",
".",
"subItems",
"=",
"null",
";",
"}",
"pos",
"++",
";",
"}",
"// now there is no subItems",
"if",
"(",
"function",
"!=",
"null",
")",
"{",
"List",
"<",
"String",
">",
"l",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"DialectSqlItem",
"item",
":",
"items",
")",
"{",
"if",
"(",
"item",
".",
"type",
"!=",
"'",
"'",
")",
"l",
".",
"add",
"(",
"(",
"String",
")",
"item",
".",
"value",
")",
";",
"}",
"return",
"renderFunction",
"(",
"d",
",",
"function",
",",
"l",
".",
"toArray",
"(",
"new",
"String",
"[",
"l",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"!",
"isTopLevel",
")",
"sb",
".",
"append",
"(",
"\"(\"",
")",
";",
"for",
"(",
"DialectSqlItem",
"item",
":",
"items",
")",
"if",
"(",
"item",
".",
"type",
"!=",
"'",
"'",
")",
"{",
"sb",
".",
"append",
"(",
"item",
".",
"value",
")",
";",
"}",
"if",
"(",
"!",
"isTopLevel",
")",
"sb",
".",
"append",
"(",
"\")\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Join items list into one String, if function is null, join as String,
otherwise treat as function parameters | [
"Join",
"items",
"list",
"into",
"one",
"String",
"if",
"function",
"is",
"null",
"join",
"as",
"String",
"otherwise",
"treat",
"as",
"function",
"parameters"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/DialectFunctionTranslator.java#L435-L472 |
2,482 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/id/SnowflakeCreator.java | SnowflakeCreator.nextId | public synchronized long nextId() {
long currTimestamp = timestampGen();
if (currTimestamp < lastTimestamp) {
throw new IllegalStateException(
String.format("Clock moved backwards. Refusing to generate id for %d milliseconds",
lastTimestamp - currTimestamp));
}
if (currTimestamp == lastTimestamp) {
sequence = (sequence + 1) & maxSequence;
if (sequence == 0) { // overflow: greater than max sequence
currTimestamp = waitNextMillis(currTimestamp);
}
} else { // reset to 0 for next period/millisecond
sequence = 0L;
}
// track and memo the time stamp last snowflake ID generated
lastTimestamp = currTimestamp;
return ((currTimestamp - epoch) << timestampShift) | //
(datacenterId << datacenterIdShift) | //
(workerId << workerIdShift) | // new line for nice looking
sequence;
} | java | public synchronized long nextId() {
long currTimestamp = timestampGen();
if (currTimestamp < lastTimestamp) {
throw new IllegalStateException(
String.format("Clock moved backwards. Refusing to generate id for %d milliseconds",
lastTimestamp - currTimestamp));
}
if (currTimestamp == lastTimestamp) {
sequence = (sequence + 1) & maxSequence;
if (sequence == 0) { // overflow: greater than max sequence
currTimestamp = waitNextMillis(currTimestamp);
}
} else { // reset to 0 for next period/millisecond
sequence = 0L;
}
// track and memo the time stamp last snowflake ID generated
lastTimestamp = currTimestamp;
return ((currTimestamp - epoch) << timestampShift) | //
(datacenterId << datacenterIdShift) | //
(workerId << workerIdShift) | // new line for nice looking
sequence;
} | [
"public",
"synchronized",
"long",
"nextId",
"(",
")",
"{",
"long",
"currTimestamp",
"=",
"timestampGen",
"(",
")",
";",
"if",
"(",
"currTimestamp",
"<",
"lastTimestamp",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"Clock moved backwards. Refusing to generate id for %d milliseconds\"",
",",
"lastTimestamp",
"-",
"currTimestamp",
")",
")",
";",
"}",
"if",
"(",
"currTimestamp",
"==",
"lastTimestamp",
")",
"{",
"sequence",
"=",
"(",
"sequence",
"+",
"1",
")",
"&",
"maxSequence",
";",
"if",
"(",
"sequence",
"==",
"0",
")",
"{",
"// overflow: greater than max sequence",
"currTimestamp",
"=",
"waitNextMillis",
"(",
"currTimestamp",
")",
";",
"}",
"}",
"else",
"{",
"// reset to 0 for next period/millisecond",
"sequence",
"=",
"0L",
";",
"}",
"// track and memo the time stamp last snowflake ID generated",
"lastTimestamp",
"=",
"currTimestamp",
";",
"return",
"(",
"(",
"currTimestamp",
"-",
"epoch",
")",
"<<",
"timestampShift",
")",
"|",
"//",
"(",
"datacenterId",
"<<",
"datacenterIdShift",
")",
"|",
"//",
"(",
"workerId",
"<<",
"workerIdShift",
")",
"|",
"// new line for nice looking",
"sequence",
";",
"}"
] | generate an unique and incrementing id
@return id | [
"generate",
"an",
"unique",
"and",
"incrementing",
"id"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/id/SnowflakeCreator.java#L106-L132 |
2,483 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/id/SnowflakeCreator.java | SnowflakeCreator.parseId | public long[] parseId(long id) {
long[] arr = new long[5];
arr[4] = ((id & diode(unusedBits, timestampBits)) >> timestampShift);
arr[0] = arr[4] + epoch;
arr[1] = (id & diode(unusedBits + timestampBits, datacenterIdBits)) >> datacenterIdShift;
arr[2] = (id & diode(unusedBits + timestampBits + datacenterIdBits, workerIdBits)) >> workerIdShift;
arr[3] = (id & diode(unusedBits + timestampBits + datacenterIdBits + workerIdBits, sequenceBits));
return arr;
} | java | public long[] parseId(long id) {
long[] arr = new long[5];
arr[4] = ((id & diode(unusedBits, timestampBits)) >> timestampShift);
arr[0] = arr[4] + epoch;
arr[1] = (id & diode(unusedBits + timestampBits, datacenterIdBits)) >> datacenterIdShift;
arr[2] = (id & diode(unusedBits + timestampBits + datacenterIdBits, workerIdBits)) >> workerIdShift;
arr[3] = (id & diode(unusedBits + timestampBits + datacenterIdBits + workerIdBits, sequenceBits));
return arr;
} | [
"public",
"long",
"[",
"]",
"parseId",
"(",
"long",
"id",
")",
"{",
"long",
"[",
"]",
"arr",
"=",
"new",
"long",
"[",
"5",
"]",
";",
"arr",
"[",
"4",
"]",
"=",
"(",
"(",
"id",
"&",
"diode",
"(",
"unusedBits",
",",
"timestampBits",
")",
")",
">>",
"timestampShift",
")",
";",
"arr",
"[",
"0",
"]",
"=",
"arr",
"[",
"4",
"]",
"+",
"epoch",
";",
"arr",
"[",
"1",
"]",
"=",
"(",
"id",
"&",
"diode",
"(",
"unusedBits",
"+",
"timestampBits",
",",
"datacenterIdBits",
")",
")",
">>",
"datacenterIdShift",
";",
"arr",
"[",
"2",
"]",
"=",
"(",
"id",
"&",
"diode",
"(",
"unusedBits",
"+",
"timestampBits",
"+",
"datacenterIdBits",
",",
"workerIdBits",
")",
")",
">>",
"workerIdShift",
";",
"arr",
"[",
"3",
"]",
"=",
"(",
"id",
"&",
"diode",
"(",
"unusedBits",
"+",
"timestampBits",
"+",
"datacenterIdBits",
"+",
"workerIdBits",
",",
"sequenceBits",
")",
")",
";",
"return",
"arr",
";",
"}"
] | extract time stamp, datacenterId, workerId and sequence number information
from the given id
@param id
a snowflake id generated by this object
@return an array containing time stamp, datacenterId, workerId and sequence
number | [
"extract",
"time",
"stamp",
"datacenterId",
"workerId",
"and",
"sequence",
"number",
"information",
"from",
"the",
"given",
"id"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/id/SnowflakeCreator.java#L219-L227 |
2,484 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/id/SnowflakeCreator.java | SnowflakeCreator.formatId | public String formatId(long id) {
long[] arr = parseId(id);
String tmf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date(arr[0]));
return String.format("%s, #%d, @(%d,%d)", tmf, arr[3], arr[1], arr[2]);
} | java | public String formatId(long id) {
long[] arr = parseId(id);
String tmf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date(arr[0]));
return String.format("%s, #%d, @(%d,%d)", tmf, arr[3], arr[1], arr[2]);
} | [
"public",
"String",
"formatId",
"(",
"long",
"id",
")",
"{",
"long",
"[",
"]",
"arr",
"=",
"parseId",
"(",
"id",
")",
";",
"String",
"tmf",
"=",
"new",
"SimpleDateFormat",
"(",
"\"yyyy-MM-dd HH:mm:ss.SSS\"",
")",
".",
"format",
"(",
"new",
"Date",
"(",
"arr",
"[",
"0",
"]",
")",
")",
";",
"return",
"String",
".",
"format",
"(",
"\"%s, #%d, @(%d,%d)\"",
",",
"tmf",
",",
"arr",
"[",
"3",
"]",
",",
"arr",
"[",
"1",
"]",
",",
"arr",
"[",
"2",
"]",
")",
";",
"}"
] | extract and display time stamp, datacenterId, workerId and sequence number
information from the given id in humanization format
@param id
snowflake id in Long format
@return snowflake id in String format | [
"extract",
"and",
"display",
"time",
"stamp",
"datacenterId",
"workerId",
"and",
"sequence",
"number",
"information",
"from",
"the",
"given",
"id",
"in",
"humanization",
"format"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/id/SnowflakeCreator.java#L237-L241 |
2,485 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/id/SnowflakeCreator.java | SnowflakeCreator.diode | private long diode(long offset, long length) {
int lb = (int) (64 - offset);
int rb = (int) (64 - (offset + length));
return (-1L << lb) ^ (-1L << rb);
} | java | private long diode(long offset, long length) {
int lb = (int) (64 - offset);
int rb = (int) (64 - (offset + length));
return (-1L << lb) ^ (-1L << rb);
} | [
"private",
"long",
"diode",
"(",
"long",
"offset",
",",
"long",
"length",
")",
"{",
"int",
"lb",
"=",
"(",
"int",
")",
"(",
"64",
"-",
"offset",
")",
";",
"int",
"rb",
"=",
"(",
"int",
")",
"(",
"64",
"-",
"(",
"offset",
"+",
"length",
")",
")",
";",
"return",
"(",
"-",
"1L",
"<<",
"lb",
")",
"^",
"(",
"-",
"1L",
"<<",
"rb",
")",
";",
"}"
] | a diode is a long value whose left and right margin are ZERO, while middle
bits are ONE in binary string layout. it looks like a diode in shape.
@param offset
left margin position
@param length
offset+length is right margin position
@return a long value | [
"a",
"diode",
"is",
"a",
"long",
"value",
"whose",
"left",
"and",
"right",
"margin",
"are",
"ZERO",
"while",
"middle",
"bits",
"are",
"ONE",
"in",
"binary",
"string",
"layout",
".",
"it",
"looks",
"like",
"a",
"diode",
"in",
"shape",
"."
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/id/SnowflakeCreator.java#L253-L257 |
2,486 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/TypeUtils.java | TypeUtils.toType | public static Type toType(Class<?> clazz) {
Type t = SQL_MAP_ABLE_TYPES.get(clazz);
if (t == null)
return Type.OTHER;
else
return t;
} | java | public static Type toType(Class<?> clazz) {
Type t = SQL_MAP_ABLE_TYPES.get(clazz);
if (t == null)
return Type.OTHER;
else
return t;
} | [
"public",
"static",
"Type",
"toType",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"Type",
"t",
"=",
"SQL_MAP_ABLE_TYPES",
".",
"get",
"(",
"clazz",
")",
";",
"if",
"(",
"t",
"==",
"null",
")",
"return",
"Type",
".",
"OTHER",
";",
"else",
"return",
"t",
";",
"}"
] | Convert a Class type to Dialect's Type | [
"Convert",
"a",
"Class",
"type",
"to",
"Dialect",
"s",
"Type"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/TypeUtils.java#L93-L99 |
2,487 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/TypeUtils.java | TypeUtils.toType | public static Type toType(String columnDef) {
if ("BIGINT".equalsIgnoreCase(columnDef))
return Type.BIGINT;
if ("BINARY".equalsIgnoreCase(columnDef))
return Type.BINARY;
if ("BIT".equalsIgnoreCase(columnDef))
return Type.BIT;
if ("BLOB".equalsIgnoreCase(columnDef))
return Type.BLOB;
if ("BOOLEAN".equalsIgnoreCase(columnDef))
return Type.BOOLEAN;
if ("CHAR".equalsIgnoreCase(columnDef))
return Type.CHAR;
if ("CLOB".equalsIgnoreCase(columnDef))
return Type.CLOB;
if ("DATE".equalsIgnoreCase(columnDef))
return Type.DATE;
if ("DECIMAL".equalsIgnoreCase(columnDef))
return Type.DECIMAL;
if ("DOUBLE".equalsIgnoreCase(columnDef))
return Type.DOUBLE;
if ("FLOAT".equalsIgnoreCase(columnDef))
return Type.FLOAT;
if ("INTEGER".equalsIgnoreCase(columnDef))
return Type.INTEGER;
if ("JAVA_OBJECT".equalsIgnoreCase(columnDef))
return Type.JAVA_OBJECT;
if ("LONGNVARCHAR".equalsIgnoreCase(columnDef))
return Type.LONGNVARCHAR;
if ("LONGVARBINARY".equalsIgnoreCase(columnDef))
return Type.LONGVARBINARY;
if ("LONGVARCHAR".equalsIgnoreCase(columnDef))
return Type.LONGVARCHAR;
if ("NCHAR".equalsIgnoreCase(columnDef))
return Type.NCHAR;
if ("NCLOB".equalsIgnoreCase(columnDef))
return Type.NCLOB;
if ("NUMERIC".equalsIgnoreCase(columnDef))
return Type.NUMERIC;
if ("NVARCHAR".equalsIgnoreCase(columnDef))
return Type.NVARCHAR;
if ("OTHER".equalsIgnoreCase(columnDef))
return Type.OTHER;
if ("REAL".equalsIgnoreCase(columnDef))
return Type.REAL;
if ("SMALLINT".equalsIgnoreCase(columnDef))
return Type.SMALLINT;
if ("TIME".equalsIgnoreCase(columnDef))
return Type.TIME;
if ("TIMESTAMP".equalsIgnoreCase(columnDef))
return Type.TIMESTAMP;
if ("TINYINT".equalsIgnoreCase(columnDef))
return Type.TINYINT;
if ("VARBINARY".equalsIgnoreCase(columnDef))
return Type.VARBINARY;
if ("VARCHAR".equalsIgnoreCase(columnDef))
return Type.VARCHAR;
// @formatter:on
throw new DialectException("'" + columnDef + "' is not a legal SQL column definition name");
} | java | public static Type toType(String columnDef) {
if ("BIGINT".equalsIgnoreCase(columnDef))
return Type.BIGINT;
if ("BINARY".equalsIgnoreCase(columnDef))
return Type.BINARY;
if ("BIT".equalsIgnoreCase(columnDef))
return Type.BIT;
if ("BLOB".equalsIgnoreCase(columnDef))
return Type.BLOB;
if ("BOOLEAN".equalsIgnoreCase(columnDef))
return Type.BOOLEAN;
if ("CHAR".equalsIgnoreCase(columnDef))
return Type.CHAR;
if ("CLOB".equalsIgnoreCase(columnDef))
return Type.CLOB;
if ("DATE".equalsIgnoreCase(columnDef))
return Type.DATE;
if ("DECIMAL".equalsIgnoreCase(columnDef))
return Type.DECIMAL;
if ("DOUBLE".equalsIgnoreCase(columnDef))
return Type.DOUBLE;
if ("FLOAT".equalsIgnoreCase(columnDef))
return Type.FLOAT;
if ("INTEGER".equalsIgnoreCase(columnDef))
return Type.INTEGER;
if ("JAVA_OBJECT".equalsIgnoreCase(columnDef))
return Type.JAVA_OBJECT;
if ("LONGNVARCHAR".equalsIgnoreCase(columnDef))
return Type.LONGNVARCHAR;
if ("LONGVARBINARY".equalsIgnoreCase(columnDef))
return Type.LONGVARBINARY;
if ("LONGVARCHAR".equalsIgnoreCase(columnDef))
return Type.LONGVARCHAR;
if ("NCHAR".equalsIgnoreCase(columnDef))
return Type.NCHAR;
if ("NCLOB".equalsIgnoreCase(columnDef))
return Type.NCLOB;
if ("NUMERIC".equalsIgnoreCase(columnDef))
return Type.NUMERIC;
if ("NVARCHAR".equalsIgnoreCase(columnDef))
return Type.NVARCHAR;
if ("OTHER".equalsIgnoreCase(columnDef))
return Type.OTHER;
if ("REAL".equalsIgnoreCase(columnDef))
return Type.REAL;
if ("SMALLINT".equalsIgnoreCase(columnDef))
return Type.SMALLINT;
if ("TIME".equalsIgnoreCase(columnDef))
return Type.TIME;
if ("TIMESTAMP".equalsIgnoreCase(columnDef))
return Type.TIMESTAMP;
if ("TINYINT".equalsIgnoreCase(columnDef))
return Type.TINYINT;
if ("VARBINARY".equalsIgnoreCase(columnDef))
return Type.VARBINARY;
if ("VARCHAR".equalsIgnoreCase(columnDef))
return Type.VARCHAR;
// @formatter:on
throw new DialectException("'" + columnDef + "' is not a legal SQL column definition name");
} | [
"public",
"static",
"Type",
"toType",
"(",
"String",
"columnDef",
")",
"{",
"if",
"(",
"\"BIGINT\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"BIGINT",
";",
"if",
"(",
"\"BINARY\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"BINARY",
";",
"if",
"(",
"\"BIT\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"BIT",
";",
"if",
"(",
"\"BLOB\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"BLOB",
";",
"if",
"(",
"\"BOOLEAN\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"BOOLEAN",
";",
"if",
"(",
"\"CHAR\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"CHAR",
";",
"if",
"(",
"\"CLOB\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"CLOB",
";",
"if",
"(",
"\"DATE\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"DATE",
";",
"if",
"(",
"\"DECIMAL\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"DECIMAL",
";",
"if",
"(",
"\"DOUBLE\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"DOUBLE",
";",
"if",
"(",
"\"FLOAT\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"FLOAT",
";",
"if",
"(",
"\"INTEGER\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"INTEGER",
";",
"if",
"(",
"\"JAVA_OBJECT\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"JAVA_OBJECT",
";",
"if",
"(",
"\"LONGNVARCHAR\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"LONGNVARCHAR",
";",
"if",
"(",
"\"LONGVARBINARY\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"LONGVARBINARY",
";",
"if",
"(",
"\"LONGVARCHAR\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"LONGVARCHAR",
";",
"if",
"(",
"\"NCHAR\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"NCHAR",
";",
"if",
"(",
"\"NCLOB\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"NCLOB",
";",
"if",
"(",
"\"NUMERIC\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"NUMERIC",
";",
"if",
"(",
"\"NVARCHAR\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"NVARCHAR",
";",
"if",
"(",
"\"OTHER\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"OTHER",
";",
"if",
"(",
"\"REAL\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"REAL",
";",
"if",
"(",
"\"SMALLINT\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"SMALLINT",
";",
"if",
"(",
"\"TIME\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"TIME",
";",
"if",
"(",
"\"TIMESTAMP\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"TIMESTAMP",
";",
"if",
"(",
"\"TINYINT\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"TINYINT",
";",
"if",
"(",
"\"VARBINARY\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"VARBINARY",
";",
"if",
"(",
"\"VARCHAR\"",
".",
"equalsIgnoreCase",
"(",
"columnDef",
")",
")",
"return",
"Type",
".",
"VARCHAR",
";",
"// @formatter:on",
"throw",
"new",
"DialectException",
"(",
"\"'\"",
"+",
"columnDef",
"+",
"\"' is not a legal SQL column definition name\"",
")",
";",
"}"
] | Convert column definition String to Dialect's Type | [
"Convert",
"column",
"definition",
"String",
"to",
"Dialect",
"s",
"Type"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/TypeUtils.java#L105-L164 |
2,488 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/TypeUtils.java | TypeUtils.javaSqlTypeToDialectType | public static Type javaSqlTypeToDialectType(int javaSqlType) {
switch (javaSqlType) {
case java.sql.Types.BIT:
return Type.BIT;
case java.sql.Types.TINYINT:
return Type.TINYINT;
case java.sql.Types.SMALLINT:
return Type.SMALLINT;
case java.sql.Types.INTEGER:
return Type.INTEGER;
case java.sql.Types.BIGINT:
return Type.BIGINT;
case java.sql.Types.FLOAT:
return Type.FLOAT;
case java.sql.Types.REAL:
return Type.REAL;
case java.sql.Types.DOUBLE:
return Type.DOUBLE;
case java.sql.Types.NUMERIC:
return Type.NUMERIC;
case java.sql.Types.DECIMAL:
return Type.DECIMAL;
case java.sql.Types.CHAR:
return Type.CHAR;
case java.sql.Types.VARCHAR:
return Type.VARCHAR;
case java.sql.Types.LONGVARCHAR:
return Type.LONGVARCHAR;
case java.sql.Types.DATE:
return Type.DATE;
case java.sql.Types.TIME:
return Type.TIME;
case java.sql.Types.TIMESTAMP:
return Type.TIMESTAMP;
case java.sql.Types.BINARY:
return Type.BINARY;
case java.sql.Types.VARBINARY:
return Type.VARBINARY;
case java.sql.Types.LONGVARBINARY:
return Type.LONGVARBINARY;
case java.sql.Types.OTHER:
return Type.OTHER;
case java.sql.Types.JAVA_OBJECT:
return Type.JAVA_OBJECT;
case java.sql.Types.BLOB:
return Type.BLOB;
case java.sql.Types.CLOB:
return Type.CLOB;
case java.sql.Types.BOOLEAN:
return Type.BOOLEAN;
case java.sql.Types.NCHAR:
return Type.NCHAR;
case java.sql.Types.NVARCHAR:
return Type.NVARCHAR;
case java.sql.Types.LONGNVARCHAR:
return Type.LONGNVARCHAR;
case java.sql.Types.NCLOB:
return Type.NCLOB;
// case java.sql.Types.SQLXML:return Type.UNSUPPORT;
// case java.sql.Types.NULL:return Type.UNSUPPORT;
// case java.sql.Types.ROWID:return Type.UNSUPPORT;
// case java.sql.Types.DISTINCT:return Type.UNSUPPORT;
// case java.sql.Types.STRUCT:return Type.UNSUPPORT;
// case java.sql.Types.ARRAY:return Type.UNSUPPORT;
// case java.sql.Types.REF:return Type.UNSUPPORT;
// case java.sql.Types.DATALINK:return Type.UNSUPPORT;
default:
throw new DialectException("Not supported java.sql.Types value:" + javaSqlType);
}
} | java | public static Type javaSqlTypeToDialectType(int javaSqlType) {
switch (javaSqlType) {
case java.sql.Types.BIT:
return Type.BIT;
case java.sql.Types.TINYINT:
return Type.TINYINT;
case java.sql.Types.SMALLINT:
return Type.SMALLINT;
case java.sql.Types.INTEGER:
return Type.INTEGER;
case java.sql.Types.BIGINT:
return Type.BIGINT;
case java.sql.Types.FLOAT:
return Type.FLOAT;
case java.sql.Types.REAL:
return Type.REAL;
case java.sql.Types.DOUBLE:
return Type.DOUBLE;
case java.sql.Types.NUMERIC:
return Type.NUMERIC;
case java.sql.Types.DECIMAL:
return Type.DECIMAL;
case java.sql.Types.CHAR:
return Type.CHAR;
case java.sql.Types.VARCHAR:
return Type.VARCHAR;
case java.sql.Types.LONGVARCHAR:
return Type.LONGVARCHAR;
case java.sql.Types.DATE:
return Type.DATE;
case java.sql.Types.TIME:
return Type.TIME;
case java.sql.Types.TIMESTAMP:
return Type.TIMESTAMP;
case java.sql.Types.BINARY:
return Type.BINARY;
case java.sql.Types.VARBINARY:
return Type.VARBINARY;
case java.sql.Types.LONGVARBINARY:
return Type.LONGVARBINARY;
case java.sql.Types.OTHER:
return Type.OTHER;
case java.sql.Types.JAVA_OBJECT:
return Type.JAVA_OBJECT;
case java.sql.Types.BLOB:
return Type.BLOB;
case java.sql.Types.CLOB:
return Type.CLOB;
case java.sql.Types.BOOLEAN:
return Type.BOOLEAN;
case java.sql.Types.NCHAR:
return Type.NCHAR;
case java.sql.Types.NVARCHAR:
return Type.NVARCHAR;
case java.sql.Types.LONGNVARCHAR:
return Type.LONGNVARCHAR;
case java.sql.Types.NCLOB:
return Type.NCLOB;
// case java.sql.Types.SQLXML:return Type.UNSUPPORT;
// case java.sql.Types.NULL:return Type.UNSUPPORT;
// case java.sql.Types.ROWID:return Type.UNSUPPORT;
// case java.sql.Types.DISTINCT:return Type.UNSUPPORT;
// case java.sql.Types.STRUCT:return Type.UNSUPPORT;
// case java.sql.Types.ARRAY:return Type.UNSUPPORT;
// case java.sql.Types.REF:return Type.UNSUPPORT;
// case java.sql.Types.DATALINK:return Type.UNSUPPORT;
default:
throw new DialectException("Not supported java.sql.Types value:" + javaSqlType);
}
} | [
"public",
"static",
"Type",
"javaSqlTypeToDialectType",
"(",
"int",
"javaSqlType",
")",
"{",
"switch",
"(",
"javaSqlType",
")",
"{",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"BIT",
":",
"return",
"Type",
".",
"BIT",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"TINYINT",
":",
"return",
"Type",
".",
"TINYINT",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"SMALLINT",
":",
"return",
"Type",
".",
"SMALLINT",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"INTEGER",
":",
"return",
"Type",
".",
"INTEGER",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"BIGINT",
":",
"return",
"Type",
".",
"BIGINT",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"FLOAT",
":",
"return",
"Type",
".",
"FLOAT",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"REAL",
":",
"return",
"Type",
".",
"REAL",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"DOUBLE",
":",
"return",
"Type",
".",
"DOUBLE",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"NUMERIC",
":",
"return",
"Type",
".",
"NUMERIC",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"DECIMAL",
":",
"return",
"Type",
".",
"DECIMAL",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"CHAR",
":",
"return",
"Type",
".",
"CHAR",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"VARCHAR",
":",
"return",
"Type",
".",
"VARCHAR",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"LONGVARCHAR",
":",
"return",
"Type",
".",
"LONGVARCHAR",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"DATE",
":",
"return",
"Type",
".",
"DATE",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"TIME",
":",
"return",
"Type",
".",
"TIME",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"TIMESTAMP",
":",
"return",
"Type",
".",
"TIMESTAMP",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"BINARY",
":",
"return",
"Type",
".",
"BINARY",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"VARBINARY",
":",
"return",
"Type",
".",
"VARBINARY",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"LONGVARBINARY",
":",
"return",
"Type",
".",
"LONGVARBINARY",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"OTHER",
":",
"return",
"Type",
".",
"OTHER",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"JAVA_OBJECT",
":",
"return",
"Type",
".",
"JAVA_OBJECT",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"BLOB",
":",
"return",
"Type",
".",
"BLOB",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"CLOB",
":",
"return",
"Type",
".",
"CLOB",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"BOOLEAN",
":",
"return",
"Type",
".",
"BOOLEAN",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"NCHAR",
":",
"return",
"Type",
".",
"NCHAR",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"NVARCHAR",
":",
"return",
"Type",
".",
"NVARCHAR",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"LONGNVARCHAR",
":",
"return",
"Type",
".",
"LONGNVARCHAR",
";",
"case",
"java",
".",
"sql",
".",
"Types",
".",
"NCLOB",
":",
"return",
"Type",
".",
"NCLOB",
";",
"// case java.sql.Types.SQLXML:return Type.UNSUPPORT;",
"// case java.sql.Types.NULL:return Type.UNSUPPORT;",
"// case java.sql.Types.ROWID:return Type.UNSUPPORT;",
"// case java.sql.Types.DISTINCT:return Type.UNSUPPORT;",
"// case java.sql.Types.STRUCT:return Type.UNSUPPORT;",
"// case java.sql.Types.ARRAY:return Type.UNSUPPORT;",
"// case java.sql.Types.REF:return Type.UNSUPPORT;",
"// case java.sql.Types.DATALINK:return Type.UNSUPPORT;",
"default",
":",
"throw",
"new",
"DialectException",
"(",
"\"Not supported java.sql.Types value:\"",
"+",
"javaSqlType",
")",
";",
"}",
"}"
] | Convert java.sql.Types.xxx type to Dialect's Type | [
"Convert",
"java",
".",
"sql",
".",
"Types",
".",
"xxx",
"type",
"to",
"Dialect",
"s",
"Type"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/TypeUtils.java#L170-L243 |
2,489 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/model/ColumnModel.java | ColumnModel.sequenceGenerator | public ColumnModel sequenceGenerator(String name, String sequenceName, Integer initialValue,
Integer allocationSize) {
makeSureTableModelExist();
this.tableModel.sequenceGenerator(name, sequenceName, initialValue, allocationSize);
this.idGenerationType = GenerationType.SEQUENCE;
this.idGeneratorName = name;
return this;
} | java | public ColumnModel sequenceGenerator(String name, String sequenceName, Integer initialValue,
Integer allocationSize) {
makeSureTableModelExist();
this.tableModel.sequenceGenerator(name, sequenceName, initialValue, allocationSize);
this.idGenerationType = GenerationType.SEQUENCE;
this.idGeneratorName = name;
return this;
} | [
"public",
"ColumnModel",
"sequenceGenerator",
"(",
"String",
"name",
",",
"String",
"sequenceName",
",",
"Integer",
"initialValue",
",",
"Integer",
"allocationSize",
")",
"{",
"makeSureTableModelExist",
"(",
")",
";",
"this",
".",
"tableModel",
".",
"sequenceGenerator",
"(",
"name",
",",
"sequenceName",
",",
"initialValue",
",",
"allocationSize",
")",
";",
"this",
".",
"idGenerationType",
"=",
"GenerationType",
".",
"SEQUENCE",
";",
"this",
".",
"idGeneratorName",
"=",
"name",
";",
"return",
"this",
";",
"}"
] | The value of this column will be generated by a sequence | [
"The",
"value",
"of",
"this",
"column",
"will",
"be",
"generated",
"by",
"a",
"sequence"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/ColumnModel.java#L311-L318 |
2,490 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/model/ColumnModel.java | ColumnModel.entityField | public ColumnModel entityField(String entityFieldName) {
DialectException.assureNotEmpty(entityFieldName, "entityFieldName can not be empty");
this.entityField = entityFieldName;
if (this.tableModel != null) {
List<ColumnModel> oldColumns = this.tableModel.getColumns();
Iterator<ColumnModel> columnIter = oldColumns.iterator();
while (columnIter.hasNext()) {
ColumnModel column = columnIter.next();
if (entityFieldName.equals(column.getEntityField())
&& !this.getColumnName().equals(column.getColumnName()))
columnIter.remove();
}
}
return this;
} | java | public ColumnModel entityField(String entityFieldName) {
DialectException.assureNotEmpty(entityFieldName, "entityFieldName can not be empty");
this.entityField = entityFieldName;
if (this.tableModel != null) {
List<ColumnModel> oldColumns = this.tableModel.getColumns();
Iterator<ColumnModel> columnIter = oldColumns.iterator();
while (columnIter.hasNext()) {
ColumnModel column = columnIter.next();
if (entityFieldName.equals(column.getEntityField())
&& !this.getColumnName().equals(column.getColumnName()))
columnIter.remove();
}
}
return this;
} | [
"public",
"ColumnModel",
"entityField",
"(",
"String",
"entityFieldName",
")",
"{",
"DialectException",
".",
"assureNotEmpty",
"(",
"entityFieldName",
",",
"\"entityFieldName can not be empty\"",
")",
";",
"this",
".",
"entityField",
"=",
"entityFieldName",
";",
"if",
"(",
"this",
".",
"tableModel",
"!=",
"null",
")",
"{",
"List",
"<",
"ColumnModel",
">",
"oldColumns",
"=",
"this",
".",
"tableModel",
".",
"getColumns",
"(",
")",
";",
"Iterator",
"<",
"ColumnModel",
">",
"columnIter",
"=",
"oldColumns",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"columnIter",
".",
"hasNext",
"(",
")",
")",
"{",
"ColumnModel",
"column",
"=",
"columnIter",
".",
"next",
"(",
")",
";",
"if",
"(",
"entityFieldName",
".",
"equals",
"(",
"column",
".",
"getEntityField",
"(",
")",
")",
"&&",
"!",
"this",
".",
"getColumnName",
"(",
")",
".",
"equals",
"(",
"column",
".",
"getColumnName",
"(",
")",
")",
")",
"columnIter",
".",
"remove",
"(",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Mark this column map to a Java entity field, if exist other columns map to
this field, delete other columns. This method only designed for ORM tool | [
"Mark",
"this",
"column",
"map",
"to",
"a",
"Java",
"entity",
"field",
"if",
"exist",
"other",
"columns",
"map",
"to",
"this",
"field",
"delete",
"other",
"columns",
".",
"This",
"method",
"only",
"designed",
"for",
"ORM",
"tool"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/ColumnModel.java#L354-L368 |
2,491 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/DialectPaginationTemplate.java | DialectPaginationTemplate.initializePaginSQLTemplate | protected static String initializePaginSQLTemplate(Dialect d) {
switch (d) {
case Cache71Dialect:
case DB2390Dialect:
case DB2390V8Dialect:
case FrontBaseDialect:
case InformixDialect:
case IngresDialect:
case JDataStoreDialect:
case MckoiDialect:
case MimerSQLDialect:
case PointbaseDialect:
case ProgressDialect:
case RDMSOS2200Dialect:
case SAPDBDialect:
case SQLServerDialect:
case Sybase11Dialect:
case SybaseASE15Dialect:
case SybaseAnywhereDialect:
case SybaseDialect:
case Teradata14Dialect:
case TeradataDialect:
case TimesTenDialect:
return Dialect.NOT_SUPPORT;
case SQLServer2005Dialect:
case SQLServer2008Dialect:
return "WITH query AS (SELECT TMP_.*, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as ROW_NUM_ FROM ( select ($DISTINCT) TOP($TOTAL_ROWS) $BODY ) TMP_ ) SELECT * FROM query WHERE ROW_NUM_ >$SKIP_ROWS AND ROW_NUM_ <= $TOTAL_ROWS";
case H2Dialect:
case HANAColumnStoreDialect:
case HANARowStoreDialect:
case PostgreSQL81Dialect:
case PostgreSQL82Dialect:
case PostgreSQL91Dialect:
case PostgreSQL92Dialect:
case PostgreSQL93Dialect:
case PostgreSQL94Dialect:
case PostgreSQL95Dialect:
case PostgreSQL9Dialect:
case PostgreSQLDialect:
case PostgresPlusDialect:
case SQLiteDialect:
return "select $BODY limit $PAGESIZE offset $SKIP_ROWS";
case AccessDialect:
case CUBRIDDialect:
case CobolDialect:
case DbfDialect:
case ExcelDialect:
case MariaDB102Dialect:
case MariaDB103Dialect:
case MariaDB10Dialect:
case MariaDB53Dialect:
case MariaDBDialect:
case MySQL55Dialect:
case MySQL57Dialect:
case MySQL57InnoDBDialect:
case MySQL5Dialect:
case MySQL5InnoDBDialect:
case MySQL8Dialect:
case MySQLDialect:
case MySQLInnoDBDialect:
case MySQLMyISAMDialect:
case ParadoxDialect:
case TextDialect:
case XMLDialect:
return "select $BODY limit $SKIP_ROWS, $PAGESIZE";
case SQLServer2012Dialect:
return "select $BODY offset $SKIP_ROWS rows fetch next $PAGESIZE rows only";
case Ingres10Dialect:
case Ingres9Dialect:
return "select $BODY offset $skip_rows fetch first $pagesize rows only";
case DerbyDialect:
case DerbyTenFiveDialect:
case DerbyTenSevenDialect:
case DerbyTenSixDialect:
return "select $BODY offset $skip_rows rows fetch next $pagesize rows only";
case InterbaseDialect:
return "select $BODY rows $SKIP_ROWS to $PAGESIZE";
case SybaseASE157Dialect:
return "select ($DISTINCT) top $total_rows $BODY";
case DB2400Dialect:
case DB297Dialect:
case DB2Dialect:
return "select * from ( select inner2_.*, rownumber() over(order by order of inner2_) as rownumber_ from ( select $BODY fetch first $total_rows rows only ) as inner2_ ) as inner1_ where rownumber_ > $skip_rows order by rownumber_";
case Oracle8iDialect:
case OracleDialect:
return "select * from ( select row_.*, rownum rownum_ from ( select $BODY ) row_ ) where rownum_ <= $TOTAL_ROWS and rownum_ > $SKIP_ROWS";
case DataDirectOracle9Dialect:
case Oracle10gDialect:
case Oracle12cDialect:
case Oracle9Dialect:
case Oracle9iDialect:
return "select * from ( select row_.*, rownum rownum_ from ( select $BODY ) row_ where rownum <= $TOTAL_ROWS) where rownum_ > $SKIP_ROWS";
case Informix10Dialect:
return "select SKIP $skip_rows first $pagesize $BODY";
case FirebirdDialect:
return "select first $PAGESIZE skip $SKIP_ROWS $BODY";
case HSQLDialect:
return "select limit $SKIP_ROWS $PAGESIZE $BODY";
default:
return Dialect.NOT_SUPPORT;
}
} | java | protected static String initializePaginSQLTemplate(Dialect d) {
switch (d) {
case Cache71Dialect:
case DB2390Dialect:
case DB2390V8Dialect:
case FrontBaseDialect:
case InformixDialect:
case IngresDialect:
case JDataStoreDialect:
case MckoiDialect:
case MimerSQLDialect:
case PointbaseDialect:
case ProgressDialect:
case RDMSOS2200Dialect:
case SAPDBDialect:
case SQLServerDialect:
case Sybase11Dialect:
case SybaseASE15Dialect:
case SybaseAnywhereDialect:
case SybaseDialect:
case Teradata14Dialect:
case TeradataDialect:
case TimesTenDialect:
return Dialect.NOT_SUPPORT;
case SQLServer2005Dialect:
case SQLServer2008Dialect:
return "WITH query AS (SELECT TMP_.*, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as ROW_NUM_ FROM ( select ($DISTINCT) TOP($TOTAL_ROWS) $BODY ) TMP_ ) SELECT * FROM query WHERE ROW_NUM_ >$SKIP_ROWS AND ROW_NUM_ <= $TOTAL_ROWS";
case H2Dialect:
case HANAColumnStoreDialect:
case HANARowStoreDialect:
case PostgreSQL81Dialect:
case PostgreSQL82Dialect:
case PostgreSQL91Dialect:
case PostgreSQL92Dialect:
case PostgreSQL93Dialect:
case PostgreSQL94Dialect:
case PostgreSQL95Dialect:
case PostgreSQL9Dialect:
case PostgreSQLDialect:
case PostgresPlusDialect:
case SQLiteDialect:
return "select $BODY limit $PAGESIZE offset $SKIP_ROWS";
case AccessDialect:
case CUBRIDDialect:
case CobolDialect:
case DbfDialect:
case ExcelDialect:
case MariaDB102Dialect:
case MariaDB103Dialect:
case MariaDB10Dialect:
case MariaDB53Dialect:
case MariaDBDialect:
case MySQL55Dialect:
case MySQL57Dialect:
case MySQL57InnoDBDialect:
case MySQL5Dialect:
case MySQL5InnoDBDialect:
case MySQL8Dialect:
case MySQLDialect:
case MySQLInnoDBDialect:
case MySQLMyISAMDialect:
case ParadoxDialect:
case TextDialect:
case XMLDialect:
return "select $BODY limit $SKIP_ROWS, $PAGESIZE";
case SQLServer2012Dialect:
return "select $BODY offset $SKIP_ROWS rows fetch next $PAGESIZE rows only";
case Ingres10Dialect:
case Ingres9Dialect:
return "select $BODY offset $skip_rows fetch first $pagesize rows only";
case DerbyDialect:
case DerbyTenFiveDialect:
case DerbyTenSevenDialect:
case DerbyTenSixDialect:
return "select $BODY offset $skip_rows rows fetch next $pagesize rows only";
case InterbaseDialect:
return "select $BODY rows $SKIP_ROWS to $PAGESIZE";
case SybaseASE157Dialect:
return "select ($DISTINCT) top $total_rows $BODY";
case DB2400Dialect:
case DB297Dialect:
case DB2Dialect:
return "select * from ( select inner2_.*, rownumber() over(order by order of inner2_) as rownumber_ from ( select $BODY fetch first $total_rows rows only ) as inner2_ ) as inner1_ where rownumber_ > $skip_rows order by rownumber_";
case Oracle8iDialect:
case OracleDialect:
return "select * from ( select row_.*, rownum rownum_ from ( select $BODY ) row_ ) where rownum_ <= $TOTAL_ROWS and rownum_ > $SKIP_ROWS";
case DataDirectOracle9Dialect:
case Oracle10gDialect:
case Oracle12cDialect:
case Oracle9Dialect:
case Oracle9iDialect:
return "select * from ( select row_.*, rownum rownum_ from ( select $BODY ) row_ where rownum <= $TOTAL_ROWS) where rownum_ > $SKIP_ROWS";
case Informix10Dialect:
return "select SKIP $skip_rows first $pagesize $BODY";
case FirebirdDialect:
return "select first $PAGESIZE skip $SKIP_ROWS $BODY";
case HSQLDialect:
return "select limit $SKIP_ROWS $PAGESIZE $BODY";
default:
return Dialect.NOT_SUPPORT;
}
} | [
"protected",
"static",
"String",
"initializePaginSQLTemplate",
"(",
"Dialect",
"d",
")",
"{",
"switch",
"(",
"d",
")",
"{",
"case",
"Cache71Dialect",
":",
"case",
"DB2390Dialect",
":",
"case",
"DB2390V8Dialect",
":",
"case",
"FrontBaseDialect",
":",
"case",
"InformixDialect",
":",
"case",
"IngresDialect",
":",
"case",
"JDataStoreDialect",
":",
"case",
"MckoiDialect",
":",
"case",
"MimerSQLDialect",
":",
"case",
"PointbaseDialect",
":",
"case",
"ProgressDialect",
":",
"case",
"RDMSOS2200Dialect",
":",
"case",
"SAPDBDialect",
":",
"case",
"SQLServerDialect",
":",
"case",
"Sybase11Dialect",
":",
"case",
"SybaseASE15Dialect",
":",
"case",
"SybaseAnywhereDialect",
":",
"case",
"SybaseDialect",
":",
"case",
"Teradata14Dialect",
":",
"case",
"TeradataDialect",
":",
"case",
"TimesTenDialect",
":",
"return",
"Dialect",
".",
"NOT_SUPPORT",
";",
"case",
"SQLServer2005Dialect",
":",
"case",
"SQLServer2008Dialect",
":",
"return",
"\"WITH query AS (SELECT TMP_.*, ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as ROW_NUM_ FROM ( select ($DISTINCT) TOP($TOTAL_ROWS) $BODY ) TMP_ ) SELECT * FROM query WHERE ROW_NUM_ >$SKIP_ROWS AND ROW_NUM_ <= $TOTAL_ROWS\"",
";",
"case",
"H2Dialect",
":",
"case",
"HANAColumnStoreDialect",
":",
"case",
"HANARowStoreDialect",
":",
"case",
"PostgreSQL81Dialect",
":",
"case",
"PostgreSQL82Dialect",
":",
"case",
"PostgreSQL91Dialect",
":",
"case",
"PostgreSQL92Dialect",
":",
"case",
"PostgreSQL93Dialect",
":",
"case",
"PostgreSQL94Dialect",
":",
"case",
"PostgreSQL95Dialect",
":",
"case",
"PostgreSQL9Dialect",
":",
"case",
"PostgreSQLDialect",
":",
"case",
"PostgresPlusDialect",
":",
"case",
"SQLiteDialect",
":",
"return",
"\"select $BODY limit $PAGESIZE offset $SKIP_ROWS\"",
";",
"case",
"AccessDialect",
":",
"case",
"CUBRIDDialect",
":",
"case",
"CobolDialect",
":",
"case",
"DbfDialect",
":",
"case",
"ExcelDialect",
":",
"case",
"MariaDB102Dialect",
":",
"case",
"MariaDB103Dialect",
":",
"case",
"MariaDB10Dialect",
":",
"case",
"MariaDB53Dialect",
":",
"case",
"MariaDBDialect",
":",
"case",
"MySQL55Dialect",
":",
"case",
"MySQL57Dialect",
":",
"case",
"MySQL57InnoDBDialect",
":",
"case",
"MySQL5Dialect",
":",
"case",
"MySQL5InnoDBDialect",
":",
"case",
"MySQL8Dialect",
":",
"case",
"MySQLDialect",
":",
"case",
"MySQLInnoDBDialect",
":",
"case",
"MySQLMyISAMDialect",
":",
"case",
"ParadoxDialect",
":",
"case",
"TextDialect",
":",
"case",
"XMLDialect",
":",
"return",
"\"select $BODY limit $SKIP_ROWS, $PAGESIZE\"",
";",
"case",
"SQLServer2012Dialect",
":",
"return",
"\"select $BODY offset $SKIP_ROWS rows fetch next $PAGESIZE rows only\"",
";",
"case",
"Ingres10Dialect",
":",
"case",
"Ingres9Dialect",
":",
"return",
"\"select $BODY offset $skip_rows fetch first $pagesize rows only\"",
";",
"case",
"DerbyDialect",
":",
"case",
"DerbyTenFiveDialect",
":",
"case",
"DerbyTenSevenDialect",
":",
"case",
"DerbyTenSixDialect",
":",
"return",
"\"select $BODY offset $skip_rows rows fetch next $pagesize rows only\"",
";",
"case",
"InterbaseDialect",
":",
"return",
"\"select $BODY rows $SKIP_ROWS to $PAGESIZE\"",
";",
"case",
"SybaseASE157Dialect",
":",
"return",
"\"select ($DISTINCT) top $total_rows $BODY\"",
";",
"case",
"DB2400Dialect",
":",
"case",
"DB297Dialect",
":",
"case",
"DB2Dialect",
":",
"return",
"\"select * from ( select inner2_.*, rownumber() over(order by order of inner2_) as rownumber_ from ( select $BODY fetch first $total_rows rows only ) as inner2_ ) as inner1_ where rownumber_ > $skip_rows order by rownumber_\"",
";",
"case",
"Oracle8iDialect",
":",
"case",
"OracleDialect",
":",
"return",
"\"select * from ( select row_.*, rownum rownum_ from ( select $BODY ) row_ ) where rownum_ <= $TOTAL_ROWS and rownum_ > $SKIP_ROWS\"",
";",
"case",
"DataDirectOracle9Dialect",
":",
"case",
"Oracle10gDialect",
":",
"case",
"Oracle12cDialect",
":",
"case",
"Oracle9Dialect",
":",
"case",
"Oracle9iDialect",
":",
"return",
"\"select * from ( select row_.*, rownum rownum_ from ( select $BODY ) row_ where rownum <= $TOTAL_ROWS) where rownum_ > $SKIP_ROWS\"",
";",
"case",
"Informix10Dialect",
":",
"return",
"\"select SKIP $skip_rows first $pagesize $BODY\"",
";",
"case",
"FirebirdDialect",
":",
"return",
"\"select first $PAGESIZE skip $SKIP_ROWS $BODY\"",
";",
"case",
"HSQLDialect",
":",
"return",
"\"select limit $SKIP_ROWS $PAGESIZE $BODY\"",
";",
"default",
":",
"return",
"Dialect",
".",
"NOT_SUPPORT",
";",
"}",
"}"
] | Return pagination template of this Dialect | [
"Return",
"pagination",
"template",
"of",
"this",
"Dialect"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/DialectPaginationTemplate.java#L27-L128 |
2,492 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtils.java | TableModelUtils.db2JavaSrcFiles | public static void db2JavaSrcFiles(DataSource ds, Dialect dialect, boolean linkStyle, boolean activeRecord,
String packageName, String outputfolder) {
Connection conn = null;
try {
conn = ds.getConnection();
TableModel[] models = db2Models(conn, dialect);
for (TableModel model : models) {
File writename = new File(
outputfolder + "/" + TableModelUtilsOfJavaSrc.getClassNameFromTableModel(model)+".java");
writename.createNewFile();// NOSONAR
BufferedWriter out = new BufferedWriter(new FileWriter(writename));
String javaSrc = model2JavaSrc(model, linkStyle, activeRecord, packageName);
out.write(javaSrc);
out.flush();
out.close();
}
} catch (Exception e) {
if (conn != null)
try {
conn.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
} | java | public static void db2JavaSrcFiles(DataSource ds, Dialect dialect, boolean linkStyle, boolean activeRecord,
String packageName, String outputfolder) {
Connection conn = null;
try {
conn = ds.getConnection();
TableModel[] models = db2Models(conn, dialect);
for (TableModel model : models) {
File writename = new File(
outputfolder + "/" + TableModelUtilsOfJavaSrc.getClassNameFromTableModel(model)+".java");
writename.createNewFile();// NOSONAR
BufferedWriter out = new BufferedWriter(new FileWriter(writename));
String javaSrc = model2JavaSrc(model, linkStyle, activeRecord, packageName);
out.write(javaSrc);
out.flush();
out.close();
}
} catch (Exception e) {
if (conn != null)
try {
conn.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
} | [
"public",
"static",
"void",
"db2JavaSrcFiles",
"(",
"DataSource",
"ds",
",",
"Dialect",
"dialect",
",",
"boolean",
"linkStyle",
",",
"boolean",
"activeRecord",
",",
"String",
"packageName",
",",
"String",
"outputfolder",
")",
"{",
"Connection",
"conn",
"=",
"null",
";",
"try",
"{",
"conn",
"=",
"ds",
".",
"getConnection",
"(",
")",
";",
"TableModel",
"[",
"]",
"models",
"=",
"db2Models",
"(",
"conn",
",",
"dialect",
")",
";",
"for",
"(",
"TableModel",
"model",
":",
"models",
")",
"{",
"File",
"writename",
"=",
"new",
"File",
"(",
"outputfolder",
"+",
"\"/\"",
"+",
"TableModelUtilsOfJavaSrc",
".",
"getClassNameFromTableModel",
"(",
"model",
")",
"+",
"\".java\"",
")",
";",
"writename",
".",
"createNewFile",
"(",
")",
";",
"// NOSONAR",
"BufferedWriter",
"out",
"=",
"new",
"BufferedWriter",
"(",
"new",
"FileWriter",
"(",
"writename",
")",
")",
";",
"String",
"javaSrc",
"=",
"model2JavaSrc",
"(",
"model",
",",
"linkStyle",
",",
"activeRecord",
",",
"packageName",
")",
";",
"out",
".",
"write",
"(",
"javaSrc",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"if",
"(",
"conn",
"!=",
"null",
")",
"try",
"{",
"conn",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"SQLException",
"e1",
")",
"{",
"e1",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}"
] | Read database structure and write them to Java entity class source code
@param ds
The DataSource instance
@param dialect
The dialect of database
@param linkStyle
if true, create linked style setter, otherwise create normal
setter
@param activeRecord
if true, build a jSqlBox ActiveRecord Entity class, otherwise
build a POJO class
@param packageName
Optional, the package name of this entity class
@param outputfolder
the out put folder | [
"Read",
"database",
"structure",
"and",
"write",
"them",
"to",
"Java",
"entity",
"class",
"source",
"code"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtils.java#L79-L103 |
2,493 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtils.java | TableModelUtils.bindGlobalModel | public static void bindGlobalModel(Class<?> entityClass, TableModel tableModel) {
TableModelUtilsOfEntity.globalTableModelCache.put(entityClass, tableModel);
} | java | public static void bindGlobalModel(Class<?> entityClass, TableModel tableModel) {
TableModelUtilsOfEntity.globalTableModelCache.put(entityClass, tableModel);
} | [
"public",
"static",
"void",
"bindGlobalModel",
"(",
"Class",
"<",
"?",
">",
"entityClass",
",",
"TableModel",
"tableModel",
")",
"{",
"TableModelUtilsOfEntity",
".",
"globalTableModelCache",
".",
"put",
"(",
"entityClass",
",",
"tableModel",
")",
";",
"}"
] | This method bind a tableModel to a entity class, this is a global setting | [
"This",
"method",
"bind",
"a",
"tableModel",
"to",
"a",
"entity",
"class",
"this",
"is",
"a",
"global",
"setting"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/TableModelUtils.java#L127-L129 |
2,494 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java | TableModel.tableGenerator | public void tableGenerator(String name, String tableName, String pkColumnName, String valueColumnName,
String pkColumnValue, Integer initialValue, Integer allocationSize) {
checkReadOnly();
addGenerator(new TableIdGenerator(name, tableName, pkColumnName, valueColumnName, pkColumnValue, initialValue,
allocationSize));
} | java | public void tableGenerator(String name, String tableName, String pkColumnName, String valueColumnName,
String pkColumnValue, Integer initialValue, Integer allocationSize) {
checkReadOnly();
addGenerator(new TableIdGenerator(name, tableName, pkColumnName, valueColumnName, pkColumnValue, initialValue,
allocationSize));
} | [
"public",
"void",
"tableGenerator",
"(",
"String",
"name",
",",
"String",
"tableName",
",",
"String",
"pkColumnName",
",",
"String",
"valueColumnName",
",",
"String",
"pkColumnValue",
",",
"Integer",
"initialValue",
",",
"Integer",
"allocationSize",
")",
"{",
"checkReadOnly",
"(",
")",
";",
"addGenerator",
"(",
"new",
"TableIdGenerator",
"(",
"name",
",",
"tableName",
",",
"pkColumnName",
",",
"valueColumnName",
",",
"pkColumnValue",
",",
"initialValue",
",",
"allocationSize",
")",
")",
";",
"}"
] | Add a TableGenerator | [
"Add",
"a",
"TableGenerator"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L128-L133 |
2,495 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java | TableModel.uuidAny | public void uuidAny(String name, Integer length) {
checkReadOnly();
addGenerator(new UUIDAnyGenerator(name, length));
} | java | public void uuidAny(String name, Integer length) {
checkReadOnly();
addGenerator(new UUIDAnyGenerator(name, length));
} | [
"public",
"void",
"uuidAny",
"(",
"String",
"name",
",",
"Integer",
"length",
")",
"{",
"checkReadOnly",
"(",
")",
";",
"addGenerator",
"(",
"new",
"UUIDAnyGenerator",
"(",
"name",
",",
"length",
")",
")",
";",
"}"
] | Add a UUIDAnyGenerator | [
"Add",
"a",
"UUIDAnyGenerator"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L136-L139 |
2,496 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java | TableModel.addGenerator | public void addGenerator(IdGenerator generator) {
checkReadOnly();
DialectException.assureNotNull(generator);
DialectException.assureNotNull(generator.getGenerationType());
DialectException.assureNotEmpty(generator.getIdGenName(), "IdGenerator name can not be empty");
getIdGenerators().add(generator);
} | java | public void addGenerator(IdGenerator generator) {
checkReadOnly();
DialectException.assureNotNull(generator);
DialectException.assureNotNull(generator.getGenerationType());
DialectException.assureNotEmpty(generator.getIdGenName(), "IdGenerator name can not be empty");
getIdGenerators().add(generator);
} | [
"public",
"void",
"addGenerator",
"(",
"IdGenerator",
"generator",
")",
"{",
"checkReadOnly",
"(",
")",
";",
"DialectException",
".",
"assureNotNull",
"(",
"generator",
")",
";",
"DialectException",
".",
"assureNotNull",
"(",
"generator",
".",
"getGenerationType",
"(",
")",
")",
";",
"DialectException",
".",
"assureNotEmpty",
"(",
"generator",
".",
"getIdGenName",
"(",
")",
",",
"\"IdGenerator name can not be empty\"",
")",
";",
"getIdGenerators",
"(",
")",
".",
"add",
"(",
"generator",
")",
";",
"}"
] | Add a "create table..." DDL to generate ID, similar like JPA's TableGen | [
"Add",
"a",
"create",
"table",
"...",
"DDL",
"to",
"generate",
"ID",
"similar",
"like",
"JPA",
"s",
"TableGen"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L144-L150 |
2,497 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java | TableModel.addColumn | public TableModel addColumn(ColumnModel column) {
checkReadOnly();
DialectException.assureNotNull(column);
DialectException.assureNotEmpty(column.getColumnName(), "Column's columnName can not be empty");
column.setTableModel(this);
columns.add(column);
return this;
} | java | public TableModel addColumn(ColumnModel column) {
checkReadOnly();
DialectException.assureNotNull(column);
DialectException.assureNotEmpty(column.getColumnName(), "Column's columnName can not be empty");
column.setTableModel(this);
columns.add(column);
return this;
} | [
"public",
"TableModel",
"addColumn",
"(",
"ColumnModel",
"column",
")",
"{",
"checkReadOnly",
"(",
")",
";",
"DialectException",
".",
"assureNotNull",
"(",
"column",
")",
";",
"DialectException",
".",
"assureNotEmpty",
"(",
"column",
".",
"getColumnName",
"(",
")",
",",
"\"Column's columnName can not be empty\"",
")",
";",
"column",
".",
"setTableModel",
"(",
"this",
")",
";",
"columns",
".",
"add",
"(",
"column",
")",
";",
"return",
"this",
";",
"}"
] | Add a ColumnModel | [
"Add",
"a",
"ColumnModel"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L201-L208 |
2,498 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java | TableModel.removeColumn | public TableModel removeColumn(String columnName) {
checkReadOnly();
List<ColumnModel> oldColumns = this.getColumns();
Iterator<ColumnModel> columnIter = oldColumns.iterator();
while (columnIter.hasNext())
if (columnIter.next().getColumnName().equalsIgnoreCase(columnName))
columnIter.remove();
return this;
} | java | public TableModel removeColumn(String columnName) {
checkReadOnly();
List<ColumnModel> oldColumns = this.getColumns();
Iterator<ColumnModel> columnIter = oldColumns.iterator();
while (columnIter.hasNext())
if (columnIter.next().getColumnName().equalsIgnoreCase(columnName))
columnIter.remove();
return this;
} | [
"public",
"TableModel",
"removeColumn",
"(",
"String",
"columnName",
")",
"{",
"checkReadOnly",
"(",
")",
";",
"List",
"<",
"ColumnModel",
">",
"oldColumns",
"=",
"this",
".",
"getColumns",
"(",
")",
";",
"Iterator",
"<",
"ColumnModel",
">",
"columnIter",
"=",
"oldColumns",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"columnIter",
".",
"hasNext",
"(",
")",
")",
"if",
"(",
"columnIter",
".",
"next",
"(",
")",
".",
"getColumnName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"columnName",
")",
")",
"columnIter",
".",
"remove",
"(",
")",
";",
"return",
"this",
";",
"}"
] | Remove a ColumnModel by given columnName | [
"Remove",
"a",
"ColumnModel",
"by",
"given",
"columnName"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L213-L221 |
2,499 | drinkjava2/jDialects | core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java | TableModel.removeFKey | public TableModel removeFKey(String fkeyName) {
checkReadOnly();
List<FKeyModel> fkeys = getFkeyConstraints();
Iterator<FKeyModel> fkeyIter = fkeys.iterator();
while (fkeyIter.hasNext())
if (fkeyIter.next().getFkeyName().equalsIgnoreCase(fkeyName))
fkeyIter.remove();
return this;
} | java | public TableModel removeFKey(String fkeyName) {
checkReadOnly();
List<FKeyModel> fkeys = getFkeyConstraints();
Iterator<FKeyModel> fkeyIter = fkeys.iterator();
while (fkeyIter.hasNext())
if (fkeyIter.next().getFkeyName().equalsIgnoreCase(fkeyName))
fkeyIter.remove();
return this;
} | [
"public",
"TableModel",
"removeFKey",
"(",
"String",
"fkeyName",
")",
"{",
"checkReadOnly",
"(",
")",
";",
"List",
"<",
"FKeyModel",
">",
"fkeys",
"=",
"getFkeyConstraints",
"(",
")",
";",
"Iterator",
"<",
"FKeyModel",
">",
"fkeyIter",
"=",
"fkeys",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"fkeyIter",
".",
"hasNext",
"(",
")",
")",
"if",
"(",
"fkeyIter",
".",
"next",
"(",
")",
".",
"getFkeyName",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"fkeyName",
")",
")",
"fkeyIter",
".",
"remove",
"(",
")",
";",
"return",
"this",
";",
"}"
] | Remove a FKey by given fkeyName | [
"Remove",
"a",
"FKey",
"by",
"given",
"fkeyName"
] | 1c165f09c6042a599b681c279024abcc1b848b88 | https://github.com/drinkjava2/jDialects/blob/1c165f09c6042a599b681c279024abcc1b848b88/core/src/main/java/com/github/drinkjava2/jdialects/model/TableModel.java#L226-L234 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.