repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
jaeksoft/jcifs-krb5
src/jcifs/smb/Dfs.java
Dfs.getDc
public SmbTransport getDc(String domain, SmbExtendedAuthenticator authenticator, NtlmPasswordAuthentication auth) throws SmbAuthException { // public SmbTransport getDc(String domain, // NtlmPasswordAuthentication auth) throws SmbAuthException { // SmbAuthenticator<< if (DISABLED) return null; try { UniAddress addr = UniAddress.getByName(domain, true); SmbTransport trans = SmbTransport.getSmbTransport(addr, 0); // >>SmbAuthenticator Fixed trusted domain issue. DfsReferral dr = trans.getDfsReferrals(authenticator,auth, "\\" + domain, 1); // DfsReferral dr = trans.getDfsReferrals(auth, "\\" + domain, 1); // SmbAuthenticator<< if (dr != null) { DfsReferral start = dr; IOException e = null; do { try { addr = UniAddress.getByName(dr.server); return SmbTransport.getSmbTransport(addr, 0); } catch (IOException ioe) { e = ioe; } dr = dr.next; } while (dr != start); throw e; } } catch (IOException ioe) { if (log.level >= 3) ioe.printStackTrace(log); if (strictView && ioe instanceof SmbAuthException) { throw (SmbAuthException)ioe; } } return null; }
java
public SmbTransport getDc(String domain, SmbExtendedAuthenticator authenticator, NtlmPasswordAuthentication auth) throws SmbAuthException { // public SmbTransport getDc(String domain, // NtlmPasswordAuthentication auth) throws SmbAuthException { // SmbAuthenticator<< if (DISABLED) return null; try { UniAddress addr = UniAddress.getByName(domain, true); SmbTransport trans = SmbTransport.getSmbTransport(addr, 0); // >>SmbAuthenticator Fixed trusted domain issue. DfsReferral dr = trans.getDfsReferrals(authenticator,auth, "\\" + domain, 1); // DfsReferral dr = trans.getDfsReferrals(auth, "\\" + domain, 1); // SmbAuthenticator<< if (dr != null) { DfsReferral start = dr; IOException e = null; do { try { addr = UniAddress.getByName(dr.server); return SmbTransport.getSmbTransport(addr, 0); } catch (IOException ioe) { e = ioe; } dr = dr.next; } while (dr != start); throw e; } } catch (IOException ioe) { if (log.level >= 3) ioe.printStackTrace(log); if (strictView && ioe instanceof SmbAuthException) { throw (SmbAuthException)ioe; } } return null; }
[ "public", "SmbTransport", "getDc", "(", "String", "domain", ",", "SmbExtendedAuthenticator", "authenticator", ",", "NtlmPasswordAuthentication", "auth", ")", "throws", "SmbAuthException", "{", "// public SmbTransport getDc(String domain,\r", "// NtlmPasswordAuthentica...
>>SmbAuthenticator Fixed trusted domain issue.
[ ">>", "SmbAuthenticator", "Fixed", "trusted", "domain", "issue", "." ]
c16ea9a39925dc198adf3e049598aaea292dc5e4
https://github.com/jaeksoft/jcifs-krb5/blob/c16ea9a39925dc198adf3e049598aaea292dc5e4/src/jcifs/smb/Dfs.java#L125-L165
train
pushbit/sprockets
src/main/java/net/sf/sprockets/util/Elements.java
Elements.addAll
public static boolean addAll(LongCollection collection, long[] array) { boolean changed = false; for (long element : array) { changed |= collection.add(element); } return changed; }
java
public static boolean addAll(LongCollection collection, long[] array) { boolean changed = false; for (long element : array) { changed |= collection.add(element); } return changed; }
[ "public", "static", "boolean", "addAll", "(", "LongCollection", "collection", ",", "long", "[", "]", "array", ")", "{", "boolean", "changed", "=", "false", ";", "for", "(", "long", "element", ":", "array", ")", "{", "changed", "|=", "collection", ".", "a...
Add all elements in the array to the collection. @return true if the collection was changed @since 2.6.0
[ "Add", "all", "elements", "in", "the", "array", "to", "the", "collection", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/util/Elements.java#L44-L50
train
pushbit/sprockets
src/main/java/net/sf/sprockets/util/Elements.java
Elements.get
@Nullable public static <T> T get(T[] array, int index) { return array != null && index >= 0 && index < array.length ? array[index] : null; }
java
@Nullable public static <T> T get(T[] array, int index) { return array != null && index >= 0 && index < array.length ? array[index] : null; }
[ "@", "Nullable", "public", "static", "<", "T", ">", "T", "get", "(", "T", "[", "]", "array", ",", "int", "index", ")", "{", "return", "array", "!=", "null", "&&", "index", ">=", "0", "&&", "index", "<", "array", ".", "length", "?", "array", "[", ...
Get the element at the index in the array. @return null if the array is null or the index is out of bounds
[ "Get", "the", "element", "at", "the", "index", "in", "the", "array", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/util/Elements.java#L57-L60
train
pushbit/sprockets
src/main/java/net/sf/sprockets/util/Elements.java
Elements.slice
public static <T> T[] slice(T[] array, int... indexes) { int length = indexes.length; T[] slice = ObjectArrays.newArray(array, length); for (int i = 0; i < length; i++) { slice[i] = array[indexes[i]]; } return slice; }
java
public static <T> T[] slice(T[] array, int... indexes) { int length = indexes.length; T[] slice = ObjectArrays.newArray(array, length); for (int i = 0; i < length; i++) { slice[i] = array[indexes[i]]; } return slice; }
[ "public", "static", "<", "T", ">", "T", "[", "]", "slice", "(", "T", "[", "]", "array", ",", "int", "...", "indexes", ")", "{", "int", "length", "=", "indexes", ".", "length", ";", "T", "[", "]", "slice", "=", "ObjectArrays", ".", "newArray", "("...
Get the elements in the array that are at the indexes. @since 1.4.0
[ "Get", "the", "elements", "in", "the", "array", "that", "are", "at", "the", "indexes", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/util/Elements.java#L77-L84
train
pushbit/sprockets
src/main/java/net/sf/sprockets/util/Elements.java
Elements.slice
public static <T> List<T> slice(List<T> list, int... indexes) { List<T> slice = new ArrayList<>(indexes.length); for (int i : indexes) { slice.add(list.get(i)); } return slice; }
java
public static <T> List<T> slice(List<T> list, int... indexes) { List<T> slice = new ArrayList<>(indexes.length); for (int i : indexes) { slice.add(list.get(i)); } return slice; }
[ "public", "static", "<", "T", ">", "List", "<", "T", ">", "slice", "(", "List", "<", "T", ">", "list", ",", "int", "...", "indexes", ")", "{", "List", "<", "T", ">", "slice", "=", "new", "ArrayList", "<>", "(", "indexes", ".", "length", ")", ";...
Get the elements in the list that are at the indexes. @since 1.4.0
[ "Get", "the", "elements", "in", "the", "list", "that", "are", "at", "the", "indexes", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/util/Elements.java#L91-L97
train
pushbit/sprockets
src/main/java/net/sf/sprockets/lang/Classes.java
Classes.getClass
public static Class<?> getClass(Object obj) { Class<?> cls = obj.getClass(); return cls != Class.class ? cls : (Class<?>) obj; }
java
public static Class<?> getClass(Object obj) { Class<?> cls = obj.getClass(); return cls != Class.class ? cls : (Class<?>) obj; }
[ "public", "static", "Class", "<", "?", ">", "getClass", "(", "Object", "obj", ")", "{", "Class", "<", "?", ">", "cls", "=", "obj", ".", "getClass", "(", ")", ";", "return", "cls", "!=", "Class", ".", "class", "?", "cls", ":", "(", "Class", "<", ...
If the object is not a Class, get its Class. Otherwise get the object as a Class. @since 4.0.0
[ "If", "the", "object", "is", "not", "a", "Class", "get", "its", "Class", ".", "Otherwise", "get", "the", "object", "as", "a", "Class", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/lang/Classes.java#L40-L43
train
pushbit/sprockets
src/main/java/net/sf/sprockets/lang/Classes.java
Classes.getNamedClass
public static Class<?> getNamedClass(Object obj) { Class<?> cls = getClass(obj); while (cls != null && cls.isAnonymousClass()) { cls = cls.getEnclosingClass(); } return cls; }
java
public static Class<?> getNamedClass(Object obj) { Class<?> cls = getClass(obj); while (cls != null && cls.isAnonymousClass()) { cls = cls.getEnclosingClass(); } return cls; }
[ "public", "static", "Class", "<", "?", ">", "getNamedClass", "(", "Object", "obj", ")", "{", "Class", "<", "?", ">", "cls", "=", "getClass", "(", "obj", ")", ";", "while", "(", "cls", "!=", "null", "&&", "cls", ".", "isAnonymousClass", "(", ")", ")...
If the object is not a Class, get its Class. Otherwise get the object as a Class. If the class is anonymous, get a non-anonymous enclosing class. @since 4.0.0
[ "If", "the", "object", "is", "not", "a", "Class", "get", "its", "Class", ".", "Otherwise", "get", "the", "object", "as", "a", "Class", ".", "If", "the", "class", "is", "anonymous", "get", "a", "non", "-", "anonymous", "enclosing", "class", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/lang/Classes.java#L51-L57
train
pushbit/sprockets
src/main/java/net/sf/sprockets/okhttp/OkHttp.java
OkHttp.request
public static Request request(String url, String... headers) { Request.Builder request = new Request.Builder().url(url); if (headers != null) { int length = headers.length; checkArgument(length % 2 == 0, "headers length must be a multiple of two"); for (int i = 0; i < length; i += 2) { request.addHeader(headers[i], headers[i + 1]); } } return request.build(); }
java
public static Request request(String url, String... headers) { Request.Builder request = new Request.Builder().url(url); if (headers != null) { int length = headers.length; checkArgument(length % 2 == 0, "headers length must be a multiple of two"); for (int i = 0; i < length; i += 2) { request.addHeader(headers[i], headers[i + 1]); } } return request.build(); }
[ "public", "static", "Request", "request", "(", "String", "url", ",", "String", "...", "headers", ")", "{", "Request", ".", "Builder", "request", "=", "new", "Request", ".", "Builder", "(", ")", ".", "url", "(", "url", ")", ";", "if", "(", "headers", ...
Get a GET request for the URL and headers. @param headers length must be a multiple of two: {@code String name, String value, ...}
[ "Get", "a", "GET", "request", "for", "the", "URL", "and", "headers", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/okhttp/OkHttp.java#L61-L71
train
pushbit/sprockets
src/main/java/net/sf/sprockets/okhttp/OkHttp.java
OkHttp.call
public Call call(String url, String... headers) { return mCaller.newCall(request(url, headers)); }
java
public Call call(String url, String... headers) { return mCaller.newCall(request(url, headers)); }
[ "public", "Call", "call", "(", "String", "url", ",", "String", "...", "headers", ")", "{", "return", "mCaller", ".", "newCall", "(", "request", "(", "url", ",", "headers", ")", ")", ";", "}" ]
Get a Call for a GET request for the URL and headers.
[ "Get", "a", "Call", "for", "a", "GET", "request", "for", "the", "URL", "and", "headers", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/okhttp/OkHttp.java#L83-L85
train
pushbit/sprockets
src/main/java/net/sf/sprockets/okhttp/OkHttp.java
OkHttp.response
public Response response(String url, String... headers) throws IOException { return call(url, headers).execute(); }
java
public Response response(String url, String... headers) throws IOException { return call(url, headers).execute(); }
[ "public", "Response", "response", "(", "String", "url", ",", "String", "...", "headers", ")", "throws", "IOException", "{", "return", "call", "(", "url", ",", "headers", ")", ".", "execute", "(", ")", ";", "}" ]
Get a response to a GET request for the URL and headers.
[ "Get", "a", "response", "to", "a", "GET", "request", "for", "the", "URL", "and", "headers", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/okhttp/OkHttp.java#L97-L99
train
pushbit/sprockets
src/main/java/net/sf/sprockets/okhttp/OkHttp.java
OkHttp.download
public Response download(String url, File destination) throws IOException { return download(url, destination, (String[]) null); }
java
public Response download(String url, File destination) throws IOException { return download(url, destination, (String[]) null); }
[ "public", "Response", "download", "(", "String", "url", ",", "File", "destination", ")", "throws", "IOException", "{", "return", "download", "(", "url", ",", "destination", ",", "(", "String", "[", "]", ")", "null", ")", ";", "}" ]
Download the resource at the URL and write it to the file. @return Response whose body has already been consumed and closed
[ "Download", "the", "resource", "at", "the", "URL", "and", "write", "it", "to", "the", "file", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/okhttp/OkHttp.java#L106-L108
train
pushbit/sprockets
src/main/java/net/sf/sprockets/okhttp/OkHttp.java
OkHttp.download
public Response download(String url, File destination, String... headers) throws IOException { try (Response resp = response(url, headers)) { if (resp.isSuccessful()) { try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) { resp.body().source().readAll(sink); } } return resp; } }
java
public Response download(String url, File destination, String... headers) throws IOException { try (Response resp = response(url, headers)) { if (resp.isSuccessful()) { try (BufferedSink sink = Okio.buffer(Okio.sink(destination))) { resp.body().source().readAll(sink); } } return resp; } }
[ "public", "Response", "download", "(", "String", "url", ",", "File", "destination", ",", "String", "...", "headers", ")", "throws", "IOException", "{", "try", "(", "Response", "resp", "=", "response", "(", "url", ",", "headers", ")", ")", "{", "if", "(",...
Download the resource at the URL with the headers and write it to the file. @return Response whose body has already been consumed and closed
[ "Download", "the", "resource", "at", "the", "URL", "with", "the", "headers", "and", "write", "it", "to", "the", "file", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/okhttp/OkHttp.java#L115-L124
train
pushbit/sprockets
src/main/java/net/sf/sprockets/lang/Substring.java
Substring.getOffset
@Default public int getOffset() { String value = getValue(); String superstring = getSuperstring(); return value != null && superstring != null ? superstring.indexOf(value) : -1; }
java
@Default public int getOffset() { String value = getValue(); String superstring = getSuperstring(); return value != null && superstring != null ? superstring.indexOf(value) : -1; }
[ "@", "Default", "public", "int", "getOffset", "(", ")", "{", "String", "value", "=", "getValue", "(", ")", ";", "String", "superstring", "=", "getSuperstring", "(", ")", ";", "return", "value", "!=", "null", "&&", "superstring", "!=", "null", "?", "super...
Zero-based position of the first character of the substring within the superstring.
[ "Zero", "-", "based", "position", "of", "the", "first", "character", "of", "the", "substring", "within", "the", "superstring", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/lang/Substring.java#L47-L52
train
jaeksoft/jcifs-krb5
src/jcifs/spnego/asn1/DERUniversalString.java
DERUniversalString.getString
public String getString() { StringBuffer buf = new StringBuffer(); for (int i = 0; i != string.length; i++) { buf.append(table[(string[i] >>> 4) % 0xf]); buf.append(table[string[i] & 0xf]); } return buf.toString(); }
java
public String getString() { StringBuffer buf = new StringBuffer(); for (int i = 0; i != string.length; i++) { buf.append(table[(string[i] >>> 4) % 0xf]); buf.append(table[string[i] & 0xf]); } return buf.toString(); }
[ "public", "String", "getString", "(", ")", "{", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "string", ".", "length", ";", "i", "++", ")", "{", "buf", ".", "append", "(", "tab...
UniversalStrings have characters which are 4 bytes long - for the moment we just return them in Hex...
[ "UniversalStrings", "have", "characters", "which", "are", "4", "bytes", "long", "-", "for", "the", "moment", "we", "just", "return", "them", "in", "Hex", "..." ]
c16ea9a39925dc198adf3e049598aaea292dc5e4
https://github.com/jaeksoft/jcifs-krb5/blob/c16ea9a39925dc198adf3e049598aaea292dc5e4/src/jcifs/spnego/asn1/DERUniversalString.java#L87-L98
train
pushbit/sprockets
src/main/java/net/sf/sprockets/lang/Maths.java
Maths.clamp
public static int clamp(int value, int min, int max) { return Math.min(Math.max(min, value), max); }
java
public static int clamp(int value, int min, int max) { return Math.min(Math.max(min, value), max); }
[ "public", "static", "int", "clamp", "(", "int", "value", ",", "int", "min", ",", "int", "max", ")", "{", "return", "Math", ".", "min", "(", "Math", ".", "max", "(", "min", ",", "value", ")", ",", "max", ")", ";", "}" ]
Get the value if it is between min and max, min if the value is less than min, or max if the value is greater than max.
[ "Get", "the", "value", "if", "it", "is", "between", "min", "and", "max", "min", "if", "the", "value", "is", "less", "than", "min", "or", "max", "if", "the", "value", "is", "greater", "than", "max", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/lang/Maths.java#L33-L35
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/SQLite.java
SQLite.normalise
public static String normalise(String s) { if (sDiacritics == null) { sDiacritics = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); } return sDiacritics.matcher(Normalizer.normalize(s, NFD)).replaceAll("").toUpperCase(US); }
java
public static String normalise(String s) { if (sDiacritics == null) { sDiacritics = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); } return sDiacritics.matcher(Normalizer.normalize(s, NFD)).replaceAll("").toUpperCase(US); }
[ "public", "static", "String", "normalise", "(", "String", "s", ")", "{", "if", "(", "sDiacritics", "==", "null", ")", "{", "sDiacritics", "=", "Pattern", ".", "compile", "(", "\"\\\\p{InCombiningDiacriticalMarks}+\"", ")", ";", "}", "return", "sDiacritics", "....
Remove diacritics from the string and convert it to upper case.
[ "Remove", "diacritics", "from", "the", "string", "and", "convert", "it", "to", "upper", "case", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/SQLite.java#L300-L305
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/SQLite.java
SQLite.distance
public static String distance(String latitudeColumn, String longitudeColumn, String latitudeCosineColumn, double latitude, double longitude, MeasureUnit unit, String alias) { double degree = unit == MILE ? LATITUDE_DEGREE_MI : LATITUDE_DEGREE_KM; return String.format((Locale) null, sDistance, degree, latitude, latitudeColumn, degree, latitude, latitudeColumn, degree, longitude, longitudeColumn, latitudeCosineColumn, degree, longitude, longitudeColumn, latitudeCosineColumn, alias); }
java
public static String distance(String latitudeColumn, String longitudeColumn, String latitudeCosineColumn, double latitude, double longitude, MeasureUnit unit, String alias) { double degree = unit == MILE ? LATITUDE_DEGREE_MI : LATITUDE_DEGREE_KM; return String.format((Locale) null, sDistance, degree, latitude, latitudeColumn, degree, latitude, latitudeColumn, degree, longitude, longitudeColumn, latitudeCosineColumn, degree, longitude, longitudeColumn, latitudeCosineColumn, alias); }
[ "public", "static", "String", "distance", "(", "String", "latitudeColumn", ",", "String", "longitudeColumn", ",", "String", "latitudeCosineColumn", ",", "double", "latitude", ",", "double", "longitude", ",", "MeasureUnit", "unit", ",", "String", "alias", ")", "{",...
Get a result column for the squared distance from the row coordinates to the supplied coordinates. SQLite doesn't have a square root core function, so this must be applied in Java when reading the result column value. @param latitudeCosineColumn see {@link Geos#cos(double)} @param unit KILOMETER or MILE @param alias result column name
[ "Get", "a", "result", "column", "for", "the", "squared", "distance", "from", "the", "row", "coordinates", "to", "the", "supplied", "coordinates", ".", "SQLite", "doesn", "t", "have", "a", "square", "root", "core", "function", "so", "this", "must", "be", "a...
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/SQLite.java#L327-L334
train
pushbit/sprockets
src/main/java/net/sf/sprockets/util/concurrent/Interruptibles.java
Interruptibles.sleep
public static void sleep(long length, TimeUnit unit) { try { unit.sleep(length); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
java
public static void sleep(long length, TimeUnit unit) { try { unit.sleep(length); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
[ "public", "static", "void", "sleep", "(", "long", "length", ",", "TimeUnit", "unit", ")", "{", "try", "{", "unit", ".", "sleep", "(", "length", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "Thread", ".", "currentThread", "(", ")"...
Sleep for the length of time.
[ "Sleep", "for", "the", "length", "of", "time", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/util/concurrent/Interruptibles.java#L37-L43
train
jaeksoft/jcifs-krb5
src/jcifs/smb/SmbSession.java
SmbSession.matches
boolean matches(SmbExtendedAuthenticator authenticator, NtlmPasswordAuthentication auth) { return matcheObject(this.authenticator, authenticator) && matcheObject(this.auth, auth); }
java
boolean matches(SmbExtendedAuthenticator authenticator, NtlmPasswordAuthentication auth) { return matcheObject(this.authenticator, authenticator) && matcheObject(this.auth, auth); }
[ "boolean", "matches", "(", "SmbExtendedAuthenticator", "authenticator", ",", "NtlmPasswordAuthentication", "auth", ")", "{", "return", "matcheObject", "(", "this", ".", "authenticator", ",", "authenticator", ")", "&&", "matcheObject", "(", "this", ".", "auth", ",", ...
authenticator to decide whether or not reuse a session.
[ "authenticator", "to", "decide", "whether", "or", "not", "reuse", "a", "session", "." ]
c16ea9a39925dc198adf3e049598aaea292dc5e4
https://github.com/jaeksoft/jcifs-krb5/blob/c16ea9a39925dc198adf3e049598aaea292dc5e4/src/jcifs/smb/SmbSession.java#L207-L211
train
jaeksoft/jcifs-krb5
src/jcifs/smb/Kerb5Context.java
Kerb5Context.searchSessionKey
Key searchSessionKey(Subject subject) throws GSSException{ /* The kerberos session key is not accessible via the JGSS API IBM and Oracle both implement a similar API to make an ExtendedGSSContext available. The older implementation to find the session key is still available as a fallback, but it is not expected, that it works. From "JCIFS with Kerberos doesn't work on JDK 7": https://bugs.openjdk.java.net/browse/JDK-8031973: This is a bug in JCIFS. It seems the SMB packet it generates that includes the AP-REQ token also includes something else that should be encrypted with the *context* session key. The standard GSS-API does not provide such a method so it looks up the service ticket in the subject and use its *ticket* session key instead. The context session key is not the ticket session key if sub key is used. Possible patch: Fix jcifs.smb.Kerb5Context's searchSessionKey() method to call Oracle JDK's ExtendedGSSContext::inquireSecContext(InquireType.KRB5_GET_SESSION_KEY) to get the real session key. The classes are defined in com.sun.security.jgss. */ if (extendedGSSContextClass == null || inquireTypeSessionKey == null || inquireSecContext == null || gssContext == null) { if(log.level > 0 && (! deprecationWarningPrinted)) { log.print("WARNING: Kerberos Session Key is extracted from Kerberos Ticket. This is known to be problematic (See: https://bugs.openjdk.java.net/browse/JDK-8031973)."); deprecationWarningPrinted = true; } MIEName src = new MIEName(gssContext.getSrcName().export()); MIEName targ = new MIEName(gssContext.getTargName().export()); for(KerberosTicket ticket: subject.getPrivateCredentials(KerberosTicket.class)) { MIEName client = new MIEName(gssContext.getMech(), ticket.getClient().getName()); MIEName server = new MIEName(gssContext.getMech(), ticket.getServer().getName()); if (src.equals(client) && targ.equals(server)) { return ticket.getSessionKey(); } } return null; } else { if (extendedGSSContextClass.isAssignableFrom(gssContext.getClass())) { try { return (Key) inquireSecContext.invoke(gssContext, new Object[]{inquireTypeSessionKey}); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { log.print("Reflective access to ExtendedGSSContext failed"); ex.printStackTrace(log); } } return null; } }
java
Key searchSessionKey(Subject subject) throws GSSException{ /* The kerberos session key is not accessible via the JGSS API IBM and Oracle both implement a similar API to make an ExtendedGSSContext available. The older implementation to find the session key is still available as a fallback, but it is not expected, that it works. From "JCIFS with Kerberos doesn't work on JDK 7": https://bugs.openjdk.java.net/browse/JDK-8031973: This is a bug in JCIFS. It seems the SMB packet it generates that includes the AP-REQ token also includes something else that should be encrypted with the *context* session key. The standard GSS-API does not provide such a method so it looks up the service ticket in the subject and use its *ticket* session key instead. The context session key is not the ticket session key if sub key is used. Possible patch: Fix jcifs.smb.Kerb5Context's searchSessionKey() method to call Oracle JDK's ExtendedGSSContext::inquireSecContext(InquireType.KRB5_GET_SESSION_KEY) to get the real session key. The classes are defined in com.sun.security.jgss. */ if (extendedGSSContextClass == null || inquireTypeSessionKey == null || inquireSecContext == null || gssContext == null) { if(log.level > 0 && (! deprecationWarningPrinted)) { log.print("WARNING: Kerberos Session Key is extracted from Kerberos Ticket. This is known to be problematic (See: https://bugs.openjdk.java.net/browse/JDK-8031973)."); deprecationWarningPrinted = true; } MIEName src = new MIEName(gssContext.getSrcName().export()); MIEName targ = new MIEName(gssContext.getTargName().export()); for(KerberosTicket ticket: subject.getPrivateCredentials(KerberosTicket.class)) { MIEName client = new MIEName(gssContext.getMech(), ticket.getClient().getName()); MIEName server = new MIEName(gssContext.getMech(), ticket.getServer().getName()); if (src.equals(client) && targ.equals(server)) { return ticket.getSessionKey(); } } return null; } else { if (extendedGSSContextClass.isAssignableFrom(gssContext.getClass())) { try { return (Key) inquireSecContext.invoke(gssContext, new Object[]{inquireTypeSessionKey}); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { log.print("Reflective access to ExtendedGSSContext failed"); ex.printStackTrace(log); } } return null; } }
[ "Key", "searchSessionKey", "(", "Subject", "subject", ")", "throws", "GSSException", "{", "/*\r\n The kerberos session key is not accessible via the JGSS API IBM and \r\n Oracle both implement a similar API to make an ExtendedGSSContext\r\n available.\r\n \r\n Th...
Extract the context session key from the gssContext. The subject is only used if no support for extraction of the session key is not possible with an API and is used as a fallback method. @param subject @return context session key @throws GSSException
[ "Extract", "the", "context", "session", "key", "from", "the", "gssContext", ".", "The", "subject", "is", "only", "used", "if", "no", "support", "for", "extraction", "of", "the", "session", "key", "is", "not", "possible", "with", "an", "API", "and", "is", ...
c16ea9a39925dc198adf3e049598aaea292dc5e4
https://github.com/jaeksoft/jcifs-krb5/blob/c16ea9a39925dc198adf3e049598aaea292dc5e4/src/jcifs/smb/Kerb5Context.java#L74-L130
train
jaeksoft/jcifs-krb5
src/jcifs/spnego/asn1/DERBitString.java
DERBitString.getPadBits
static protected int getPadBits( int bitString) { int val; if (bitString == 0) { return 7; } if (bitString > 255) { val = ((bitString >> 8) & 0xFF); } else { val = (bitString & 0xFF); } int bits = 1; while (((val <<= 1) & 0xFF) != 0) { bits++; } return 8 - bits; }
java
static protected int getPadBits( int bitString) { int val; if (bitString == 0) { return 7; } if (bitString > 255) { val = ((bitString >> 8) & 0xFF); } else { val = (bitString & 0xFF); } int bits = 1; while (((val <<= 1) & 0xFF) != 0) { bits++; } return 8 - bits; }
[ "static", "protected", "int", "getPadBits", "(", "int", "bitString", ")", "{", "int", "val", ";", "if", "(", "bitString", "==", "0", ")", "{", "return", "7", ";", "}", "if", "(", "bitString", ">", "255", ")", "{", "val", "=", "(", "(", "bitString",...
return the correct number of pad bits for a bit string defined in a 16 bit constant
[ "return", "the", "correct", "number", "of", "pad", "bits", "for", "a", "bit", "string", "defined", "in", "a", "16", "bit", "constant" ]
c16ea9a39925dc198adf3e049598aaea292dc5e4
https://github.com/jaeksoft/jcifs-krb5/blob/c16ea9a39925dc198adf3e049598aaea292dc5e4/src/jcifs/spnego/asn1/DERBitString.java#L38-L65
train
jaeksoft/jcifs-krb5
src/jcifs/spnego/asn1/DERBitString.java
DERBitString.getBytes
static protected byte[] getBytes( int bitString) { if (bitString > 255) { byte[] bytes = new byte[2]; bytes[0] = (byte)(bitString & 0xFF); bytes[1] = (byte)((bitString >> 8) & 0xFF); return bytes; } else { byte[] bytes = new byte[1]; bytes[0] = (byte)(bitString & 0xFF); return bytes; } }
java
static protected byte[] getBytes( int bitString) { if (bitString > 255) { byte[] bytes = new byte[2]; bytes[0] = (byte)(bitString & 0xFF); bytes[1] = (byte)((bitString >> 8) & 0xFF); return bytes; } else { byte[] bytes = new byte[1]; bytes[0] = (byte)(bitString & 0xFF); return bytes; } }
[ "static", "protected", "byte", "[", "]", "getBytes", "(", "int", "bitString", ")", "{", "if", "(", "bitString", ">", "255", ")", "{", "byte", "[", "]", "bytes", "=", "new", "byte", "[", "2", "]", ";", "bytes", "[", "0", "]", "=", "(", "byte", "...
return the correct number of bytes for a bit string defined in a 16 bit constant
[ "return", "the", "correct", "number", "of", "bytes", "for", "a", "bit", "string", "defined", "in", "a", "16", "bit", "constant" ]
c16ea9a39925dc198adf3e049598aaea292dc5e4
https://github.com/jaeksoft/jcifs-krb5/blob/c16ea9a39925dc198adf3e049598aaea292dc5e4/src/jcifs/spnego/asn1/DERBitString.java#L71-L91
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/Statements.java
Statements.setStrings
public static PreparedStatement setStrings(PreparedStatement stmt, String... params) throws SQLException { return setStrings(1, stmt, params); }
java
public static PreparedStatement setStrings(PreparedStatement stmt, String... params) throws SQLException { return setStrings(1, stmt, params); }
[ "public", "static", "PreparedStatement", "setStrings", "(", "PreparedStatement", "stmt", ",", "String", "...", "params", ")", "throws", "SQLException", "{", "return", "setStrings", "(", "1", ",", "stmt", ",", "params", ")", ";", "}" ]
Set the statement parameters, starting at 1, in the order of the params. @since 3.0.0
[ "Set", "the", "statement", "parameters", "starting", "at", "1", "in", "the", "order", "of", "the", "params", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/Statements.java#L90-L93
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/Statements.java
Statements.firstInt
public static int firstInt(PreparedStatement stmt) throws SQLException { ResultSet rs = stmt.executeQuery(); int i = rs.next() ? rs.getInt(1) : Integer.MIN_VALUE; stmt.close(); return i; }
java
public static int firstInt(PreparedStatement stmt) throws SQLException { ResultSet rs = stmt.executeQuery(); int i = rs.next() ? rs.getInt(1) : Integer.MIN_VALUE; stmt.close(); return i; }
[ "public", "static", "int", "firstInt", "(", "PreparedStatement", "stmt", ")", "throws", "SQLException", "{", "ResultSet", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "int", "i", "=", "rs", ".", "next", "(", ")", "?", "rs", ".", "getInt", "("...
Execute the query, get the int value in the first row and column of the result set, and close the statement. @param stmt must already have parameters set @return {@link Integer#MIN_VALUE} if the result set is empty
[ "Execute", "the", "query", "get", "the", "int", "value", "in", "the", "first", "row", "and", "column", "of", "the", "result", "set", "and", "close", "the", "statement", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/Statements.java#L128-L133
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/Statements.java
Statements.firstLong
public static long firstLong(PreparedStatement stmt) throws SQLException { ResultSet rs = stmt.executeQuery(); long l = rs.next() ? rs.getLong(1) : Long.MIN_VALUE; stmt.close(); return l; }
java
public static long firstLong(PreparedStatement stmt) throws SQLException { ResultSet rs = stmt.executeQuery(); long l = rs.next() ? rs.getLong(1) : Long.MIN_VALUE; stmt.close(); return l; }
[ "public", "static", "long", "firstLong", "(", "PreparedStatement", "stmt", ")", "throws", "SQLException", "{", "ResultSet", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "long", "l", "=", "rs", ".", "next", "(", ")", "?", "rs", ".", "getLong", ...
Execute the query, get the long value in the first row and column of the result set, and close the statement. @param stmt must already have parameters set @return {@link Long#MIN_VALUE} if the result set is empty
[ "Execute", "the", "query", "get", "the", "long", "value", "in", "the", "first", "row", "and", "column", "of", "the", "result", "set", "and", "close", "the", "statement", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/Statements.java#L143-L148
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/Statements.java
Statements.firstString
@Nullable public static String firstString(PreparedStatement stmt) throws SQLException { ResultSet rs = stmt.executeQuery(); String s = rs.next() ? rs.getString(1) : null; stmt.close(); return s; }
java
@Nullable public static String firstString(PreparedStatement stmt) throws SQLException { ResultSet rs = stmt.executeQuery(); String s = rs.next() ? rs.getString(1) : null; stmt.close(); return s; }
[ "@", "Nullable", "public", "static", "String", "firstString", "(", "PreparedStatement", "stmt", ")", "throws", "SQLException", "{", "ResultSet", "rs", "=", "stmt", ".", "executeQuery", "(", ")", ";", "String", "s", "=", "rs", ".", "next", "(", ")", "?", ...
Execute the query, get the String value in the first row and column of the result set, and close the statement. @param stmt must already have parameters set @return null if the result set is empty @since 3.0.0
[ "Execute", "the", "query", "get", "the", "String", "value", "in", "the", "first", "row", "and", "column", "of", "the", "result", "set", "and", "close", "the", "statement", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/Statements.java#L159-L165
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/Statements.java
Statements.firstStringRow
@SuppressWarnings("unchecked") public static List<String> firstStringRow(PreparedStatement stmt) throws SQLException { return (List<String>) firstRow(stmt, String.class); }
java
@SuppressWarnings("unchecked") public static List<String> firstStringRow(PreparedStatement stmt) throws SQLException { return (List<String>) firstRow(stmt, String.class); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "List", "<", "String", ">", "firstStringRow", "(", "PreparedStatement", "stmt", ")", "throws", "SQLException", "{", "return", "(", "List", "<", "String", ">", ")", "firstRow", "(", "stmt",...
Execute the query, get the String values in the first row of the result set, and close the statement. @param stmt must already have parameters set @since 3.0.0
[ "Execute", "the", "query", "get", "the", "String", "values", "in", "the", "first", "row", "of", "the", "result", "set", "and", "close", "the", "statement", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/Statements.java#L199-L202
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/Statements.java
Statements.allStrings
@SuppressWarnings("unchecked") public static List<String> allStrings(PreparedStatement stmt) throws SQLException { return (List<String>) all(stmt, String.class); }
java
@SuppressWarnings("unchecked") public static List<String> allStrings(PreparedStatement stmt) throws SQLException { return (List<String>) all(stmt, String.class); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "List", "<", "String", ">", "allStrings", "(", "PreparedStatement", "stmt", ")", "throws", "SQLException", "{", "return", "(", "List", "<", "String", ">", ")", "all", "(", "stmt", ",", ...
Execute the query, get the String values in the first column of the result set, and close the statement. @param stmt must already have parameters set @since 1.5.0
[ "Execute", "the", "query", "get", "the", "String", "values", "in", "the", "first", "column", "of", "the", "result", "set", "and", "close", "the", "statement", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/Statements.java#L262-L265
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/Statements.java
Statements.firstIntKey
public static int firstIntKey(PreparedStatement stmt) throws SQLException { stmt.execute(); ResultSet rs = stmt.getGeneratedKeys(); int key = rs.next() ? rs.getInt(1) : 0; stmt.close(); return key; }
java
public static int firstIntKey(PreparedStatement stmt) throws SQLException { stmt.execute(); ResultSet rs = stmt.getGeneratedKeys(); int key = rs.next() ? rs.getInt(1) : 0; stmt.close(); return key; }
[ "public", "static", "int", "firstIntKey", "(", "PreparedStatement", "stmt", ")", "throws", "SQLException", "{", "stmt", ".", "execute", "(", ")", ";", "ResultSet", "rs", "=", "stmt", ".", "getGeneratedKeys", "(", ")", ";", "int", "key", "=", "rs", ".", "...
Execute the insert statement, get the first generated key as an int, and close the statement. @param stmt must have been created with {@link Statement#RETURN_GENERATED_KEYS} and already have parameters set @return 0 if the statement did not generate any keys @since 3.0.0
[ "Execute", "the", "insert", "statement", "get", "the", "first", "generated", "key", "as", "an", "int", "and", "close", "the", "statement", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/Statements.java#L301-L307
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/Statements.java
Statements.firstLongKey
public static long firstLongKey(PreparedStatement stmt) throws SQLException { stmt.execute(); ResultSet rs = stmt.getGeneratedKeys(); long key = rs.next() ? rs.getLong(1) : 0L; stmt.close(); return key; }
java
public static long firstLongKey(PreparedStatement stmt) throws SQLException { stmt.execute(); ResultSet rs = stmt.getGeneratedKeys(); long key = rs.next() ? rs.getLong(1) : 0L; stmt.close(); return key; }
[ "public", "static", "long", "firstLongKey", "(", "PreparedStatement", "stmt", ")", "throws", "SQLException", "{", "stmt", ".", "execute", "(", ")", ";", "ResultSet", "rs", "=", "stmt", ".", "getGeneratedKeys", "(", ")", ";", "long", "key", "=", "rs", ".", ...
Execute the insert statement, get the first generated key as a long, and close the statement. @param stmt must have been created with {@link Statement#RETURN_GENERATED_KEYS} and already have parameters set @return 0 if the statement did not generate any keys
[ "Execute", "the", "insert", "statement", "get", "the", "first", "generated", "key", "as", "a", "long", "and", "close", "the", "statement", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/Statements.java#L317-L323
train
pushbit/sprockets
src/main/java/net/sf/sprockets/sql/Statements.java
Statements.update
public static int update(PreparedStatement stmt) throws SQLException { int rows = stmt.executeUpdate(); stmt.close(); return rows; }
java
public static int update(PreparedStatement stmt) throws SQLException { int rows = stmt.executeUpdate(); stmt.close(); return rows; }
[ "public", "static", "int", "update", "(", "PreparedStatement", "stmt", ")", "throws", "SQLException", "{", "int", "rows", "=", "stmt", ".", "executeUpdate", "(", ")", ";", "stmt", ".", "close", "(", ")", ";", "return", "rows", ";", "}" ]
Execute the insert, update, or delete statement, get the number of rows affected, and close the statement. @param stmt must already have parameters set @since 1.4.0
[ "Execute", "the", "insert", "update", "or", "delete", "statement", "get", "the", "number", "of", "rows", "affected", "and", "close", "the", "statement", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/sql/Statements.java#L333-L337
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/CpeParser.java
CpeParser.parse
public static Cpe parse(String cpeString, boolean lenient) throws CpeParsingException { if (cpeString == null) { throw new CpeParsingException("CPE String is null and cannot be parsed"); } else if (cpeString.regionMatches(0, "cpe:/", 0, 5)) { return parse22(cpeString, lenient); } else if (cpeString.regionMatches(0, "cpe:2.3:", 0, 8)) { return parse23(cpeString, lenient); } throw new CpeParsingException("The CPE string specified does not conform to the CPE 2.2 or 2.3 specification"); }
java
public static Cpe parse(String cpeString, boolean lenient) throws CpeParsingException { if (cpeString == null) { throw new CpeParsingException("CPE String is null and cannot be parsed"); } else if (cpeString.regionMatches(0, "cpe:/", 0, 5)) { return parse22(cpeString, lenient); } else if (cpeString.regionMatches(0, "cpe:2.3:", 0, 8)) { return parse23(cpeString, lenient); } throw new CpeParsingException("The CPE string specified does not conform to the CPE 2.2 or 2.3 specification"); }
[ "public", "static", "Cpe", "parse", "(", "String", "cpeString", ",", "boolean", "lenient", ")", "throws", "CpeParsingException", "{", "if", "(", "cpeString", "==", "null", ")", "{", "throw", "new", "CpeParsingException", "(", "\"CPE String is null and cannot be pars...
Parses a CPE String into an object with the option of parsing CPE 2.2 URI strings in lenient mode - allowing for CPE values that do not adhere to the specification. @param cpeString the CPE string to parse @param lenient when <code>true</code> the CPE 2.2 parser will put in lenient mode attempting to parse invalid CPE URI values. @return the CPE object represented by the given cpeString @throws CpeParsingException thrown if the cpeString is invalid
[ "Parses", "a", "CPE", "String", "into", "an", "object", "with", "the", "option", "of", "parsing", "CPE", "2", ".", "2", "URI", "strings", "in", "lenient", "mode", "-", "allowing", "for", "CPE", "values", "that", "do", "not", "adhere", "to", "the", "spe...
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/CpeParser.java#L71-L80
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/CpeParser.java
CpeParser.parse22
protected static Cpe parse22(String cpeString, boolean lenient) throws CpeParsingException { if (cpeString == null || cpeString.isEmpty()) { throw new CpeParsingException("CPE String is null ir enpty - unable to parse"); } CpeBuilder cb = new CpeBuilder(); String[] parts = cpeString.split(":"); if (parts.length <= 1 || parts.length > 8) { throw new CpeParsingException("CPE String is invalid - too many components specified: " + cpeString); } if (parts[1].length() != 2) { throw new CpeParsingException("CPE String contains a malformed part: " + cpeString); } try { cb.part(parts[1].substring(1)); if (parts.length > 2) { cb.wfVendor(Convert.cpeUriToWellFormed(parts[2], lenient)); } if (parts.length > 3) { cb.wfProduct(Convert.cpeUriToWellFormed(parts[3], lenient)); } if (parts.length > 4) { cb.wfVersion(Convert.cpeUriToWellFormed(parts[4], lenient)); } if (parts.length > 5) { cb.wfUpdate(Convert.cpeUriToWellFormed(parts[5], lenient)); } if (parts.length > 6) { unpackEdition(parts[6], cb, lenient); } if (parts.length > 7) { cb.wfLanguage(Convert.cpeUriToWellFormed(parts[7], lenient)); } return cb.build(); } catch (CpeValidationException | CpeEncodingException ex) { throw new CpeParsingException(ex.getMessage()); } }
java
protected static Cpe parse22(String cpeString, boolean lenient) throws CpeParsingException { if (cpeString == null || cpeString.isEmpty()) { throw new CpeParsingException("CPE String is null ir enpty - unable to parse"); } CpeBuilder cb = new CpeBuilder(); String[] parts = cpeString.split(":"); if (parts.length <= 1 || parts.length > 8) { throw new CpeParsingException("CPE String is invalid - too many components specified: " + cpeString); } if (parts[1].length() != 2) { throw new CpeParsingException("CPE String contains a malformed part: " + cpeString); } try { cb.part(parts[1].substring(1)); if (parts.length > 2) { cb.wfVendor(Convert.cpeUriToWellFormed(parts[2], lenient)); } if (parts.length > 3) { cb.wfProduct(Convert.cpeUriToWellFormed(parts[3], lenient)); } if (parts.length > 4) { cb.wfVersion(Convert.cpeUriToWellFormed(parts[4], lenient)); } if (parts.length > 5) { cb.wfUpdate(Convert.cpeUriToWellFormed(parts[5], lenient)); } if (parts.length > 6) { unpackEdition(parts[6], cb, lenient); } if (parts.length > 7) { cb.wfLanguage(Convert.cpeUriToWellFormed(parts[7], lenient)); } return cb.build(); } catch (CpeValidationException | CpeEncodingException ex) { throw new CpeParsingException(ex.getMessage()); } }
[ "protected", "static", "Cpe", "parse22", "(", "String", "cpeString", ",", "boolean", "lenient", ")", "throws", "CpeParsingException", "{", "if", "(", "cpeString", "==", "null", "||", "cpeString", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "CpeParsin...
Parses a CPE 2.2 URI. @param cpeString the CPE string to parse @param lenient when <code>true</code> the parser will put in lenient mode attempting to parse invalid CPE values. @return the CPE object represented by the cpeString @throws CpeParsingException thrown if the cpeString is invalid
[ "Parses", "a", "CPE", "2", ".", "2", "URI", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/CpeParser.java#L102-L138
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/CpeParser.java
CpeParser.unpackEdition
protected static void unpackEdition(String edition, CpeBuilder cb, boolean lenient) throws CpeParsingException { if (edition == null || edition.isEmpty()) { return; } try { String[] unpacked = edition.split("~"); if (edition.startsWith("~")) { if (unpacked.length > 1) { cb.wfEdition(Convert.cpeUriToWellFormed(unpacked[1], lenient)); } if (unpacked.length > 2) { cb.wfSwEdition(Convert.cpeUriToWellFormed(unpacked[2], lenient)); } if (unpacked.length > 3) { cb.wfTargetSw(Convert.cpeUriToWellFormed(unpacked[3], lenient)); } if (unpacked.length > 4) { cb.wfTargetHw(Convert.cpeUriToWellFormed(unpacked[4], lenient)); } if (unpacked.length > 5) { cb.wfOther(Convert.cpeUriToWellFormed(unpacked[5], lenient)); } if (unpacked.length > 6) { throw new CpeParsingException("Invalid packed edition"); } } else { cb.wfEdition(Convert.cpeUriToWellFormed(edition, lenient)); } } catch (CpeEncodingException ex) { throw new CpeParsingException(ex.getMessage()); } }
java
protected static void unpackEdition(String edition, CpeBuilder cb, boolean lenient) throws CpeParsingException { if (edition == null || edition.isEmpty()) { return; } try { String[] unpacked = edition.split("~"); if (edition.startsWith("~")) { if (unpacked.length > 1) { cb.wfEdition(Convert.cpeUriToWellFormed(unpacked[1], lenient)); } if (unpacked.length > 2) { cb.wfSwEdition(Convert.cpeUriToWellFormed(unpacked[2], lenient)); } if (unpacked.length > 3) { cb.wfTargetSw(Convert.cpeUriToWellFormed(unpacked[3], lenient)); } if (unpacked.length > 4) { cb.wfTargetHw(Convert.cpeUriToWellFormed(unpacked[4], lenient)); } if (unpacked.length > 5) { cb.wfOther(Convert.cpeUriToWellFormed(unpacked[5], lenient)); } if (unpacked.length > 6) { throw new CpeParsingException("Invalid packed edition"); } } else { cb.wfEdition(Convert.cpeUriToWellFormed(edition, lenient)); } } catch (CpeEncodingException ex) { throw new CpeParsingException(ex.getMessage()); } }
[ "protected", "static", "void", "unpackEdition", "(", "String", "edition", ",", "CpeBuilder", "cb", ",", "boolean", "lenient", ")", "throws", "CpeParsingException", "{", "if", "(", "edition", "==", "null", "||", "edition", ".", "isEmpty", "(", ")", ")", "{", ...
In a CPE 2.2 URI the new fields from CPE 2.3 may be "packed" into the edition field. If present, each field will be preceeded by a '~'. Example, "~edition~swEdition~targetSw~targetHw~other". @param edition the edition string to unpack @param cb a reference to the CPE Builder to unpack the edition into @param lenient whether or not to use lenient parsing @throws CpeParsingException thrown if the edition value is invalid
[ "In", "a", "CPE", "2", ".", "2", "URI", "the", "new", "fields", "from", "CPE", "2", ".", "3", "may", "be", "packed", "into", "the", "edition", "field", ".", "If", "present", "each", "field", "will", "be", "preceeded", "by", "a", "~", ".", "Example"...
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/CpeParser.java#L150-L181
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/CpeParser.java
CpeParser.parse23
protected static Cpe parse23(String cpeString, boolean lenient) throws CpeParsingException { if (cpeString == null || cpeString.isEmpty()) { throw new CpeParsingException("CPE String is null ir enpty - unable to parse"); } CpeBuilder cb = new CpeBuilder(); Cpe23PartIterator cpe = new Cpe23PartIterator(cpeString); try { cb.part(cpe.next()); cb.wfVendor(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfProduct(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfVersion(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfUpdate(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfEdition(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfLanguage(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfSwEdition(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfTargetSw(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfTargetHw(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfOther(Convert.fsToWellFormed(cpe.next(), lenient)); } catch (NoSuchElementException ex) { throw new CpeParsingException("Invalid CPE (too few components): " + cpeString); } if (cpe.hasNext()) { throw new CpeParsingException("Invalid CPE (too many components): " + cpeString); } try { return cb.build(); } catch (CpeValidationException ex) { throw new CpeParsingException(ex.getMessage()); } }
java
protected static Cpe parse23(String cpeString, boolean lenient) throws CpeParsingException { if (cpeString == null || cpeString.isEmpty()) { throw new CpeParsingException("CPE String is null ir enpty - unable to parse"); } CpeBuilder cb = new CpeBuilder(); Cpe23PartIterator cpe = new Cpe23PartIterator(cpeString); try { cb.part(cpe.next()); cb.wfVendor(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfProduct(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfVersion(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfUpdate(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfEdition(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfLanguage(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfSwEdition(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfTargetSw(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfTargetHw(Convert.fsToWellFormed(cpe.next(), lenient)); cb.wfOther(Convert.fsToWellFormed(cpe.next(), lenient)); } catch (NoSuchElementException ex) { throw new CpeParsingException("Invalid CPE (too few components): " + cpeString); } if (cpe.hasNext()) { throw new CpeParsingException("Invalid CPE (too many components): " + cpeString); } try { return cb.build(); } catch (CpeValidationException ex) { throw new CpeParsingException(ex.getMessage()); } }
[ "protected", "static", "Cpe", "parse23", "(", "String", "cpeString", ",", "boolean", "lenient", ")", "throws", "CpeParsingException", "{", "if", "(", "cpeString", "==", "null", "||", "cpeString", ".", "isEmpty", "(", ")", ")", "{", "throw", "new", "CpeParsin...
Parses a CPE 2.3 Formatted String. @param cpeString the CPE string to parse @param lenient when <code>true</code> the parser will put in lenient mode attempting to parse invalid CPE values. @return the CPE object represented by the cpeString @throws CpeParsingException thrown if the cpeString is invalid
[ "Parses", "a", "CPE", "2", ".", "3", "Formatted", "String", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/CpeParser.java#L203-L232
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/util/Validate.java
Validate.component
public static Status component(String value) { if (value != null && !value.isEmpty()) { if ("\\-".equals(value)) { return Status.SINGLE_QUOTED_HYPHEN; } for (int x = 0; x < value.length(); x++) { char c = value.charAt(x); if (c == '?' && x > 0 && x < value.length() - 1 && !((value.charAt(x - 1) == '?' || value.charAt(x - 1) == '*' || value.charAt(x - 1) == '\\') || (x < value.length() - 1 && (value.charAt(x + 1) == '?' || value.charAt(x + 1) == '*')))) { return Status.UNQUOTED_QUESTION_MARK; } else if (Character.isWhitespace(c)) { return Status.WHITESPACE; } else if (c < 32 || c > 127) { return Status.NON_PRINTABLE; } else if (c == '*' && x != 0 && value.charAt(x - 1) == '*') { return Status.ASTERISK_SEQUENCE; } else if (c == '*' && !((x == 0 || x == value.length() - 1) || (x > 0 && '\\' == value.charAt(x - 1)))) { return Status.UNQUOTED_ASTERISK; } } return Status.VALID; } return Status.EMPTY; }
java
public static Status component(String value) { if (value != null && !value.isEmpty()) { if ("\\-".equals(value)) { return Status.SINGLE_QUOTED_HYPHEN; } for (int x = 0; x < value.length(); x++) { char c = value.charAt(x); if (c == '?' && x > 0 && x < value.length() - 1 && !((value.charAt(x - 1) == '?' || value.charAt(x - 1) == '*' || value.charAt(x - 1) == '\\') || (x < value.length() - 1 && (value.charAt(x + 1) == '?' || value.charAt(x + 1) == '*')))) { return Status.UNQUOTED_QUESTION_MARK; } else if (Character.isWhitespace(c)) { return Status.WHITESPACE; } else if (c < 32 || c > 127) { return Status.NON_PRINTABLE; } else if (c == '*' && x != 0 && value.charAt(x - 1) == '*') { return Status.ASTERISK_SEQUENCE; } else if (c == '*' && !((x == 0 || x == value.length() - 1) || (x > 0 && '\\' == value.charAt(x - 1)))) { return Status.UNQUOTED_ASTERISK; } } return Status.VALID; } return Status.EMPTY; }
[ "public", "static", "Status", "component", "(", "String", "value", ")", "{", "if", "(", "value", "!=", "null", "&&", "!", "value", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "\"\\\\-\"", ".", "equals", "(", "value", ")", ")", "{", "return", "St...
Validates the component to ensure it meets the CPE 2.3 specification of allowed values. @param value the value to validate @return the validation status given value; @see us.springett.parsers.cpe.util.Status#isValid()
[ "Validates", "the", "component", "to", "ensure", "it", "meets", "the", "CPE", "2", ".", "3", "specification", "of", "allowed", "values", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/util/Validate.java#L61-L86
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/util/Validate.java
Validate.countCharacter
private static long countCharacter(String value, char c) { return value.chars().filter(s -> s == c).count(); }
java
private static long countCharacter(String value, char c) { return value.chars().filter(s -> s == c).count(); }
[ "private", "static", "long", "countCharacter", "(", "String", "value", ",", "char", "c", ")", "{", "return", "value", ".", "chars", "(", ")", ".", "filter", "(", "s", "->", "s", "==", "c", ")", ".", "count", "(", ")", ";", "}" ]
Counts the number of times the char c is contained in the value. @param value the string to search @param c the character to count @return the number of times the char c is contained in the value
[ "Counts", "the", "number", "of", "times", "the", "char", "c", "is", "contained", "in", "the", "value", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/util/Validate.java#L358-L360
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/util/Validate.java
Validate.cpe
public static Status cpe(String value) { if ("cpe:2.3:".regionMatches(0, value, 0, 8)) { return formattedString(value); } return cpeUri(value); }
java
public static Status cpe(String value) { if ("cpe:2.3:".regionMatches(0, value, 0, 8)) { return formattedString(value); } return cpeUri(value); }
[ "public", "static", "Status", "cpe", "(", "String", "value", ")", "{", "if", "(", "\"cpe:2.3:\"", ".", "regionMatches", "(", "0", ",", "value", ",", "0", ",", "8", ")", ")", "{", "return", "formattedString", "(", "value", ")", ";", "}", "return", "cp...
Validates the given CPE string value to ensure it is either a valid CPE URI or Formatted String. @param value the CPE to validate @return the validation status given value; @see us.springett.parsers.cpe.util.Status#isValid()
[ "Validates", "the", "given", "CPE", "string", "value", "to", "ensure", "it", "is", "either", "a", "valid", "CPE", "URI", "or", "Formatted", "String", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/util/Validate.java#L370-L375
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/util/Convert.java
Convert.fromWellFormed
public static String fromWellFormed(String value) { if (value == null) { return LogicalValue.ANY.getAbbreviation(); } //return value.replaceAll("\\\\([^0-9A-Za-z])", "$1"); StringBuilder buffer = new StringBuilder(value); char p = ' '; for (int x = 0; x < buffer.length() - 1; x++) { char c = buffer.charAt(x); if (c == '\\' && p != '\\') { buffer.delete(x, x + 1); x -= 1; } p = c; } return buffer.toString(); }
java
public static String fromWellFormed(String value) { if (value == null) { return LogicalValue.ANY.getAbbreviation(); } //return value.replaceAll("\\\\([^0-9A-Za-z])", "$1"); StringBuilder buffer = new StringBuilder(value); char p = ' '; for (int x = 0; x < buffer.length() - 1; x++) { char c = buffer.charAt(x); if (c == '\\' && p != '\\') { buffer.delete(x, x + 1); x -= 1; } p = c; } return buffer.toString(); }
[ "public", "static", "String", "fromWellFormed", "(", "String", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "LogicalValue", ".", "ANY", ".", "getAbbreviation", "(", ")", ";", "}", "//return value.replaceAll(\"\\\\\\\\([^0-9A-Za-z])\", \...
Transforms the given well formed string into a non-escaped string. A well formed string has all non-alphanumeric characters escaped with a backslash. @param value the well formed string @return the string value represented by the well formed string
[ "Transforms", "the", "given", "well", "formed", "string", "into", "a", "non", "-", "escaped", "string", ".", "A", "well", "formed", "string", "has", "all", "non", "-", "alphanumeric", "characters", "escaped", "with", "a", "backslash", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/util/Convert.java#L87-L103
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/util/Convert.java
Convert.wellFormedToFS
public static String wellFormedToFS(Part value) { if (value == null) { return LogicalValue.ANY.getAbbreviation(); } return value.getAbbreviation(); }
java
public static String wellFormedToFS(Part value) { if (value == null) { return LogicalValue.ANY.getAbbreviation(); } return value.getAbbreviation(); }
[ "public", "static", "String", "wellFormedToFS", "(", "Part", "value", ")", "{", "if", "(", "value", "==", "null", ")", "{", "return", "LogicalValue", ".", "ANY", ".", "getAbbreviation", "(", ")", ";", "}", "return", "value", ".", "getAbbreviation", "(", ...
Encodes the given value into the CPE 2.3 Formatted String representation. @param value the component value to encode @return the formatted string
[ "Encodes", "the", "given", "value", "into", "the", "CPE", "2", ".", "3", "Formatted", "String", "representation", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/util/Convert.java#L251-L256
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/util/Convert.java
Convert.wellFormedToPattern
public static Pattern wellFormedToPattern(String value) { StringBuilder sb = new StringBuilder(value.length() + 4); for (int x = 0; x < value.length(); x++) { if (value.charAt(x) == '*') { sb.append(".*"); } else if (value.charAt(x) == '?') { sb.append("."); } else if (value.charAt(x) == '\\' && (x + 1) < value.length()) { sb.append('\\').append(value.charAt(x++)).append('\\').append(value.charAt(x)); } else if ((value.charAt(x) >= 'a' && value.charAt(x) <= 'z') || (value.charAt(x) >= 'A' && value.charAt(x) <= 'Z') || (value.charAt(x) >= '0' && value.charAt(x) <= '9')) { sb.append(value.charAt(x)); } else { sb.append('\\').append(value.charAt(x)); } } return Pattern.compile(sb.toString()); }
java
public static Pattern wellFormedToPattern(String value) { StringBuilder sb = new StringBuilder(value.length() + 4); for (int x = 0; x < value.length(); x++) { if (value.charAt(x) == '*') { sb.append(".*"); } else if (value.charAt(x) == '?') { sb.append("."); } else if (value.charAt(x) == '\\' && (x + 1) < value.length()) { sb.append('\\').append(value.charAt(x++)).append('\\').append(value.charAt(x)); } else if ((value.charAt(x) >= 'a' && value.charAt(x) <= 'z') || (value.charAt(x) >= 'A' && value.charAt(x) <= 'Z') || (value.charAt(x) >= '0' && value.charAt(x) <= '9')) { sb.append(value.charAt(x)); } else { sb.append('\\').append(value.charAt(x)); } } return Pattern.compile(sb.toString()); }
[ "public", "static", "Pattern", "wellFormedToPattern", "(", "String", "value", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "value", ".", "length", "(", ")", "+", "4", ")", ";", "for", "(", "int", "x", "=", "0", ";", "x", "<", "v...
Converts a well formed string into a regular expression pattern. @param value the well formed string to convert @return the generated pattern object
[ "Converts", "a", "well", "formed", "string", "into", "a", "regular", "expression", "pattern", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/util/Convert.java#L373-L391
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/Cpe.java
Cpe.validate
private void validate(String vendor1, String product1, String version1, String update1, String edition1, String language1, String swEdition1, String targetSw1, String targetHw1, String other1) throws CpeValidationException { Status status = Validate.component(vendor1); if (!status.isValid()) { throw new CpeValidationException("Invalid vendor component: " + status.getMessage()); } status = Validate.component(product1); if (!status.isValid()) { throw new CpeValidationException("Invalid product component: " + status.getMessage()); } status = Validate.component(version1); if (!status.isValid()) { throw new CpeValidationException("Invalid version component: " + status.getMessage()); } status = Validate.component(update1); if (!status.isValid()) { throw new CpeValidationException("Invalid update component: " + status.getMessage()); } status = Validate.component(edition1); if (!status.isValid()) { throw new CpeValidationException("Invalid edition component: " + status.getMessage()); } status = Validate.component(language1); if (!status.isValid()) { throw new CpeValidationException("Invalid language component: " + status.getMessage()); } status = Validate.component(swEdition1); if (!status.isValid()) { throw new CpeValidationException("Invalid swEdition component: " + status.getMessage()); } status = Validate.component(targetSw1); if (!status.isValid()) { throw new CpeValidationException("Invalid targetSw component: " + status.getMessage()); } status = Validate.component(targetHw1); if (!status.isValid()) { throw new CpeValidationException("Invalid targetHw component: " + status.getMessage()); } status = Validate.component(other1); if (!status.isValid()) { throw new CpeValidationException("Invalid other component: " + status.getMessage()); } }
java
private void validate(String vendor1, String product1, String version1, String update1, String edition1, String language1, String swEdition1, String targetSw1, String targetHw1, String other1) throws CpeValidationException { Status status = Validate.component(vendor1); if (!status.isValid()) { throw new CpeValidationException("Invalid vendor component: " + status.getMessage()); } status = Validate.component(product1); if (!status.isValid()) { throw new CpeValidationException("Invalid product component: " + status.getMessage()); } status = Validate.component(version1); if (!status.isValid()) { throw new CpeValidationException("Invalid version component: " + status.getMessage()); } status = Validate.component(update1); if (!status.isValid()) { throw new CpeValidationException("Invalid update component: " + status.getMessage()); } status = Validate.component(edition1); if (!status.isValid()) { throw new CpeValidationException("Invalid edition component: " + status.getMessage()); } status = Validate.component(language1); if (!status.isValid()) { throw new CpeValidationException("Invalid language component: " + status.getMessage()); } status = Validate.component(swEdition1); if (!status.isValid()) { throw new CpeValidationException("Invalid swEdition component: " + status.getMessage()); } status = Validate.component(targetSw1); if (!status.isValid()) { throw new CpeValidationException("Invalid targetSw component: " + status.getMessage()); } status = Validate.component(targetHw1); if (!status.isValid()) { throw new CpeValidationException("Invalid targetHw component: " + status.getMessage()); } status = Validate.component(other1); if (!status.isValid()) { throw new CpeValidationException("Invalid other component: " + status.getMessage()); } }
[ "private", "void", "validate", "(", "String", "vendor1", ",", "String", "product1", ",", "String", "version1", ",", "String", "update1", ",", "String", "edition1", ",", "String", "language1", ",", "String", "swEdition1", ",", "String", "targetSw1", ",", "Strin...
Validates the CPE attributes. @param vendor1 the vendor @param product1 the product @param version1 the version @param update1 the update version @param edition1 the edition @param language1 the language @param swEdition1 the software edition @param targetSw1 the target software @param targetHw1 the target hardware @param other1 the other attribute @throws CpeValidationException thrown if one or more of the attributes are invalid
[ "Validates", "the", "CPE", "attributes", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/Cpe.java#L151-L194
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/Cpe.java
Cpe.toCpe22Uri
@Override public String toCpe22Uri() throws CpeEncodingException { StringBuilder sb = new StringBuilder("cpe:/"); sb.append(Convert.wellFormedToCpeUri(part)).append(":"); sb.append(Convert.wellFormedToCpeUri(vendor)).append(":"); sb.append(Convert.wellFormedToCpeUri(product)).append(":"); sb.append(Convert.wellFormedToCpeUri(version)).append(":"); sb.append(Convert.wellFormedToCpeUri(update)).append(":"); //pack the extra fields from CPE 2.3 into the edition field if present //when outputing to 2.2 format if (!((swEdition.isEmpty() || "*".equals(swEdition)) && (targetSw.isEmpty() || "*".equals(targetSw)) && (targetHw.isEmpty() || "*".equals(targetHw)) && (other.isEmpty() || "*".equals(other)))) { sb.append("~") .append(Convert.wellFormedToCpeUri(edition)) .append("~") .append(Convert.wellFormedToCpeUri(swEdition)) .append("~") .append(Convert.wellFormedToCpeUri(targetSw)) .append("~") .append(Convert.wellFormedToCpeUri(targetHw)) .append("~") .append(Convert.wellFormedToCpeUri(other)) .append(":"); } else { sb.append(Convert.wellFormedToCpeUri(edition)).append(":"); } sb.append(Convert.wellFormedToCpeUri(language)); return sb.toString().replaceAll("[:]*$", ""); }
java
@Override public String toCpe22Uri() throws CpeEncodingException { StringBuilder sb = new StringBuilder("cpe:/"); sb.append(Convert.wellFormedToCpeUri(part)).append(":"); sb.append(Convert.wellFormedToCpeUri(vendor)).append(":"); sb.append(Convert.wellFormedToCpeUri(product)).append(":"); sb.append(Convert.wellFormedToCpeUri(version)).append(":"); sb.append(Convert.wellFormedToCpeUri(update)).append(":"); //pack the extra fields from CPE 2.3 into the edition field if present //when outputing to 2.2 format if (!((swEdition.isEmpty() || "*".equals(swEdition)) && (targetSw.isEmpty() || "*".equals(targetSw)) && (targetHw.isEmpty() || "*".equals(targetHw)) && (other.isEmpty() || "*".equals(other)))) { sb.append("~") .append(Convert.wellFormedToCpeUri(edition)) .append("~") .append(Convert.wellFormedToCpeUri(swEdition)) .append("~") .append(Convert.wellFormedToCpeUri(targetSw)) .append("~") .append(Convert.wellFormedToCpeUri(targetHw)) .append("~") .append(Convert.wellFormedToCpeUri(other)) .append(":"); } else { sb.append(Convert.wellFormedToCpeUri(edition)).append(":"); } sb.append(Convert.wellFormedToCpeUri(language)); return sb.toString().replaceAll("[:]*$", ""); }
[ "@", "Override", "public", "String", "toCpe22Uri", "(", ")", "throws", "CpeEncodingException", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"cpe:/\"", ")", ";", "sb", ".", "append", "(", "Convert", ".", "wellFormedToCpeUri", "(", "part", ")"...
Converts the CPE into the CPE 2.2 URI format. @return the CPE 2.2 URI format of the CPE @throws CpeEncodingException thrown if the CPE is not well formed
[ "Converts", "the", "CPE", "into", "the", "CPE", "2", ".", "2", "URI", "format", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/Cpe.java#L456-L486
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/Cpe.java
Cpe.toCpe23FS
@Override public String toCpe23FS() { return String.format("cpe:2.3:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s", Convert.wellFormedToFS(part), Convert.wellFormedToFS(vendor), Convert.wellFormedToFS(product), Convert.wellFormedToFS(version), Convert.wellFormedToFS(update), Convert.wellFormedToFS(edition), Convert.wellFormedToFS(language), Convert.wellFormedToFS(swEdition), Convert.wellFormedToFS(targetSw), Convert.wellFormedToFS(targetHw), Convert.wellFormedToFS(other)); }
java
@Override public String toCpe23FS() { return String.format("cpe:2.3:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s", Convert.wellFormedToFS(part), Convert.wellFormedToFS(vendor), Convert.wellFormedToFS(product), Convert.wellFormedToFS(version), Convert.wellFormedToFS(update), Convert.wellFormedToFS(edition), Convert.wellFormedToFS(language), Convert.wellFormedToFS(swEdition), Convert.wellFormedToFS(targetSw), Convert.wellFormedToFS(targetHw), Convert.wellFormedToFS(other)); }
[ "@", "Override", "public", "String", "toCpe23FS", "(", ")", "{", "return", "String", ".", "format", "(", "\"cpe:2.3:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\"", ",", "Convert", ".", "wellFormedToFS", "(", "part", ")", ",", "Convert", ".", "wellFormedToFS", "(", "vendor", ...
Converts the CPE into the CPE 2.3 Formatted String. @return the CPE 2.3 Formatted String
[ "Converts", "the", "CPE", "into", "the", "CPE", "2", ".", "3", "Formatted", "String", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/Cpe.java#L493-L507
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/Cpe.java
Cpe.matches
@Override public boolean matches(ICpe target) { boolean result = true; result &= compareAttributes(this.part, target.getPart()); result &= compareAttributes(this.vendor, target.getWellFormedVendor()); result &= compareAttributes(this.product, target.getWellFormedProduct()); result &= compareAttributes(this.version, target.getWellFormedVersion()); result &= compareAttributes(this.update, target.getWellFormedUpdate()); result &= compareAttributes(this.edition, target.getWellFormedEdition()); result &= compareAttributes(this.language, target.getWellFormedLanguage()); result &= compareAttributes(this.swEdition, target.getWellFormedSwEdition()); result &= compareAttributes(this.targetSw, target.getWellFormedTargetSw()); result &= compareAttributes(this.targetHw, target.getWellFormedTargetHw()); result &= compareAttributes(this.other, target.getWellFormedOther()); return result; }
java
@Override public boolean matches(ICpe target) { boolean result = true; result &= compareAttributes(this.part, target.getPart()); result &= compareAttributes(this.vendor, target.getWellFormedVendor()); result &= compareAttributes(this.product, target.getWellFormedProduct()); result &= compareAttributes(this.version, target.getWellFormedVersion()); result &= compareAttributes(this.update, target.getWellFormedUpdate()); result &= compareAttributes(this.edition, target.getWellFormedEdition()); result &= compareAttributes(this.language, target.getWellFormedLanguage()); result &= compareAttributes(this.swEdition, target.getWellFormedSwEdition()); result &= compareAttributes(this.targetSw, target.getWellFormedTargetSw()); result &= compareAttributes(this.targetHw, target.getWellFormedTargetHw()); result &= compareAttributes(this.other, target.getWellFormedOther()); return result; }
[ "@", "Override", "public", "boolean", "matches", "(", "ICpe", "target", ")", "{", "boolean", "result", "=", "true", ";", "result", "&=", "compareAttributes", "(", "this", ".", "part", ",", "target", ".", "getPart", "(", ")", ")", ";", "result", "&=", "...
Determines if the CPE matches the given target CPE. This does not follow the CPE 2.3 Specification exactly as there are cases where undefined comparisons will result in either true or false. For instance, 'ANY' will match 'm+wild cards' and NA will return false when the target has 'm+wild cards'. @param target the target CPE to evaluate @return <code>true</code> if the CPE matches the target; otherwise <code>false</code>
[ "Determines", "if", "the", "CPE", "matches", "the", "given", "target", "CPE", ".", "This", "does", "not", "follow", "the", "CPE", "2", ".", "3", "Specification", "exactly", "as", "there", "are", "cases", "where", "undefined", "comparisons", "will", "result",...
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/Cpe.java#L537-L552
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/Cpe.java
Cpe.containsSpecialCharacter
private static boolean containsSpecialCharacter(String value) { for (int x = 0; x < value.length(); x++) { char c = value.charAt(x); if (c == '?' || c == '*') { return true; } else if (c == '\\') { //skip the next character because it is quoted x += 1; } } return false; }
java
private static boolean containsSpecialCharacter(String value) { for (int x = 0; x < value.length(); x++) { char c = value.charAt(x); if (c == '?' || c == '*') { return true; } else if (c == '\\') { //skip the next character because it is quoted x += 1; } } return false; }
[ "private", "static", "boolean", "containsSpecialCharacter", "(", "String", "value", ")", "{", "for", "(", "int", "x", "=", "0", ";", "x", "<", "value", ".", "length", "(", ")", ";", "x", "++", ")", "{", "char", "c", "=", "value", ".", "charAt", "("...
Determines if the string has an unquoted special character. @param value the string to check @return <code>true</code> if the string contains an unquoted special character; otherwise <code>false</code>
[ "Determines", "if", "the", "string", "has", "an", "unquoted", "special", "character", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/Cpe.java#L644-L655
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/Cpe.java
Cpe.compareTo
@Override public int compareTo(Object o) { if (o instanceof ICpe) { ICpe otherObject = (ICpe) o; final int before = -1; final int equal = 0; final int after = 1; if (this == otherObject) { return equal; } int r = getPart().getAbbreviation().compareTo(otherObject.getPart().getAbbreviation()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getVendor().compareTo(otherObject.getVendor()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getProduct().compareTo(otherObject.getProduct()); if (r < 0) { return before; } else if (r > 0) { return after; } r = compareVersions(getVersion(), otherObject.getVersion()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getUpdate().compareTo(otherObject.getUpdate()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getEdition().compareTo(otherObject.getEdition()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getLanguage().compareTo(otherObject.getLanguage()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getSwEdition().compareTo(otherObject.getSwEdition()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getTargetSw().compareTo(otherObject.getTargetSw()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getTargetHw().compareTo(otherObject.getTargetHw()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getOther().compareTo(otherObject.getOther()); if (r < 0) { return before; } else if (r > 0) { return after; } return equal; } throw new RuntimeException("Unable to compare " + o.getClass().getCanonicalName()); }
java
@Override public int compareTo(Object o) { if (o instanceof ICpe) { ICpe otherObject = (ICpe) o; final int before = -1; final int equal = 0; final int after = 1; if (this == otherObject) { return equal; } int r = getPart().getAbbreviation().compareTo(otherObject.getPart().getAbbreviation()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getVendor().compareTo(otherObject.getVendor()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getProduct().compareTo(otherObject.getProduct()); if (r < 0) { return before; } else if (r > 0) { return after; } r = compareVersions(getVersion(), otherObject.getVersion()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getUpdate().compareTo(otherObject.getUpdate()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getEdition().compareTo(otherObject.getEdition()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getLanguage().compareTo(otherObject.getLanguage()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getSwEdition().compareTo(otherObject.getSwEdition()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getTargetSw().compareTo(otherObject.getTargetSw()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getTargetHw().compareTo(otherObject.getTargetHw()); if (r < 0) { return before; } else if (r > 0) { return after; } r = getOther().compareTo(otherObject.getOther()); if (r < 0) { return before; } else if (r > 0) { return after; } return equal; } throw new RuntimeException("Unable to compare " + o.getClass().getCanonicalName()); }
[ "@", "Override", "public", "int", "compareTo", "(", "Object", "o", ")", "{", "if", "(", "o", "instanceof", "ICpe", ")", "{", "ICpe", "otherObject", "=", "(", "ICpe", ")", "o", ";", "final", "int", "before", "=", "-", "1", ";", "final", "int", "equa...
CompareTo is used for sorting, this does not implement any CPE Matching rules. @param o the CPE to compare @return the sort order
[ "CompareTo", "is", "used", "for", "sorting", "this", "does", "not", "implement", "any", "CPE", "Matching", "rules", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/Cpe.java#L717-L798
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/Cpe.java
Cpe.compareVersions
protected static int compareVersions(String left, String right) { int result = 0; //while the strings are well formed - the backslashes will be in the exact //same location in equal strings - for version numbers the cost of conversion //should not be incurred //final List<String> subLeft = splitVersion(Convert.fromWellFormed(left)); //final List<String> subRight = splitVersion(Convert.fromWellFormed(right)); final List<String> subLeft = splitVersion(left); final List<String> subRight = splitVersion(right); final int subMax = (subLeft.size() <= subRight.size()) ? subLeft.size() : subRight.size(); for (int x = 0; result == 0 && x < subMax; x++) { if (isPositiveInteger(subLeft.get(x)) && isPositiveInteger(subRight.get(x))) { try { result = Long.valueOf(subLeft.get(x)).compareTo(Long.valueOf(subRight.get(x))); } catch (NumberFormatException ex) { //infeasible path - unless one of the values is larger then a long? if (!subLeft.get(x).equalsIgnoreCase(subRight.get(x))) { result = subLeft.get(x).compareTo(subRight.get(x)); } } } else { result = subLeft.get(x).compareTo(subRight.get(x)); } if (result != 0) { return result; } } if (subLeft.size() > subRight.size()) { result = 1; } if (subRight.size() > subLeft.size()) { result = -1; } return result; }
java
protected static int compareVersions(String left, String right) { int result = 0; //while the strings are well formed - the backslashes will be in the exact //same location in equal strings - for version numbers the cost of conversion //should not be incurred //final List<String> subLeft = splitVersion(Convert.fromWellFormed(left)); //final List<String> subRight = splitVersion(Convert.fromWellFormed(right)); final List<String> subLeft = splitVersion(left); final List<String> subRight = splitVersion(right); final int subMax = (subLeft.size() <= subRight.size()) ? subLeft.size() : subRight.size(); for (int x = 0; result == 0 && x < subMax; x++) { if (isPositiveInteger(subLeft.get(x)) && isPositiveInteger(subRight.get(x))) { try { result = Long.valueOf(subLeft.get(x)).compareTo(Long.valueOf(subRight.get(x))); } catch (NumberFormatException ex) { //infeasible path - unless one of the values is larger then a long? if (!subLeft.get(x).equalsIgnoreCase(subRight.get(x))) { result = subLeft.get(x).compareTo(subRight.get(x)); } } } else { result = subLeft.get(x).compareTo(subRight.get(x)); } if (result != 0) { return result; } } if (subLeft.size() > subRight.size()) { result = 1; } if (subRight.size() > subLeft.size()) { result = -1; } return result; }
[ "protected", "static", "int", "compareVersions", "(", "String", "left", ",", "String", "right", ")", "{", "int", "result", "=", "0", ";", "//while the strings are well formed - the backslashes will be in the exact", "//same location in equal strings - for version numbers the cost...
Compare version numbers to obtain the correct ordering. @param left the left hand version for comparison @param right the right hand version for comparison @return <code>-1</code> if left is before the right; <code>0</code> if the left and right are equal;<code>1</code> if left is after the right
[ "Compare", "version", "numbers", "to", "obtain", "the", "correct", "ordering", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/Cpe.java#L808-L844
train
stevespringett/CPE-Parser
src/main/java/us/springett/parsers/cpe/CpeBuilder.java
CpeBuilder.reset
protected void reset() { part = Part.ANY; vendor = LogicalValue.ANY.getAbbreviation(); product = LogicalValue.ANY.getAbbreviation(); version = LogicalValue.ANY.getAbbreviation(); update = LogicalValue.ANY.getAbbreviation(); edition = LogicalValue.ANY.getAbbreviation(); language = LogicalValue.ANY.getAbbreviation(); swEdition = LogicalValue.ANY.getAbbreviation(); targetSw = LogicalValue.ANY.getAbbreviation(); targetHw = LogicalValue.ANY.getAbbreviation(); other = LogicalValue.ANY.getAbbreviation(); }
java
protected void reset() { part = Part.ANY; vendor = LogicalValue.ANY.getAbbreviation(); product = LogicalValue.ANY.getAbbreviation(); version = LogicalValue.ANY.getAbbreviation(); update = LogicalValue.ANY.getAbbreviation(); edition = LogicalValue.ANY.getAbbreviation(); language = LogicalValue.ANY.getAbbreviation(); swEdition = LogicalValue.ANY.getAbbreviation(); targetSw = LogicalValue.ANY.getAbbreviation(); targetHw = LogicalValue.ANY.getAbbreviation(); other = LogicalValue.ANY.getAbbreviation(); }
[ "protected", "void", "reset", "(", ")", "{", "part", "=", "Part", ".", "ANY", ";", "vendor", "=", "LogicalValue", ".", "ANY", ".", "getAbbreviation", "(", ")", ";", "product", "=", "LogicalValue", ".", "ANY", ".", "getAbbreviation", "(", ")", ";", "ver...
Resets the CPE Builder to a clean state.
[ "Resets", "the", "CPE", "Builder", "to", "a", "clean", "state", "." ]
e6324ca020dc0790097d3d62bb98aabf60e56843
https://github.com/stevespringett/CPE-Parser/blob/e6324ca020dc0790097d3d62bb98aabf60e56843/src/main/java/us/springett/parsers/cpe/CpeBuilder.java#L81-L93
train
gtri/bk-tree
src/main/java/edu/gatech/gtri/bktree/MutableBkTree.java
MutableBkTree.add
public void add(E element) { if (element == null) throw new NullPointerException(); if (root == null) { root = new MutableNode<>(element); } else { MutableNode<E> node = root; while (!node.getElement().equals(element)) { int distance = distance(node.getElement(), element); MutableNode<E> parent = node; node = parent.childrenByDistance.get(distance); if (node == null) { node = new MutableNode<>(element); parent.childrenByDistance.put(distance, node); break; } } } }
java
public void add(E element) { if (element == null) throw new NullPointerException(); if (root == null) { root = new MutableNode<>(element); } else { MutableNode<E> node = root; while (!node.getElement().equals(element)) { int distance = distance(node.getElement(), element); MutableNode<E> parent = node; node = parent.childrenByDistance.get(distance); if (node == null) { node = new MutableNode<>(element); parent.childrenByDistance.put(distance, node); break; } } } }
[ "public", "void", "add", "(", "E", "element", ")", "{", "if", "(", "element", "==", "null", ")", "throw", "new", "NullPointerException", "(", ")", ";", "if", "(", "root", "==", "null", ")", "{", "root", "=", "new", "MutableNode", "<>", "(", "element"...
Adds the given element to this tree, if it's not already present. @param element element
[ "Adds", "the", "given", "element", "to", "this", "tree", "if", "it", "s", "not", "already", "present", "." ]
fed9d01a85d63a8bb548995b5a455e784ed8b28d
https://github.com/gtri/bk-tree/blob/fed9d01a85d63a8bb548995b5a455e784ed8b28d/src/main/java/edu/gatech/gtri/bktree/MutableBkTree.java#L55-L74
train
gtri/bk-tree
src/main/java/edu/gatech/gtri/bktree/BkTreeSearcher.java
BkTreeSearcher.search
public Set<Match<? extends E>> search(E query, int maxDistance) { if (query == null) throw new NullPointerException(); if (maxDistance < 0) throw new IllegalArgumentException("maxDistance must be non-negative"); Metric<? super E> metric = tree.getMetric(); Set<Match<? extends E>> matches = new HashSet<>(); Queue<Node<E>> queue = new ArrayDeque<>(); queue.add(tree.getRoot()); while (!queue.isEmpty()) { Node<E> node = queue.remove(); E element = node.getElement(); int distance = metric.distance(element, query); if (distance < 0) { throw new IllegalMetricException( format("negative distance (%d) defined between element `%s` and query `%s`", distance, element, query)); } if (distance <= maxDistance) { matches.add(new Match<>(element, distance)); } int minSearchDistance = max(distance - maxDistance, 0); int maxSearchDistance = distance + maxDistance; for (int searchDistance = minSearchDistance; searchDistance <= maxSearchDistance; ++searchDistance) { Node<E> childNode = node.getChildNode(searchDistance); if (childNode != null) { queue.add(childNode); } } } return matches; }
java
public Set<Match<? extends E>> search(E query, int maxDistance) { if (query == null) throw new NullPointerException(); if (maxDistance < 0) throw new IllegalArgumentException("maxDistance must be non-negative"); Metric<? super E> metric = tree.getMetric(); Set<Match<? extends E>> matches = new HashSet<>(); Queue<Node<E>> queue = new ArrayDeque<>(); queue.add(tree.getRoot()); while (!queue.isEmpty()) { Node<E> node = queue.remove(); E element = node.getElement(); int distance = metric.distance(element, query); if (distance < 0) { throw new IllegalMetricException( format("negative distance (%d) defined between element `%s` and query `%s`", distance, element, query)); } if (distance <= maxDistance) { matches.add(new Match<>(element, distance)); } int minSearchDistance = max(distance - maxDistance, 0); int maxSearchDistance = distance + maxDistance; for (int searchDistance = minSearchDistance; searchDistance <= maxSearchDistance; ++searchDistance) { Node<E> childNode = node.getChildNode(searchDistance); if (childNode != null) { queue.add(childNode); } } } return matches; }
[ "public", "Set", "<", "Match", "<", "?", "extends", "E", ">", ">", "search", "(", "E", "query", ",", "int", "maxDistance", ")", "{", "if", "(", "query", "==", "null", ")", "throw", "new", "NullPointerException", "(", ")", ";", "if", "(", "maxDistance...
Searches the tree for elements whose distance from the given query is less than or equal to the given maximum distance. @param query query against which to match tree elements @param maxDistance non-negative maximum distance of matching elements from query @return matching elements in no particular order
[ "Searches", "the", "tree", "for", "elements", "whose", "distance", "from", "the", "given", "query", "is", "less", "than", "or", "equal", "to", "the", "given", "maximum", "distance", "." ]
fed9d01a85d63a8bb548995b5a455e784ed8b28d
https://github.com/gtri/bk-tree/blob/fed9d01a85d63a8bb548995b5a455e784ed8b28d/src/main/java/edu/gatech/gtri/bktree/BkTreeSearcher.java#L56-L94
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/LoggingJBossASClient.java
LoggingJBossASClient.isLogger
public boolean isLogger(String loggerName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, LOGGING, LOGGER, loggerName); return null != readResource(addr); }
java
public boolean isLogger(String loggerName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, LOGGING, LOGGER, loggerName); return null != readResource(addr); }
[ "public", "boolean", "isLogger", "(", "String", "loggerName", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "LOGGING", ",", "LOGGER", ",", "loggerName", ")", ";", "return", "...
Checks to see if there is already a logger with the given name. @param loggerName the name to check (this is also known as the category name) @return true if there is a logger/category with the given name already in existence @throws Exception any error
[ "Checks", "to", "see", "if", "there", "is", "already", "a", "logger", "with", "the", "given", "name", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/LoggingJBossASClient.java#L44-L47
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/LoggingJBossASClient.java
LoggingJBossASClient.getLoggerLevel
public String getLoggerLevel(String loggerName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, LOGGING, LOGGER, loggerName); return getStringAttribute("level", addr); }
java
public String getLoggerLevel(String loggerName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, LOGGING, LOGGER, loggerName); return getStringAttribute("level", addr); }
[ "public", "String", "getLoggerLevel", "(", "String", "loggerName", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "LOGGING", ",", "LOGGER", ",", "loggerName", ")", ";", "return"...
Returns the level of the given logger. @param loggerName the name of the logger (this is also known as the category name) @return level of the logger @throws Exception if the log level could not be obtained (typically because the logger doesn't exist)
[ "Returns", "the", "level", "of", "the", "given", "logger", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/LoggingJBossASClient.java#L56-L59
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/LoggingJBossASClient.java
LoggingJBossASClient.setLoggerLevel
public void setLoggerLevel(String loggerName, String level) throws Exception { final Address addr = Address.root().add(SUBSYSTEM, LOGGING, LOGGER, loggerName); final ModelNode request; if (isLogger(loggerName)) { request = createWriteAttributeRequest("level", level, addr); } else { final String dmrTemplate = "" // + "{" // + "\"category\" => \"%s\" " // + ", \"level\" => \"%s\" " // + ", \"use-parent-handlers\" => \"true\" " // + "}"; final String dmr = String.format(dmrTemplate, loggerName, level); request = ModelNode.fromString(dmr); request.get(OPERATION).set(ADD); request.get(ADDRESS).set(addr.getAddressNode()); } final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response); } return; }
java
public void setLoggerLevel(String loggerName, String level) throws Exception { final Address addr = Address.root().add(SUBSYSTEM, LOGGING, LOGGER, loggerName); final ModelNode request; if (isLogger(loggerName)) { request = createWriteAttributeRequest("level", level, addr); } else { final String dmrTemplate = "" // + "{" // + "\"category\" => \"%s\" " // + ", \"level\" => \"%s\" " // + ", \"use-parent-handlers\" => \"true\" " // + "}"; final String dmr = String.format(dmrTemplate, loggerName, level); request = ModelNode.fromString(dmr); request.get(OPERATION).set(ADD); request.get(ADDRESS).set(addr.getAddressNode()); } final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response); } return; }
[ "public", "void", "setLoggerLevel", "(", "String", "loggerName", ",", "String", "level", ")", "throws", "Exception", "{", "final", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "LOGGING", ",", "LOGGER", ",", ...
Sets the logger to the given level. If the logger does not exist yet, it will be created. @param loggerName the logger name (this is also known as the category name) @param level the new level of the logger (e.g. DEBUG, INFO, ERROR, etc.) @throws Exception any error
[ "Sets", "the", "logger", "to", "the", "given", "level", ".", "If", "the", "logger", "does", "not", "exist", "yet", "it", "will", "be", "created", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/LoggingJBossASClient.java#L69-L95
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java
WebJBossASClient.isWebSubsystem
public boolean isWebSubsystem() throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB); return null != readResource(addr); }
java
public boolean isWebSubsystem() throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB); return null != readResource(addr); }
[ "public", "boolean", "isWebSubsystem", "(", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_WEB", ")", ";", "return", "null", "!=", "readResource", "(", "addr", ")", ...
Checks to see if the web subsystem exists. This should always exist unless the server is just starting up and its web subsystem has not even initialized yet. @return true if the web subsystem is ready @throws Exception any error
[ "Checks", "to", "see", "if", "the", "web", "subsystem", "exists", ".", "This", "should", "always", "exist", "unless", "the", "server", "is", "just", "starting", "up", "and", "its", "web", "subsystem", "has", "not", "even", "initialized", "yet", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java#L46-L49
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java
WebJBossASClient.setEnableWelcomeRoot
public void setEnableWelcomeRoot(boolean enableFlag) throws Exception { final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, VIRTUAL_SERVER, DEFAULT_HOST); final ModelNode req = createWriteAttributeRequest("enable-welcome-root", Boolean.toString(enableFlag), address); final ModelNode response = execute(req); if (!isSuccess(response)) { throw new FailureException(response); } return; }
java
public void setEnableWelcomeRoot(boolean enableFlag) throws Exception { final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, VIRTUAL_SERVER, DEFAULT_HOST); final ModelNode req = createWriteAttributeRequest("enable-welcome-root", Boolean.toString(enableFlag), address); final ModelNode response = execute(req); if (!isSuccess(response)) { throw new FailureException(response); } return; }
[ "public", "void", "setEnableWelcomeRoot", "(", "boolean", "enableFlag", ")", "throws", "Exception", "{", "final", "Address", "address", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_WEB", ",", "VIRTUAL_SERVER", ",", "DEFA...
The enable-welcome-root setting controls whether or not to deploy JBoss' welcome-content application at root context. If you want to deploy your own app at the root context, you need to disable the enable-welcome-root setting on the default host virtual server. If you want to show the JBoss' welcome screen, you need to enable this setting. @param enableFlag true if the welcome screen at the root context should be enabled; false otherwise @throws Exception any error
[ "The", "enable", "-", "welcome", "-", "root", "setting", "controls", "whether", "or", "not", "to", "deploy", "JBoss", "welcome", "-", "content", "application", "at", "root", "context", ".", "If", "you", "want", "to", "deploy", "your", "own", "app", "at", ...
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java#L61-L69
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java
WebJBossASClient.isConnector
public boolean isConnector(String name) throws Exception { final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, CONNECTOR, name); return null != readResource(address); }
java
public boolean isConnector(String name) throws Exception { final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, CONNECTOR, name); return null != readResource(address); }
[ "public", "boolean", "isConnector", "(", "String", "name", ")", "throws", "Exception", "{", "final", "Address", "address", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_WEB", ",", "CONNECTOR", ",", "name", ")", ";", ...
Checks to see if there is already a connector with the given name. @param name the name to check @return true if there is a connector with the given name already in existence @throws Exception any error
[ "Checks", "to", "see", "if", "there", "is", "already", "a", "connector", "with", "the", "given", "name", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java#L78-L81
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java
WebJBossASClient.getConnector
public ModelNode getConnector(String name) throws Exception { final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, CONNECTOR, name); return readResource(address, true); }
java
public ModelNode getConnector(String name) throws Exception { final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, CONNECTOR, name); return readResource(address, true); }
[ "public", "ModelNode", "getConnector", "(", "String", "name", ")", "throws", "Exception", "{", "final", "Address", "address", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_WEB", ",", "CONNECTOR", ",", "name", ")", ";"...
Returns the connector node with all its attributes. Will be null if it doesn't exist. @param name the name of the connector whose node is to be returned @return the node if there is a connector with the given name already in existence, null otherwise @throws Exception any error
[ "Returns", "the", "connector", "node", "with", "all", "its", "attributes", ".", "Will", "be", "null", "if", "it", "doesn", "t", "exist", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java#L90-L93
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java
WebJBossASClient.changeConnector
public void changeConnector(String connectorName, String attribName, String attribValue) throws Exception { final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, CONNECTOR, connectorName); final ModelNode op = createWriteAttributeRequest(attribName, attribValue, address); final ModelNode response = execute(op); if (!isSuccess(response)) { throw new FailureException(response); } return; }
java
public void changeConnector(String connectorName, String attribName, String attribValue) throws Exception { final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, CONNECTOR, connectorName); final ModelNode op = createWriteAttributeRequest(attribName, attribValue, address); final ModelNode response = execute(op); if (!isSuccess(response)) { throw new FailureException(response); } return; }
[ "public", "void", "changeConnector", "(", "String", "connectorName", ",", "String", "attribName", ",", "String", "attribValue", ")", "throws", "Exception", "{", "final", "Address", "address", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM",...
Use this to modify an attribute for an existing connector. @param connectorName the existing connector whose attribute is to be changed @param attribName the attribute to get a new value @param attribValue the new value of the attribute @throws Exception if failed to change the attribute on the named connector
[ "Use", "this", "to", "modify", "an", "attribute", "for", "an", "existing", "connector", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java#L102-L110
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java
WebJBossASClient.removeConnector
public void removeConnector(String doomedConnectorName) throws Exception { final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, CONNECTOR, doomedConnectorName); if (isConnector(doomedConnectorName)) { remove(address); } return; }
java
public void removeConnector(String doomedConnectorName) throws Exception { final Address address = Address.root().add(SUBSYSTEM, SUBSYSTEM_WEB, CONNECTOR, doomedConnectorName); if (isConnector(doomedConnectorName)) { remove(address); } return; }
[ "public", "void", "removeConnector", "(", "String", "doomedConnectorName", ")", "throws", "Exception", "{", "final", "Address", "address", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_WEB", ",", "CONNECTOR", ",", "doomed...
Removes the given web connector. @param doomedConnectorName the name of the web connector to remove. @throws Exception any error
[ "Removes", "the", "given", "web", "connector", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/WebJBossASClient.java#L118-L124
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java
JBossASClient.createWriteAttributeRequest
public static ModelNode createWriteAttributeRequest(String attributeName, String attributeValue, Address address) { final ModelNode op = createRequest(WRITE_ATTRIBUTE, address); op.get(NAME).set(attributeName); setPossibleExpression(op, VALUE, attributeValue); return op; }
java
public static ModelNode createWriteAttributeRequest(String attributeName, String attributeValue, Address address) { final ModelNode op = createRequest(WRITE_ATTRIBUTE, address); op.get(NAME).set(attributeName); setPossibleExpression(op, VALUE, attributeValue); return op; }
[ "public", "static", "ModelNode", "createWriteAttributeRequest", "(", "String", "attributeName", ",", "String", "attributeValue", ",", "Address", "address", ")", "{", "final", "ModelNode", "op", "=", "createRequest", "(", "WRITE_ATTRIBUTE", ",", "address", ")", ";", ...
Convienence method that allows you to create request that writes a single attribute's string value to a resource. @param attributeName the name of the attribute whose value is to be written @param attributeValue the attribute value that is to be written @param address identifies the resource @return the request
[ "Convienence", "method", "that", "allows", "you", "to", "create", "request", "that", "writes", "a", "single", "attribute", "s", "string", "value", "to", "a", "resource", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java#L111-L116
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java
JBossASClient.createRequest
public static ModelNode createRequest(String operation, Address address) { return createRequest(operation, address, null); }
java
public static ModelNode createRequest(String operation, Address address) { return createRequest(operation, address, null); }
[ "public", "static", "ModelNode", "createRequest", "(", "String", "operation", ",", "Address", "address", ")", "{", "return", "createRequest", "(", "operation", ",", "address", ",", "null", ")", ";", "}" ]
Convienence method that builds a partial operation request node. @param operation the operation to be requested @param address identifies the target resource @return the partial operation request node - caller should fill this in further to complete the node
[ "Convienence", "method", "that", "builds", "a", "partial", "operation", "request", "node", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java#L125-L127
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java
JBossASClient.createRequest
public static ModelNode createRequest(String operation, Address address, ModelNode extra) { final ModelNode request = (extra != null) ? extra.clone() : new ModelNode(); request.get(OPERATION).set(operation); request.get(ADDRESS).set(address.getAddressNode()); return request; }
java
public static ModelNode createRequest(String operation, Address address, ModelNode extra) { final ModelNode request = (extra != null) ? extra.clone() : new ModelNode(); request.get(OPERATION).set(operation); request.get(ADDRESS).set(address.getAddressNode()); return request; }
[ "public", "static", "ModelNode", "createRequest", "(", "String", "operation", ",", "Address", "address", ",", "ModelNode", "extra", ")", "{", "final", "ModelNode", "request", "=", "(", "extra", "!=", "null", ")", "?", "extra", ".", "clone", "(", ")", ":", ...
Convienence method that builds a partial operation request node, with additional node properties supplied by the given node. @param operation the operation to be requested @param address identifies the target resource @param extra provides additional properties to add to the returned request node. @return the partial operation request node - caller can fill this in further to complete the node
[ "Convienence", "method", "that", "builds", "a", "partial", "operation", "request", "node", "with", "additional", "node", "properties", "supplied", "by", "the", "given", "node", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java#L138-L143
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java
JBossASClient.createBatchRequest
public static ModelNode createBatchRequest(ModelNode... steps) { final ModelNode composite = new ModelNode(); composite.get(OPERATION).set(BATCH); composite.get(ADDRESS).setEmptyList(); final ModelNode stepsNode = composite.get(BATCH_STEPS); for (ModelNode step : steps) { if (step != null) { stepsNode.add(step); } } return composite; }
java
public static ModelNode createBatchRequest(ModelNode... steps) { final ModelNode composite = new ModelNode(); composite.get(OPERATION).set(BATCH); composite.get(ADDRESS).setEmptyList(); final ModelNode stepsNode = composite.get(BATCH_STEPS); for (ModelNode step : steps) { if (step != null) { stepsNode.add(step); } } return composite; }
[ "public", "static", "ModelNode", "createBatchRequest", "(", "ModelNode", "...", "steps", ")", "{", "final", "ModelNode", "composite", "=", "new", "ModelNode", "(", ")", ";", "composite", ".", "get", "(", "OPERATION", ")", ".", "set", "(", "BATCH", ")", ";"...
Creates a batch of operations that can be atomically invoked. @param steps the different operation steps of the batch @return the batch operation node
[ "Creates", "a", "batch", "of", "operations", "that", "can", "be", "atomically", "invoked", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java#L152-L163
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java
JBossASClient.getResults
public static ModelNode getResults(ModelNode operationResult) { if (!operationResult.hasDefined(RESULT)) { return new ModelNode(); } return operationResult.get(RESULT); }
java
public static ModelNode getResults(ModelNode operationResult) { if (!operationResult.hasDefined(RESULT)) { return new ModelNode(); } return operationResult.get(RESULT); }
[ "public", "static", "ModelNode", "getResults", "(", "ModelNode", "operationResult", ")", "{", "if", "(", "!", "operationResult", ".", "hasDefined", "(", "RESULT", ")", ")", "{", "return", "new", "ModelNode", "(", ")", ";", "}", "return", "operationResult", "...
If the given node has results, those results are returned in a ModelNode. Otherwise, an empty node is returned. @param operationResult the node to examine @return the results as a ModelNode
[ "If", "the", "given", "node", "has", "results", "those", "results", "are", "returned", "in", "a", "ModelNode", ".", "Otherwise", "an", "empty", "node", "is", "returned", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java#L197-L203
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java
JBossASClient.execute
public ModelNode execute(ModelNode request) throws Exception { ModelControllerClient mcc = getModelControllerClient(); return mcc.execute(request, OperationMessageHandler.logging); }
java
public ModelNode execute(ModelNode request) throws Exception { ModelControllerClient mcc = getModelControllerClient(); return mcc.execute(request, OperationMessageHandler.logging); }
[ "public", "ModelNode", "execute", "(", "ModelNode", "request", ")", "throws", "Exception", "{", "ModelControllerClient", "mcc", "=", "getModelControllerClient", "(", ")", ";", "return", "mcc", ".", "execute", "(", "request", ",", "OperationMessageHandler", ".", "l...
Convienence method that executes the request. @param request request to execute @return results results of execution @throws Exception any error
[ "Convienence", "method", "that", "executes", "the", "request", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java#L282-L285
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java
JBossASClient.remove
public void remove(Address doomedAddr) throws Exception { final ModelNode request = createRequest(REMOVE, doomedAddr); final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response, "Failed to remove resource at address [" + doomedAddr + "]"); } return; }
java
public void remove(Address doomedAddr) throws Exception { final ModelNode request = createRequest(REMOVE, doomedAddr); final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response, "Failed to remove resource at address [" + doomedAddr + "]"); } return; }
[ "public", "void", "remove", "(", "Address", "doomedAddr", ")", "throws", "Exception", "{", "final", "ModelNode", "request", "=", "createRequest", "(", "REMOVE", ",", "doomedAddr", ")", ";", "final", "ModelNode", "response", "=", "execute", "(", "request", ")",...
Removes the resource at the given address. @param doomedAddr the address of the resource to remove @throws Exception any error
[ "Removes", "the", "resource", "at", "the", "given", "address", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/JBossASClient.java#L329-L336
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/DeploymentJBossASClient.java
DeploymentJBossASClient.deploy
public void deploy(String deploymentName, InputStream content, boolean enabled, Set<String> serverGroups, boolean forceDeploy) { if (serverGroups == null) { serverGroups = Collections.emptySet(); } DeploymentResult result = null; try { DeploymentManager dm = DeploymentManager.Factory.create(getModelControllerClient()); Deployment deployment = Deployment.of(content, deploymentName) .addServerGroups(serverGroups) .setEnabled(enabled); if (forceDeploy) { result = dm.forceDeploy(deployment); } else { result = dm.deploy(deployment); } } catch (Exception e) { String errMsg; if (serverGroups.isEmpty()) { errMsg = String.format("Failed to deploy [%s] (standalone mode)", deploymentName); } else { errMsg = String.format("Failed to deploy [%s] to server groups: %s", deploymentName, serverGroups); } throw new FailureException(errMsg, e); } if (!result.successful()) { String errMsg; if (serverGroups.isEmpty()) { errMsg = String.format("Failed to deploy [%s] (standalone mode)", deploymentName); } else { errMsg = String.format("Failed to deploy [%s] to server groups [%s]", deploymentName, serverGroups); } throw new FailureException(errMsg + ": " + result.getFailureMessage()); } return; // everything is OK }
java
public void deploy(String deploymentName, InputStream content, boolean enabled, Set<String> serverGroups, boolean forceDeploy) { if (serverGroups == null) { serverGroups = Collections.emptySet(); } DeploymentResult result = null; try { DeploymentManager dm = DeploymentManager.Factory.create(getModelControllerClient()); Deployment deployment = Deployment.of(content, deploymentName) .addServerGroups(serverGroups) .setEnabled(enabled); if (forceDeploy) { result = dm.forceDeploy(deployment); } else { result = dm.deploy(deployment); } } catch (Exception e) { String errMsg; if (serverGroups.isEmpty()) { errMsg = String.format("Failed to deploy [%s] (standalone mode)", deploymentName); } else { errMsg = String.format("Failed to deploy [%s] to server groups: %s", deploymentName, serverGroups); } throw new FailureException(errMsg, e); } if (!result.successful()) { String errMsg; if (serverGroups.isEmpty()) { errMsg = String.format("Failed to deploy [%s] (standalone mode)", deploymentName); } else { errMsg = String.format("Failed to deploy [%s] to server groups [%s]", deploymentName, serverGroups); } throw new FailureException(errMsg + ": " + result.getFailureMessage()); } return; // everything is OK }
[ "public", "void", "deploy", "(", "String", "deploymentName", ",", "InputStream", "content", ",", "boolean", "enabled", ",", "Set", "<", "String", ">", "serverGroups", ",", "boolean", "forceDeploy", ")", "{", "if", "(", "serverGroups", "==", "null", ")", "{",...
Uploads the content to the app server's content repository and then deploys the content. If this is to be used for app servers in "domain" mode you have to pass in one or more server groups. If this is to be used to deploy an app in a standalone server, the server groups should be empty. @param deploymentName name that the content will be known as @param content stream containing the actual content data @param enabled if true, the content will be uploaded and actually deployed; if false, content will be uploaded to the server, but it won't be deployed in the server runtime @param serverGroups the server groups where the application will be deployed if in domain mode @param forceDeploy if true the deployment content is uploaded even if that deployment name already has content (in other words, the new content will overwrite the old). If false, an error will occur if there is already content associated with the deployment name.
[ "Uploads", "the", "content", "to", "the", "app", "server", "s", "content", "repository", "and", "then", "deploys", "the", "content", ".", "If", "this", "is", "to", "be", "used", "for", "app", "servers", "in", "domain", "mode", "you", "have", "to", "pass"...
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/DeploymentJBossASClient.java#L107-L146
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/DeploymentJBossASClient.java
DeploymentJBossASClient.undeploy
public void undeploy(String deploymentName, Set<String> serverGroups, boolean removeContent) { if (serverGroups == null) { serverGroups = Collections.emptySet(); } DeploymentResult result = null; try { DeploymentManager dm = DeploymentManager.Factory.create(getModelControllerClient()); UndeployDescription undeployDescription = UndeployDescription.of(deploymentName) .addServerGroups(serverGroups) .setFailOnMissing(false) .setRemoveContent(removeContent); result = dm.undeploy(undeployDescription); } catch (Exception e) { String errMsg; if (serverGroups.isEmpty()) { errMsg = String.format("Failed to undeploy [%s] (standalone mode)", deploymentName); } else { errMsg = String.format("Failed to undeploy [%s] from server groups: %s", deploymentName, serverGroups); } throw new FailureException(errMsg, e); } if (!result.successful()) { String errMsg; if (serverGroups.isEmpty()) { errMsg = String.format("Failed to undeploy [%s] (standalone mode)", deploymentName); } else { errMsg = String.format("Failed to undeploy [%s] from server groups [%s]", deploymentName, serverGroups); } throw new FailureException(errMsg + ": " + result.getFailureMessage()); } return; // everything is OK }
java
public void undeploy(String deploymentName, Set<String> serverGroups, boolean removeContent) { if (serverGroups == null) { serverGroups = Collections.emptySet(); } DeploymentResult result = null; try { DeploymentManager dm = DeploymentManager.Factory.create(getModelControllerClient()); UndeployDescription undeployDescription = UndeployDescription.of(deploymentName) .addServerGroups(serverGroups) .setFailOnMissing(false) .setRemoveContent(removeContent); result = dm.undeploy(undeployDescription); } catch (Exception e) { String errMsg; if (serverGroups.isEmpty()) { errMsg = String.format("Failed to undeploy [%s] (standalone mode)", deploymentName); } else { errMsg = String.format("Failed to undeploy [%s] from server groups: %s", deploymentName, serverGroups); } throw new FailureException(errMsg, e); } if (!result.successful()) { String errMsg; if (serverGroups.isEmpty()) { errMsg = String.format("Failed to undeploy [%s] (standalone mode)", deploymentName); } else { errMsg = String.format("Failed to undeploy [%s] from server groups [%s]", deploymentName, serverGroups); } throw new FailureException(errMsg + ": " + result.getFailureMessage()); } return; // everything is OK }
[ "public", "void", "undeploy", "(", "String", "deploymentName", ",", "Set", "<", "String", ">", "serverGroups", ",", "boolean", "removeContent", ")", "{", "if", "(", "serverGroups", "==", "null", ")", "{", "serverGroups", "=", "Collections", ".", "emptySet", ...
Undeploys an app. If an empty set of server groups is passed in, this will assume we are operating on a standalone server. @param deploymentName name that the app is known as @param serverGroups the server groups where the application may already be deployed. If empty, this will assume the app server is in STANDALONE mode. @param removeContent if true, the content will be removed from the repository; false means the content stays.
[ "Undeploys", "an", "app", ".", "If", "an", "empty", "set", "of", "server", "groups", "is", "passed", "in", "this", "will", "assume", "we", "are", "operating", "on", "a", "standalone", "server", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/DeploymentJBossASClient.java#L157-L193
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/VaultJBossASClient.java
VaultJBossASClient.isVault
public boolean isVault() throws Exception { Address addr = Address.root().add(CORE_SERVICE, VAULT); final ModelNode queryNode = createRequest(READ_RESOURCE, addr); final ModelNode results = execute(queryNode); if (isSuccess(results)) { return true; } return false; }
java
public boolean isVault() throws Exception { Address addr = Address.root().add(CORE_SERVICE, VAULT); final ModelNode queryNode = createRequest(READ_RESOURCE, addr); final ModelNode results = execute(queryNode); if (isSuccess(results)) { return true; } return false; }
[ "public", "boolean", "isVault", "(", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "CORE_SERVICE", ",", "VAULT", ")", ";", "final", "ModelNode", "queryNode", "=", "createRequest", "(", "READ_RES...
Checks to see if there is already a vault configured. @return true if the vault is already configured @throws Exception any error
[ "Checks", "to", "see", "if", "there", "is", "already", "a", "vault", "configured", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/VaultJBossASClient.java#L42-L51
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/VaultJBossASClient.java
VaultJBossASClient.getVaultClass
public String getVaultClass() throws Exception { Address addr = Address.root().add(CORE_SERVICE, VAULT); ModelNode vaultNode = readResource(addr); if (vaultNode == null) { return null; } ModelNode codeNode = vaultNode.get("code"); if (codeNode == null) { return null; } return codeNode.asString(); }
java
public String getVaultClass() throws Exception { Address addr = Address.root().add(CORE_SERVICE, VAULT); ModelNode vaultNode = readResource(addr); if (vaultNode == null) { return null; } ModelNode codeNode = vaultNode.get("code"); if (codeNode == null) { return null; } return codeNode.asString(); }
[ "public", "String", "getVaultClass", "(", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "CORE_SERVICE", ",", "VAULT", ")", ";", "ModelNode", "vaultNode", "=", "readResource", "(", "addr", ")", ...
Attempts to retrieve the configured class for the vault. This method will return null if no vault is configured or if the vault does not have a custom vault class. @return vault configured class @throws Exception any error
[ "Attempts", "to", "retrieve", "the", "configured", "class", "for", "the", "vault", ".", "This", "method", "will", "return", "null", "if", "no", "vault", "is", "configured", "or", "if", "the", "vault", "does", "not", "have", "a", "custom", "vault", "class",...
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/VaultJBossASClient.java#L61-L75
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/VaultJBossASClient.java
VaultJBossASClient.createNewVaultRequest
public ModelNode createNewVaultRequest(String className) { String dmrTemplate = "" // + "{" // + "\"code\" => \"%s\"" + "}"; String dmr = String.format(dmrTemplate, className); Address addr = Address.root().add(CORE_SERVICE, VAULT); final ModelNode request = ModelNode.fromString(dmr); request.get(OPERATION).set(ADD); request.get(ADDRESS).set(addr.getAddressNode()); return request; }
java
public ModelNode createNewVaultRequest(String className) { String dmrTemplate = "" // + "{" // + "\"code\" => \"%s\"" + "}"; String dmr = String.format(dmrTemplate, className); Address addr = Address.root().add(CORE_SERVICE, VAULT); final ModelNode request = ModelNode.fromString(dmr); request.get(OPERATION).set(ADD); request.get(ADDRESS).set(addr.getAddressNode()); return request; }
[ "public", "ModelNode", "createNewVaultRequest", "(", "String", "className", ")", "{", "String", "dmrTemplate", "=", "\"\"", "//", "+", "\"{\"", "//", "+", "\"\\\"code\\\" => \\\"%s\\\"\"", "+", "\"}\"", ";", "String", "dmr", "=", "String", ".", "format", "(", ...
Returns a ModelNode that can be used to create the vault. Callers are free to tweak the queue request that is returned, if they so choose, before asking the client to execute the request. @param className class name for the custom vault @return the request that can be used to create the vault
[ "Returns", "a", "ModelNode", "that", "can", "be", "used", "to", "create", "the", "vault", ".", "Callers", "are", "free", "to", "tweak", "the", "queue", "request", "that", "is", "returned", "if", "they", "so", "choose", "before", "asking", "the", "client", ...
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/VaultJBossASClient.java#L86-L100
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.setEnableAdminConsole
public void setEnableAdminConsole(boolean enableFlag) throws Exception { final Address address = Address.root() .add(CORE_SERVICE, CORE_SERVICE_MGMT, MGMT_INTERFACE, MGMT_INTERFACE_HTTP); final ModelNode req = createWriteAttributeRequest("console-enabled", Boolean.toString(enableFlag), address); final ModelNode response = execute(req); if (!isSuccess(response)) { throw new FailureException(response); } return; }
java
public void setEnableAdminConsole(boolean enableFlag) throws Exception { final Address address = Address.root() .add(CORE_SERVICE, CORE_SERVICE_MGMT, MGMT_INTERFACE, MGMT_INTERFACE_HTTP); final ModelNode req = createWriteAttributeRequest("console-enabled", Boolean.toString(enableFlag), address); final ModelNode response = execute(req); if (!isSuccess(response)) { throw new FailureException(response); } return; }
[ "public", "void", "setEnableAdminConsole", "(", "boolean", "enableFlag", ")", "throws", "Exception", "{", "final", "Address", "address", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "CORE_SERVICE", ",", "CORE_SERVICE_MGMT", ",", "MGMT_INTERFACE", ",",...
Allows the caller to turn on or off complete access for the app server's admin console. @param enableFlag true if the admin console enabled and visible; false if you want to prohibit all access to the admin console @throws Exception any error
[ "Allows", "the", "caller", "to", "turn", "on", "or", "off", "complete", "access", "for", "the", "app", "server", "s", "admin", "console", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L56-L65
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.getSystemProperties
public Properties getSystemProperties() throws Exception { final String[] address = { CORE_SERVICE, PLATFORM_MBEAN, "type", "runtime" }; final ModelNode op = createReadAttributeRequest(true, "system-properties", Address.root().add(address)); final ModelNode results = execute(op); if (isSuccess(results)) { // extract the DMR representation into a java Properties object final Properties sysprops = new Properties(); final ModelNode node = getResults(results); final List<Property> propertyList = node.asPropertyList(); for (Property property : propertyList) { final String name = property.getName(); final ModelNode value = property.getValue(); if (name != null) { sysprops.put(name, value != null ? value.asString() : ""); } } return sysprops; } else { throw new FailureException(results, "Failed to get system properties"); } }
java
public Properties getSystemProperties() throws Exception { final String[] address = { CORE_SERVICE, PLATFORM_MBEAN, "type", "runtime" }; final ModelNode op = createReadAttributeRequest(true, "system-properties", Address.root().add(address)); final ModelNode results = execute(op); if (isSuccess(results)) { // extract the DMR representation into a java Properties object final Properties sysprops = new Properties(); final ModelNode node = getResults(results); final List<Property> propertyList = node.asPropertyList(); for (Property property : propertyList) { final String name = property.getName(); final ModelNode value = property.getValue(); if (name != null) { sysprops.put(name, value != null ? value.asString() : ""); } } return sysprops; } else { throw new FailureException(results, "Failed to get system properties"); } }
[ "public", "Properties", "getSystemProperties", "(", ")", "throws", "Exception", "{", "final", "String", "[", "]", "address", "=", "{", "CORE_SERVICE", ",", "PLATFORM_MBEAN", ",", "\"type\"", ",", "\"runtime\"", "}", ";", "final", "ModelNode", "op", "=", "creat...
This returns the system properties that are set in the AS JVM. This is not the system properties in the JVM of this client object - it is actually the system properties in the remote JVM of the AS instance that the client is talking to. @return the AS JVM's system properties @throws Exception any error
[ "This", "returns", "the", "system", "properties", "that", "are", "set", "in", "the", "AS", "JVM", ".", "This", "is", "not", "the", "system", "properties", "in", "the", "JVM", "of", "this", "client", "object", "-", "it", "is", "actually", "the", "system",...
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L98-L118
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.setAppServerDefaultDeploymentScanEnabled
public void setAppServerDefaultDeploymentScanEnabled(boolean enabled) throws Exception { final String[] addressArr = { SUBSYSTEM, DEPLOYMENT_SCANNER, SCANNER, "default" }; final Address address = Address.root().add(addressArr); final ModelNode req = createWriteAttributeRequest("scan-enabled", Boolean.toString(enabled), address); final ModelNode response = execute(req); if (!isSuccess(response)) { throw new FailureException(response); } return; }
java
public void setAppServerDefaultDeploymentScanEnabled(boolean enabled) throws Exception { final String[] addressArr = { SUBSYSTEM, DEPLOYMENT_SCANNER, SCANNER, "default" }; final Address address = Address.root().add(addressArr); final ModelNode req = createWriteAttributeRequest("scan-enabled", Boolean.toString(enabled), address); final ModelNode response = execute(req); if (!isSuccess(response)) { throw new FailureException(response); } return; }
[ "public", "void", "setAppServerDefaultDeploymentScanEnabled", "(", "boolean", "enabled", ")", "throws", "Exception", "{", "final", "String", "[", "]", "addressArr", "=", "{", "SUBSYSTEM", ",", "DEPLOYMENT_SCANNER", ",", "SCANNER", ",", "\"default\"", "}", ";", "fi...
Enabled or disables the default deployment scanner. @param enabled the new status to be set @throws Exception any error
[ "Enabled", "or", "disables", "the", "default", "deployment", "scanner", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L182-L192
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.getAppServerDefaultDeploymentDir
public String getAppServerDefaultDeploymentDir() throws Exception { final String[] addressArr = { SUBSYSTEM, DEPLOYMENT_SCANNER, SCANNER, "default" }; final Address address = Address.root().add(addressArr); final ModelNode resourceAttributes = readResource(address); if (resourceAttributes == null) { return null; // there is no default scanner } final String path = resourceAttributes.get("path").asString(); String relativeTo = null; if (resourceAttributes.hasDefined("relative-to")) { relativeTo = resourceAttributes.get("relative-to").asString(); } // path = the actual filesystem path to be scanned. Treated as an absolute path, // unless 'relative-to' is specified, in which case value is treated as relative to that path. // relative-to = Reference to a filesystem path defined in the "paths" section of the server // configuration, or one of the system properties specified on startup. // NOTE: here we will assume that if specified, it is a system property name. if (relativeTo != null) { String syspropValue = System.getProperty(relativeTo); if (syspropValue == null) { throw new IllegalStateException("Cannot support relative-to that isn't a sysprop: " + relativeTo); } relativeTo = syspropValue; } final File dir = new File(relativeTo, path); return dir.getAbsolutePath(); }
java
public String getAppServerDefaultDeploymentDir() throws Exception { final String[] addressArr = { SUBSYSTEM, DEPLOYMENT_SCANNER, SCANNER, "default" }; final Address address = Address.root().add(addressArr); final ModelNode resourceAttributes = readResource(address); if (resourceAttributes == null) { return null; // there is no default scanner } final String path = resourceAttributes.get("path").asString(); String relativeTo = null; if (resourceAttributes.hasDefined("relative-to")) { relativeTo = resourceAttributes.get("relative-to").asString(); } // path = the actual filesystem path to be scanned. Treated as an absolute path, // unless 'relative-to' is specified, in which case value is treated as relative to that path. // relative-to = Reference to a filesystem path defined in the "paths" section of the server // configuration, or one of the system properties specified on startup. // NOTE: here we will assume that if specified, it is a system property name. if (relativeTo != null) { String syspropValue = System.getProperty(relativeTo); if (syspropValue == null) { throw new IllegalStateException("Cannot support relative-to that isn't a sysprop: " + relativeTo); } relativeTo = syspropValue; } final File dir = new File(relativeTo, path); return dir.getAbsolutePath(); }
[ "public", "String", "getAppServerDefaultDeploymentDir", "(", ")", "throws", "Exception", "{", "final", "String", "[", "]", "addressArr", "=", "{", "SUBSYSTEM", ",", "DEPLOYMENT_SCANNER", ",", "SCANNER", ",", "\"default\"", "}", ";", "final", "Address", "address", ...
Returns the location where the default deployment scanner is pointing to. This is where EARs, WARs and the like are deployed to. @return the default deployments directory - null if there is no deployment scanner @throws Exception any error
[ "Returns", "the", "location", "where", "the", "default", "deployment", "scanner", "is", "pointing", "to", ".", "This", "is", "where", "EARs", "WARs", "and", "the", "like", "are", "deployed", "to", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L200-L231
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.setAppServerDefaultDeploymentTimeout
public void setAppServerDefaultDeploymentTimeout(long secs) throws Exception { final String[] addressArr = { SUBSYSTEM, DEPLOYMENT_SCANNER, SCANNER, "default" }; final Address address = Address.root().add(addressArr); final ModelNode req = createWriteAttributeRequest("deployment-timeout", Long.toString(secs), address); final ModelNode response = execute(req); if (!isSuccess(response)) { throw new FailureException(response); } return; }
java
public void setAppServerDefaultDeploymentTimeout(long secs) throws Exception { final String[] addressArr = { SUBSYSTEM, DEPLOYMENT_SCANNER, SCANNER, "default" }; final Address address = Address.root().add(addressArr); final ModelNode req = createWriteAttributeRequest("deployment-timeout", Long.toString(secs), address); final ModelNode response = execute(req); if (!isSuccess(response)) { throw new FailureException(response); } return; }
[ "public", "void", "setAppServerDefaultDeploymentTimeout", "(", "long", "secs", ")", "throws", "Exception", "{", "final", "String", "[", "]", "addressArr", "=", "{", "SUBSYSTEM", ",", "DEPLOYMENT_SCANNER", ",", "SCANNER", ",", "\"default\"", "}", ";", "final", "A...
Sets the deployment timeout of the default deployment scanner. If a deployment takes longer than this value, it will fail. @param secs number of seconds the app server will wait for a deployment to finish @throws Exception any error
[ "Sets", "the", "deployment", "timeout", "of", "the", "default", "deployment", "scanner", ".", "If", "a", "deployment", "takes", "longer", "than", "this", "value", "it", "will", "fail", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L257-L267
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.setSystemProperty
public void setSystemProperty(String name, String value) throws Exception { final ModelNode request = createRequest(ADD, Address.root().add(SYSTEM_PROPERTY, name)); request.get(VALUE).set(value); final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response, "Failed to set system property [" + name + "]"); } }
java
public void setSystemProperty(String name, String value) throws Exception { final ModelNode request = createRequest(ADD, Address.root().add(SYSTEM_PROPERTY, name)); request.get(VALUE).set(value); final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response, "Failed to set system property [" + name + "]"); } }
[ "public", "void", "setSystemProperty", "(", "String", "name", ",", "String", "value", ")", "throws", "Exception", "{", "final", "ModelNode", "request", "=", "createRequest", "(", "ADD", ",", "Address", ".", "root", "(", ")", ".", "add", "(", "SYSTEM_PROPERTY...
Set a runtime system property in the JVM that is managed by JBossAS. @param name system property name to set @param value the new value of the system property @throws Exception any error
[ "Set", "a", "runtime", "system", "property", "in", "the", "JVM", "that", "is", "managed", "by", "JBossAS", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L276-L283
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.addExtension
public void addExtension(String name) throws Exception { // /extension=<name>/:add(module=<name>) final ModelNode request = createRequest(ADD, Address.root().add(EXTENSION, name)); request.get(MODULE).set(name); final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response, "Failed to add new module extension [" + name + "]"); } return; }
java
public void addExtension(String name) throws Exception { // /extension=<name>/:add(module=<name>) final ModelNode request = createRequest(ADD, Address.root().add(EXTENSION, name)); request.get(MODULE).set(name); final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response, "Failed to add new module extension [" + name + "]"); } return; }
[ "public", "void", "addExtension", "(", "String", "name", ")", "throws", "Exception", "{", "// /extension=<name>/:add(module=<name>)", "final", "ModelNode", "request", "=", "createRequest", "(", "ADD", ",", "Address", ".", "root", "(", ")", ".", "add", "(", "EXTE...
Adds a new module extension to the core system. @param name the name of the new module extension @throws Exception any error
[ "Adds", "a", "new", "module", "extension", "to", "the", "core", "system", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L291-L300
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.isExtension
public boolean isExtension(String name) throws Exception { return null != readResource(Address.root().add(EXTENSION, name)); }
java
public boolean isExtension(String name) throws Exception { return null != readResource(Address.root().add(EXTENSION, name)); }
[ "public", "boolean", "isExtension", "(", "String", "name", ")", "throws", "Exception", "{", "return", "null", "!=", "readResource", "(", "Address", ".", "root", "(", ")", ".", "add", "(", "EXTENSION", ",", "name", ")", ")", ";", "}" ]
Returns true if the given extension is already in existence. @param name the name of the extension to check @return true if the extension already exists; false if not @throws Exception any error
[ "Returns", "true", "if", "the", "given", "extension", "is", "already", "in", "existence", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L309-L311
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.isSubsystem
public boolean isSubsystem(String name) throws Exception { return null != readResource(Address.root().add(SUBSYSTEM, name)); }
java
public boolean isSubsystem(String name) throws Exception { return null != readResource(Address.root().add(SUBSYSTEM, name)); }
[ "public", "boolean", "isSubsystem", "(", "String", "name", ")", "throws", "Exception", "{", "return", "null", "!=", "readResource", "(", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "name", ")", ")", ";", "}" ]
Returns true if the given subsystem is already in existence. @param name the name of the subsystem to check @return true if the subsystem already exists; false if not @throws Exception any error
[ "Returns", "true", "if", "the", "given", "subsystem", "is", "already", "in", "existence", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L348-L350
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.reload
public void reload(boolean adminOnly) throws Exception { final ModelNode request = createRequest("reload", Address.root()); request.get("admin-only").set(adminOnly); final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response); } return; }
java
public void reload(boolean adminOnly) throws Exception { final ModelNode request = createRequest("reload", Address.root()); request.get("admin-only").set(adminOnly); final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response); } return; }
[ "public", "void", "reload", "(", "boolean", "adminOnly", ")", "throws", "Exception", "{", "final", "ModelNode", "request", "=", "createRequest", "(", "\"reload\"", ",", "Address", ".", "root", "(", ")", ")", ";", "request", ".", "get", "(", "\"admin-only\"",...
Invokes the management "reload" operation which will shut down all the app server services and restart them again potentially in admin-only mode. This does not shutdown the JVM itself. NOTE: once this method returns, the client is probably unusable since the server side will probably shutdown the connection. You will need to throw away this object and rebuild another one with a newly reconnected {@link #getModelControllerClient() client}. @param adminOnly if <code>true</code>, reloads the server in admin-only mode @throws Exception any error
[ "Invokes", "the", "management", "reload", "operation", "which", "will", "shut", "down", "all", "the", "app", "server", "services", "and", "restart", "them", "again", "potentially", "in", "admin", "-", "only", "mode", ".", "This", "does", "not", "shutdown", "...
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L380-L388
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java
CoreJBossASClient.shutdown
public void shutdown(boolean restart) throws Exception { final ModelNode request = createRequest("shutdown", Address.root()); request.get("restart").set(restart); final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response); } return; }
java
public void shutdown(boolean restart) throws Exception { final ModelNode request = createRequest("shutdown", Address.root()); request.get("restart").set(restart); final ModelNode response = execute(request); if (!isSuccess(response)) { throw new FailureException(response); } return; }
[ "public", "void", "shutdown", "(", "boolean", "restart", ")", "throws", "Exception", "{", "final", "ModelNode", "request", "=", "createRequest", "(", "\"shutdown\"", ",", "Address", ".", "root", "(", ")", ")", ";", "request", ".", "get", "(", "\"restart\"", ...
Invokes the management "shutdown" operation that kills the JVM completely with System.exit. If restart is set to true, the JVM will immediately be restarted again. If restart is false, the JVM is killed and will stay down. Note that in either case, the caller may not be returned to since the JVM in which this call is made will be killed and if the client is co-located with the server JVM, this client will also die. NOTE: even if this method returns, the client is unusable since the server side will shutdown the connection. You will need to throw away this object and rebuild another one with a newly reconnected {@link #getModelControllerClient() client}. @param restart if true, the JVM will be restarted @throws Exception any error
[ "Invokes", "the", "management", "shutdown", "operation", "that", "kills", "the", "JVM", "completely", "with", "System", ".", "exit", ".", "If", "restart", "is", "set", "to", "true", "the", "JVM", "will", "immediately", "be", "restarted", "again", ".", "If", ...
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/CoreJBossASClient.java#L423-L431
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/MessagingJBossASClient.java
MessagingJBossASClient.isQueue
public boolean isQueue(String queueName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_MESSAGING, HORNETQ_SERVER, "default"); String haystack = JMS_QUEUE; return null != findNodeInList(addr, haystack, queueName); }
java
public boolean isQueue(String queueName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_MESSAGING, HORNETQ_SERVER, "default"); String haystack = JMS_QUEUE; return null != findNodeInList(addr, haystack, queueName); }
[ "public", "boolean", "isQueue", "(", "String", "queueName", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_MESSAGING", ",", "HORNETQ_SERVER", ",", "\"default\"", ")", "...
Checks to see if there is already a queue with the given name. @param queueName the name to check @return true if there is a queue with the given name already in existence @throws Exception any error
[ "Checks", "to", "see", "if", "there", "is", "already", "a", "queue", "with", "the", "given", "name", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/MessagingJBossASClient.java#L47-L51
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/MessagingJBossASClient.java
MessagingJBossASClient.createNewQueueRequest
public ModelNode createNewQueueRequest(String name, Boolean durable, List<String> entryNames) { String dmrTemplate = "" // + "{" // + "\"durable\" => \"%s\", " // + "\"entries\" => [\"%s\"] " // + "}"; String dmr = String.format(dmrTemplate, ((null == durable) ? "true" : durable.toString()), entryNames.get(0)); Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_MESSAGING, HORNETQ_SERVER, "default", JMS_QUEUE, name); final ModelNode request = ModelNode.fromString(dmr); request.get(OPERATION).set(ADD); request.get(ADDRESS).set(addr.getAddressNode()); return request; }
java
public ModelNode createNewQueueRequest(String name, Boolean durable, List<String> entryNames) { String dmrTemplate = "" // + "{" // + "\"durable\" => \"%s\", " // + "\"entries\" => [\"%s\"] " // + "}"; String dmr = String.format(dmrTemplate, ((null == durable) ? "true" : durable.toString()), entryNames.get(0)); Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_MESSAGING, HORNETQ_SERVER, "default", JMS_QUEUE, name); final ModelNode request = ModelNode.fromString(dmr); request.get(OPERATION).set(ADD); request.get(ADDRESS).set(addr.getAddressNode()); return request; }
[ "public", "ModelNode", "createNewQueueRequest", "(", "String", "name", ",", "Boolean", "durable", ",", "List", "<", "String", ">", "entryNames", ")", "{", "String", "dmrTemplate", "=", "\"\"", "//", "+", "\"{\"", "//", "+", "\"\\\"durable\\\" => \\\"%s\\\", \"", ...
Returns a ModelNode that can be used to create a queue. Callers are free to tweak the queue request that is returned, if they so choose, before asking the client to execute the request. @param name the queue name @param durable if null, default is "true" @param entryNames the jndiNames, each is prefixed with 'java:/'. Only supports one entry currently. @return the request that can be used to create the queue
[ "Returns", "a", "ModelNode", "that", "can", "be", "used", "to", "create", "a", "queue", ".", "Callers", "are", "free", "to", "tweak", "the", "queue", "request", "that", "is", "returned", "if", "they", "so", "choose", "before", "asking", "the", "client", ...
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/MessagingJBossASClient.java#L64-L80
train
hawkular/hawkular-agent
hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/Util.java
Util.cloneArray
@SuppressWarnings("unchecked") public static <T> T[] cloneArray(T[] original) { if (original == null) { return null; } try { Class<?> clazz = original.getClass().getComponentType(); T[] copy = (T[]) Array.newInstance(clazz, original.length); if (copy.length != 0) { Constructor<T> copyConstructor = (Constructor<T>) clazz.getConstructor(clazz); int i = 0; for (T t : original) { copy[i++] = copyConstructor.newInstance(t); } } return copy; } catch (Exception e) { throw new RuntimeException("Cannot copy array. Does its type have a copy-constructor? " + original, e); } }
java
@SuppressWarnings("unchecked") public static <T> T[] cloneArray(T[] original) { if (original == null) { return null; } try { Class<?> clazz = original.getClass().getComponentType(); T[] copy = (T[]) Array.newInstance(clazz, original.length); if (copy.length != 0) { Constructor<T> copyConstructor = (Constructor<T>) clazz.getConstructor(clazz); int i = 0; for (T t : original) { copy[i++] = copyConstructor.newInstance(t); } } return copy; } catch (Exception e) { throw new RuntimeException("Cannot copy array. Does its type have a copy-constructor? " + original, e); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "[", "]", "cloneArray", "(", "T", "[", "]", "original", ")", "{", "if", "(", "original", "==", "null", ")", "{", "return", "null", ";", "}", "try", "{", "Cl...
Performs a deep copy of the given array by calling a copy constructor to build clones of each array element.
[ "Performs", "a", "deep", "copy", "of", "the", "given", "array", "by", "calling", "a", "copy", "constructor", "to", "build", "clones", "of", "each", "array", "element", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/Util.java#L27-L47
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java
SecurityDomainJBossASClient.isSecurityDomain
public boolean isSecurityDomain(String securityDomainName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY); String haystack = SECURITY_DOMAIN; return null != findNodeInList(addr, haystack, securityDomainName); }
java
public boolean isSecurityDomain(String securityDomainName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY); String haystack = SECURITY_DOMAIN; return null != findNodeInList(addr, haystack, securityDomainName); }
[ "public", "boolean", "isSecurityDomain", "(", "String", "securityDomainName", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_SECURITY", ")", ";", "String", "haystack", "=...
Checks to see if there is already a security domain with the given name. @param securityDomainName the name to check @return true if there is a security domain with the given name already in existence @throws Exception any error
[ "Checks", "to", "see", "if", "there", "is", "already", "a", "security", "domain", "with", "the", "given", "name", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java#L66-L70
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java
SecurityDomainJBossASClient.createNewSecureIdentitySecurityDomain72
public void createNewSecureIdentitySecurityDomain72(String securityDomainName, String username, String password) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN, securityDomainName); ModelNode addTopNode = createRequest(ADD, addr); addTopNode.get(CACHE_TYPE).set("default"); Address authAddr = addr.clone().add(AUTHENTICATION, CLASSIC); ModelNode addAuthNode = createRequest(ADD, authAddr); Address loginAddr = authAddr.clone().add("login-module", "SecureIdentity"); ModelNode loginModule = createRequest(ADD, loginAddr); loginModule.get(CODE).set("SecureIdentity"); loginModule.get(FLAG).set("required"); ModelNode moduleOptions = loginModule.get(MODULE_OPTIONS); moduleOptions.setEmptyList(); addPossibleExpression(moduleOptions, USERNAME, username); addPossibleExpression(moduleOptions, PASSWORD, password); ModelNode batch = createBatchRequest(addTopNode, addAuthNode, loginModule); ModelNode results = execute(batch); if (!isSuccess(results)) { throw new FailureException(results, "Failed to create security domain [" + securityDomainName + "]"); } return; }
java
public void createNewSecureIdentitySecurityDomain72(String securityDomainName, String username, String password) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN, securityDomainName); ModelNode addTopNode = createRequest(ADD, addr); addTopNode.get(CACHE_TYPE).set("default"); Address authAddr = addr.clone().add(AUTHENTICATION, CLASSIC); ModelNode addAuthNode = createRequest(ADD, authAddr); Address loginAddr = authAddr.clone().add("login-module", "SecureIdentity"); ModelNode loginModule = createRequest(ADD, loginAddr); loginModule.get(CODE).set("SecureIdentity"); loginModule.get(FLAG).set("required"); ModelNode moduleOptions = loginModule.get(MODULE_OPTIONS); moduleOptions.setEmptyList(); addPossibleExpression(moduleOptions, USERNAME, username); addPossibleExpression(moduleOptions, PASSWORD, password); ModelNode batch = createBatchRequest(addTopNode, addAuthNode, loginModule); ModelNode results = execute(batch); if (!isSuccess(results)) { throw new FailureException(results, "Failed to create security domain [" + securityDomainName + "]"); } return; }
[ "public", "void", "createNewSecureIdentitySecurityDomain72", "(", "String", "securityDomainName", ",", "String", "username", ",", "String", "password", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "S...
Create a new security domain using the SecureIdentity authentication method. This is used when you want to obfuscate a database password in the configuration. This is the version for as7.2+ (e.g. eap 6.1) @param securityDomainName the name of the new security domain @param username the username associated with the security domain @param password the value of the password to store in the configuration (e.g. the obfuscated password itself) @throws Exception if failed to create security domain
[ "Create", "a", "new", "security", "domain", "using", "the", "SecureIdentity", "authentication", "method", ".", "This", "is", "used", "when", "you", "want", "to", "obfuscate", "a", "database", "password", "in", "the", "configuration", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java#L85-L113
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java
SecurityDomainJBossASClient.getSecureIdentitySecurityDomainModuleOptions
public ModelNode getSecureIdentitySecurityDomainModuleOptions(String securityDomainName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN, securityDomainName, AUTHENTICATION, CLASSIC); ModelNode authResource = readResource(addr); List<ModelNode> loginModules = authResource.get(LOGIN_MODULES).asList(); for (ModelNode loginModule : loginModules) { if ("SecureIdentity".equals(loginModule.get(CODE).asString())) { ModelNode moduleOptions = loginModule.get(MODULE_OPTIONS); return moduleOptions; } } return null; }
java
public ModelNode getSecureIdentitySecurityDomainModuleOptions(String securityDomainName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN, securityDomainName, AUTHENTICATION, CLASSIC); ModelNode authResource = readResource(addr); List<ModelNode> loginModules = authResource.get(LOGIN_MODULES).asList(); for (ModelNode loginModule : loginModules) { if ("SecureIdentity".equals(loginModule.get(CODE).asString())) { ModelNode moduleOptions = loginModule.get(MODULE_OPTIONS); return moduleOptions; } } return null; }
[ "public", "ModelNode", "getSecureIdentitySecurityDomainModuleOptions", "(", "String", "securityDomainName", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_SECURITY", ",", "SECU...
Given the name of an existing security domain that uses the SecureIdentity authentication method, this returns the module options for that security domain authentication method. This includes the username and password of the domain. @param securityDomainName the name of the security domain whose module options are to be returned @return the module options or null if the security domain doesn't exist @throws Exception if the security domain could not be looked up
[ "Given", "the", "name", "of", "an", "existing", "security", "domain", "that", "uses", "the", "SecureIdentity", "authentication", "method", "this", "returns", "the", "module", "options", "for", "that", "security", "domain", "authentication", "method", ".", "This", ...
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java#L177-L192
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java
SecurityDomainJBossASClient.removeSecurityDomain
public void removeSecurityDomain(String securityDomainName) throws Exception { // If not there just return if (!isSecurityDomain(securityDomainName)) { return; } final Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN, securityDomainName); ModelNode removeSecurityDomainNode = createRequest(REMOVE, addr); final ModelNode results = execute(removeSecurityDomainNode); if (!isSuccess(results)) { throw new FailureException(results, "Failed to remove security domain [" + securityDomainName + "]"); } return; }
java
public void removeSecurityDomain(String securityDomainName) throws Exception { // If not there just return if (!isSecurityDomain(securityDomainName)) { return; } final Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN, securityDomainName); ModelNode removeSecurityDomainNode = createRequest(REMOVE, addr); final ModelNode results = execute(removeSecurityDomainNode); if (!isSuccess(results)) { throw new FailureException(results, "Failed to remove security domain [" + securityDomainName + "]"); } return; }
[ "public", "void", "removeSecurityDomain", "(", "String", "securityDomainName", ")", "throws", "Exception", "{", "// If not there just return", "if", "(", "!", "isSecurityDomain", "(", "securityDomainName", ")", ")", "{", "return", ";", "}", "final", "Address", "addr...
Convenience method that removes a security domain by name. Useful when changing the characteristics of the login modules. @param securityDomainName the name of the new security domain @throws Exception if failed to remove the security domain
[ "Convenience", "method", "that", "removes", "a", "security", "domain", "by", "name", ".", "Useful", "when", "changing", "the", "characteristics", "of", "the", "login", "modules", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java#L247-L263
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java
SecurityDomainJBossASClient.createNewSecurityDomain
public void createNewSecurityDomain(String securityDomainName, LoginModuleRequest... loginModules) throws Exception { //do not close the controller client here, we're using our own.. CoreJBossASClient coreClient = new CoreJBossASClient(getModelControllerClient()); String serverVersion = coreClient.getAppServerVersion(); if (serverVersion.startsWith("7.2")) { createNewSecurityDomain72(securityDomainName, loginModules); } else { createNewSecurityDomain71(securityDomainName, loginModules); } }
java
public void createNewSecurityDomain(String securityDomainName, LoginModuleRequest... loginModules) throws Exception { //do not close the controller client here, we're using our own.. CoreJBossASClient coreClient = new CoreJBossASClient(getModelControllerClient()); String serverVersion = coreClient.getAppServerVersion(); if (serverVersion.startsWith("7.2")) { createNewSecurityDomain72(securityDomainName, loginModules); } else { createNewSecurityDomain71(securityDomainName, loginModules); } }
[ "public", "void", "createNewSecurityDomain", "(", "String", "securityDomainName", ",", "LoginModuleRequest", "...", "loginModules", ")", "throws", "Exception", "{", "//do not close the controller client here, we're using our own..", "CoreJBossASClient", "coreClient", "=", "new", ...
Creates a new security domain including one or more login modules. The security domain will be replaced if it exists. @param securityDomainName the name of the new security domain @param loginModules an array of login modules to place in the security domain. They are ordered top-down in the same index order of the array. @throws Exception if failed to create security domain
[ "Creates", "a", "new", "security", "domain", "including", "one", "or", "more", "login", "modules", ".", "The", "security", "domain", "will", "be", "replaced", "if", "it", "exists", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java#L274-L286
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java
SecurityDomainJBossASClient.securityDomainHasLoginModule
public boolean securityDomainHasLoginModule(String domainName, String moduleName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN, domainName); addr.add(AUTHENTICATION, CLASSIC); addr.add(LOGIN_MODULE, moduleName); ModelNode request = createRequest("read-resource", addr); ModelNode response = execute(request); return isSuccess(response); }
java
public boolean securityDomainHasLoginModule(String domainName, String moduleName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN, domainName); addr.add(AUTHENTICATION, CLASSIC); addr.add(LOGIN_MODULE, moduleName); ModelNode request = createRequest("read-resource", addr); ModelNode response = execute(request); return isSuccess(response); }
[ "public", "boolean", "securityDomainHasLoginModule", "(", "String", "domainName", ",", "String", "moduleName", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_SECURITY", ","...
Check if a certain login module is present inside the passed security domain @param domainName Name of the security domain @param moduleName Name of the Login module - wich usually is it FQCN @return True if the module is present @throws Exception any error
[ "Check", "if", "a", "certain", "login", "module", "is", "present", "inside", "the", "passed", "security", "domain" ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/SecurityDomainJBossASClient.java#L406-L413
train
hawkular/hawkular-agent
hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/ConfigConverter.java
ConfigConverter.populateMetricTypesForResourceType
private static <L> void populateMetricTypesForResourceType( ResourceType.Builder<?, L> resourceTypeBuilder, TypeSets.Builder<L> typeSetsBuilder) { Map<Name, TypeSet<MetricType<L>>> metricTypeSets = typeSetsBuilder.getMetricTypeSets(); List<Name> metricSetNames = resourceTypeBuilder.getMetricSetNames(); for (Name metricSetName : metricSetNames) { TypeSet<MetricType<L>> metricSet = metricTypeSets.get(metricSetName); if (metricSet != null && metricSet.isEnabled()) { resourceTypeBuilder.metricTypes(metricSet.getTypeMap().values()); } } }
java
private static <L> void populateMetricTypesForResourceType( ResourceType.Builder<?, L> resourceTypeBuilder, TypeSets.Builder<L> typeSetsBuilder) { Map<Name, TypeSet<MetricType<L>>> metricTypeSets = typeSetsBuilder.getMetricTypeSets(); List<Name> metricSetNames = resourceTypeBuilder.getMetricSetNames(); for (Name metricSetName : metricSetNames) { TypeSet<MetricType<L>> metricSet = metricTypeSets.get(metricSetName); if (metricSet != null && metricSet.isEnabled()) { resourceTypeBuilder.metricTypes(metricSet.getTypeMap().values()); } } }
[ "private", "static", "<", "L", ">", "void", "populateMetricTypesForResourceType", "(", "ResourceType", ".", "Builder", "<", "?", ",", "L", ">", "resourceTypeBuilder", ",", "TypeSets", ".", "Builder", "<", "L", ">", "typeSetsBuilder", ")", "{", "Map", "<", "N...
Given a resource type builder, this will fill in its metric types. @param resourceTypeBuilder the type being built whose metric types are to be filled in @param typeSetsBuilder all type metadata - this is where our metrics are
[ "Given", "a", "resource", "type", "builder", "this", "will", "fill", "in", "its", "metric", "types", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-javaagent/src/main/java/org/hawkular/agent/javaagent/config/ConfigConverter.java#L529-L542
train
hawkular/hawkular-agent
hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/protocol/Discovery.java
Discovery.discoverChildren
public <N, S extends Session<L>> void discoverChildren( Resource<L> parent, ResourceType<L> childType, Session<L> session, EndpointService<L, S> service, Consumer<Resource<L>> resourceConsumer) { try { L parentLocation = parent != null ? parent.getLocation() : null; log.debugf("Discovering children of [%s] of type [%s]", parent, childType); final L childQuery = session.getLocationResolver().absolutize(parentLocation, childType.getLocation()); Map<L, N> nativeResources = session.getDriver().fetchNodes(childQuery); for (Map.Entry<L, N> entry : nativeResources.entrySet()) { L location = entry.getKey(); // this is the unique DMR address for this resource String resourceName = session.getLocationResolver().applyTemplate(childType.getResourceNameTemplate(), location, session.getEndpoint().getName()); ID id = InventoryIdUtil.generateResourceId( session.getFeedId(), session.getEndpoint(), location.toString()); Builder<L> builder = Resource.<L> builder() .id(id) .name(new Name(resourceName)) .location(location) .type(childType); if (parent != null) { builder.parent(parent); } // get the configuration of the resource discoverResourceConfiguration(id, childType, location, entry.getValue(), builder, session); // populate the metrics based on the resource's type addMetricInstances(id, childType, location, entry.getValue(), builder, session); // build the resource now - we might need it to generate metric IDs Resource<L> resource = builder.build(); // The resource is built (and measurement instances assigned to it) so we can generate family names/labels for (MeasurementInstance<L, MetricType<L>> instance : resource.getMetrics()) { instance.setMetricFamily(service.generateMetricFamily(instance)); instance.setMetricLabels(service.generateMetricLabels(instance)); } log.debugf("Discovered resource [%s]", resource); // tell our consumer about our new resource if (resourceConsumer != null) { resourceConsumer.accept(resource); } // recursively discover children of child types Set<ResourceType<L>> childTypes = session.getResourceTypeManager() .getChildren(childType); for (ResourceType<L> nextLevelChildType : childTypes) { discoverChildren(resource, nextLevelChildType, session, service, resourceConsumer); } } } catch (Exception e) { log.errorFailedToDiscoverResources(e, session.getEndpoint()); resourceConsumer.report(e); } }
java
public <N, S extends Session<L>> void discoverChildren( Resource<L> parent, ResourceType<L> childType, Session<L> session, EndpointService<L, S> service, Consumer<Resource<L>> resourceConsumer) { try { L parentLocation = parent != null ? parent.getLocation() : null; log.debugf("Discovering children of [%s] of type [%s]", parent, childType); final L childQuery = session.getLocationResolver().absolutize(parentLocation, childType.getLocation()); Map<L, N> nativeResources = session.getDriver().fetchNodes(childQuery); for (Map.Entry<L, N> entry : nativeResources.entrySet()) { L location = entry.getKey(); // this is the unique DMR address for this resource String resourceName = session.getLocationResolver().applyTemplate(childType.getResourceNameTemplate(), location, session.getEndpoint().getName()); ID id = InventoryIdUtil.generateResourceId( session.getFeedId(), session.getEndpoint(), location.toString()); Builder<L> builder = Resource.<L> builder() .id(id) .name(new Name(resourceName)) .location(location) .type(childType); if (parent != null) { builder.parent(parent); } // get the configuration of the resource discoverResourceConfiguration(id, childType, location, entry.getValue(), builder, session); // populate the metrics based on the resource's type addMetricInstances(id, childType, location, entry.getValue(), builder, session); // build the resource now - we might need it to generate metric IDs Resource<L> resource = builder.build(); // The resource is built (and measurement instances assigned to it) so we can generate family names/labels for (MeasurementInstance<L, MetricType<L>> instance : resource.getMetrics()) { instance.setMetricFamily(service.generateMetricFamily(instance)); instance.setMetricLabels(service.generateMetricLabels(instance)); } log.debugf("Discovered resource [%s]", resource); // tell our consumer about our new resource if (resourceConsumer != null) { resourceConsumer.accept(resource); } // recursively discover children of child types Set<ResourceType<L>> childTypes = session.getResourceTypeManager() .getChildren(childType); for (ResourceType<L> nextLevelChildType : childTypes) { discoverChildren(resource, nextLevelChildType, session, service, resourceConsumer); } } } catch (Exception e) { log.errorFailedToDiscoverResources(e, session.getEndpoint()); resourceConsumer.report(e); } }
[ "public", "<", "N", ",", "S", "extends", "Session", "<", "L", ">", ">", "void", "discoverChildren", "(", "Resource", "<", "L", ">", "parent", ",", "ResourceType", "<", "L", ">", "childType", ",", "Session", "<", "L", ">", "session", ",", "EndpointServi...
Discovers children of the given type underneath the given parent. @param parent look under this resource to find its children (if null, this looks for root resources) @param childType only find children of this type @param session session used to query the managed endpoint @param samplingService the service that collects measurements - this is used here just to generate metric IDs @param resourceConsumer if not null, will be a listener that gets notified when resources are discovered
[ "Discovers", "children", "of", "the", "given", "type", "underneath", "the", "given", "parent", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/protocol/Discovery.java#L61-L127
train
hawkular/hawkular-agent
hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/prometheus/JmxScraper.java
JmxScraper.doScrape
public void doScrape() throws Exception { MBeanServerConnection beanConn; JMXConnector jmxc = null; if (jmxUrl.isEmpty()) { beanConn = ManagementFactory.getPlatformMBeanServer(); } else { Map<String, Object> environment = new HashMap<String, Object>(); if (username != null && username.length() != 0 && password != null && password.length() != 0) { String[] credent = new String[] {username, password}; environment.put(javax.management.remote.JMXConnector.CREDENTIALS, credent); } if (ssl) { environment.put(Context.SECURITY_PROTOCOL, "ssl"); SslRMIClientSocketFactory clientSocketFactory = new SslRMIClientSocketFactory(); environment.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, clientSocketFactory); environment.put("com.sun.jndi.rmi.factory.socket", clientSocketFactory); } jmxc = JMXConnectorFactory.connect(new JMXServiceURL(jmxUrl), environment); beanConn = jmxc.getMBeanServerConnection(); } try { // Query MBean names, see #89 for reasons queryMBeans() is used instead of queryNames() Set<ObjectInstance> mBeanNames = new HashSet(); for (ObjectName name : whitelistObjectNames) { mBeanNames.addAll(beanConn.queryMBeans(name, null)); } for (ObjectName name : whitelistObjectInstances) { mBeanNames.add(beanConn.getObjectInstance(name)); } for (ObjectName name : blacklistObjectNames) { mBeanNames.removeAll(beanConn.queryMBeans(name, null)); } for (ObjectName name : blacklistObjectInstances) { mBeanNames.remove(beanConn.getObjectInstance(name)); } for (ObjectInstance name : mBeanNames) { long start = System.nanoTime(); scrapeBean(beanConn, name.getObjectName()); logger.fine("TIME: " + (System.nanoTime() - start) + " ns for " + name.getObjectName().toString()); } } finally { if (jmxc != null) { jmxc.close(); } } }
java
public void doScrape() throws Exception { MBeanServerConnection beanConn; JMXConnector jmxc = null; if (jmxUrl.isEmpty()) { beanConn = ManagementFactory.getPlatformMBeanServer(); } else { Map<String, Object> environment = new HashMap<String, Object>(); if (username != null && username.length() != 0 && password != null && password.length() != 0) { String[] credent = new String[] {username, password}; environment.put(javax.management.remote.JMXConnector.CREDENTIALS, credent); } if (ssl) { environment.put(Context.SECURITY_PROTOCOL, "ssl"); SslRMIClientSocketFactory clientSocketFactory = new SslRMIClientSocketFactory(); environment.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, clientSocketFactory); environment.put("com.sun.jndi.rmi.factory.socket", clientSocketFactory); } jmxc = JMXConnectorFactory.connect(new JMXServiceURL(jmxUrl), environment); beanConn = jmxc.getMBeanServerConnection(); } try { // Query MBean names, see #89 for reasons queryMBeans() is used instead of queryNames() Set<ObjectInstance> mBeanNames = new HashSet(); for (ObjectName name : whitelistObjectNames) { mBeanNames.addAll(beanConn.queryMBeans(name, null)); } for (ObjectName name : whitelistObjectInstances) { mBeanNames.add(beanConn.getObjectInstance(name)); } for (ObjectName name : blacklistObjectNames) { mBeanNames.removeAll(beanConn.queryMBeans(name, null)); } for (ObjectName name : blacklistObjectInstances) { mBeanNames.remove(beanConn.getObjectInstance(name)); } for (ObjectInstance name : mBeanNames) { long start = System.nanoTime(); scrapeBean(beanConn, name.getObjectName()); logger.fine("TIME: " + (System.nanoTime() - start) + " ns for " + name.getObjectName().toString()); } } finally { if (jmxc != null) { jmxc.close(); } } }
[ "public", "void", "doScrape", "(", ")", "throws", "Exception", "{", "MBeanServerConnection", "beanConn", ";", "JMXConnector", "jmxc", "=", "null", ";", "if", "(", "jmxUrl", ".", "isEmpty", "(", ")", ")", "{", "beanConn", "=", "ManagementFactory", ".", "getPl...
Get a list of mbeans on host_port and scrape their values. Values are passed to the receiver in a single thread.
[ "Get", "a", "list", "of", "mbeans", "on", "host_port", "and", "scrape", "their", "values", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-agent-core/src/main/java/org/hawkular/agent/monitor/prometheus/JmxScraper.java#L124-L170
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/InfinispanJBossASClient.java
InfinispanJBossASClient.isCacheContainer
public boolean isCacheContainer(String cacheContainerName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_INFINISPAN); String haystack = CACHE_CONTAINER; return null != findNodeInList(addr, haystack, cacheContainerName); }
java
public boolean isCacheContainer(String cacheContainerName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_INFINISPAN); String haystack = CACHE_CONTAINER; return null != findNodeInList(addr, haystack, cacheContainerName); }
[ "public", "boolean", "isCacheContainer", "(", "String", "cacheContainerName", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_INFINISPAN", ")", ";", "String", "haystack", ...
Checks to see if there is already a cache container with the given name. @param cacheContainerName the name to check @return true if there is a cache container with the given name already in existence @throws Exception any error
[ "Checks", "to", "see", "if", "there", "is", "already", "a", "cache", "container", "with", "the", "given", "name", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/InfinispanJBossASClient.java#L45-L49
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/InfinispanJBossASClient.java
InfinispanJBossASClient.isLocalCache
public boolean isLocalCache(String cacheContainerName, String localCacheName) throws Exception { if (!isCacheContainer(cacheContainerName)) { return false; } Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_INFINISPAN, CACHE_CONTAINER, cacheContainerName); String haystack = LOCAL_CACHE; return null != findNodeInList(addr, haystack, localCacheName); }
java
public boolean isLocalCache(String cacheContainerName, String localCacheName) throws Exception { if (!isCacheContainer(cacheContainerName)) { return false; } Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_INFINISPAN, CACHE_CONTAINER, cacheContainerName); String haystack = LOCAL_CACHE; return null != findNodeInList(addr, haystack, localCacheName); }
[ "public", "boolean", "isLocalCache", "(", "String", "cacheContainerName", ",", "String", "localCacheName", ")", "throws", "Exception", "{", "if", "(", "!", "isCacheContainer", "(", "cacheContainerName", ")", ")", "{", "return", "false", ";", "}", "Address", "add...
Checks to see if there is already a local cache with the given name. @param cacheContainerName the parent container @param localCacheName the name to check @return true if there is a local cache with the given name already in existence @throws Exception any error
[ "Checks", "to", "see", "if", "there", "is", "already", "a", "local", "cache", "with", "the", "given", "name", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/InfinispanJBossASClient.java#L59-L67
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/DatasourceJBossASClient.java
DatasourceJBossASClient.isJDBCDriver
public boolean isJDBCDriver(String jdbcDriverName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES); String haystack = JDBC_DRIVER; return null != findNodeInList(addr, haystack, jdbcDriverName); }
java
public boolean isJDBCDriver(String jdbcDriverName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES); String haystack = JDBC_DRIVER; return null != findNodeInList(addr, haystack, jdbcDriverName); }
[ "public", "boolean", "isJDBCDriver", "(", "String", "jdbcDriverName", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_DATASOURCES", ")", ";", "String", "haystack", "=", ...
Checks to see if there is already a JDBC driver with the given name. @param jdbcDriverName the name to check @return true if there is a JDBC driver with the given name already in existence @throws Exception any error
[ "Checks", "to", "see", "if", "there", "is", "already", "a", "JDBC", "driver", "with", "the", "given", "name", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/DatasourceJBossASClient.java#L149-L153
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/DatasourceJBossASClient.java
DatasourceJBossASClient.isDatasource
public boolean isDatasource(String datasourceName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES); String haystack = DATA_SOURCE; return null != findNodeInList(addr, haystack, datasourceName); }
java
public boolean isDatasource(String datasourceName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES); String haystack = DATA_SOURCE; return null != findNodeInList(addr, haystack, datasourceName); }
[ "public", "boolean", "isDatasource", "(", "String", "datasourceName", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_DATASOURCES", ")", ";", "String", "haystack", "=", ...
Checks to see if there is already a datasource with the given name. @param datasourceName the name to check @return true if there is a datasource with the given name already in existence @throws Exception any error
[ "Checks", "to", "see", "if", "there", "is", "already", "a", "datasource", "with", "the", "given", "name", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/DatasourceJBossASClient.java#L162-L166
train
hawkular/hawkular-agent
hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/DatasourceJBossASClient.java
DatasourceJBossASClient.isXADatasource
public boolean isXADatasource(String datasourceName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES); String haystack = XA_DATA_SOURCE; return null != findNodeInList(addr, haystack, datasourceName); }
java
public boolean isXADatasource(String datasourceName) throws Exception { Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_DATASOURCES); String haystack = XA_DATA_SOURCE; return null != findNodeInList(addr, haystack, datasourceName); }
[ "public", "boolean", "isXADatasource", "(", "String", "datasourceName", ")", "throws", "Exception", "{", "Address", "addr", "=", "Address", ".", "root", "(", ")", ".", "add", "(", "SUBSYSTEM", ",", "SUBSYSTEM_DATASOURCES", ")", ";", "String", "haystack", "=", ...
Checks to see if there is already a XA datasource with the given name. @param datasourceName the name to check @return true if there is a XA datasource with the given name already in existence @throws Exception any error
[ "Checks", "to", "see", "if", "there", "is", "already", "a", "XA", "datasource", "with", "the", "given", "name", "." ]
a7a88fc7e4f12302e4c4306d1c91e11f81c8b811
https://github.com/hawkular/hawkular-agent/blob/a7a88fc7e4f12302e4c4306d1c91e11f81c8b811/hawkular-dmr-client/src/main/java/org/hawkular/dmrclient/DatasourceJBossASClient.java#L175-L179
train