id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
142,000
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readIntArray
public int[] readIntArray(final int items, final JBBPByteOrder byteOrder) throws IOException { int pos = 0; if (items < 0) { int[] buffer = new int[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (hasAvailableData()) { final int next = readInt(byteOrder); if (buffer.length == pos) { final int[] newbuffer = new int[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } buffer[pos++] = next; } if (buffer.length == pos) { return buffer; } final int[] result = new int[pos]; System.arraycopy(buffer, 0, result, 0, pos); return result; } else { // number final int[] buffer = new int[items]; for (int i = 0; i < items; i++) { buffer[i] = readInt(byteOrder); } return buffer; } }
java
public int[] readIntArray(final int items, final JBBPByteOrder byteOrder) throws IOException { int pos = 0; if (items < 0) { int[] buffer = new int[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (hasAvailableData()) { final int next = readInt(byteOrder); if (buffer.length == pos) { final int[] newbuffer = new int[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } buffer[pos++] = next; } if (buffer.length == pos) { return buffer; } final int[] result = new int[pos]; System.arraycopy(buffer, 0, result, 0, pos); return result; } else { // number final int[] buffer = new int[items]; for (int i = 0; i < items; i++) { buffer[i] = readInt(byteOrder); } return buffer; } }
[ "public", "int", "[", "]", "readIntArray", "(", "final", "int", "items", ",", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "int", "pos", "=", "0", ";", "if", "(", "items", "<", "0", ")", "{", "int", "[", "]", "buffer", "=", "new", "int", "[", "INITIAL_ARRAY_BUFFER_SIZE", "]", ";", "// till end", "while", "(", "hasAvailableData", "(", ")", ")", "{", "final", "int", "next", "=", "readInt", "(", "byteOrder", ")", ";", "if", "(", "buffer", ".", "length", "==", "pos", ")", "{", "final", "int", "[", "]", "newbuffer", "=", "new", "int", "[", "buffer", ".", "length", "<<", "1", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "newbuffer", ",", "0", ",", "buffer", ".", "length", ")", ";", "buffer", "=", "newbuffer", ";", "}", "buffer", "[", "pos", "++", "]", "=", "next", ";", "}", "if", "(", "buffer", ".", "length", "==", "pos", ")", "{", "return", "buffer", ";", "}", "final", "int", "[", "]", "result", "=", "new", "int", "[", "pos", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "result", ",", "0", ",", "pos", ")", ";", "return", "result", ";", "}", "else", "{", "// number", "final", "int", "[", "]", "buffer", "=", "new", "int", "[", "items", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ";", "i", "++", ")", "{", "buffer", "[", "i", "]", "=", "readInt", "(", "byteOrder", ")", ";", "}", "return", "buffer", ";", "}", "}" ]
Read number of integer items from the input stream. @param items number of items to be read from the input stream, if less than zero then all stream till the end will be read @param byteOrder the order of bytes to be used to decode values @return read items as an integer array @throws IOException it will be thrown for any transport problem during the operation @see JBBPByteOrder#BIG_ENDIAN @see JBBPByteOrder#LITTLE_ENDIAN
[ "Read", "number", "of", "integer", "items", "from", "the", "input", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L331-L359
142,001
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readFloatArray
public float[] readFloatArray(final int items, final JBBPByteOrder byteOrder) throws IOException { int pos = 0; if (items < 0) { float[] buffer = new float[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (hasAvailableData()) { final float next = readFloat(byteOrder); if (buffer.length == pos) { final float[] newbuffer = new float[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } buffer[pos++] = next; } if (buffer.length == pos) { return buffer; } final float[] result = new float[pos]; System.arraycopy(buffer, 0, result, 0, pos); return result; } else { // number final float[] buffer = new float[items]; for (int i = 0; i < items; i++) { buffer[i] = readFloat(byteOrder); } return buffer; } }
java
public float[] readFloatArray(final int items, final JBBPByteOrder byteOrder) throws IOException { int pos = 0; if (items < 0) { float[] buffer = new float[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (hasAvailableData()) { final float next = readFloat(byteOrder); if (buffer.length == pos) { final float[] newbuffer = new float[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } buffer[pos++] = next; } if (buffer.length == pos) { return buffer; } final float[] result = new float[pos]; System.arraycopy(buffer, 0, result, 0, pos); return result; } else { // number final float[] buffer = new float[items]; for (int i = 0; i < items; i++) { buffer[i] = readFloat(byteOrder); } return buffer; } }
[ "public", "float", "[", "]", "readFloatArray", "(", "final", "int", "items", ",", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "int", "pos", "=", "0", ";", "if", "(", "items", "<", "0", ")", "{", "float", "[", "]", "buffer", "=", "new", "float", "[", "INITIAL_ARRAY_BUFFER_SIZE", "]", ";", "// till end", "while", "(", "hasAvailableData", "(", ")", ")", "{", "final", "float", "next", "=", "readFloat", "(", "byteOrder", ")", ";", "if", "(", "buffer", ".", "length", "==", "pos", ")", "{", "final", "float", "[", "]", "newbuffer", "=", "new", "float", "[", "buffer", ".", "length", "<<", "1", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "newbuffer", ",", "0", ",", "buffer", ".", "length", ")", ";", "buffer", "=", "newbuffer", ";", "}", "buffer", "[", "pos", "++", "]", "=", "next", ";", "}", "if", "(", "buffer", ".", "length", "==", "pos", ")", "{", "return", "buffer", ";", "}", "final", "float", "[", "]", "result", "=", "new", "float", "[", "pos", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "result", ",", "0", ",", "pos", ")", ";", "return", "result", ";", "}", "else", "{", "// number", "final", "float", "[", "]", "buffer", "=", "new", "float", "[", "items", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ";", "i", "++", ")", "{", "buffer", "[", "i", "]", "=", "readFloat", "(", "byteOrder", ")", ";", "}", "return", "buffer", ";", "}", "}" ]
Read number of float items from the input stream. @param items number of items to be read from the input stream, if less than zero then all stream till the end will be read @param byteOrder the order of bytes to be used to decode values @return read items as float array @throws IOException it will be thrown for any transport problem during the operation @see JBBPByteOrder#BIG_ENDIAN @see JBBPByteOrder#LITTLE_ENDIAN @since 1.4.0
[ "Read", "number", "of", "float", "items", "from", "the", "input", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L374-L402
142,002
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readLongArray
public long[] readLongArray(final int items, final JBBPByteOrder byteOrder) throws IOException { int pos = 0; if (items < 0) { long[] buffer = new long[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (hasAvailableData()) { final long next = readLong(byteOrder); if (buffer.length == pos) { final long[] newbuffer = new long[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } buffer[pos++] = next; } if (buffer.length == pos) { return buffer; } final long[] result = new long[pos]; System.arraycopy(buffer, 0, result, 0, pos); return result; } else { // number final long[] buffer = new long[items]; for (int i = 0; i < items; i++) { buffer[i] = readLong(byteOrder); } return buffer; } }
java
public long[] readLongArray(final int items, final JBBPByteOrder byteOrder) throws IOException { int pos = 0; if (items < 0) { long[] buffer = new long[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (hasAvailableData()) { final long next = readLong(byteOrder); if (buffer.length == pos) { final long[] newbuffer = new long[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } buffer[pos++] = next; } if (buffer.length == pos) { return buffer; } final long[] result = new long[pos]; System.arraycopy(buffer, 0, result, 0, pos); return result; } else { // number final long[] buffer = new long[items]; for (int i = 0; i < items; i++) { buffer[i] = readLong(byteOrder); } return buffer; } }
[ "public", "long", "[", "]", "readLongArray", "(", "final", "int", "items", ",", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "int", "pos", "=", "0", ";", "if", "(", "items", "<", "0", ")", "{", "long", "[", "]", "buffer", "=", "new", "long", "[", "INITIAL_ARRAY_BUFFER_SIZE", "]", ";", "// till end", "while", "(", "hasAvailableData", "(", ")", ")", "{", "final", "long", "next", "=", "readLong", "(", "byteOrder", ")", ";", "if", "(", "buffer", ".", "length", "==", "pos", ")", "{", "final", "long", "[", "]", "newbuffer", "=", "new", "long", "[", "buffer", ".", "length", "<<", "1", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "newbuffer", ",", "0", ",", "buffer", ".", "length", ")", ";", "buffer", "=", "newbuffer", ";", "}", "buffer", "[", "pos", "++", "]", "=", "next", ";", "}", "if", "(", "buffer", ".", "length", "==", "pos", ")", "{", "return", "buffer", ";", "}", "final", "long", "[", "]", "result", "=", "new", "long", "[", "pos", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "result", ",", "0", ",", "pos", ")", ";", "return", "result", ";", "}", "else", "{", "// number", "final", "long", "[", "]", "buffer", "=", "new", "long", "[", "items", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ";", "i", "++", ")", "{", "buffer", "[", "i", "]", "=", "readLong", "(", "byteOrder", ")", ";", "}", "return", "buffer", ";", "}", "}" ]
Read number of long items from the input stream. @param items number of items to be read from the input stream, if less than zero then all stream till the end will be read @param byteOrder the order of bytes to be used to decode values @return read items as a long array @throws IOException it will be thrown for any transport problem during the operation @see JBBPByteOrder#BIG_ENDIAN @see JBBPByteOrder#LITTLE_ENDIAN
[ "Read", "number", "of", "long", "items", "from", "the", "input", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L416-L444
142,003
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readDoubleArray
public double[] readDoubleArray(final int items, final JBBPByteOrder byteOrder) throws IOException { int pos = 0; if (items < 0) { double[] buffer = new double[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (hasAvailableData()) { final long next = readLong(byteOrder); if (buffer.length == pos) { final double[] newbuffer = new double[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } buffer[pos++] = Double.longBitsToDouble(next); } if (buffer.length == pos) { return buffer; } final double[] result = new double[pos]; System.arraycopy(buffer, 0, result, 0, pos); return result; } else { // number final double[] buffer = new double[items]; for (int i = 0; i < items; i++) { buffer[i] = readDouble(byteOrder); } return buffer; } }
java
public double[] readDoubleArray(final int items, final JBBPByteOrder byteOrder) throws IOException { int pos = 0; if (items < 0) { double[] buffer = new double[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (hasAvailableData()) { final long next = readLong(byteOrder); if (buffer.length == pos) { final double[] newbuffer = new double[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } buffer[pos++] = Double.longBitsToDouble(next); } if (buffer.length == pos) { return buffer; } final double[] result = new double[pos]; System.arraycopy(buffer, 0, result, 0, pos); return result; } else { // number final double[] buffer = new double[items]; for (int i = 0; i < items; i++) { buffer[i] = readDouble(byteOrder); } return buffer; } }
[ "public", "double", "[", "]", "readDoubleArray", "(", "final", "int", "items", ",", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "int", "pos", "=", "0", ";", "if", "(", "items", "<", "0", ")", "{", "double", "[", "]", "buffer", "=", "new", "double", "[", "INITIAL_ARRAY_BUFFER_SIZE", "]", ";", "// till end", "while", "(", "hasAvailableData", "(", ")", ")", "{", "final", "long", "next", "=", "readLong", "(", "byteOrder", ")", ";", "if", "(", "buffer", ".", "length", "==", "pos", ")", "{", "final", "double", "[", "]", "newbuffer", "=", "new", "double", "[", "buffer", ".", "length", "<<", "1", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "newbuffer", ",", "0", ",", "buffer", ".", "length", ")", ";", "buffer", "=", "newbuffer", ";", "}", "buffer", "[", "pos", "++", "]", "=", "Double", ".", "longBitsToDouble", "(", "next", ")", ";", "}", "if", "(", "buffer", ".", "length", "==", "pos", ")", "{", "return", "buffer", ";", "}", "final", "double", "[", "]", "result", "=", "new", "double", "[", "pos", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "result", ",", "0", ",", "pos", ")", ";", "return", "result", ";", "}", "else", "{", "// number", "final", "double", "[", "]", "buffer", "=", "new", "double", "[", "items", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ";", "i", "++", ")", "{", "buffer", "[", "i", "]", "=", "readDouble", "(", "byteOrder", ")", ";", "}", "return", "buffer", ";", "}", "}" ]
Read number of double items from the input stream. @param items number of items to be read from the input stream, if less than zero then all stream till the end will be read @param byteOrder the order of bytes to be used to decode values @return read items as a double array @throws IOException it will be thrown for any transport problem during the operation @see JBBPByteOrder#BIG_ENDIAN @see JBBPByteOrder#LITTLE_ENDIAN @since 1.4.0
[ "Read", "number", "of", "double", "items", "from", "the", "input", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L459-L487
142,004
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readUnsignedShort
public int readUnsignedShort(final JBBPByteOrder byteOrder) throws IOException { final int b0 = this.read(); if (b0 < 0) { throw new EOFException(); } final int b1 = this.read(); if (b1 < 0) { throw new EOFException(); } return byteOrder == JBBPByteOrder.BIG_ENDIAN ? (b0 << 8) | b1 : (b1 << 8) | b0; }
java
public int readUnsignedShort(final JBBPByteOrder byteOrder) throws IOException { final int b0 = this.read(); if (b0 < 0) { throw new EOFException(); } final int b1 = this.read(); if (b1 < 0) { throw new EOFException(); } return byteOrder == JBBPByteOrder.BIG_ENDIAN ? (b0 << 8) | b1 : (b1 << 8) | b0; }
[ "public", "int", "readUnsignedShort", "(", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "final", "int", "b0", "=", "this", ".", "read", "(", ")", ";", "if", "(", "b0", "<", "0", ")", "{", "throw", "new", "EOFException", "(", ")", ";", "}", "final", "int", "b1", "=", "this", ".", "read", "(", ")", ";", "if", "(", "b1", "<", "0", ")", "{", "throw", "new", "EOFException", "(", ")", ";", "}", "return", "byteOrder", "==", "JBBPByteOrder", ".", "BIG_ENDIAN", "?", "(", "b0", "<<", "8", ")", "|", "b1", ":", "(", "b1", "<<", "8", ")", "|", "b0", ";", "}" ]
Read a unsigned short value from the stream. @param byteOrder he order of bytes to be used to decode the read value @return the unsigned short value read from stream @throws IOException it will be thrown for any transport problem during the operation @throws EOFException if the end of the stream has been reached @see JBBPByteOrder#BIG_ENDIAN @see JBBPByteOrder#LITTLE_ENDIAN
[ "Read", "a", "unsigned", "short", "value", "from", "the", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L500-L510
142,005
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readInt
public int readInt(final JBBPByteOrder byteOrder) throws IOException { if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { return (readUnsignedShort(byteOrder) << 16) | readUnsignedShort(byteOrder); } else { return readUnsignedShort(byteOrder) | (readUnsignedShort(byteOrder) << 16); } }
java
public int readInt(final JBBPByteOrder byteOrder) throws IOException { if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { return (readUnsignedShort(byteOrder) << 16) | readUnsignedShort(byteOrder); } else { return readUnsignedShort(byteOrder) | (readUnsignedShort(byteOrder) << 16); } }
[ "public", "int", "readInt", "(", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "if", "(", "byteOrder", "==", "JBBPByteOrder", ".", "BIG_ENDIAN", ")", "{", "return", "(", "readUnsignedShort", "(", "byteOrder", ")", "<<", "16", ")", "|", "readUnsignedShort", "(", "byteOrder", ")", ";", "}", "else", "{", "return", "readUnsignedShort", "(", "byteOrder", ")", "|", "(", "readUnsignedShort", "(", "byteOrder", ")", "<<", "16", ")", ";", "}", "}" ]
Read an integer value from the stream. @param byteOrder the order of bytes to be used to decode the read value @return the integer value from the stream @throws IOException it will be thrown for any transport problem during the operation @throws EOFException if the end of the stream has been reached @see JBBPByteOrder#BIG_ENDIAN @see JBBPByteOrder#LITTLE_ENDIAN
[ "Read", "an", "integer", "value", "from", "the", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L523-L529
142,006
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readFloat
public float readFloat(final JBBPByteOrder byteOrder) throws IOException { final int value; if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { value = (readUnsignedShort(byteOrder) << 16) | readUnsignedShort(byteOrder); } else { value = readUnsignedShort(byteOrder) | (readUnsignedShort(byteOrder) << 16); } return Float.intBitsToFloat(value); }
java
public float readFloat(final JBBPByteOrder byteOrder) throws IOException { final int value; if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { value = (readUnsignedShort(byteOrder) << 16) | readUnsignedShort(byteOrder); } else { value = readUnsignedShort(byteOrder) | (readUnsignedShort(byteOrder) << 16); } return Float.intBitsToFloat(value); }
[ "public", "float", "readFloat", "(", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "final", "int", "value", ";", "if", "(", "byteOrder", "==", "JBBPByteOrder", ".", "BIG_ENDIAN", ")", "{", "value", "=", "(", "readUnsignedShort", "(", "byteOrder", ")", "<<", "16", ")", "|", "readUnsignedShort", "(", "byteOrder", ")", ";", "}", "else", "{", "value", "=", "readUnsignedShort", "(", "byteOrder", ")", "|", "(", "readUnsignedShort", "(", "byteOrder", ")", "<<", "16", ")", ";", "}", "return", "Float", ".", "intBitsToFloat", "(", "value", ")", ";", "}" ]
Read a float value from the stream. @param byteOrder the order of bytes to be used to decode the read value @return the float value from the stream @throws IOException it will be thrown for any transport problem during the operation @throws EOFException if the end of the stream has been reached @see JBBPByteOrder#BIG_ENDIAN @see JBBPByteOrder#LITTLE_ENDIAN @since 1.4.0
[ "Read", "a", "float", "value", "from", "the", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L543-L551
142,007
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readLong
public long readLong(final JBBPByteOrder byteOrder) throws IOException { if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { return (((long) readInt(byteOrder) & 0xFFFFFFFFL) << 32) | ((long) readInt(byteOrder) & 0xFFFFFFFFL); } else { return ((long) readInt(byteOrder) & 0xFFFFFFFFL) | (((long) readInt(byteOrder) & 0xFFFFFFFFL) << 32); } }
java
public long readLong(final JBBPByteOrder byteOrder) throws IOException { if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { return (((long) readInt(byteOrder) & 0xFFFFFFFFL) << 32) | ((long) readInt(byteOrder) & 0xFFFFFFFFL); } else { return ((long) readInt(byteOrder) & 0xFFFFFFFFL) | (((long) readInt(byteOrder) & 0xFFFFFFFFL) << 32); } }
[ "public", "long", "readLong", "(", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "if", "(", "byteOrder", "==", "JBBPByteOrder", ".", "BIG_ENDIAN", ")", "{", "return", "(", "(", "(", "long", ")", "readInt", "(", "byteOrder", ")", "&", "0xFFFFFFFF", "L", ")", "<<", "32", ")", "|", "(", "(", "long", ")", "readInt", "(", "byteOrder", ")", "&", "0xFFFFFFFF", "L", ")", ";", "}", "else", "{", "return", "(", "(", "long", ")", "readInt", "(", "byteOrder", ")", "&", "0xFFFFFFFF", "L", ")", "|", "(", "(", "(", "long", ")", "readInt", "(", "byteOrder", ")", "&", "0xFFFFFFFF", "L", ")", "<<", "32", ")", ";", "}", "}" ]
Read a long value from the stream. @param byteOrder the order of bytes to be used to decode the read value @return the long value from stream @throws IOException it will be thrown for any transport problem during the operation @throws EOFException if the end of the stream has been reached @see JBBPByteOrder#BIG_ENDIAN @see JBBPByteOrder#LITTLE_ENDIAN
[ "Read", "a", "long", "value", "from", "the", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L564-L570
142,008
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readDouble
public double readDouble(final JBBPByteOrder byteOrder) throws IOException { final long value; if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { value = (((long) readInt(byteOrder) & 0xFFFFFFFFL) << 32) | ((long) readInt(byteOrder) & 0xFFFFFFFFL); } else { value = ((long) readInt(byteOrder) & 0xFFFFFFFFL) | (((long) readInt(byteOrder) & 0xFFFFFFFFL) << 32); } return Double.longBitsToDouble(value); }
java
public double readDouble(final JBBPByteOrder byteOrder) throws IOException { final long value; if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { value = (((long) readInt(byteOrder) & 0xFFFFFFFFL) << 32) | ((long) readInt(byteOrder) & 0xFFFFFFFFL); } else { value = ((long) readInt(byteOrder) & 0xFFFFFFFFL) | (((long) readInt(byteOrder) & 0xFFFFFFFFL) << 32); } return Double.longBitsToDouble(value); }
[ "public", "double", "readDouble", "(", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "final", "long", "value", ";", "if", "(", "byteOrder", "==", "JBBPByteOrder", ".", "BIG_ENDIAN", ")", "{", "value", "=", "(", "(", "(", "long", ")", "readInt", "(", "byteOrder", ")", "&", "0xFFFFFFFF", "L", ")", "<<", "32", ")", "|", "(", "(", "long", ")", "readInt", "(", "byteOrder", ")", "&", "0xFFFFFFFF", "L", ")", ";", "}", "else", "{", "value", "=", "(", "(", "long", ")", "readInt", "(", "byteOrder", ")", "&", "0xFFFFFFFF", "L", ")", "|", "(", "(", "(", "long", ")", "readInt", "(", "byteOrder", ")", "&", "0xFFFFFFFF", "L", ")", "<<", "32", ")", ";", "}", "return", "Double", ".", "longBitsToDouble", "(", "value", ")", ";", "}" ]
Read a double value from the stream. @param byteOrder the order of bytes to be used to decode the read value @return the double value from stream @throws IOException it will be thrown for any transport problem during the operation @throws EOFException if the end of the stream has been reached @see JBBPByteOrder#BIG_ENDIAN @see JBBPByteOrder#LITTLE_ENDIAN @since 1.4.0
[ "Read", "a", "double", "value", "from", "the", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L584-L592
142,009
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readBitField
public byte readBitField(final JBBPBitNumber numOfBitsToRead) throws IOException { final int value = this.readBits(numOfBitsToRead); if (value < 0) { throw new EOFException("Can't read bits from stream [" + numOfBitsToRead + ']'); } return (byte) value; }
java
public byte readBitField(final JBBPBitNumber numOfBitsToRead) throws IOException { final int value = this.readBits(numOfBitsToRead); if (value < 0) { throw new EOFException("Can't read bits from stream [" + numOfBitsToRead + ']'); } return (byte) value; }
[ "public", "byte", "readBitField", "(", "final", "JBBPBitNumber", "numOfBitsToRead", ")", "throws", "IOException", "{", "final", "int", "value", "=", "this", ".", "readBits", "(", "numOfBitsToRead", ")", ";", "if", "(", "value", "<", "0", ")", "{", "throw", "new", "EOFException", "(", "\"Can't read bits from stream [\"", "+", "numOfBitsToRead", "+", "'", "'", ")", ";", "}", "return", "(", "byte", ")", "value", ";", "}" ]
Read bit field from the stream, if it is impossible then IOException will be thrown. @param numOfBitsToRead field width, must not be null @return read value from the stream @throws IOException it will be thrown if EOF or troubles to read the stream @since 1.3.0
[ "Read", "bit", "field", "from", "the", "stream", "if", "it", "is", "impossible", "then", "IOException", "will", "be", "thrown", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L644-L650
142,010
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readBits
public int readBits(final JBBPBitNumber numOfBitsToRead) throws IOException { int result; final int numOfBitsAsNumber = numOfBitsToRead.getBitNumber(); if (this.bitsInBuffer == 0 && numOfBitsAsNumber == 8) { result = this.readByteFromStream(); if (result >= 0) { this.byteCounter++; } return result; } else { result = 0; if (numOfBitsAsNumber == this.bitsInBuffer) { result = this.bitBuffer; this.bitBuffer = 0; this.bitsInBuffer = 0; this.byteCounter++; return result; } int i = numOfBitsAsNumber; int theBitBuffer = this.bitBuffer; int theBitBufferCounter = this.bitsInBuffer; final boolean doIncCounter = theBitBufferCounter != 0; while (i > 0) { if (theBitBufferCounter == 0) { if (doIncCounter) { this.byteCounter++; } final int nextByte = this.readByteFromStream(); if (nextByte < 0) { if (i == numOfBitsAsNumber) { return nextByte; } else { break; } } else { theBitBuffer = nextByte; theBitBufferCounter = 8; } } result = (result << 1) | (theBitBuffer & 1); theBitBuffer >>= 1; theBitBufferCounter--; i--; } this.bitBuffer = theBitBuffer; this.bitsInBuffer = theBitBufferCounter; return JBBPUtils.reverseBitsInByte(JBBPBitNumber.decode(numOfBitsAsNumber - i), (byte) result) & 0xFF; } }
java
public int readBits(final JBBPBitNumber numOfBitsToRead) throws IOException { int result; final int numOfBitsAsNumber = numOfBitsToRead.getBitNumber(); if (this.bitsInBuffer == 0 && numOfBitsAsNumber == 8) { result = this.readByteFromStream(); if (result >= 0) { this.byteCounter++; } return result; } else { result = 0; if (numOfBitsAsNumber == this.bitsInBuffer) { result = this.bitBuffer; this.bitBuffer = 0; this.bitsInBuffer = 0; this.byteCounter++; return result; } int i = numOfBitsAsNumber; int theBitBuffer = this.bitBuffer; int theBitBufferCounter = this.bitsInBuffer; final boolean doIncCounter = theBitBufferCounter != 0; while (i > 0) { if (theBitBufferCounter == 0) { if (doIncCounter) { this.byteCounter++; } final int nextByte = this.readByteFromStream(); if (nextByte < 0) { if (i == numOfBitsAsNumber) { return nextByte; } else { break; } } else { theBitBuffer = nextByte; theBitBufferCounter = 8; } } result = (result << 1) | (theBitBuffer & 1); theBitBuffer >>= 1; theBitBufferCounter--; i--; } this.bitBuffer = theBitBuffer; this.bitsInBuffer = theBitBufferCounter; return JBBPUtils.reverseBitsInByte(JBBPBitNumber.decode(numOfBitsAsNumber - i), (byte) result) & 0xFF; } }
[ "public", "int", "readBits", "(", "final", "JBBPBitNumber", "numOfBitsToRead", ")", "throws", "IOException", "{", "int", "result", ";", "final", "int", "numOfBitsAsNumber", "=", "numOfBitsToRead", ".", "getBitNumber", "(", ")", ";", "if", "(", "this", ".", "bitsInBuffer", "==", "0", "&&", "numOfBitsAsNumber", "==", "8", ")", "{", "result", "=", "this", ".", "readByteFromStream", "(", ")", ";", "if", "(", "result", ">=", "0", ")", "{", "this", ".", "byteCounter", "++", ";", "}", "return", "result", ";", "}", "else", "{", "result", "=", "0", ";", "if", "(", "numOfBitsAsNumber", "==", "this", ".", "bitsInBuffer", ")", "{", "result", "=", "this", ".", "bitBuffer", ";", "this", ".", "bitBuffer", "=", "0", ";", "this", ".", "bitsInBuffer", "=", "0", ";", "this", ".", "byteCounter", "++", ";", "return", "result", ";", "}", "int", "i", "=", "numOfBitsAsNumber", ";", "int", "theBitBuffer", "=", "this", ".", "bitBuffer", ";", "int", "theBitBufferCounter", "=", "this", ".", "bitsInBuffer", ";", "final", "boolean", "doIncCounter", "=", "theBitBufferCounter", "!=", "0", ";", "while", "(", "i", ">", "0", ")", "{", "if", "(", "theBitBufferCounter", "==", "0", ")", "{", "if", "(", "doIncCounter", ")", "{", "this", ".", "byteCounter", "++", ";", "}", "final", "int", "nextByte", "=", "this", ".", "readByteFromStream", "(", ")", ";", "if", "(", "nextByte", "<", "0", ")", "{", "if", "(", "i", "==", "numOfBitsAsNumber", ")", "{", "return", "nextByte", ";", "}", "else", "{", "break", ";", "}", "}", "else", "{", "theBitBuffer", "=", "nextByte", ";", "theBitBufferCounter", "=", "8", ";", "}", "}", "result", "=", "(", "result", "<<", "1", ")", "|", "(", "theBitBuffer", "&", "1", ")", ";", "theBitBuffer", ">>=", "1", ";", "theBitBufferCounter", "--", ";", "i", "--", ";", "}", "this", ".", "bitBuffer", "=", "theBitBuffer", ";", "this", ".", "bitsInBuffer", "=", "theBitBufferCounter", ";", "return", "JBBPUtils", ".", "reverseBitsInByte", "(", "JBBPBitNumber", ".", "decode", "(", "numOfBitsAsNumber", "-", "i", ")", ",", "(", "byte", ")", "result", ")", "&", "0xFF", ";", "}", "}" ]
Read number of bits from the input stream. It reads bits from input stream since 0 bit and make reversion to return bits in the right order when 0 bit is 0 bit. if the stream is completed early than the data read then reading is just stopped and read value returned. The First read bit is placed as 0th bit. @param numOfBitsToRead the number of bits to be read, must be 1..8 @return the read bits as integer, -1 if the end of stream has been reached @throws IOException it will be thrown for transport errors to be read @throws NullPointerException if number of bits to be read is null
[ "Read", "number", "of", "bits", "from", "the", "input", "stream", ".", "It", "reads", "bits", "from", "input", "stream", "since", "0", "bit", "and", "make", "reversion", "to", "return", "bits", "in", "the", "right", "order", "when", "0", "bit", "is", "0", "bit", ".", "if", "the", "stream", "is", "completed", "early", "than", "the", "data", "read", "then", "reading", "is", "just", "stopped", "and", "read", "value", "returned", ".", "The", "First", "read", "bit", "is", "placed", "as", "0th", "bit", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L664-L721
142,011
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.align
public void align(final long alignByteNumber) throws IOException { this.alignByte(); if (alignByteNumber > 0) { long padding = (alignByteNumber - (this.byteCounter % alignByteNumber)) % alignByteNumber; while (padding > 0) { final int skippedByte = this.read(); if (skippedByte < 0) { throw new EOFException("Can't align for " + alignByteNumber + " byte(s)"); } padding--; } } }
java
public void align(final long alignByteNumber) throws IOException { this.alignByte(); if (alignByteNumber > 0) { long padding = (alignByteNumber - (this.byteCounter % alignByteNumber)) % alignByteNumber; while (padding > 0) { final int skippedByte = this.read(); if (skippedByte < 0) { throw new EOFException("Can't align for " + alignByteNumber + " byte(s)"); } padding--; } } }
[ "public", "void", "align", "(", "final", "long", "alignByteNumber", ")", "throws", "IOException", "{", "this", ".", "alignByte", "(", ")", ";", "if", "(", "alignByteNumber", ">", "0", ")", "{", "long", "padding", "=", "(", "alignByteNumber", "-", "(", "this", ".", "byteCounter", "%", "alignByteNumber", ")", ")", "%", "alignByteNumber", ";", "while", "(", "padding", ">", "0", ")", "{", "final", "int", "skippedByte", "=", "this", ".", "read", "(", ")", ";", "if", "(", "skippedByte", "<", "0", ")", "{", "throw", "new", "EOFException", "(", "\"Can't align for \"", "+", "alignByteNumber", "+", "\" byte(s)\"", ")", ";", "}", "padding", "--", ";", "}", "}", "}" ]
Read padding bytes from the stream and ignore them to align the stream counter. @param alignByteNumber the byte number to align the stream @throws IOException it will be thrown for transport errors @throws EOFException it will be thrown if the stream end has been reached the before align border.
[ "Read", "padding", "bytes", "from", "the", "stream", "and", "ignore", "them", "to", "align", "the", "stream", "counter", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L776-L791
142,012
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readByteFromStream
private int readByteFromStream() throws IOException { int result = this.in.read(); if (result >= 0 && this.msb0) { result = JBBPUtils.reverseBitsInByte((byte) result) & 0xFF; } return result; }
java
private int readByteFromStream() throws IOException { int result = this.in.read(); if (result >= 0 && this.msb0) { result = JBBPUtils.reverseBitsInByte((byte) result) & 0xFF; } return result; }
[ "private", "int", "readByteFromStream", "(", ")", "throws", "IOException", "{", "int", "result", "=", "this", ".", "in", ".", "read", "(", ")", ";", "if", "(", "result", ">=", "0", "&&", "this", ".", "msb0", ")", "{", "result", "=", "JBBPUtils", ".", "reverseBitsInByte", "(", "(", "byte", ")", "result", ")", "&", "0xFF", ";", "}", "return", "result", ";", "}" ]
Inside method to read a byte from stream. @return the read byte or -1 if the end of the stream has been reached @throws IOException it will be thrown for transport errors
[ "Inside", "method", "to", "read", "a", "byte", "from", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L820-L826
142,013
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.loadNextByteInBuffer
private int loadNextByteInBuffer() throws IOException { final int value = this.readByteFromStream(); if (value < 0) { return value; } this.bitBuffer = value; this.bitsInBuffer = 8; return value; }
java
private int loadNextByteInBuffer() throws IOException { final int value = this.readByteFromStream(); if (value < 0) { return value; } this.bitBuffer = value; this.bitsInBuffer = 8; return value; }
[ "private", "int", "loadNextByteInBuffer", "(", ")", "throws", "IOException", "{", "final", "int", "value", "=", "this", ".", "readByteFromStream", "(", ")", ";", "if", "(", "value", "<", "0", ")", "{", "return", "value", ";", "}", "this", ".", "bitBuffer", "=", "value", ";", "this", ".", "bitsInBuffer", "=", "8", ";", "return", "value", ";", "}" ]
Read the next stream byte into bit buffer. @return the read byte or -1 if the endo of stream has been reached. @throws IOException it will be thrown for transport errors
[ "Read", "the", "next", "stream", "byte", "into", "bit", "buffer", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L834-L844
142,014
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readString
public String readString(final JBBPByteOrder byteOrder) throws IOException { final int prefix = this.readByte(); final int len; if (prefix == 0) { len = 0; } else if (prefix == 0xFF) { len = -1; } else if (prefix < 0x80) { len = prefix; } else if ((prefix & 0xF0) == 0x80) { switch (prefix & 0x0F) { case 1: { len = this.readByte(); } break; case 2: { len = this.readUnsignedShort(byteOrder); } break; case 3: { int buffer; if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { buffer = (this.readByte() << 16) | (this.readByte() << 8) | this.readByte(); } else { buffer = this.readByte() | (this.readByte() << 8) | (this.readByte() << 16); } len = buffer; } break; case 4: { len = this.readInt(byteOrder); } break; default: { throw makeIOExceptionForWrongPrefix(prefix); } } } else { throw makeIOExceptionForWrongPrefix(prefix); } final String result; if (len < 0) { result = null; } else if (len == 0) { result = ""; } else { result = JBBPUtils.utf8ToStr(this.readByteArray(len)); } return result; }
java
public String readString(final JBBPByteOrder byteOrder) throws IOException { final int prefix = this.readByte(); final int len; if (prefix == 0) { len = 0; } else if (prefix == 0xFF) { len = -1; } else if (prefix < 0x80) { len = prefix; } else if ((prefix & 0xF0) == 0x80) { switch (prefix & 0x0F) { case 1: { len = this.readByte(); } break; case 2: { len = this.readUnsignedShort(byteOrder); } break; case 3: { int buffer; if (byteOrder == JBBPByteOrder.BIG_ENDIAN) { buffer = (this.readByte() << 16) | (this.readByte() << 8) | this.readByte(); } else { buffer = this.readByte() | (this.readByte() << 8) | (this.readByte() << 16); } len = buffer; } break; case 4: { len = this.readInt(byteOrder); } break; default: { throw makeIOExceptionForWrongPrefix(prefix); } } } else { throw makeIOExceptionForWrongPrefix(prefix); } final String result; if (len < 0) { result = null; } else if (len == 0) { result = ""; } else { result = JBBPUtils.utf8ToStr(this.readByteArray(len)); } return result; }
[ "public", "String", "readString", "(", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "final", "int", "prefix", "=", "this", ".", "readByte", "(", ")", ";", "final", "int", "len", ";", "if", "(", "prefix", "==", "0", ")", "{", "len", "=", "0", ";", "}", "else", "if", "(", "prefix", "==", "0xFF", ")", "{", "len", "=", "-", "1", ";", "}", "else", "if", "(", "prefix", "<", "0x80", ")", "{", "len", "=", "prefix", ";", "}", "else", "if", "(", "(", "prefix", "&", "0xF0", ")", "==", "0x80", ")", "{", "switch", "(", "prefix", "&", "0x0F", ")", "{", "case", "1", ":", "{", "len", "=", "this", ".", "readByte", "(", ")", ";", "}", "break", ";", "case", "2", ":", "{", "len", "=", "this", ".", "readUnsignedShort", "(", "byteOrder", ")", ";", "}", "break", ";", "case", "3", ":", "{", "int", "buffer", ";", "if", "(", "byteOrder", "==", "JBBPByteOrder", ".", "BIG_ENDIAN", ")", "{", "buffer", "=", "(", "this", ".", "readByte", "(", ")", "<<", "16", ")", "|", "(", "this", ".", "readByte", "(", ")", "<<", "8", ")", "|", "this", ".", "readByte", "(", ")", ";", "}", "else", "{", "buffer", "=", "this", ".", "readByte", "(", ")", "|", "(", "this", ".", "readByte", "(", ")", "<<", "8", ")", "|", "(", "this", ".", "readByte", "(", ")", "<<", "16", ")", ";", "}", "len", "=", "buffer", ";", "}", "break", ";", "case", "4", ":", "{", "len", "=", "this", ".", "readInt", "(", "byteOrder", ")", ";", "}", "break", ";", "default", ":", "{", "throw", "makeIOExceptionForWrongPrefix", "(", "prefix", ")", ";", "}", "}", "}", "else", "{", "throw", "makeIOExceptionForWrongPrefix", "(", "prefix", ")", ";", "}", "final", "String", "result", ";", "if", "(", "len", "<", "0", ")", "{", "result", "=", "null", ";", "}", "else", "if", "(", "len", "==", "0", ")", "{", "result", "=", "\"\"", ";", "}", "else", "{", "result", "=", "JBBPUtils", ".", "utf8ToStr", "(", "this", ".", "readByteArray", "(", "len", ")", ")", ";", "}", "return", "result", ";", "}" ]
Read string in UTF8 format. @param byteOrder byte order, must not be null @return read string, can be null @throws IOException it will be thrown for transport error or wrong format @see JBBPBitOutputStream#writeString(String, JBBPByteOrder) @since 1.4.0
[ "Read", "string", "in", "UTF8", "format", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L966-L1017
142,015
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java
JBBPBitInputStream.readStringArray
public String[] readStringArray(final int items, final JBBPByteOrder byteOrder) throws IOException { int pos = 0; if (items < 0) { String[] buffer = new String[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (hasAvailableData()) { final String next = readString(byteOrder); if (buffer.length == pos) { final String[] newbuffer = new String[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } buffer[pos++] = next; } if (buffer.length == pos) { return buffer; } final String[] result = new String[pos]; System.arraycopy(buffer, 0, result, 0, pos); return result; } else { // number final String[] buffer = new String[items]; for (int i = 0; i < items; i++) { buffer[i] = readString(byteOrder); } return buffer; } }
java
public String[] readStringArray(final int items, final JBBPByteOrder byteOrder) throws IOException { int pos = 0; if (items < 0) { String[] buffer = new String[INITIAL_ARRAY_BUFFER_SIZE]; // till end while (hasAvailableData()) { final String next = readString(byteOrder); if (buffer.length == pos) { final String[] newbuffer = new String[buffer.length << 1]; System.arraycopy(buffer, 0, newbuffer, 0, buffer.length); buffer = newbuffer; } buffer[pos++] = next; } if (buffer.length == pos) { return buffer; } final String[] result = new String[pos]; System.arraycopy(buffer, 0, result, 0, pos); return result; } else { // number final String[] buffer = new String[items]; for (int i = 0; i < items; i++) { buffer[i] = readString(byteOrder); } return buffer; } }
[ "public", "String", "[", "]", "readStringArray", "(", "final", "int", "items", ",", "final", "JBBPByteOrder", "byteOrder", ")", "throws", "IOException", "{", "int", "pos", "=", "0", ";", "if", "(", "items", "<", "0", ")", "{", "String", "[", "]", "buffer", "=", "new", "String", "[", "INITIAL_ARRAY_BUFFER_SIZE", "]", ";", "// till end", "while", "(", "hasAvailableData", "(", ")", ")", "{", "final", "String", "next", "=", "readString", "(", "byteOrder", ")", ";", "if", "(", "buffer", ".", "length", "==", "pos", ")", "{", "final", "String", "[", "]", "newbuffer", "=", "new", "String", "[", "buffer", ".", "length", "<<", "1", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "newbuffer", ",", "0", ",", "buffer", ".", "length", ")", ";", "buffer", "=", "newbuffer", ";", "}", "buffer", "[", "pos", "++", "]", "=", "next", ";", "}", "if", "(", "buffer", ".", "length", "==", "pos", ")", "{", "return", "buffer", ";", "}", "final", "String", "[", "]", "result", "=", "new", "String", "[", "pos", "]", ";", "System", ".", "arraycopy", "(", "buffer", ",", "0", ",", "result", ",", "0", ",", "pos", ")", ";", "return", "result", ";", "}", "else", "{", "// number", "final", "String", "[", "]", "buffer", "=", "new", "String", "[", "items", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "items", ";", "i", "++", ")", "{", "buffer", "[", "i", "]", "=", "readString", "(", "byteOrder", ")", ";", "}", "return", "buffer", ";", "}", "}" ]
Read array of srings from stream. @param items number of items, or -1 if read whole stream @param byteOrder order of bytes in structure, must not be null @return array, it can contain null among values, must not be null @throws IOException thrown for transport errors @see JBBPBitOutputStream#writeStringArray(String[], JBBPByteOrder) @since 1.4.0
[ "Read", "array", "of", "srings", "from", "stream", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java#L1030-L1059
142,016
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/compiler/JBBPCompiledBlock.java
JBBPCompiledBlock.findFieldForPath
public JBBPNamedFieldInfo findFieldForPath(final String fieldPath) { JBBPNamedFieldInfo result = null; for (final JBBPNamedFieldInfo f : this.namedFieldData) { if (f.getFieldPath().equals(fieldPath)) { result = f; break; } } return result; }
java
public JBBPNamedFieldInfo findFieldForPath(final String fieldPath) { JBBPNamedFieldInfo result = null; for (final JBBPNamedFieldInfo f : this.namedFieldData) { if (f.getFieldPath().equals(fieldPath)) { result = f; break; } } return result; }
[ "public", "JBBPNamedFieldInfo", "findFieldForPath", "(", "final", "String", "fieldPath", ")", "{", "JBBPNamedFieldInfo", "result", "=", "null", ";", "for", "(", "final", "JBBPNamedFieldInfo", "f", ":", "this", ".", "namedFieldData", ")", "{", "if", "(", "f", ".", "getFieldPath", "(", ")", ".", "equals", "(", "fieldPath", ")", ")", "{", "result", "=", "f", ";", "break", ";", "}", "}", "return", "result", ";", "}" ]
Find a field for its path. @param fieldPath a field path @return a field to be found for the path, null otherwise
[ "Find", "a", "field", "for", "its", "path", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/compiler/JBBPCompiledBlock.java#L166-L177
142,017
raydac/java-binary-block-parser
jbbp/src/main/java/com/igormaznitsa/jbbp/compiler/JBBPCompiledBlock.java
JBBPCompiledBlock.findFieldOffsetForPath
public int findFieldOffsetForPath(final String fieldPath) { for (final JBBPNamedFieldInfo f : this.namedFieldData) { if (f.getFieldPath().equals(fieldPath)) { return f.getFieldOffsetInCompiledBlock(); } } throw new JBBPIllegalArgumentException("Unknown field path [" + fieldPath + ']'); }
java
public int findFieldOffsetForPath(final String fieldPath) { for (final JBBPNamedFieldInfo f : this.namedFieldData) { if (f.getFieldPath().equals(fieldPath)) { return f.getFieldOffsetInCompiledBlock(); } } throw new JBBPIllegalArgumentException("Unknown field path [" + fieldPath + ']'); }
[ "public", "int", "findFieldOffsetForPath", "(", "final", "String", "fieldPath", ")", "{", "for", "(", "final", "JBBPNamedFieldInfo", "f", ":", "this", ".", "namedFieldData", ")", "{", "if", "(", "f", ".", "getFieldPath", "(", ")", ".", "equals", "(", "fieldPath", ")", ")", "{", "return", "f", ".", "getFieldOffsetInCompiledBlock", "(", ")", ";", "}", "}", "throw", "new", "JBBPIllegalArgumentException", "(", "\"Unknown field path [\"", "+", "fieldPath", "+", "'", "'", ")", ";", "}" ]
Find offset of a field in the compiled block for its field path. @param fieldPath a field path, it must not be null @return the offset as integer for the field path @throws JBBPException if the field is not found
[ "Find", "offset", "of", "a", "field", "in", "the", "compiled", "block", "for", "its", "field", "path", "." ]
6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b
https://github.com/raydac/java-binary-block-parser/blob/6d98abcab01e0c72d525ebcc9e7b694f9ce49f5b/jbbp/src/main/java/com/igormaznitsa/jbbp/compiler/JBBPCompiledBlock.java#L186-L193
142,018
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/inspector/kafka/PrivilegeEventProducer.java
PrivilegeEventProducer.sendEvent
@Deprecated public void sendEvent(String eventId, String ymlPrivileges) { SystemEvent event = buildSystemEvent(eventId, ymlPrivileges); serializeEvent(event).ifPresent(this::send); }
java
@Deprecated public void sendEvent(String eventId, String ymlPrivileges) { SystemEvent event = buildSystemEvent(eventId, ymlPrivileges); serializeEvent(event).ifPresent(this::send); }
[ "@", "Deprecated", "public", "void", "sendEvent", "(", "String", "eventId", ",", "String", "ymlPrivileges", ")", "{", "SystemEvent", "event", "=", "buildSystemEvent", "(", "eventId", ",", "ymlPrivileges", ")", ";", "serializeEvent", "(", "event", ")", ".", "ifPresent", "(", "this", "::", "send", ")", ";", "}" ]
Build message for kafka's event and send it. @param eventId the event id @param ymlPrivileges the content @deprecated left only for backward compatibility, use {@link #sendEvent(String, Set)}
[ "Build", "message", "for", "kafka", "s", "event", "and", "send", "it", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/inspector/kafka/PrivilegeEventProducer.java#L48-L52
142,019
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/inspector/kafka/PrivilegeEventProducer.java
PrivilegeEventProducer.sendEvent
public void sendEvent(String eventId, Set<Privilege> privileges) { // TODO do not use yml in json events... String ymlPrivileges = PrivilegeMapper.privilegesToYml(privileges); SystemEvent event = buildSystemEvent(eventId, ymlPrivileges); serializeEvent(event).ifPresent(this::send); }
java
public void sendEvent(String eventId, Set<Privilege> privileges) { // TODO do not use yml in json events... String ymlPrivileges = PrivilegeMapper.privilegesToYml(privileges); SystemEvent event = buildSystemEvent(eventId, ymlPrivileges); serializeEvent(event).ifPresent(this::send); }
[ "public", "void", "sendEvent", "(", "String", "eventId", ",", "Set", "<", "Privilege", ">", "privileges", ")", "{", "// TODO do not use yml in json events...", "String", "ymlPrivileges", "=", "PrivilegeMapper", ".", "privilegesToYml", "(", "privileges", ")", ";", "SystemEvent", "event", "=", "buildSystemEvent", "(", "eventId", ",", "ymlPrivileges", ")", ";", "serializeEvent", "(", "event", ")", ".", "ifPresent", "(", "this", "::", "send", ")", ";", "}" ]
Build MS_PRIVILEGES message for system queue event and send it. @param eventId the event id @param privileges the event data (privileges)
[ "Build", "MS_PRIVILEGES", "message", "for", "system", "queue", "event", "and", "send", "it", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/inspector/kafka/PrivilegeEventProducer.java#L60-L66
142,020
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/inspector/kafka/PrivilegeEventProducer.java
PrivilegeEventProducer.send
private void send(String content) { if (!StringUtils.isBlank(content)) { log.info("Sending system queue event to kafka-topic = '{}', data = '{}'", topicName, content); template.send(topicName, content); } }
java
private void send(String content) { if (!StringUtils.isBlank(content)) { log.info("Sending system queue event to kafka-topic = '{}', data = '{}'", topicName, content); template.send(topicName, content); } }
[ "private", "void", "send", "(", "String", "content", ")", "{", "if", "(", "!", "StringUtils", ".", "isBlank", "(", "content", ")", ")", "{", "log", ".", "info", "(", "\"Sending system queue event to kafka-topic = '{}', data = '{}'\"", ",", "topicName", ",", "content", ")", ";", "template", ".", "send", "(", "topicName", ",", "content", ")", ";", "}", "}" ]
Send event to system queue. @param content the event content
[ "Send", "event", "to", "system", "queue", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/inspector/kafka/PrivilegeEventProducer.java#L93-L98
142,021
xm-online/xm-commons
xm-commons-migration-db/src/main/java/com/icthh/xm/commons/migration/db/util/DatabaseUtil.java
DatabaseUtil.createSchema
public static void createSchema(DataSource dataSource, String name) { try (Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement()) { statement.executeUpdate(String.format(Constants.DDL_CREATE_SCHEMA, name)); } catch (SQLException e) { throw new RuntimeException("Can not connect to database", e); } }
java
public static void createSchema(DataSource dataSource, String name) { try (Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement()) { statement.executeUpdate(String.format(Constants.DDL_CREATE_SCHEMA, name)); } catch (SQLException e) { throw new RuntimeException("Can not connect to database", e); } }
[ "public", "static", "void", "createSchema", "(", "DataSource", "dataSource", ",", "String", "name", ")", "{", "try", "(", "Connection", "connection", "=", "dataSource", ".", "getConnection", "(", ")", ";", "Statement", "statement", "=", "connection", ".", "createStatement", "(", ")", ")", "{", "statement", ".", "executeUpdate", "(", "String", ".", "format", "(", "Constants", ".", "DDL_CREATE_SCHEMA", ",", "name", ")", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Can not connect to database\"", ",", "e", ")", ";", "}", "}" ]
Creates new database scheme. @param dataSource the datasource @param name schema name
[ "Creates", "new", "database", "scheme", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-migration-db/src/main/java/com/icthh/xm/commons/migration/db/util/DatabaseUtil.java#L25-L32
142,022
xm-online/xm-commons
xm-commons-messaging/src/main/java/com/icthh/xm/commons/messaging/event/system/SystemEvent.java
SystemEvent.getDataMap
@JsonIgnore @SuppressWarnings("unchecked") public Map<String, Object> getDataMap() { if (data instanceof Map) { return (Map<String, Object>) data; } return Collections.emptyMap(); }
java
@JsonIgnore @SuppressWarnings("unchecked") public Map<String, Object> getDataMap() { if (data instanceof Map) { return (Map<String, Object>) data; } return Collections.emptyMap(); }
[ "@", "JsonIgnore", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Map", "<", "String", ",", "Object", ">", "getDataMap", "(", ")", "{", "if", "(", "data", "instanceof", "Map", ")", "{", "return", "(", "Map", "<", "String", ",", "Object", ">", ")", "data", ";", "}", "return", "Collections", ".", "emptyMap", "(", ")", ";", "}" ]
Get data as Map. @return map with data
[ "Get", "data", "as", "Map", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-messaging/src/main/java/com/icthh/xm/commons/messaging/event/system/SystemEvent.java#L45-L52
142,023
xm-online/xm-commons
xm-commons-i18n/src/main/java/com/icthh/xm/commons/i18n/spring/service/LocalizationMessageService.java
LocalizationMessageService.getMessage
public String getMessage(String code, Map<String, String> substitutes, boolean firstFindInMessageBundle, String defaultMessage) { Locale locale = authContextHolder.getContext().getDetailsValue(LANGUAGE) .map(Locale::forLanguageTag).orElse(LocaleContextHolder.getLocale()); String localizedMessage = getFromConfig(code, locale).orElseGet(() -> { if (firstFindInMessageBundle) { return messageSource.getMessage(code, null, defaultMessage, locale); } else { return defaultMessage != null ? defaultMessage : messageSource.getMessage(code, null, locale); } }); if (MapUtils.isNotEmpty(substitutes)) { localizedMessage = new StringSubstitutor(substitutes).replace(localizedMessage); } return localizedMessage; }
java
public String getMessage(String code, Map<String, String> substitutes, boolean firstFindInMessageBundle, String defaultMessage) { Locale locale = authContextHolder.getContext().getDetailsValue(LANGUAGE) .map(Locale::forLanguageTag).orElse(LocaleContextHolder.getLocale()); String localizedMessage = getFromConfig(code, locale).orElseGet(() -> { if (firstFindInMessageBundle) { return messageSource.getMessage(code, null, defaultMessage, locale); } else { return defaultMessage != null ? defaultMessage : messageSource.getMessage(code, null, locale); } }); if (MapUtils.isNotEmpty(substitutes)) { localizedMessage = new StringSubstitutor(substitutes).replace(localizedMessage); } return localizedMessage; }
[ "public", "String", "getMessage", "(", "String", "code", ",", "Map", "<", "String", ",", "String", ">", "substitutes", ",", "boolean", "firstFindInMessageBundle", ",", "String", "defaultMessage", ")", "{", "Locale", "locale", "=", "authContextHolder", ".", "getContext", "(", ")", ".", "getDetailsValue", "(", "LANGUAGE", ")", ".", "map", "(", "Locale", "::", "forLanguageTag", ")", ".", "orElse", "(", "LocaleContextHolder", ".", "getLocale", "(", ")", ")", ";", "String", "localizedMessage", "=", "getFromConfig", "(", "code", ",", "locale", ")", ".", "orElseGet", "(", "(", ")", "->", "{", "if", "(", "firstFindInMessageBundle", ")", "{", "return", "messageSource", ".", "getMessage", "(", "code", ",", "null", ",", "defaultMessage", ",", "locale", ")", ";", "}", "else", "{", "return", "defaultMessage", "!=", "null", "?", "defaultMessage", ":", "messageSource", ".", "getMessage", "(", "code", ",", "null", ",", "locale", ")", ";", "}", "}", ")", ";", "if", "(", "MapUtils", ".", "isNotEmpty", "(", "substitutes", ")", ")", "{", "localizedMessage", "=", "new", "StringSubstitutor", "(", "substitutes", ")", ".", "replace", "(", "localizedMessage", ")", ";", "}", "return", "localizedMessage", ";", "}" ]
Finds localized message template by code and current locale from config. If not found it takes message from message bundle or from default message first, depends on flag. @param code the message code @param firstFindInMessageBundle indicates where try to find message first when config has returned NULL @param defaultMessage the default message @return localized message
[ "Finds", "localized", "message", "template", "by", "code", "and", "current", "locale", "from", "config", ".", "If", "not", "found", "it", "takes", "message", "from", "message", "bundle", "or", "from", "default", "message", "first", "depends", "on", "flag", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-i18n/src/main/java/com/icthh/xm/commons/i18n/spring/service/LocalizationMessageService.java#L64-L84
142,024
xm-online/xm-commons
xm-commons-i18n/src/main/java/com/icthh/xm/commons/i18n/spring/service/LocalizationMessageService.java
LocalizationMessageService.getMessage
public String getMessage(String code, Map<String, String> substitutes) { return getMessage(code, substitutes, true, null); }
java
public String getMessage(String code, Map<String, String> substitutes) { return getMessage(code, substitutes, true, null); }
[ "public", "String", "getMessage", "(", "String", "code", ",", "Map", "<", "String", ",", "String", ">", "substitutes", ")", "{", "return", "getMessage", "(", "code", ",", "substitutes", ",", "true", ",", "null", ")", ";", "}" ]
Finds localized message template by code and current locale from config. If not found it takes message from message bundle and replaces all the occurrences of variables with their matching values from the substitute map. @param code the message code @param substitutes the substitute map for message template @return localized message
[ "Finds", "localized", "message", "template", "by", "code", "and", "current", "locale", "from", "config", ".", "If", "not", "found", "it", "takes", "message", "from", "message", "bundle", "and", "replaces", "all", "the", "occurrences", "of", "variables", "with", "their", "matching", "values", "from", "the", "substitute", "map", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-i18n/src/main/java/com/icthh/xm/commons/i18n/spring/service/LocalizationMessageService.java#L104-L106
142,025
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/RoleService.java
RoleService.getRoles
public Map<String, Role> getRoles(String tenant) { if (!roles.containsKey(tenant)) { return new HashMap<>(); } return roles.get(tenant); }
java
public Map<String, Role> getRoles(String tenant) { if (!roles.containsKey(tenant)) { return new HashMap<>(); } return roles.get(tenant); }
[ "public", "Map", "<", "String", ",", "Role", ">", "getRoles", "(", "String", "tenant", ")", "{", "if", "(", "!", "roles", ".", "containsKey", "(", "tenant", ")", ")", "{", "return", "new", "HashMap", "<>", "(", ")", ";", "}", "return", "roles", ".", "get", "(", "tenant", ")", ";", "}" ]
Get roles configuration for tenant. Map key is ROLE_KEY and value is role. @param tenant the tenant @return role
[ "Get", "roles", "configuration", "for", "tenant", ".", "Map", "key", "is", "ROLE_KEY", "and", "value", "is", "role", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/RoleService.java#L37-L42
142,026
xm-online/xm-commons
xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/LogObjectPrinter.java
LogObjectPrinter.printExceptionWithStackInfo
public static String printExceptionWithStackInfo(Throwable throwable) { StringBuilder out = new StringBuilder(); printExceptionWithStackInfo(throwable, out); return out.toString(); }
java
public static String printExceptionWithStackInfo(Throwable throwable) { StringBuilder out = new StringBuilder(); printExceptionWithStackInfo(throwable, out); return out.toString(); }
[ "public", "static", "String", "printExceptionWithStackInfo", "(", "Throwable", "throwable", ")", "{", "StringBuilder", "out", "=", "new", "StringBuilder", "(", ")", ";", "printExceptionWithStackInfo", "(", "throwable", ",", "out", ")", ";", "return", "out", ".", "toString", "(", ")", ";", "}" ]
Builds log string for exception with stack trace. @param throwable the exception @return exception description string with stack trace
[ "Builds", "log", "string", "for", "exception", "with", "stack", "trace", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/LogObjectPrinter.java#L68-L72
142,027
xm-online/xm-commons
xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/LogObjectPrinter.java
LogObjectPrinter.joinUrlPaths
@SafeVarargs public static <T> String joinUrlPaths(final T[] arr, final T... arr2) { try { T[] url = ArrayUtils.addAll(arr, arr2); String res = StringUtils.join(url); return (res == null) ? "" : res; } catch (IndexOutOfBoundsException | IllegalArgumentException | ArrayStoreException e) { log.warn("Error while join URL paths from: {}, {}", arr, arr2); return "printerror:" + e; } }
java
@SafeVarargs public static <T> String joinUrlPaths(final T[] arr, final T... arr2) { try { T[] url = ArrayUtils.addAll(arr, arr2); String res = StringUtils.join(url); return (res == null) ? "" : res; } catch (IndexOutOfBoundsException | IllegalArgumentException | ArrayStoreException e) { log.warn("Error while join URL paths from: {}, {}", arr, arr2); return "printerror:" + e; } }
[ "@", "SafeVarargs", "public", "static", "<", "T", ">", "String", "joinUrlPaths", "(", "final", "T", "[", "]", "arr", ",", "final", "T", "...", "arr2", ")", "{", "try", "{", "T", "[", "]", "url", "=", "ArrayUtils", ".", "addAll", "(", "arr", ",", "arr2", ")", ";", "String", "res", "=", "StringUtils", ".", "join", "(", "url", ")", ";", "return", "(", "res", "==", "null", ")", "?", "\"\"", ":", "res", ";", "}", "catch", "(", "IndexOutOfBoundsException", "|", "IllegalArgumentException", "|", "ArrayStoreException", "e", ")", "{", "log", ".", "warn", "(", "\"Error while join URL paths from: {}, {}\"", ",", "arr", ",", "arr2", ")", ";", "return", "\"printerror:\"", "+", "e", ";", "}", "}" ]
Join URL path into one string. @param arr first url paths @param arr2 other url paths @param <T> url part path type @return URL representation string
[ "Join", "URL", "path", "into", "one", "string", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/LogObjectPrinter.java#L110-L120
142,028
xm-online/xm-commons
xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/LogObjectPrinter.java
LogObjectPrinter.getCallMethod
public static String getCallMethod(JoinPoint joinPoint) { if (joinPoint != null && joinPoint.getSignature() != null) { Class<?> declaringType = joinPoint.getSignature().getDeclaringType(); String className = (declaringType != null) ? declaringType.getSimpleName() : PRINT_QUESTION; String methodName = joinPoint.getSignature().getName(); return className + PRINT_SEMICOLON + methodName; } return PRINT_EMPTY_METHOD; }
java
public static String getCallMethod(JoinPoint joinPoint) { if (joinPoint != null && joinPoint.getSignature() != null) { Class<?> declaringType = joinPoint.getSignature().getDeclaringType(); String className = (declaringType != null) ? declaringType.getSimpleName() : PRINT_QUESTION; String methodName = joinPoint.getSignature().getName(); return className + PRINT_SEMICOLON + methodName; } return PRINT_EMPTY_METHOD; }
[ "public", "static", "String", "getCallMethod", "(", "JoinPoint", "joinPoint", ")", "{", "if", "(", "joinPoint", "!=", "null", "&&", "joinPoint", ".", "getSignature", "(", ")", "!=", "null", ")", "{", "Class", "<", "?", ">", "declaringType", "=", "joinPoint", ".", "getSignature", "(", ")", ".", "getDeclaringType", "(", ")", ";", "String", "className", "=", "(", "declaringType", "!=", "null", ")", "?", "declaringType", ".", "getSimpleName", "(", ")", ":", "PRINT_QUESTION", ";", "String", "methodName", "=", "joinPoint", ".", "getSignature", "(", ")", ".", "getName", "(", ")", ";", "return", "className", "+", "PRINT_SEMICOLON", "+", "methodName", ";", "}", "return", "PRINT_EMPTY_METHOD", ";", "}" ]
Gets method description string from join point. @param joinPoint aspect join point @return method description string from join point
[ "Gets", "method", "description", "string", "from", "join", "point", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/LogObjectPrinter.java#L128-L136
142,029
xm-online/xm-commons
xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/LogObjectPrinter.java
LogObjectPrinter.printInputParams
public static String printInputParams(JoinPoint joinPoint, String... includeParamNames) { try { if (joinPoint == null) { return "joinPoint is null"; } Signature signature = joinPoint.getSignature(); if (!(signature instanceof MethodSignature)) { return PRINT_EMPTY_LIST; } Optional<LoggingAspectConfig> config = AopAnnotationUtils.getConfigAnnotation(joinPoint); String[] includeParams = includeParamNames; String[] excludeParams = EMPTY_ARRAY; boolean inputCollectionAware = LoggingAspectConfig.DEFAULT_INPUT_COLLECTION_AWARE; if (config.isPresent()) { if (!config.get().inputDetails()) { return PRINT_HIDDEN; } inputCollectionAware = config.get().inputCollectionAware(); if (ArrayUtils.isNotEmpty(config.get().inputIncludeParams())) { includeParams = config.get().inputIncludeParams(); } if (ArrayUtils.isEmpty(includeParams) && ArrayUtils.isNotEmpty(config.get().inputExcludeParams())) { excludeParams = config.get().inputExcludeParams(); } } MethodSignature ms = (MethodSignature) signature; String[] params = ms.getParameterNames(); return ArrayUtils.isNotEmpty(params) ? renderParams(joinPoint, params, includeParams, excludeParams, inputCollectionAware) : PRINT_EMPTY_LIST; } catch (IndexOutOfBoundsException | IllegalArgumentException e) { log.warn("Error while print params: {}, params = {}", e, joinPoint.getArgs()); return "printerror: " + e; } }
java
public static String printInputParams(JoinPoint joinPoint, String... includeParamNames) { try { if (joinPoint == null) { return "joinPoint is null"; } Signature signature = joinPoint.getSignature(); if (!(signature instanceof MethodSignature)) { return PRINT_EMPTY_LIST; } Optional<LoggingAspectConfig> config = AopAnnotationUtils.getConfigAnnotation(joinPoint); String[] includeParams = includeParamNames; String[] excludeParams = EMPTY_ARRAY; boolean inputCollectionAware = LoggingAspectConfig.DEFAULT_INPUT_COLLECTION_AWARE; if (config.isPresent()) { if (!config.get().inputDetails()) { return PRINT_HIDDEN; } inputCollectionAware = config.get().inputCollectionAware(); if (ArrayUtils.isNotEmpty(config.get().inputIncludeParams())) { includeParams = config.get().inputIncludeParams(); } if (ArrayUtils.isEmpty(includeParams) && ArrayUtils.isNotEmpty(config.get().inputExcludeParams())) { excludeParams = config.get().inputExcludeParams(); } } MethodSignature ms = (MethodSignature) signature; String[] params = ms.getParameterNames(); return ArrayUtils.isNotEmpty(params) ? renderParams(joinPoint, params, includeParams, excludeParams, inputCollectionAware) : PRINT_EMPTY_LIST; } catch (IndexOutOfBoundsException | IllegalArgumentException e) { log.warn("Error while print params: {}, params = {}", e, joinPoint.getArgs()); return "printerror: " + e; } }
[ "public", "static", "String", "printInputParams", "(", "JoinPoint", "joinPoint", ",", "String", "...", "includeParamNames", ")", "{", "try", "{", "if", "(", "joinPoint", "==", "null", ")", "{", "return", "\"joinPoint is null\"", ";", "}", "Signature", "signature", "=", "joinPoint", ".", "getSignature", "(", ")", ";", "if", "(", "!", "(", "signature", "instanceof", "MethodSignature", ")", ")", "{", "return", "PRINT_EMPTY_LIST", ";", "}", "Optional", "<", "LoggingAspectConfig", ">", "config", "=", "AopAnnotationUtils", ".", "getConfigAnnotation", "(", "joinPoint", ")", ";", "String", "[", "]", "includeParams", "=", "includeParamNames", ";", "String", "[", "]", "excludeParams", "=", "EMPTY_ARRAY", ";", "boolean", "inputCollectionAware", "=", "LoggingAspectConfig", ".", "DEFAULT_INPUT_COLLECTION_AWARE", ";", "if", "(", "config", ".", "isPresent", "(", ")", ")", "{", "if", "(", "!", "config", ".", "get", "(", ")", ".", "inputDetails", "(", ")", ")", "{", "return", "PRINT_HIDDEN", ";", "}", "inputCollectionAware", "=", "config", ".", "get", "(", ")", ".", "inputCollectionAware", "(", ")", ";", "if", "(", "ArrayUtils", ".", "isNotEmpty", "(", "config", ".", "get", "(", ")", ".", "inputIncludeParams", "(", ")", ")", ")", "{", "includeParams", "=", "config", ".", "get", "(", ")", ".", "inputIncludeParams", "(", ")", ";", "}", "if", "(", "ArrayUtils", ".", "isEmpty", "(", "includeParams", ")", "&&", "ArrayUtils", ".", "isNotEmpty", "(", "config", ".", "get", "(", ")", ".", "inputExcludeParams", "(", ")", ")", ")", "{", "excludeParams", "=", "config", ".", "get", "(", ")", ".", "inputExcludeParams", "(", ")", ";", "}", "}", "MethodSignature", "ms", "=", "(", "MethodSignature", ")", "signature", ";", "String", "[", "]", "params", "=", "ms", ".", "getParameterNames", "(", ")", ";", "return", "ArrayUtils", ".", "isNotEmpty", "(", "params", ")", "?", "renderParams", "(", "joinPoint", ",", "params", ",", "includeParams", ",", "excludeParams", ",", "inputCollectionAware", ")", ":", "PRINT_EMPTY_LIST", ";", "}", "catch", "(", "IndexOutOfBoundsException", "|", "IllegalArgumentException", "e", ")", "{", "log", ".", "warn", "(", "\"Error while print params: {}, params = {}\"", ",", "e", ",", "joinPoint", ".", "getArgs", "(", ")", ")", ";", "return", "\"printerror: \"", "+", "e", ";", "}", "}" ]
Gets join point input params description string. @param joinPoint aspect join point @param includeParamNames input parameters names to be printed. NOTE! can be overridden with @{@link LoggingAspectConfig} @return join point input params description string
[ "Gets", "join", "point", "input", "params", "description", "string", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/LogObjectPrinter.java#L146-L187
142,030
xm-online/xm-commons
xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/LogObjectPrinter.java
LogObjectPrinter.printCollectionAware
public static String printCollectionAware(final Object object, final boolean printBody) { if (!printBody) { return PRINT_HIDDEN; } if (object == null) { return String.valueOf(object); } Class<?> clazz = object.getClass(); if (!Collection.class.isAssignableFrom(clazz)) { return String.valueOf(object); } return new StringBuilder().append("[<") .append(clazz.getSimpleName()) .append("> size = ") .append(Collection.class.cast(object).size()).append("]") .toString(); }
java
public static String printCollectionAware(final Object object, final boolean printBody) { if (!printBody) { return PRINT_HIDDEN; } if (object == null) { return String.valueOf(object); } Class<?> clazz = object.getClass(); if (!Collection.class.isAssignableFrom(clazz)) { return String.valueOf(object); } return new StringBuilder().append("[<") .append(clazz.getSimpleName()) .append("> size = ") .append(Collection.class.cast(object).size()).append("]") .toString(); }
[ "public", "static", "String", "printCollectionAware", "(", "final", "Object", "object", ",", "final", "boolean", "printBody", ")", "{", "if", "(", "!", "printBody", ")", "{", "return", "PRINT_HIDDEN", ";", "}", "if", "(", "object", "==", "null", ")", "{", "return", "String", ".", "valueOf", "(", "object", ")", ";", "}", "Class", "<", "?", ">", "clazz", "=", "object", ".", "getClass", "(", ")", ";", "if", "(", "!", "Collection", ".", "class", ".", "isAssignableFrom", "(", "clazz", ")", ")", "{", "return", "String", ".", "valueOf", "(", "object", ")", ";", "}", "return", "new", "StringBuilder", "(", ")", ".", "append", "(", "\"[<\"", ")", ".", "append", "(", "clazz", ".", "getSimpleName", "(", ")", ")", ".", "append", "(", "\"> size = \"", ")", ".", "append", "(", "Collection", ".", "class", ".", "cast", "(", "object", ")", ".", "size", "(", ")", ")", ".", "append", "(", "\"]\"", ")", ".", "toString", "(", ")", ";", "}" ]
Gets object representation with size for collection case. @param object object instance to log @param printBody if {@code true} then prevent object string representation @return object representation with size for collection case
[ "Gets", "object", "representation", "with", "size", "for", "collection", "case", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/LogObjectPrinter.java#L297-L317
142,031
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/translator/SpelToJpqlTranslator.java
SpelToJpqlTranslator.replaceOperators
private static String replaceOperators(String spel) { if (StringUtils.isBlank(spel)) { return spel; } return spel.replaceAll("==", " = ") .replaceAll("&&", " and ") .replaceAll("\\|\\|", " or "); }
java
private static String replaceOperators(String spel) { if (StringUtils.isBlank(spel)) { return spel; } return spel.replaceAll("==", " = ") .replaceAll("&&", " and ") .replaceAll("\\|\\|", " or "); }
[ "private", "static", "String", "replaceOperators", "(", "String", "spel", ")", "{", "if", "(", "StringUtils", ".", "isBlank", "(", "spel", ")", ")", "{", "return", "spel", ";", "}", "return", "spel", ".", "replaceAll", "(", "\"==\"", ",", "\" = \"", ")", ".", "replaceAll", "(", "\"&&\"", ",", "\" and \"", ")", ".", "replaceAll", "(", "\"\\\\|\\\\|\"", ",", "\" or \"", ")", ";", "}" ]
Replace SPEL ==, &&, || to SQL =, and, or . @param spel the spring expression @return sql expression
[ "Replace", "SPEL", "==", "&&", "||", "to", "SQL", "=", "and", "or", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/translator/SpelToJpqlTranslator.java#L29-L36
142,032
xm-online/xm-commons
xm-commons-tenant/src/main/java/com/icthh/xm/commons/tenant/XmJvmSecurityUtils.java
XmJvmSecurityUtils.checkSecurity
public static void checkSecurity() { SecurityManager securityManager = System.getSecurityManager(); if (securityManager != null) { securityManager.checkPermission(new ManagementPermission(PERMISSION_NAME_CONTROL)); } }
java
public static void checkSecurity() { SecurityManager securityManager = System.getSecurityManager(); if (securityManager != null) { securityManager.checkPermission(new ManagementPermission(PERMISSION_NAME_CONTROL)); } }
[ "public", "static", "void", "checkSecurity", "(", ")", "{", "SecurityManager", "securityManager", "=", "System", ".", "getSecurityManager", "(", ")", ";", "if", "(", "securityManager", "!=", "null", ")", "{", "securityManager", ".", "checkPermission", "(", "new", "ManagementPermission", "(", "PERMISSION_NAME_CONTROL", ")", ")", ";", "}", "}" ]
If JVM security manager exists then checks JVM security 'control' permission.
[ "If", "JVM", "security", "manager", "exists", "then", "checks", "JVM", "security", "control", "permission", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-tenant/src/main/java/com/icthh/xm/commons/tenant/XmJvmSecurityUtils.java#L18-L23
142,033
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/AbstractConfig.java
AbstractConfig.getString
protected final <T> String getString(final IKey<T> key) { final Object value = config.get(key.key()); return String.valueOf(value != null ? value : key.getDefaultValue()); }
java
protected final <T> String getString(final IKey<T> key) { final Object value = config.get(key.key()); return String.valueOf(value != null ? value : key.getDefaultValue()); }
[ "protected", "final", "<", "T", ">", "String", "getString", "(", "final", "IKey", "<", "T", ">", "key", ")", "{", "final", "Object", "value", "=", "config", ".", "get", "(", "key", ".", "key", "(", ")", ")", ";", "return", "String", ".", "valueOf", "(", "value", "!=", "null", "?", "value", ":", "key", ".", "getDefaultValue", "(", ")", ")", ";", "}" ]
returns the value as string according to given key. If no value is set, the default value will be returned. @param key The key to read. @return the value as string.
[ "returns", "the", "value", "as", "string", "according", "to", "given", "key", ".", "If", "no", "value", "is", "set", "the", "default", "value", "will", "be", "returned", "." ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/AbstractConfig.java#L96-L100
142,034
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/AbstractConfig.java
AbstractConfig.get
@SuppressWarnings("unchecked") @Override public final <T> T get(final IKey<T> key) { T value = (T) config.get(key.key()); return value != null ? value : key.getDefaultValue(); }
java
@SuppressWarnings("unchecked") @Override public final <T> T get(final IKey<T> key) { T value = (T) config.get(key.key()); return value != null ? value : key.getDefaultValue(); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "final", "<", "T", ">", "T", "get", "(", "final", "IKey", "<", "T", ">", "key", ")", "{", "T", "value", "=", "(", "T", ")", "config", ".", "get", "(", "key", ".", "key", "(", ")", ")", ";", "return", "value", "!=", "null", "?", "value", ":", "key", ".", "getDefaultValue", "(", ")", ";", "}" ]
returns the value for the given key. If no value is set, the default value will be returned. @param key The key to read. @return the value.
[ "returns", "the", "value", "for", "the", "given", "key", ".", "If", "no", "value", "is", "set", "the", "default", "value", "will", "be", "returned", "." ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/AbstractConfig.java#L109-L115
142,035
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/AbstractConfig.java
AbstractConfig.newKey
protected static <T> IKey<T> newKey(final String key, final T defaultValue) { return new Key<T>(key, defaultValue); }
java
protected static <T> IKey<T> newKey(final String key, final T defaultValue) { return new Key<T>(key, defaultValue); }
[ "protected", "static", "<", "T", ">", "IKey", "<", "T", ">", "newKey", "(", "final", "String", "key", ",", "final", "T", "defaultValue", ")", "{", "return", "new", "Key", "<", "T", ">", "(", "key", ",", "defaultValue", ")", ";", "}" ]
creates a new key. @param key string representation of this key @param defaultValue The default value
[ "creates", "a", "new", "key", "." ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/AbstractConfig.java#L134-L136
142,036
xm-online/xm-commons
xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/XmLepScriptConfigServerResourceLoader.java
XmLepScriptConfigServerResourceLoader.getResource
@Override public Resource getResource(String location) { String cfgPath = StringUtils.removeStart(location, XM_MS_CONFIG_URL_PREFIX); return scriptResources.getOrDefault(cfgPath, XmLepScriptResource.nonExist()); }
java
@Override public Resource getResource(String location) { String cfgPath = StringUtils.removeStart(location, XM_MS_CONFIG_URL_PREFIX); return scriptResources.getOrDefault(cfgPath, XmLepScriptResource.nonExist()); }
[ "@", "Override", "public", "Resource", "getResource", "(", "String", "location", ")", "{", "String", "cfgPath", "=", "StringUtils", ".", "removeStart", "(", "location", ",", "XM_MS_CONFIG_URL_PREFIX", ")", ";", "return", "scriptResources", ".", "getOrDefault", "(", "cfgPath", ",", "XmLepScriptResource", ".", "nonExist", "(", ")", ")", ";", "}" ]
Get LEP script resource. @param location {@code /config/tenant/{tenant-key}/{ms-name}/lep/a/b/c/SomeScript.groovy} @return the LEP script resource
[ "Get", "LEP", "script", "resource", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/XmLepScriptConfigServerResourceLoader.java#L99-L103
142,037
xm-online/xm-commons
xm-commons-config/src/main/java/com/icthh/xm/commons/config/client/api/AbstractConfigService.java
AbstractConfigService.updateConfigurations
@Override public void updateConfigurations(String commit, Collection<String> paths) { Map<String, Configuration> configurationsMap = getConfigurationMap(commit, paths); paths.forEach(path -> notifyUpdated(configurationsMap .getOrDefault(path, new Configuration(path, null)))); }
java
@Override public void updateConfigurations(String commit, Collection<String> paths) { Map<String, Configuration> configurationsMap = getConfigurationMap(commit, paths); paths.forEach(path -> notifyUpdated(configurationsMap .getOrDefault(path, new Configuration(path, null)))); }
[ "@", "Override", "public", "void", "updateConfigurations", "(", "String", "commit", ",", "Collection", "<", "String", ">", "paths", ")", "{", "Map", "<", "String", ",", "Configuration", ">", "configurationsMap", "=", "getConfigurationMap", "(", "commit", ",", "paths", ")", ";", "paths", ".", "forEach", "(", "path", "->", "notifyUpdated", "(", "configurationsMap", ".", "getOrDefault", "(", "path", ",", "new", "Configuration", "(", "path", ",", "null", ")", ")", ")", ")", ";", "}" ]
Update configuration from config service @param commit commit hash, will be empty if configuration deleted @param paths collection of paths updated
[ "Update", "configuration", "from", "config", "service" ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-config/src/main/java/com/icthh/xm/commons/config/client/api/AbstractConfigService.java#L28-L33
142,038
xm-online/xm-commons
xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/MdcUtils.java
MdcUtils.generateRid
public static String generateRid() { byte[] encode = Base64.getEncoder().encode(DigestUtils.sha256(UUID.randomUUID().toString())); try { String rid = new String(encode, StandardCharsets.UTF_8.name()); rid = StringUtils.replaceChars(rid, "+/=", ""); return StringUtils.right(rid, RID_LENGTH); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e); } }
java
public static String generateRid() { byte[] encode = Base64.getEncoder().encode(DigestUtils.sha256(UUID.randomUUID().toString())); try { String rid = new String(encode, StandardCharsets.UTF_8.name()); rid = StringUtils.replaceChars(rid, "+/=", ""); return StringUtils.right(rid, RID_LENGTH); } catch (UnsupportedEncodingException e) { throw new IllegalStateException(e); } }
[ "public", "static", "String", "generateRid", "(", ")", "{", "byte", "[", "]", "encode", "=", "Base64", ".", "getEncoder", "(", ")", ".", "encode", "(", "DigestUtils", ".", "sha256", "(", "UUID", ".", "randomUUID", "(", ")", ".", "toString", "(", ")", ")", ")", ";", "try", "{", "String", "rid", "=", "new", "String", "(", "encode", ",", "StandardCharsets", ".", "UTF_8", ".", "name", "(", ")", ")", ";", "rid", "=", "StringUtils", ".", "replaceChars", "(", "rid", ",", "\"+/=\"", ",", "\"\"", ")", ";", "return", "StringUtils", ".", "right", "(", "rid", ",", "RID_LENGTH", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "e", ")", ";", "}", "}" ]
Generates request id based on UID and SHA-256. @return request identity
[ "Generates", "request", "id", "based", "on", "UID", "and", "SHA", "-", "256", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/MdcUtils.java#L82-L91
142,039
xm-online/xm-commons
xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/spring/SpringLepProcessingApplicationListener.java
SpringLepProcessingApplicationListener.onBeforeExecutionEvent
@Override public void onBeforeExecutionEvent(BeforeExecutionEvent event) { LepManager manager = event.getSource(); ScopedContext threadContext = manager.getContext(ContextScopes.THREAD); if (threadContext == null) { throw new IllegalStateException("LEP manager thread context doesn't initialized"); } TenantContext tenantContext = getRequiredValue(threadContext, THREAD_CONTEXT_KEY_TENANT_CONTEXT, TenantContext.class); XmAuthenticationContext authContext = getRequiredValue(threadContext, THREAD_CONTEXT_KEY_AUTH_CONTEXT, XmAuthenticationContext.class); ScopedContext executionContext = manager.getContext(ContextScopes.EXECUTION); // add contexts executionContext.setValue(BINDING_KEY_TENANT_CONTEXT, tenantContext); executionContext.setValue(BINDING_KEY_AUTH_CONTEXT, authContext); bindExecutionContext(executionContext); }
java
@Override public void onBeforeExecutionEvent(BeforeExecutionEvent event) { LepManager manager = event.getSource(); ScopedContext threadContext = manager.getContext(ContextScopes.THREAD); if (threadContext == null) { throw new IllegalStateException("LEP manager thread context doesn't initialized"); } TenantContext tenantContext = getRequiredValue(threadContext, THREAD_CONTEXT_KEY_TENANT_CONTEXT, TenantContext.class); XmAuthenticationContext authContext = getRequiredValue(threadContext, THREAD_CONTEXT_KEY_AUTH_CONTEXT, XmAuthenticationContext.class); ScopedContext executionContext = manager.getContext(ContextScopes.EXECUTION); // add contexts executionContext.setValue(BINDING_KEY_TENANT_CONTEXT, tenantContext); executionContext.setValue(BINDING_KEY_AUTH_CONTEXT, authContext); bindExecutionContext(executionContext); }
[ "@", "Override", "public", "void", "onBeforeExecutionEvent", "(", "BeforeExecutionEvent", "event", ")", "{", "LepManager", "manager", "=", "event", ".", "getSource", "(", ")", ";", "ScopedContext", "threadContext", "=", "manager", ".", "getContext", "(", "ContextScopes", ".", "THREAD", ")", ";", "if", "(", "threadContext", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"LEP manager thread context doesn't initialized\"", ")", ";", "}", "TenantContext", "tenantContext", "=", "getRequiredValue", "(", "threadContext", ",", "THREAD_CONTEXT_KEY_TENANT_CONTEXT", ",", "TenantContext", ".", "class", ")", ";", "XmAuthenticationContext", "authContext", "=", "getRequiredValue", "(", "threadContext", ",", "THREAD_CONTEXT_KEY_AUTH_CONTEXT", ",", "XmAuthenticationContext", ".", "class", ")", ";", "ScopedContext", "executionContext", "=", "manager", ".", "getContext", "(", "ContextScopes", ".", "EXECUTION", ")", ";", "// add contexts", "executionContext", ".", "setValue", "(", "BINDING_KEY_TENANT_CONTEXT", ",", "tenantContext", ")", ";", "executionContext", ".", "setValue", "(", "BINDING_KEY_AUTH_CONTEXT", ",", "authContext", ")", ";", "bindExecutionContext", "(", "executionContext", ")", ";", "}" ]
Init execution context for script variables bindings. @param event the BeforeExecutionEvent
[ "Init", "execution", "context", "for", "script", "variables", "bindings", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/spring/SpringLepProcessingApplicationListener.java#L59-L78
142,040
xm-online/xm-commons
xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/spring/LepServiceHandler.java
LepServiceHandler.onMethodInvoke
@SuppressWarnings("squid:S00112") //suppress throwable warning public Object onMethodInvoke(Class<?> targetType, Object target, Method method, Object[] args) throws Throwable { LepService typeLepService = targetType.getAnnotation(LepService.class); Objects.requireNonNull(typeLepService, "No " + LepService.class.getSimpleName() + " annotation for type " + targetType.getCanonicalName()); LogicExtensionPoint methodLep = AnnotationUtils.getAnnotation(method, LogicExtensionPoint.class); // TODO methodLep can be null (if used interface method without @LogicExtensionPoint) !!! // create/get key resolver instance LepKeyResolver keyResolver = getKeyResolver(methodLep); // create base LEP key instance LepKey baseLepKey = getBaseLepKey(typeLepService, methodLep, method); // create LEP method descriptor LepMethod lepMethod = buildLepMethod(targetType, target, method, args); // call LepManager to process LEP try { return getLepManager().processLep(baseLepKey, XmLepConstants.UNUSED_RESOURCE_VERSION, keyResolver, lepMethod); } catch (LepInvocationCauseException e) { log.debug("Error process target", e); throw e.getCause(); } catch (Exception e) { throw e; } }
java
@SuppressWarnings("squid:S00112") //suppress throwable warning public Object onMethodInvoke(Class<?> targetType, Object target, Method method, Object[] args) throws Throwable { LepService typeLepService = targetType.getAnnotation(LepService.class); Objects.requireNonNull(typeLepService, "No " + LepService.class.getSimpleName() + " annotation for type " + targetType.getCanonicalName()); LogicExtensionPoint methodLep = AnnotationUtils.getAnnotation(method, LogicExtensionPoint.class); // TODO methodLep can be null (if used interface method without @LogicExtensionPoint) !!! // create/get key resolver instance LepKeyResolver keyResolver = getKeyResolver(methodLep); // create base LEP key instance LepKey baseLepKey = getBaseLepKey(typeLepService, methodLep, method); // create LEP method descriptor LepMethod lepMethod = buildLepMethod(targetType, target, method, args); // call LepManager to process LEP try { return getLepManager().processLep(baseLepKey, XmLepConstants.UNUSED_RESOURCE_VERSION, keyResolver, lepMethod); } catch (LepInvocationCauseException e) { log.debug("Error process target", e); throw e.getCause(); } catch (Exception e) { throw e; } }
[ "@", "SuppressWarnings", "(", "\"squid:S00112\"", ")", "//suppress throwable warning", "public", "Object", "onMethodInvoke", "(", "Class", "<", "?", ">", "targetType", ",", "Object", "target", ",", "Method", "method", ",", "Object", "[", "]", "args", ")", "throws", "Throwable", "{", "LepService", "typeLepService", "=", "targetType", ".", "getAnnotation", "(", "LepService", ".", "class", ")", ";", "Objects", ".", "requireNonNull", "(", "typeLepService", ",", "\"No \"", "+", "LepService", ".", "class", ".", "getSimpleName", "(", ")", "+", "\" annotation for type \"", "+", "targetType", ".", "getCanonicalName", "(", ")", ")", ";", "LogicExtensionPoint", "methodLep", "=", "AnnotationUtils", ".", "getAnnotation", "(", "method", ",", "LogicExtensionPoint", ".", "class", ")", ";", "// TODO methodLep can be null (if used interface method without @LogicExtensionPoint) !!!", "// create/get key resolver instance", "LepKeyResolver", "keyResolver", "=", "getKeyResolver", "(", "methodLep", ")", ";", "// create base LEP key instance", "LepKey", "baseLepKey", "=", "getBaseLepKey", "(", "typeLepService", ",", "methodLep", ",", "method", ")", ";", "// create LEP method descriptor", "LepMethod", "lepMethod", "=", "buildLepMethod", "(", "targetType", ",", "target", ",", "method", ",", "args", ")", ";", "// call LepManager to process LEP", "try", "{", "return", "getLepManager", "(", ")", ".", "processLep", "(", "baseLepKey", ",", "XmLepConstants", ".", "UNUSED_RESOURCE_VERSION", ",", "keyResolver", ",", "lepMethod", ")", ";", "}", "catch", "(", "LepInvocationCauseException", "e", ")", "{", "log", ".", "debug", "(", "\"Error process target\"", ",", "e", ")", ";", "throw", "e", ".", "getCause", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "e", ";", "}", "}" ]
Processes a LEP method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with. @param targetType type of LEP service (interface, concrete class) @param target target LEP service object, can be {@code null} @param method called LEP method @param args called LEP method arguments @return LEP method result object @throws Throwable the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the {@code throws} clause of the interface method or to the unchecked exception types {@code java.lang.RuntimeException} or {@code java.lang.Error}. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the {@code throws} clause of the interface method, then an {@link UndeclaredThrowableException} containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.
[ "Processes", "a", "LEP", "method", "invocation", "on", "a", "proxy", "instance", "and", "returns", "the", "result", ".", "This", "method", "will", "be", "invoked", "on", "an", "invocation", "handler", "when", "a", "method", "is", "invoked", "on", "a", "proxy", "instance", "that", "it", "is", "associated", "with", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/spring/LepServiceHandler.java#L64-L91
142,041
xm-online/xm-commons
xm-commons-config/src/main/java/com/icthh/xm/commons/config/client/repository/kafka/ConfigTopicConsumer.java
ConfigTopicConsumer.consumeEvent
@Retryable(maxAttemptsExpression = "${application.retry.max-attempts}", backoff = @Backoff(delayExpression = "${application.retry.delay}", multiplierExpression = "${application.retry.multiplier}")) public void consumeEvent(ConsumerRecord<String, String> message) { MdcUtils.putRid(); try { log.info("Consume event from topic [{}]", message.topic()); try { ConfigEvent event = mapper.readValue(message.value(), ConfigEvent.class); log.info("Process event from topic [{}], event_id ='{}'", message.topic(), event.getEventId()); configService.updateConfigurations(event.getCommit(), event.getPaths()); } catch (IOException e) { log.error("Config topic message has incorrect format: '{}'", message.value(), e); } } finally { MdcUtils.removeRid(); } }
java
@Retryable(maxAttemptsExpression = "${application.retry.max-attempts}", backoff = @Backoff(delayExpression = "${application.retry.delay}", multiplierExpression = "${application.retry.multiplier}")) public void consumeEvent(ConsumerRecord<String, String> message) { MdcUtils.putRid(); try { log.info("Consume event from topic [{}]", message.topic()); try { ConfigEvent event = mapper.readValue(message.value(), ConfigEvent.class); log.info("Process event from topic [{}], event_id ='{}'", message.topic(), event.getEventId()); configService.updateConfigurations(event.getCommit(), event.getPaths()); } catch (IOException e) { log.error("Config topic message has incorrect format: '{}'", message.value(), e); } } finally { MdcUtils.removeRid(); } }
[ "@", "Retryable", "(", "maxAttemptsExpression", "=", "\"${application.retry.max-attempts}\"", ",", "backoff", "=", "@", "Backoff", "(", "delayExpression", "=", "\"${application.retry.delay}\"", ",", "multiplierExpression", "=", "\"${application.retry.multiplier}\"", ")", ")", "public", "void", "consumeEvent", "(", "ConsumerRecord", "<", "String", ",", "String", ">", "message", ")", "{", "MdcUtils", ".", "putRid", "(", ")", ";", "try", "{", "log", ".", "info", "(", "\"Consume event from topic [{}]\"", ",", "message", ".", "topic", "(", ")", ")", ";", "try", "{", "ConfigEvent", "event", "=", "mapper", ".", "readValue", "(", "message", ".", "value", "(", ")", ",", "ConfigEvent", ".", "class", ")", ";", "log", ".", "info", "(", "\"Process event from topic [{}], event_id ='{}'\"", ",", "message", ".", "topic", "(", ")", ",", "event", ".", "getEventId", "(", ")", ")", ";", "configService", ".", "updateConfigurations", "(", "event", ".", "getCommit", "(", ")", ",", "event", ".", "getPaths", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"Config topic message has incorrect format: '{}'\"", ",", "message", ".", "value", "(", ")", ",", "e", ")", ";", "}", "}", "finally", "{", "MdcUtils", ".", "removeRid", "(", ")", ";", "}", "}" ]
Consume tenant command event message. @param message the tenant command event message
[ "Consume", "tenant", "command", "event", "message", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-config/src/main/java/com/icthh/xm/commons/config/client/repository/kafka/ConfigTopicConsumer.java#L32-L51
142,042
xm-online/xm-commons
xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/LepScriptUtils.java
LepScriptUtils.executeScript
static Object executeScript(UrlLepResourceKey scriptResourceKey, ProceedingLep proceedingLep, // can be null LepMethod method, LepManagerService managerService, Supplier<GroovyScriptRunner> resourceExecutorSupplier, LepMethodResult methodResult, // can be null Object... overrodeArgValues) throws LepInvocationCauseException { GroovyScriptRunner runner = resourceExecutorSupplier.get(); String scriptName = runner.getResourceKeyMapper().map(scriptResourceKey); Binding binding = buildBinding(scriptResourceKey, managerService, method, proceedingLep, methodResult, overrodeArgValues); return runner.runScript(scriptResourceKey, method, managerService, scriptName, binding); }
java
static Object executeScript(UrlLepResourceKey scriptResourceKey, ProceedingLep proceedingLep, // can be null LepMethod method, LepManagerService managerService, Supplier<GroovyScriptRunner> resourceExecutorSupplier, LepMethodResult methodResult, // can be null Object... overrodeArgValues) throws LepInvocationCauseException { GroovyScriptRunner runner = resourceExecutorSupplier.get(); String scriptName = runner.getResourceKeyMapper().map(scriptResourceKey); Binding binding = buildBinding(scriptResourceKey, managerService, method, proceedingLep, methodResult, overrodeArgValues); return runner.runScript(scriptResourceKey, method, managerService, scriptName, binding); }
[ "static", "Object", "executeScript", "(", "UrlLepResourceKey", "scriptResourceKey", ",", "ProceedingLep", "proceedingLep", ",", "// can be null", "LepMethod", "method", ",", "LepManagerService", "managerService", ",", "Supplier", "<", "GroovyScriptRunner", ">", "resourceExecutorSupplier", ",", "LepMethodResult", "methodResult", ",", "// can be null", "Object", "...", "overrodeArgValues", ")", "throws", "LepInvocationCauseException", "{", "GroovyScriptRunner", "runner", "=", "resourceExecutorSupplier", ".", "get", "(", ")", ";", "String", "scriptName", "=", "runner", ".", "getResourceKeyMapper", "(", ")", ".", "map", "(", "scriptResourceKey", ")", ";", "Binding", "binding", "=", "buildBinding", "(", "scriptResourceKey", ",", "managerService", ",", "method", ",", "proceedingLep", ",", "methodResult", ",", "overrodeArgValues", ")", ";", "return", "runner", ".", "runScript", "(", "scriptResourceKey", ",", "method", ",", "managerService", ",", "scriptName", ",", "binding", ")", ";", "}" ]
Executes any script. @param scriptResourceKey current script resource key @param proceedingLep method proceed for Around scripts @param method LEP method @param managerService LEP manager service @param resourceExecutorSupplier LEP resource script executor supplier @param methodResult LEP method result @param overrodeArgValues arg values to override (can be {@code null}) @return Groovy script binding @throws LepInvocationCauseException when exception in script occurs
[ "Executes", "any", "script", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/LepScriptUtils.java#L37-L53
142,043
xm-online/xm-commons
xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/LepScriptUtils.java
LepScriptUtils.buildBinding
private static Binding buildBinding(UrlLepResourceKey scriptResourceKey, LepManagerService managerService, LepMethod method, ProceedingLep proceedingLep, LepMethodResult lepMethodResult, Object... overrodeArgValues) { boolean isOverrodeArgs = overrodeArgValues != null && overrodeArgValues.length > 0; if (isOverrodeArgs) { int actual = overrodeArgValues.length; int expected = method.getMethodSignature().getParameterTypes().length; if (actual != expected) { throw new IllegalArgumentException("When calling LEP resource: " + scriptResourceKey + ", overrode method argument values " + "count doesn't corresponds method signature (expected: " + expected + ", actual: " + actual + ")"); } } Map<String, Object> lepContext = new LinkedHashMap<>(); Binding binding = new Binding(); // add execution context values ScopedContext executionContext = managerService.getContext(ContextScopes.EXECUTION); if (executionContext != null) { executionContext.getValues().forEach(lepContext::put); } // add method arg values final String[] parameterNames = method.getMethodSignature().getParameterNames(); final Object[] methodArgValues = isOverrodeArgs ? overrodeArgValues : method.getMethodArgValues(); Map<String, Object> inVars = new LinkedHashMap<>(parameterNames.length); for (int i = 0; i < parameterNames.length; i++) { String paramName = parameterNames[i]; Object paramValue = methodArgValues[i]; inVars.put(paramName, paramValue); } lepContext.put(XmLepScriptConstants.BINDING_KEY_IN_ARGS, inVars); // add proceedingLep support lepContext.put(XmLepScriptConstants.BINDING_KEY_LEP, proceedingLep); // add returned value if (lepMethodResult != null) { lepContext.put(XmLepScriptConstants.BINDING_KEY_RETURNED_VALUE, lepMethodResult.getReturnedValue()); } // add method result lepContext.put(XmLepScriptConstants.BINDING_KEY_METHOD_RESULT, lepMethodResult); binding.setVariable(XmLepScriptConstants.BINDING_VAR_LEP_SCRIPT_CONTEXT, lepContext); return binding; }
java
private static Binding buildBinding(UrlLepResourceKey scriptResourceKey, LepManagerService managerService, LepMethod method, ProceedingLep proceedingLep, LepMethodResult lepMethodResult, Object... overrodeArgValues) { boolean isOverrodeArgs = overrodeArgValues != null && overrodeArgValues.length > 0; if (isOverrodeArgs) { int actual = overrodeArgValues.length; int expected = method.getMethodSignature().getParameterTypes().length; if (actual != expected) { throw new IllegalArgumentException("When calling LEP resource: " + scriptResourceKey + ", overrode method argument values " + "count doesn't corresponds method signature (expected: " + expected + ", actual: " + actual + ")"); } } Map<String, Object> lepContext = new LinkedHashMap<>(); Binding binding = new Binding(); // add execution context values ScopedContext executionContext = managerService.getContext(ContextScopes.EXECUTION); if (executionContext != null) { executionContext.getValues().forEach(lepContext::put); } // add method arg values final String[] parameterNames = method.getMethodSignature().getParameterNames(); final Object[] methodArgValues = isOverrodeArgs ? overrodeArgValues : method.getMethodArgValues(); Map<String, Object> inVars = new LinkedHashMap<>(parameterNames.length); for (int i = 0; i < parameterNames.length; i++) { String paramName = parameterNames[i]; Object paramValue = methodArgValues[i]; inVars.put(paramName, paramValue); } lepContext.put(XmLepScriptConstants.BINDING_KEY_IN_ARGS, inVars); // add proceedingLep support lepContext.put(XmLepScriptConstants.BINDING_KEY_LEP, proceedingLep); // add returned value if (lepMethodResult != null) { lepContext.put(XmLepScriptConstants.BINDING_KEY_RETURNED_VALUE, lepMethodResult.getReturnedValue()); } // add method result lepContext.put(XmLepScriptConstants.BINDING_KEY_METHOD_RESULT, lepMethodResult); binding.setVariable(XmLepScriptConstants.BINDING_VAR_LEP_SCRIPT_CONTEXT, lepContext); return binding; }
[ "private", "static", "Binding", "buildBinding", "(", "UrlLepResourceKey", "scriptResourceKey", ",", "LepManagerService", "managerService", ",", "LepMethod", "method", ",", "ProceedingLep", "proceedingLep", ",", "LepMethodResult", "lepMethodResult", ",", "Object", "...", "overrodeArgValues", ")", "{", "boolean", "isOverrodeArgs", "=", "overrodeArgValues", "!=", "null", "&&", "overrodeArgValues", ".", "length", ">", "0", ";", "if", "(", "isOverrodeArgs", ")", "{", "int", "actual", "=", "overrodeArgValues", ".", "length", ";", "int", "expected", "=", "method", ".", "getMethodSignature", "(", ")", ".", "getParameterTypes", "(", ")", ".", "length", ";", "if", "(", "actual", "!=", "expected", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"When calling LEP resource: \"", "+", "scriptResourceKey", "+", "\", overrode method argument values \"", "+", "\"count doesn't corresponds method signature (expected: \"", "+", "expected", "+", "\", actual: \"", "+", "actual", "+", "\")\"", ")", ";", "}", "}", "Map", "<", "String", ",", "Object", ">", "lepContext", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "Binding", "binding", "=", "new", "Binding", "(", ")", ";", "// add execution context values", "ScopedContext", "executionContext", "=", "managerService", ".", "getContext", "(", "ContextScopes", ".", "EXECUTION", ")", ";", "if", "(", "executionContext", "!=", "null", ")", "{", "executionContext", ".", "getValues", "(", ")", ".", "forEach", "(", "lepContext", "::", "put", ")", ";", "}", "// add method arg values", "final", "String", "[", "]", "parameterNames", "=", "method", ".", "getMethodSignature", "(", ")", ".", "getParameterNames", "(", ")", ";", "final", "Object", "[", "]", "methodArgValues", "=", "isOverrodeArgs", "?", "overrodeArgValues", ":", "method", ".", "getMethodArgValues", "(", ")", ";", "Map", "<", "String", ",", "Object", ">", "inVars", "=", "new", "LinkedHashMap", "<>", "(", "parameterNames", ".", "length", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "parameterNames", ".", "length", ";", "i", "++", ")", "{", "String", "paramName", "=", "parameterNames", "[", "i", "]", ";", "Object", "paramValue", "=", "methodArgValues", "[", "i", "]", ";", "inVars", ".", "put", "(", "paramName", ",", "paramValue", ")", ";", "}", "lepContext", ".", "put", "(", "XmLepScriptConstants", ".", "BINDING_KEY_IN_ARGS", ",", "inVars", ")", ";", "// add proceedingLep support", "lepContext", ".", "put", "(", "XmLepScriptConstants", ".", "BINDING_KEY_LEP", ",", "proceedingLep", ")", ";", "// add returned value", "if", "(", "lepMethodResult", "!=", "null", ")", "{", "lepContext", ".", "put", "(", "XmLepScriptConstants", ".", "BINDING_KEY_RETURNED_VALUE", ",", "lepMethodResult", ".", "getReturnedValue", "(", ")", ")", ";", "}", "// add method result", "lepContext", ".", "put", "(", "XmLepScriptConstants", ".", "BINDING_KEY_METHOD_RESULT", ",", "lepMethodResult", ")", ";", "binding", ".", "setVariable", "(", "XmLepScriptConstants", ".", "BINDING_VAR_LEP_SCRIPT_CONTEXT", ",", "lepContext", ")", ";", "return", "binding", ";", "}" ]
Build scripts bindings. @param scriptResourceKey current script resource key @param managerService LEP manager service @param method LEP method @param proceedingLep proceeding object (can be {@code null}) @param overrodeArgValues arg values to override (can be {@code null}) @return Groovy script binding
[ "Build", "scripts", "bindings", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/LepScriptUtils.java#L65-L117
142,044
xm-online/xm-commons
xm-commons-security/src/main/java/com/icthh/xm/commons/security/oauth2/OAuth2JwtAccessTokenConverter.java
OAuth2JwtAccessTokenConverter.decode
@Override protected Map<String, Object> decode(String token) { try { //check if our public key and thus SignatureVerifier have expired long ttl = oAuth2Properties.getSignatureVerification().getTtl(); if (ttl > 0 && System.currentTimeMillis() - lastKeyFetchTimestamp > ttl) { throw new InvalidTokenException("public key expired"); } return super.decode(token); } catch (InvalidTokenException ex) { if (tryCreateSignatureVerifier()) { return super.decode(token); } throw ex; } }
java
@Override protected Map<String, Object> decode(String token) { try { //check if our public key and thus SignatureVerifier have expired long ttl = oAuth2Properties.getSignatureVerification().getTtl(); if (ttl > 0 && System.currentTimeMillis() - lastKeyFetchTimestamp > ttl) { throw new InvalidTokenException("public key expired"); } return super.decode(token); } catch (InvalidTokenException ex) { if (tryCreateSignatureVerifier()) { return super.decode(token); } throw ex; } }
[ "@", "Override", "protected", "Map", "<", "String", ",", "Object", ">", "decode", "(", "String", "token", ")", "{", "try", "{", "//check if our public key and thus SignatureVerifier have expired", "long", "ttl", "=", "oAuth2Properties", ".", "getSignatureVerification", "(", ")", ".", "getTtl", "(", ")", ";", "if", "(", "ttl", ">", "0", "&&", "System", ".", "currentTimeMillis", "(", ")", "-", "lastKeyFetchTimestamp", ">", "ttl", ")", "{", "throw", "new", "InvalidTokenException", "(", "\"public key expired\"", ")", ";", "}", "return", "super", ".", "decode", "(", "token", ")", ";", "}", "catch", "(", "InvalidTokenException", "ex", ")", "{", "if", "(", "tryCreateSignatureVerifier", "(", ")", ")", "{", "return", "super", ".", "decode", "(", "token", ")", ";", "}", "throw", "ex", ";", "}", "}" ]
Try to decode the token with the current public key. If it fails, contact the OAuth2 server to get a new public key, then try again. We might not have fetched it in the first place or it might have changed. @param token the JWT token to decode. @return the resulting claims. @throws InvalidTokenException if we cannot decode the token.
[ "Try", "to", "decode", "the", "token", "with", "the", "current", "public", "key", ".", "If", "it", "fails", "contact", "the", "OAuth2", "server", "to", "get", "a", "new", "public", "key", "then", "try", "again", ".", "We", "might", "not", "have", "fetched", "it", "in", "the", "first", "place", "or", "it", "might", "have", "changed", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-security/src/main/java/com/icthh/xm/commons/security/oauth2/OAuth2JwtAccessTokenConverter.java#L41-L56
142,045
xm-online/xm-commons
xm-commons-security/src/main/java/com/icthh/xm/commons/security/oauth2/OAuth2JwtAccessTokenConverter.java
OAuth2JwtAccessTokenConverter.tryCreateSignatureVerifier
private boolean tryCreateSignatureVerifier() { long t = System.currentTimeMillis(); if (t - lastKeyFetchTimestamp < oAuth2Properties.getSignatureVerification().getPublicKeyRefreshRateLimit()) { return false; } try { SignatureVerifier verifier = signatureVerifierClient.getSignatureVerifier(); if (verifier != null) { setVerifier(verifier); lastKeyFetchTimestamp = t; log.debug("Public key retrieved from OAuth2 server to create SignatureVerifier"); return true; } } catch (Throwable ex) { log.error("could not get public key from OAuth2 server to create SignatureVerifier", ex); } return false; }
java
private boolean tryCreateSignatureVerifier() { long t = System.currentTimeMillis(); if (t - lastKeyFetchTimestamp < oAuth2Properties.getSignatureVerification().getPublicKeyRefreshRateLimit()) { return false; } try { SignatureVerifier verifier = signatureVerifierClient.getSignatureVerifier(); if (verifier != null) { setVerifier(verifier); lastKeyFetchTimestamp = t; log.debug("Public key retrieved from OAuth2 server to create SignatureVerifier"); return true; } } catch (Throwable ex) { log.error("could not get public key from OAuth2 server to create SignatureVerifier", ex); } return false; }
[ "private", "boolean", "tryCreateSignatureVerifier", "(", ")", "{", "long", "t", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "t", "-", "lastKeyFetchTimestamp", "<", "oAuth2Properties", ".", "getSignatureVerification", "(", ")", ".", "getPublicKeyRefreshRateLimit", "(", ")", ")", "{", "return", "false", ";", "}", "try", "{", "SignatureVerifier", "verifier", "=", "signatureVerifierClient", ".", "getSignatureVerifier", "(", ")", ";", "if", "(", "verifier", "!=", "null", ")", "{", "setVerifier", "(", "verifier", ")", ";", "lastKeyFetchTimestamp", "=", "t", ";", "log", ".", "debug", "(", "\"Public key retrieved from OAuth2 server to create SignatureVerifier\"", ")", ";", "return", "true", ";", "}", "}", "catch", "(", "Throwable", "ex", ")", "{", "log", ".", "error", "(", "\"could not get public key from OAuth2 server to create SignatureVerifier\"", ",", "ex", ")", ";", "}", "return", "false", ";", "}" ]
Fetch a new public key from the AuthorizationServer. @return true, if we could fetch it; false, if we could not.
[ "Fetch", "a", "new", "public", "key", "from", "the", "AuthorizationServer", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-security/src/main/java/com/icthh/xm/commons/security/oauth2/OAuth2JwtAccessTokenConverter.java#L63-L80
142,046
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/WicketJquerySelectors.java
WicketJquerySelectors.install
public static void install(Application app, IWicketJquerySelectorsSettings settings) { final IWicketJquerySelectorsSettings existingSettings = settings(app); if (existingSettings == null) { if (settings == null) { settings = new WicketJquerySelectorsSettings(); } app.setMetaData(JQUERY_SELECTORS_SETTINGS_METADATA_KEY, settings); LOG.info("initialize wicket jquery selectors with given settings: {}", settings); } }
java
public static void install(Application app, IWicketJquerySelectorsSettings settings) { final IWicketJquerySelectorsSettings existingSettings = settings(app); if (existingSettings == null) { if (settings == null) { settings = new WicketJquerySelectorsSettings(); } app.setMetaData(JQUERY_SELECTORS_SETTINGS_METADATA_KEY, settings); LOG.info("initialize wicket jquery selectors with given settings: {}", settings); } }
[ "public", "static", "void", "install", "(", "Application", "app", ",", "IWicketJquerySelectorsSettings", "settings", ")", "{", "final", "IWicketJquerySelectorsSettings", "existingSettings", "=", "settings", "(", "app", ")", ";", "if", "(", "existingSettings", "==", "null", ")", "{", "if", "(", "settings", "==", "null", ")", "{", "settings", "=", "new", "WicketJquerySelectorsSettings", "(", ")", ";", "}", "app", ".", "setMetaData", "(", "JQUERY_SELECTORS_SETTINGS_METADATA_KEY", ",", "settings", ")", ";", "LOG", ".", "info", "(", "\"initialize wicket jquery selectors with given settings: {}\"", ",", "settings", ")", ";", "}", "}" ]
installs the library settings to given app. @param app the wicket application @param settings the settings to use
[ "installs", "the", "library", "settings", "to", "given", "app", "." ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/WicketJquerySelectors.java#L49-L61
142,047
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/PrivilegeMapper.java
PrivilegeMapper.privilegesToYml
public String privilegesToYml(Collection<Privilege> privileges) { try { Map<String, Set<Privilege>> map = new TreeMap<>(); privileges.forEach(privilege -> { map.putIfAbsent(privilege.getMsName(), new TreeSet<>()); map.get(privilege.getMsName()).add(privilege); }); return mapper.writeValueAsString(map); } catch (Exception e) { log.error("Failed to create privileges YML file from collection, error: {}", e.getMessage(), e); } return null; }
java
public String privilegesToYml(Collection<Privilege> privileges) { try { Map<String, Set<Privilege>> map = new TreeMap<>(); privileges.forEach(privilege -> { map.putIfAbsent(privilege.getMsName(), new TreeSet<>()); map.get(privilege.getMsName()).add(privilege); }); return mapper.writeValueAsString(map); } catch (Exception e) { log.error("Failed to create privileges YML file from collection, error: {}", e.getMessage(), e); } return null; }
[ "public", "String", "privilegesToYml", "(", "Collection", "<", "Privilege", ">", "privileges", ")", "{", "try", "{", "Map", "<", "String", ",", "Set", "<", "Privilege", ">", ">", "map", "=", "new", "TreeMap", "<>", "(", ")", ";", "privileges", ".", "forEach", "(", "privilege", "->", "{", "map", ".", "putIfAbsent", "(", "privilege", ".", "getMsName", "(", ")", ",", "new", "TreeSet", "<>", "(", ")", ")", ";", "map", ".", "get", "(", "privilege", ".", "getMsName", "(", ")", ")", ".", "add", "(", "privilege", ")", ";", "}", ")", ";", "return", "mapper", ".", "writeValueAsString", "(", "map", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Failed to create privileges YML file from collection, error: {}\"", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "return", "null", ";", "}" ]
Convert privileges collection to yml string. @param privileges collection @return yml string
[ "Convert", "privileges", "collection", "to", "yml", "string", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/PrivilegeMapper.java#L29-L41
142,048
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/PrivilegeMapper.java
PrivilegeMapper.privilegesMapToYml
public String privilegesMapToYml(Map<String, Collection<Privilege>> privileges) { try { return mapper.writeValueAsString(privileges); } catch (Exception e) { log.error("Failed to create privileges YML file from map, error: {}", e.getMessage(), e); } return null; }
java
public String privilegesMapToYml(Map<String, Collection<Privilege>> privileges) { try { return mapper.writeValueAsString(privileges); } catch (Exception e) { log.error("Failed to create privileges YML file from map, error: {}", e.getMessage(), e); } return null; }
[ "public", "String", "privilegesMapToYml", "(", "Map", "<", "String", ",", "Collection", "<", "Privilege", ">", ">", "privileges", ")", "{", "try", "{", "return", "mapper", ".", "writeValueAsString", "(", "privileges", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Failed to create privileges YML file from map, error: {}\"", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "return", "null", ";", "}" ]
Convert privileges map to yml string. @param privileges map @return yml string
[ "Convert", "privileges", "map", "to", "yml", "string", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/PrivilegeMapper.java#L49-L56
142,049
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/PrivilegeMapper.java
PrivilegeMapper.ymlToPrivileges
public Map<String, Set<Privilege>> ymlToPrivileges(String yml) { try { Map<String, Set<Privilege>> map = mapper.readValue(yml, new TypeReference<TreeMap<String, TreeSet<Privilege>>>() { }); map.forEach((msName, privileges) -> privileges.forEach(privilege -> privilege.setMsName(msName))); return Collections.unmodifiableMap(map); } catch (Exception e) { log.error("Failed to create privileges collection from YML file, error: {}", e.getMessage(), e); } return Collections.emptyMap(); }
java
public Map<String, Set<Privilege>> ymlToPrivileges(String yml) { try { Map<String, Set<Privilege>> map = mapper.readValue(yml, new TypeReference<TreeMap<String, TreeSet<Privilege>>>() { }); map.forEach((msName, privileges) -> privileges.forEach(privilege -> privilege.setMsName(msName))); return Collections.unmodifiableMap(map); } catch (Exception e) { log.error("Failed to create privileges collection from YML file, error: {}", e.getMessage(), e); } return Collections.emptyMap(); }
[ "public", "Map", "<", "String", ",", "Set", "<", "Privilege", ">", ">", "ymlToPrivileges", "(", "String", "yml", ")", "{", "try", "{", "Map", "<", "String", ",", "Set", "<", "Privilege", ">", ">", "map", "=", "mapper", ".", "readValue", "(", "yml", ",", "new", "TypeReference", "<", "TreeMap", "<", "String", ",", "TreeSet", "<", "Privilege", ">", ">", ">", "(", ")", "{", "}", ")", ";", "map", ".", "forEach", "(", "(", "msName", ",", "privileges", ")", "->", "privileges", ".", "forEach", "(", "privilege", "->", "privilege", ".", "setMsName", "(", "msName", ")", ")", ")", ";", "return", "Collections", ".", "unmodifiableMap", "(", "map", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Failed to create privileges collection from YML file, error: {}\"", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "return", "Collections", ".", "emptyMap", "(", ")", ";", "}" ]
Convert privileges yml string to map. @param yml string @return privileges map
[ "Convert", "privileges", "yml", "string", "to", "map", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/PrivilegeMapper.java#L64-L75
142,050
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/util/Json.java
Json.fromJson
public static <T> T fromJson(final String json, final JavaType type) { try { return createObjectMapper().readValue(json, type); } catch (Exception e) { throw new ParseException(e); } }
java
public static <T> T fromJson(final String json, final JavaType type) { try { return createObjectMapper().readValue(json, type); } catch (Exception e) { throw new ParseException(e); } }
[ "public", "static", "<", "T", ">", "T", "fromJson", "(", "final", "String", "json", ",", "final", "JavaType", "type", ")", "{", "try", "{", "return", "createObjectMapper", "(", ")", ".", "readValue", "(", "json", ",", "type", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ParseException", "(", "e", ")", ";", "}", "}" ]
Convert a string to a Java value @param json Json value to convert. @param type Expected Java value type. @param <T> type of return object @return casted value of given json object @throws ParseException to runtime if json node can't be casted to clazz.
[ "Convert", "a", "string", "to", "a", "Java", "value" ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/util/Json.java#L44-L50
142,051
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/util/Json.java
Json.toJson
public static JsonNode toJson(final Object data) { if (data == null) { return newObject(); } try { return createObjectMapper().valueToTree(data); } catch (Exception e) { throw new ParseException(e); } }
java
public static JsonNode toJson(final Object data) { if (data == null) { return newObject(); } try { return createObjectMapper().valueToTree(data); } catch (Exception e) { throw new ParseException(e); } }
[ "public", "static", "JsonNode", "toJson", "(", "final", "Object", "data", ")", "{", "if", "(", "data", "==", "null", ")", "{", "return", "newObject", "(", ")", ";", "}", "try", "{", "return", "createObjectMapper", "(", ")", ".", "valueToTree", "(", "data", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "ParseException", "(", "e", ")", ";", "}", "}" ]
Convert an object to JsonNode. @param data Value to convert in Json. @return creates a new json object from given data object @throws ParseException to runtime if object can't be parsed
[ "Convert", "an", "object", "to", "JsonNode", "." ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/util/Json.java#L67-L77
142,052
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/util/Json.java
Json.stringify
public static String stringify(final JsonNode json) { try { return json != null ? createObjectMapper().writeValueAsString(json) : "{}"; } catch (JsonProcessingException jpx) { throw new RuntimeException("A problem occurred while stringifying a JsonNode: " + jpx.getMessage(), jpx); } }
java
public static String stringify(final JsonNode json) { try { return json != null ? createObjectMapper().writeValueAsString(json) : "{}"; } catch (JsonProcessingException jpx) { throw new RuntimeException("A problem occurred while stringifying a JsonNode: " + jpx.getMessage(), jpx); } }
[ "public", "static", "String", "stringify", "(", "final", "JsonNode", "json", ")", "{", "try", "{", "return", "json", "!=", "null", "?", "createObjectMapper", "(", ")", ".", "writeValueAsString", "(", "json", ")", ":", "\"{}\"", ";", "}", "catch", "(", "JsonProcessingException", "jpx", ")", "{", "throw", "new", "RuntimeException", "(", "\"A problem occurred while stringifying a JsonNode: \"", "+", "jpx", ".", "getMessage", "(", ")", ",", "jpx", ")", ";", "}", "}" ]
Convert a JsonNode to its string representation. If given value is null an empty json object will returned. @param json The json object to toJsonString @return stringified version of given json object
[ "Convert", "a", "JsonNode", "to", "its", "string", "representation", ".", "If", "given", "value", "is", "null", "an", "empty", "json", "object", "will", "returned", "." ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/util/Json.java#L124-L130
142,053
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/util/Json.java
Json.isValid
public static boolean isValid(final String json) { if (Strings.isEmpty(json)) { return false; } try { return parse(json) != null; } catch (ParseException e) { return false; } }
java
public static boolean isValid(final String json) { if (Strings.isEmpty(json)) { return false; } try { return parse(json) != null; } catch (ParseException e) { return false; } }
[ "public", "static", "boolean", "isValid", "(", "final", "String", "json", ")", "{", "if", "(", "Strings", ".", "isEmpty", "(", "json", ")", ")", "{", "return", "false", ";", "}", "try", "{", "return", "parse", "(", "json", ")", "!=", "null", ";", "}", "catch", "(", "ParseException", "e", ")", "{", "return", "false", ";", "}", "}" ]
verifies a valid json string @param json The json string @return true, if string is a valid json string
[ "verifies", "a", "valid", "json", "string" ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/util/Json.java#L149-L159
142,054
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/util/Json.java
Json.parse
public static JsonNode parse(final String jsonString) { if (Strings.isEmpty(jsonString)) { return newObject(); } try { return createObjectMapper().readValue(jsonString, JsonNode.class); } catch (Throwable e) { throw new ParseException(String.format("can't parse string [%s]", jsonString), e); } }
java
public static JsonNode parse(final String jsonString) { if (Strings.isEmpty(jsonString)) { return newObject(); } try { return createObjectMapper().readValue(jsonString, JsonNode.class); } catch (Throwable e) { throw new ParseException(String.format("can't parse string [%s]", jsonString), e); } }
[ "public", "static", "JsonNode", "parse", "(", "final", "String", "jsonString", ")", "{", "if", "(", "Strings", ".", "isEmpty", "(", "jsonString", ")", ")", "{", "return", "newObject", "(", ")", ";", "}", "try", "{", "return", "createObjectMapper", "(", ")", ".", "readValue", "(", "jsonString", ",", "JsonNode", ".", "class", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "ParseException", "(", "String", ".", "format", "(", "\"can't parse string [%s]\"", ",", "jsonString", ")", ",", "e", ")", ";", "}", "}" ]
Parse a String representing a json, and return it as a JsonNode. @param jsonString string to parse @return parsed json string as json node @throws ParseException to runtime if json string can't be parsed
[ "Parse", "a", "String", "representing", "a", "json", "and", "return", "it", "as", "a", "JsonNode", "." ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/util/Json.java#L168-L178
142,055
xm-online/xm-commons
xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/XmLepScriptRules.java
XmLepScriptRules.validateScriptsCombination
public static void validateScriptsCombination(Set<XmLepResourceSubType> scriptTypes, LepMethod lepMethod, UrlLepResourceKey compositeResourceKey) { byte mask = getCombinationMask(scriptTypes, lepMethod, compositeResourceKey); StringBuilder errors = new StringBuilder(); if (isZero(mask, ZERO_PATTERN_NO_TENANT_AND_DEFAULT_AND_JAVA_CODE)) { errors.append(String.format("Has no one script of '%s', '%s' or native (java) implementation.", XmLepResourceSubType.TENANT, XmLepResourceSubType.DEFAULT)); } if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_BEFORE)) { if (errors.length() > 0) { errors.append(" "); } errors.append(String.format("Has '%s' script with '%s'.", XmLepResourceSubType.BEFORE, XmLepResourceSubType.AROUND)); } if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_AFTER)) { if (errors.length() > 0) { errors.append(" "); } errors.append(String.format("Has '%s' script with '%s'.", XmLepResourceSubType.AROUND, XmLepResourceSubType.AFTER)); } if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_TENANT)) { if (errors.length() > 0) { errors.append(" "); } errors.append(String.format("Unallowed combination '%s' and '%s' scripts.", XmLepResourceSubType.AROUND, XmLepResourceSubType.TENANT)); } if (errors.length() > 0) { throw new IllegalArgumentException(String.format("Resource key %s has script combination errors. %s", compositeResourceKey, errors.toString())); } }
java
public static void validateScriptsCombination(Set<XmLepResourceSubType> scriptTypes, LepMethod lepMethod, UrlLepResourceKey compositeResourceKey) { byte mask = getCombinationMask(scriptTypes, lepMethod, compositeResourceKey); StringBuilder errors = new StringBuilder(); if (isZero(mask, ZERO_PATTERN_NO_TENANT_AND_DEFAULT_AND_JAVA_CODE)) { errors.append(String.format("Has no one script of '%s', '%s' or native (java) implementation.", XmLepResourceSubType.TENANT, XmLepResourceSubType.DEFAULT)); } if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_BEFORE)) { if (errors.length() > 0) { errors.append(" "); } errors.append(String.format("Has '%s' script with '%s'.", XmLepResourceSubType.BEFORE, XmLepResourceSubType.AROUND)); } if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_AFTER)) { if (errors.length() > 0) { errors.append(" "); } errors.append(String.format("Has '%s' script with '%s'.", XmLepResourceSubType.AROUND, XmLepResourceSubType.AFTER)); } if (isSetByPattern(mask, IS_SET_PATTERN_AROUND_AND_TENANT)) { if (errors.length() > 0) { errors.append(" "); } errors.append(String.format("Unallowed combination '%s' and '%s' scripts.", XmLepResourceSubType.AROUND, XmLepResourceSubType.TENANT)); } if (errors.length() > 0) { throw new IllegalArgumentException(String.format("Resource key %s has script combination errors. %s", compositeResourceKey, errors.toString())); } }
[ "public", "static", "void", "validateScriptsCombination", "(", "Set", "<", "XmLepResourceSubType", ">", "scriptTypes", ",", "LepMethod", "lepMethod", ",", "UrlLepResourceKey", "compositeResourceKey", ")", "{", "byte", "mask", "=", "getCombinationMask", "(", "scriptTypes", ",", "lepMethod", ",", "compositeResourceKey", ")", ";", "StringBuilder", "errors", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "isZero", "(", "mask", ",", "ZERO_PATTERN_NO_TENANT_AND_DEFAULT_AND_JAVA_CODE", ")", ")", "{", "errors", ".", "append", "(", "String", ".", "format", "(", "\"Has no one script of '%s', '%s' or native (java) implementation.\"", ",", "XmLepResourceSubType", ".", "TENANT", ",", "XmLepResourceSubType", ".", "DEFAULT", ")", ")", ";", "}", "if", "(", "isSetByPattern", "(", "mask", ",", "IS_SET_PATTERN_AROUND_AND_BEFORE", ")", ")", "{", "if", "(", "errors", ".", "length", "(", ")", ">", "0", ")", "{", "errors", ".", "append", "(", "\" \"", ")", ";", "}", "errors", ".", "append", "(", "String", ".", "format", "(", "\"Has '%s' script with '%s'.\"", ",", "XmLepResourceSubType", ".", "BEFORE", ",", "XmLepResourceSubType", ".", "AROUND", ")", ")", ";", "}", "if", "(", "isSetByPattern", "(", "mask", ",", "IS_SET_PATTERN_AROUND_AND_AFTER", ")", ")", "{", "if", "(", "errors", ".", "length", "(", ")", ">", "0", ")", "{", "errors", ".", "append", "(", "\" \"", ")", ";", "}", "errors", ".", "append", "(", "String", ".", "format", "(", "\"Has '%s' script with '%s'.\"", ",", "XmLepResourceSubType", ".", "AROUND", ",", "XmLepResourceSubType", ".", "AFTER", ")", ")", ";", "}", "if", "(", "isSetByPattern", "(", "mask", ",", "IS_SET_PATTERN_AROUND_AND_TENANT", ")", ")", "{", "if", "(", "errors", ".", "length", "(", ")", ">", "0", ")", "{", "errors", ".", "append", "(", "\" \"", ")", ";", "}", "errors", ".", "append", "(", "String", ".", "format", "(", "\"Unallowed combination '%s' and '%s' scripts.\"", ",", "XmLepResourceSubType", ".", "AROUND", ",", "XmLepResourceSubType", ".", "TENANT", ")", ")", ";", "}", "if", "(", "errors", ".", "length", "(", ")", ">", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "String", ".", "format", "(", "\"Resource key %s has script combination errors. %s\"", ",", "compositeResourceKey", ",", "errors", ".", "toString", "(", ")", ")", ")", ";", "}", "}" ]
Validate script combination. @param scriptTypes current point script types @param lepMethod executed LEP method @param compositeResourceKey used only for informative exception message
[ "Validate", "script", "combination", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/XmLepScriptRules.java#L36-L77
142,056
xm-online/xm-commons
xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/XmLepScriptRules.java
XmLepScriptRules.getCombinationMask
private static byte getCombinationMask(Set<XmLepResourceSubType> scriptTypes, LepMethod lepMethod, UrlLepResourceKey compositeResourceKey) { byte combinationMask = 0; for (XmLepResourceSubType scriptType : scriptTypes) { switch (scriptType) { case BEFORE: combinationMask |= BEFORE_MASK; break; case AROUND: combinationMask |= AROUND_MASK; break; case TENANT: combinationMask |= TENANT_MASK; break; case DEFAULT: combinationMask |= DEFAULT_MASK; break; case AFTER: combinationMask |= AFTER_MASK; break; default: throw new IllegalArgumentException("Unsupported script type: " + scriptType + " for resource key: " + compositeResourceKey + ", all script types: " + scriptTypes); } } if (lepMethod.getTarget() != null) { combinationMask |= JAVA_CODE_MASK; } return combinationMask; }
java
private static byte getCombinationMask(Set<XmLepResourceSubType> scriptTypes, LepMethod lepMethod, UrlLepResourceKey compositeResourceKey) { byte combinationMask = 0; for (XmLepResourceSubType scriptType : scriptTypes) { switch (scriptType) { case BEFORE: combinationMask |= BEFORE_MASK; break; case AROUND: combinationMask |= AROUND_MASK; break; case TENANT: combinationMask |= TENANT_MASK; break; case DEFAULT: combinationMask |= DEFAULT_MASK; break; case AFTER: combinationMask |= AFTER_MASK; break; default: throw new IllegalArgumentException("Unsupported script type: " + scriptType + " for resource key: " + compositeResourceKey + ", all script types: " + scriptTypes); } } if (lepMethod.getTarget() != null) { combinationMask |= JAVA_CODE_MASK; } return combinationMask; }
[ "private", "static", "byte", "getCombinationMask", "(", "Set", "<", "XmLepResourceSubType", ">", "scriptTypes", ",", "LepMethod", "lepMethod", ",", "UrlLepResourceKey", "compositeResourceKey", ")", "{", "byte", "combinationMask", "=", "0", ";", "for", "(", "XmLepResourceSubType", "scriptType", ":", "scriptTypes", ")", "{", "switch", "(", "scriptType", ")", "{", "case", "BEFORE", ":", "combinationMask", "|=", "BEFORE_MASK", ";", "break", ";", "case", "AROUND", ":", "combinationMask", "|=", "AROUND_MASK", ";", "break", ";", "case", "TENANT", ":", "combinationMask", "|=", "TENANT_MASK", ";", "break", ";", "case", "DEFAULT", ":", "combinationMask", "|=", "DEFAULT_MASK", ";", "break", ";", "case", "AFTER", ":", "combinationMask", "|=", "AFTER_MASK", ";", "break", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", "\"Unsupported script type: \"", "+", "scriptType", "+", "\" for resource key: \"", "+", "compositeResourceKey", "+", "\", all script types: \"", "+", "scriptTypes", ")", ";", "}", "}", "if", "(", "lepMethod", ".", "getTarget", "(", ")", "!=", "null", ")", "{", "combinationMask", "|=", "JAVA_CODE_MASK", ";", "}", "return", "combinationMask", ";", "}" ]
Builds script combination mask. @param scriptTypes current point script types @param lepMethod executed LEP method @param compositeResourceKey used only for informative exception message @return available scripts mask for current LEP
[ "Builds", "script", "combination", "mask", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-lep/src/main/java/com/icthh/xm/commons/lep/XmLepScriptRules.java#L95-L134
142,057
xm-online/xm-commons
xm-commons-timeline/src/main/java/com/icthh/xm/commons/timeline/TimelineEventProducer.java
TimelineEventProducer.createEventJson
public String createEventJson(HttpServletRequest request, HttpServletResponse response, String tenant, String userLogin, String userKey) { try { String requestBody = getRequestContent(request); String responseBody = getResponseContent(response); Instant startDate = Instant.ofEpochMilli(System.currentTimeMillis() - MdcUtils.getExecTimeMs()); Map<String, Object> data = new LinkedHashMap<>(); data.put("rid", MdcUtils.getRid()); data.put("login", userLogin); data.put("userKey", userKey); data.put("tenant", tenant); data.put("msName", appName); data.put("operationName", getResourceName(request.getRequestURI()) + " " + getOperation(request.getMethod())); data.put("operationUrl", request.getRequestURI()); data.put("operationQueryString", request.getQueryString()); data.put("startDate", startDate.toString()); data.put("httpMethod", request.getMethod()); data.put("requestBody", maskContent(requestBody, request.getRequestURI(), true, request.getMethod())); data.put("requestLength", requestBody.length()); data.put("responseBody", maskContent(responseBody, request.getRequestURI(), false, request.getMethod())); data.put("responseLength", responseBody.length()); data.put("requestHeaders", getRequestHeaders(request)); data.put("responseHeaders", getResponseHeaders(response)); data.put("httpStatusCode", response.getStatus()); data.put("channelType", "HTTP"); data.put("entityId", getEntityField(responseBody, "id")); data.put("entityKey", getEntityField(responseBody, "key")); data.put("entityTypeKey", getEntityField(responseBody, "typeKey")); data.put("execTime", MdcUtils.getExecTimeMs()); return mapper.writeValueAsString(data); } catch (Exception e) { log.warn("Error creating timeline event", e); } return null; }
java
public String createEventJson(HttpServletRequest request, HttpServletResponse response, String tenant, String userLogin, String userKey) { try { String requestBody = getRequestContent(request); String responseBody = getResponseContent(response); Instant startDate = Instant.ofEpochMilli(System.currentTimeMillis() - MdcUtils.getExecTimeMs()); Map<String, Object> data = new LinkedHashMap<>(); data.put("rid", MdcUtils.getRid()); data.put("login", userLogin); data.put("userKey", userKey); data.put("tenant", tenant); data.put("msName", appName); data.put("operationName", getResourceName(request.getRequestURI()) + " " + getOperation(request.getMethod())); data.put("operationUrl", request.getRequestURI()); data.put("operationQueryString", request.getQueryString()); data.put("startDate", startDate.toString()); data.put("httpMethod", request.getMethod()); data.put("requestBody", maskContent(requestBody, request.getRequestURI(), true, request.getMethod())); data.put("requestLength", requestBody.length()); data.put("responseBody", maskContent(responseBody, request.getRequestURI(), false, request.getMethod())); data.put("responseLength", responseBody.length()); data.put("requestHeaders", getRequestHeaders(request)); data.put("responseHeaders", getResponseHeaders(response)); data.put("httpStatusCode", response.getStatus()); data.put("channelType", "HTTP"); data.put("entityId", getEntityField(responseBody, "id")); data.put("entityKey", getEntityField(responseBody, "key")); data.put("entityTypeKey", getEntityField(responseBody, "typeKey")); data.put("execTime", MdcUtils.getExecTimeMs()); return mapper.writeValueAsString(data); } catch (Exception e) { log.warn("Error creating timeline event", e); } return null; }
[ "public", "String", "createEventJson", "(", "HttpServletRequest", "request", ",", "HttpServletResponse", "response", ",", "String", "tenant", ",", "String", "userLogin", ",", "String", "userKey", ")", "{", "try", "{", "String", "requestBody", "=", "getRequestContent", "(", "request", ")", ";", "String", "responseBody", "=", "getResponseContent", "(", "response", ")", ";", "Instant", "startDate", "=", "Instant", ".", "ofEpochMilli", "(", "System", ".", "currentTimeMillis", "(", ")", "-", "MdcUtils", ".", "getExecTimeMs", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "data", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "data", ".", "put", "(", "\"rid\"", ",", "MdcUtils", ".", "getRid", "(", ")", ")", ";", "data", ".", "put", "(", "\"login\"", ",", "userLogin", ")", ";", "data", ".", "put", "(", "\"userKey\"", ",", "userKey", ")", ";", "data", ".", "put", "(", "\"tenant\"", ",", "tenant", ")", ";", "data", ".", "put", "(", "\"msName\"", ",", "appName", ")", ";", "data", ".", "put", "(", "\"operationName\"", ",", "getResourceName", "(", "request", ".", "getRequestURI", "(", ")", ")", "+", "\" \"", "+", "getOperation", "(", "request", ".", "getMethod", "(", ")", ")", ")", ";", "data", ".", "put", "(", "\"operationUrl\"", ",", "request", ".", "getRequestURI", "(", ")", ")", ";", "data", ".", "put", "(", "\"operationQueryString\"", ",", "request", ".", "getQueryString", "(", ")", ")", ";", "data", ".", "put", "(", "\"startDate\"", ",", "startDate", ".", "toString", "(", ")", ")", ";", "data", ".", "put", "(", "\"httpMethod\"", ",", "request", ".", "getMethod", "(", ")", ")", ";", "data", ".", "put", "(", "\"requestBody\"", ",", "maskContent", "(", "requestBody", ",", "request", ".", "getRequestURI", "(", ")", ",", "true", ",", "request", ".", "getMethod", "(", ")", ")", ")", ";", "data", ".", "put", "(", "\"requestLength\"", ",", "requestBody", ".", "length", "(", ")", ")", ";", "data", ".", "put", "(", "\"responseBody\"", ",", "maskContent", "(", "responseBody", ",", "request", ".", "getRequestURI", "(", ")", ",", "false", ",", "request", ".", "getMethod", "(", ")", ")", ")", ";", "data", ".", "put", "(", "\"responseLength\"", ",", "responseBody", ".", "length", "(", ")", ")", ";", "data", ".", "put", "(", "\"requestHeaders\"", ",", "getRequestHeaders", "(", "request", ")", ")", ";", "data", ".", "put", "(", "\"responseHeaders\"", ",", "getResponseHeaders", "(", "response", ")", ")", ";", "data", ".", "put", "(", "\"httpStatusCode\"", ",", "response", ".", "getStatus", "(", ")", ")", ";", "data", ".", "put", "(", "\"channelType\"", ",", "\"HTTP\"", ")", ";", "data", ".", "put", "(", "\"entityId\"", ",", "getEntityField", "(", "responseBody", ",", "\"id\"", ")", ")", ";", "data", ".", "put", "(", "\"entityKey\"", ",", "getEntityField", "(", "responseBody", ",", "\"key\"", ")", ")", ";", "data", ".", "put", "(", "\"entityTypeKey\"", ",", "getEntityField", "(", "responseBody", ",", "\"typeKey\"", ")", ")", ";", "data", ".", "put", "(", "\"execTime\"", ",", "MdcUtils", ".", "getExecTimeMs", "(", ")", ")", ";", "return", "mapper", ".", "writeValueAsString", "(", "data", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "warn", "(", "\"Error creating timeline event\"", ",", "e", ")", ";", "}", "return", "null", ";", "}" ]
Create event json string. @param request the http request @param response the http response
[ "Create", "event", "json", "string", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-timeline/src/main/java/com/icthh/xm/commons/timeline/TimelineEventProducer.java#L60-L101
142,058
xm-online/xm-commons
xm-commons-timeline/src/main/java/com/icthh/xm/commons/timeline/TimelineEventProducer.java
TimelineEventProducer.send
@Async public void send(String topic, String content) { try { if (!StringUtils.isBlank(content)) { log.debug("Sending kafka event with data {} to topic {}", content, topic); template.send(topic, content); } } catch (Exception e) { log.error("Error send timeline event", e); throw e; } }
java
@Async public void send(String topic, String content) { try { if (!StringUtils.isBlank(content)) { log.debug("Sending kafka event with data {} to topic {}", content, topic); template.send(topic, content); } } catch (Exception e) { log.error("Error send timeline event", e); throw e; } }
[ "@", "Async", "public", "void", "send", "(", "String", "topic", ",", "String", "content", ")", "{", "try", "{", "if", "(", "!", "StringUtils", ".", "isBlank", "(", "content", ")", ")", "{", "log", ".", "debug", "(", "\"Sending kafka event with data {} to topic {}\"", ",", "content", ",", "topic", ")", ";", "template", ".", "send", "(", "topic", ",", "content", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Error send timeline event\"", ",", "e", ")", ";", "throw", "e", ";", "}", "}" ]
Send event to kafka. @param topic the kafka topic @param content the event content
[ "Send", "event", "to", "kafka", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-timeline/src/main/java/com/icthh/xm/commons/timeline/TimelineEventProducer.java#L109-L120
142,059
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/util/Generics2.java
Generics2.join
public static String join(final Iterable<?> elements, final char separator) { return Joiner.on(separator).skipNulls().join(elements); }
java
public static String join(final Iterable<?> elements, final char separator) { return Joiner.on(separator).skipNulls().join(elements); }
[ "public", "static", "String", "join", "(", "final", "Iterable", "<", "?", ">", "elements", ",", "final", "char", "separator", ")", "{", "return", "Joiner", ".", "on", "(", "separator", ")", ".", "skipNulls", "(", ")", ".", "join", "(", "elements", ")", ";", "}" ]
joins all given elements with a special separator @param elements elements to join @param separator separator to use @return elements as string
[ "joins", "all", "given", "elements", "with", "a", "special", "separator" ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/util/Generics2.java#L92-L94
142,060
xm-online/xm-commons
xm-commons-ms-web/src/main/java/com/icthh/xm/commons/web/spring/config/XmWebMvcConfigurerAdapter.java
XmWebMvcConfigurerAdapter.registerTenantInterceptorWithIgnorePathPattern
protected void registerTenantInterceptorWithIgnorePathPattern( InterceptorRegistry registry, HandlerInterceptor interceptor) { InterceptorRegistration tenantInterceptorRegistration = registry.addInterceptor(interceptor); tenantInterceptorRegistration.addPathPatterns("/**"); List<String> tenantIgnorePathPatterns = getTenantIgnorePathPatterns(); Objects.requireNonNull(tenantIgnorePathPatterns, "tenantIgnorePathPatterns can't be null"); for (String pattern : tenantIgnorePathPatterns) { tenantInterceptorRegistration.excludePathPatterns(pattern); } LOGGER.info("Added handler interceptor '{}' to all urls, exclude {}", interceptor.getClass() .getSimpleName(), tenantIgnorePathPatterns); }
java
protected void registerTenantInterceptorWithIgnorePathPattern( InterceptorRegistry registry, HandlerInterceptor interceptor) { InterceptorRegistration tenantInterceptorRegistration = registry.addInterceptor(interceptor); tenantInterceptorRegistration.addPathPatterns("/**"); List<String> tenantIgnorePathPatterns = getTenantIgnorePathPatterns(); Objects.requireNonNull(tenantIgnorePathPatterns, "tenantIgnorePathPatterns can't be null"); for (String pattern : tenantIgnorePathPatterns) { tenantInterceptorRegistration.excludePathPatterns(pattern); } LOGGER.info("Added handler interceptor '{}' to all urls, exclude {}", interceptor.getClass() .getSimpleName(), tenantIgnorePathPatterns); }
[ "protected", "void", "registerTenantInterceptorWithIgnorePathPattern", "(", "InterceptorRegistry", "registry", ",", "HandlerInterceptor", "interceptor", ")", "{", "InterceptorRegistration", "tenantInterceptorRegistration", "=", "registry", ".", "addInterceptor", "(", "interceptor", ")", ";", "tenantInterceptorRegistration", ".", "addPathPatterns", "(", "\"/**\"", ")", ";", "List", "<", "String", ">", "tenantIgnorePathPatterns", "=", "getTenantIgnorePathPatterns", "(", ")", ";", "Objects", ".", "requireNonNull", "(", "tenantIgnorePathPatterns", ",", "\"tenantIgnorePathPatterns can't be null\"", ")", ";", "for", "(", "String", "pattern", ":", "tenantIgnorePathPatterns", ")", "{", "tenantInterceptorRegistration", ".", "excludePathPatterns", "(", "pattern", ")", ";", "}", "LOGGER", ".", "info", "(", "\"Added handler interceptor '{}' to all urls, exclude {}\"", ",", "interceptor", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", ",", "tenantIgnorePathPatterns", ")", ";", "}" ]
Registered interceptor to all request except passed urls. @param registry helps with configuring a list of mapped interceptors. @param interceptor the interceptor
[ "Registered", "interceptor", "to", "all", "request", "except", "passed", "urls", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-ms-web/src/main/java/com/icthh/xm/commons/web/spring/config/XmWebMvcConfigurerAdapter.java#L81-L95
142,061
xm-online/xm-commons
xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/AopAnnotationUtils.java
AopAnnotationUtils.getConfigAnnotation
public static Optional<LoggingAspectConfig> getConfigAnnotation(JoinPoint joinPoint) { Optional<Method> method = getCallingMethod(joinPoint); Optional<LoggingAspectConfig> result = method .map(m -> AnnotationUtils.findAnnotation(m, LoggingAspectConfig.class)); if (!result.isPresent()) { Optional<Class> clazz = getDeclaringClass(joinPoint); result = clazz.map(aClass -> AnnotationUtils.getAnnotation(aClass, LoggingAspectConfig.class)); } return result; }
java
public static Optional<LoggingAspectConfig> getConfigAnnotation(JoinPoint joinPoint) { Optional<Method> method = getCallingMethod(joinPoint); Optional<LoggingAspectConfig> result = method .map(m -> AnnotationUtils.findAnnotation(m, LoggingAspectConfig.class)); if (!result.isPresent()) { Optional<Class> clazz = getDeclaringClass(joinPoint); result = clazz.map(aClass -> AnnotationUtils.getAnnotation(aClass, LoggingAspectConfig.class)); } return result; }
[ "public", "static", "Optional", "<", "LoggingAspectConfig", ">", "getConfigAnnotation", "(", "JoinPoint", "joinPoint", ")", "{", "Optional", "<", "Method", ">", "method", "=", "getCallingMethod", "(", "joinPoint", ")", ";", "Optional", "<", "LoggingAspectConfig", ">", "result", "=", "method", ".", "map", "(", "m", "->", "AnnotationUtils", ".", "findAnnotation", "(", "m", ",", "LoggingAspectConfig", ".", "class", ")", ")", ";", "if", "(", "!", "result", ".", "isPresent", "(", ")", ")", "{", "Optional", "<", "Class", ">", "clazz", "=", "getDeclaringClass", "(", "joinPoint", ")", ";", "result", "=", "clazz", ".", "map", "(", "aClass", "->", "AnnotationUtils", ".", "getAnnotation", "(", "aClass", ",", "LoggingAspectConfig", ".", "class", ")", ")", ";", "}", "return", "result", ";", "}" ]
Find annotation related to method intercepted by joinPoint. Annotation is searched on method level at first and then if not found on class lever as well. Method uses spring {@link AnnotationUtils} findAnnotation(), so it is search for annotation by class hierarchy. @param joinPoint join point @return Optional value of type @{@link LoggingAspectConfig} @see AnnotationUtils
[ "Find", "annotation", "related", "to", "method", "intercepted", "by", "joinPoint", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-logging/src/main/java/com/icthh/xm/commons/logging/util/AopAnnotationUtils.java#L30-L43
142,062
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/RoleMapper.java
RoleMapper.rolesToYml
public String rolesToYml(Collection<Role> roles) { try { Map<String, Role> map = new TreeMap<>(); roles.forEach(role -> map.put(role.getKey(), role)); return mapper.writeValueAsString(map); } catch (Exception e) { log.error("Failed to create roles YML file from collection, error: {}", e.getMessage(), e); } return null; }
java
public String rolesToYml(Collection<Role> roles) { try { Map<String, Role> map = new TreeMap<>(); roles.forEach(role -> map.put(role.getKey(), role)); return mapper.writeValueAsString(map); } catch (Exception e) { log.error("Failed to create roles YML file from collection, error: {}", e.getMessage(), e); } return null; }
[ "public", "String", "rolesToYml", "(", "Collection", "<", "Role", ">", "roles", ")", "{", "try", "{", "Map", "<", "String", ",", "Role", ">", "map", "=", "new", "TreeMap", "<>", "(", ")", ";", "roles", ".", "forEach", "(", "role", "->", "map", ".", "put", "(", "role", ".", "getKey", "(", ")", ",", "role", ")", ")", ";", "return", "mapper", ".", "writeValueAsString", "(", "map", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Failed to create roles YML file from collection, error: {}\"", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "return", "null", ";", "}" ]
Convert roles collection to yml string. @param roles collection @return yml string
[ "Convert", "roles", "collection", "to", "yml", "string", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/RoleMapper.java#L27-L36
142,063
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/RoleMapper.java
RoleMapper.ymlToRoles
public Map<String, Role> ymlToRoles(String yml) { try { Map<String, Role> map = mapper .readValue(yml, new TypeReference<TreeMap<String, Role>>() { }); map.forEach((roleKey, role) -> role.setKey(roleKey)); return map; } catch (Exception e) { log.error("Failed to create roles collection from YML file, error: {}", e.getMessage(), e); } return Collections.emptyMap(); }
java
public Map<String, Role> ymlToRoles(String yml) { try { Map<String, Role> map = mapper .readValue(yml, new TypeReference<TreeMap<String, Role>>() { }); map.forEach((roleKey, role) -> role.setKey(roleKey)); return map; } catch (Exception e) { log.error("Failed to create roles collection from YML file, error: {}", e.getMessage(), e); } return Collections.emptyMap(); }
[ "public", "Map", "<", "String", ",", "Role", ">", "ymlToRoles", "(", "String", "yml", ")", "{", "try", "{", "Map", "<", "String", ",", "Role", ">", "map", "=", "mapper", ".", "readValue", "(", "yml", ",", "new", "TypeReference", "<", "TreeMap", "<", "String", ",", "Role", ">", ">", "(", ")", "{", "}", ")", ";", "map", ".", "forEach", "(", "(", "roleKey", ",", "role", ")", "->", "role", ".", "setKey", "(", "roleKey", ")", ")", ";", "return", "map", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Failed to create roles collection from YML file, error: {}\"", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "return", "Collections", ".", "emptyMap", "(", ")", ";", "}" ]
Convert roles yml string to map. @param yml string @return roles map
[ "Convert", "roles", "yml", "string", "to", "map", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/RoleMapper.java#L44-L55
142,064
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/PermissionCheckService.java
PermissionCheckService.hasPermission
public boolean hasPermission(Authentication authentication, Object privilege) { return checkRole(authentication, privilege, true) || checkPermission(authentication, null, privilege, false, true); }
java
public boolean hasPermission(Authentication authentication, Object privilege) { return checkRole(authentication, privilege, true) || checkPermission(authentication, null, privilege, false, true); }
[ "public", "boolean", "hasPermission", "(", "Authentication", "authentication", ",", "Object", "privilege", ")", "{", "return", "checkRole", "(", "authentication", ",", "privilege", ",", "true", ")", "||", "checkPermission", "(", "authentication", ",", "null", ",", "privilege", ",", "false", ",", "true", ")", ";", "}" ]
Check permission for role and privilege key only. @param authentication the authentication @param privilege the privilege key @return true if permitted
[ "Check", "permission", "for", "role", "and", "privilege", "key", "only", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/PermissionCheckService.java#L55-L59
142,065
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/PermissionCheckService.java
PermissionCheckService.hasPermission
public boolean hasPermission(Authentication authentication, Object resource, Object privilege) { boolean logPermission = isLogPermission(resource); return checkRole(authentication, privilege, logPermission) || checkPermission(authentication, resource, privilege, true, logPermission); }
java
public boolean hasPermission(Authentication authentication, Object resource, Object privilege) { boolean logPermission = isLogPermission(resource); return checkRole(authentication, privilege, logPermission) || checkPermission(authentication, resource, privilege, true, logPermission); }
[ "public", "boolean", "hasPermission", "(", "Authentication", "authentication", ",", "Object", "resource", ",", "Object", "privilege", ")", "{", "boolean", "logPermission", "=", "isLogPermission", "(", "resource", ")", ";", "return", "checkRole", "(", "authentication", ",", "privilege", ",", "logPermission", ")", "||", "checkPermission", "(", "authentication", ",", "resource", ",", "privilege", ",", "true", ",", "logPermission", ")", ";", "}" ]
Check permission for role, privilege key and resource condition. @param authentication the authentication @param resource the resource @param privilege the privilege key @return true if permitted
[ "Check", "permission", "for", "role", "privilege", "key", "and", "resource", "condition", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/PermissionCheckService.java#L68-L74
142,066
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/PermissionCheckService.java
PermissionCheckService.hasPermission
@SuppressWarnings("unchecked") public boolean hasPermission(Authentication authentication, Serializable resource, String resourceType, Object privilege) { boolean logPermission = isLogPermission(resource); if (checkRole(authentication, privilege, logPermission)) { return true; } if (resource != null) { Object resourceId = ((Map<String, Object>) resource).get("id"); if (resourceId != null) { ((Map<String, Object>) resource).put(resourceType, resourceFactory.getResource(resourceId, resourceType)); } } return checkPermission(authentication, resource, privilege, true, logPermission); }
java
@SuppressWarnings("unchecked") public boolean hasPermission(Authentication authentication, Serializable resource, String resourceType, Object privilege) { boolean logPermission = isLogPermission(resource); if (checkRole(authentication, privilege, logPermission)) { return true; } if (resource != null) { Object resourceId = ((Map<String, Object>) resource).get("id"); if (resourceId != null) { ((Map<String, Object>) resource).put(resourceType, resourceFactory.getResource(resourceId, resourceType)); } } return checkPermission(authentication, resource, privilege, true, logPermission); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "boolean", "hasPermission", "(", "Authentication", "authentication", ",", "Serializable", "resource", ",", "String", "resourceType", ",", "Object", "privilege", ")", "{", "boolean", "logPermission", "=", "isLogPermission", "(", "resource", ")", ";", "if", "(", "checkRole", "(", "authentication", ",", "privilege", ",", "logPermission", ")", ")", "{", "return", "true", ";", "}", "if", "(", "resource", "!=", "null", ")", "{", "Object", "resourceId", "=", "(", "(", "Map", "<", "String", ",", "Object", ">", ")", "resource", ")", ".", "get", "(", "\"id\"", ")", ";", "if", "(", "resourceId", "!=", "null", ")", "{", "(", "(", "Map", "<", "String", ",", "Object", ">", ")", "resource", ")", ".", "put", "(", "resourceType", ",", "resourceFactory", ".", "getResource", "(", "resourceId", ",", "resourceType", ")", ")", ";", "}", "}", "return", "checkPermission", "(", "authentication", ",", "resource", ",", "privilege", ",", "true", ",", "logPermission", ")", ";", "}" ]
Check permission for role, privilege key, new resource and old resource. @param authentication the authentication @param resource the old resource @param resourceType the resource type @param privilege the privilege key @return true if permitted
[ "Check", "permission", "for", "role", "privilege", "key", "new", "resource", "and", "old", "resource", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/PermissionCheckService.java#L84-L101
142,067
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/PermissionCheckService.java
PermissionCheckService.createCondition
public String createCondition(Authentication authentication, Object privilegeKey, SpelTranslator translator) { if (!hasPermission(authentication, privilegeKey)) { throw new AccessDeniedException("Access is denied"); } String roleKey = getRoleKey(authentication); Permission permission = getPermission(roleKey, privilegeKey); Subject subject = getSubject(roleKey); if (!RoleConstant.SUPER_ADMIN.equals(roleKey) && permission != null && permission.getResourceCondition() != null) { return translator.translate(permission.getResourceCondition().getExpressionString(), subject); } return null; }
java
public String createCondition(Authentication authentication, Object privilegeKey, SpelTranslator translator) { if (!hasPermission(authentication, privilegeKey)) { throw new AccessDeniedException("Access is denied"); } String roleKey = getRoleKey(authentication); Permission permission = getPermission(roleKey, privilegeKey); Subject subject = getSubject(roleKey); if (!RoleConstant.SUPER_ADMIN.equals(roleKey) && permission != null && permission.getResourceCondition() != null) { return translator.translate(permission.getResourceCondition().getExpressionString(), subject); } return null; }
[ "public", "String", "createCondition", "(", "Authentication", "authentication", ",", "Object", "privilegeKey", ",", "SpelTranslator", "translator", ")", "{", "if", "(", "!", "hasPermission", "(", "authentication", ",", "privilegeKey", ")", ")", "{", "throw", "new", "AccessDeniedException", "(", "\"Access is denied\"", ")", ";", "}", "String", "roleKey", "=", "getRoleKey", "(", "authentication", ")", ";", "Permission", "permission", "=", "getPermission", "(", "roleKey", ",", "privilegeKey", ")", ";", "Subject", "subject", "=", "getSubject", "(", "roleKey", ")", ";", "if", "(", "!", "RoleConstant", ".", "SUPER_ADMIN", ".", "equals", "(", "roleKey", ")", "&&", "permission", "!=", "null", "&&", "permission", ".", "getResourceCondition", "(", ")", "!=", "null", ")", "{", "return", "translator", ".", "translate", "(", "permission", ".", "getResourceCondition", "(", ")", ".", "getExpressionString", "(", ")", ",", "subject", ")", ";", "}", "return", "null", ";", "}" ]
Create condition with replaced subject variables. <p>SpEL condition translated to SQL condition with replacing #returnObject to returnObject and enriching #subject.* from Subject object (see {@link Subject}). <p>As an option, SpEL could be translated to SQL via {@link SpelExpression} method {@code getAST()} with traversing through {@link SpelNode} nodes and building SQL expression. @param authentication the authentication @param privilegeKey the privilege key @param translator the spel translator @return condition if permitted, or null
[ "Create", "condition", "with", "replaced", "subject", "variables", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/service/PermissionCheckService.java#L118-L134
142,068
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/settings/DefaultObjectMapperFactory.java
DefaultObjectMapperFactory.addSerializer
protected Module addSerializer(SimpleModule module) { module.addSerializer(ConfigModel.class, Holder.CONFIG_MODEL_SERIALIZER); module.addSerializer(Config.class, Holder.CONFIG_SERIALIZER); module.addSerializer(Json.RawValue.class, Holder.RAW_VALUE_SERIALIZER); return module; }
java
protected Module addSerializer(SimpleModule module) { module.addSerializer(ConfigModel.class, Holder.CONFIG_MODEL_SERIALIZER); module.addSerializer(Config.class, Holder.CONFIG_SERIALIZER); module.addSerializer(Json.RawValue.class, Holder.RAW_VALUE_SERIALIZER); return module; }
[ "protected", "Module", "addSerializer", "(", "SimpleModule", "module", ")", "{", "module", ".", "addSerializer", "(", "ConfigModel", ".", "class", ",", "Holder", ".", "CONFIG_MODEL_SERIALIZER", ")", ";", "module", ".", "addSerializer", "(", "Config", ".", "class", ",", "Holder", ".", "CONFIG_SERIALIZER", ")", ";", "module", ".", "addSerializer", "(", "Json", ".", "RawValue", ".", "class", ",", "Holder", ".", "RAW_VALUE_SERIALIZER", ")", ";", "return", "module", ";", "}" ]
adds custom serializers to given module @param module the module to extend @return module instance for chaining
[ "adds", "custom", "serializers", "to", "given", "module" ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/settings/DefaultObjectMapperFactory.java#L63-L69
142,069
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/settings/DefaultObjectMapperFactory.java
DefaultObjectMapperFactory.configure
protected ObjectMapper configure(ObjectMapper mapper) { mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); return mapper; }
java
protected ObjectMapper configure(ObjectMapper mapper) { mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); return mapper; }
[ "protected", "ObjectMapper", "configure", "(", "ObjectMapper", "mapper", ")", "{", "mapper", ".", "configure", "(", "JsonParser", ".", "Feature", ".", "ALLOW_SINGLE_QUOTES", ",", "true", ")", ";", "mapper", ".", "configure", "(", "JsonParser", ".", "Feature", ".", "ALLOW_UNQUOTED_FIELD_NAMES", ",", "true", ")", ";", "return", "mapper", ";", "}" ]
configures given object mapper instance. @param mapper the object to configure @return mapper instance for chaining
[ "configures", "given", "object", "mapper", "instance", "." ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/settings/DefaultObjectMapperFactory.java#L77-L82
142,070
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/PermissionMapper.java
PermissionMapper.permissionsToYml
public String permissionsToYml(Collection<Permission> permissions) { try { Map<String, Map<String, Set<Permission>>> map = new TreeMap<>(); permissions.forEach(permission -> { map.putIfAbsent(permission.getMsName(), new TreeMap<>()); map.get(permission.getMsName()).putIfAbsent(permission.getRoleKey(), new TreeSet<>()); map.get(permission.getMsName()).get(permission.getRoleKey()).add(permission); }); return mapper.writeValueAsString(map); } catch (Exception e) { log.error("Failed to create permissions YML file from collection, error: {}", e.getMessage(), e); } return null; }
java
public String permissionsToYml(Collection<Permission> permissions) { try { Map<String, Map<String, Set<Permission>>> map = new TreeMap<>(); permissions.forEach(permission -> { map.putIfAbsent(permission.getMsName(), new TreeMap<>()); map.get(permission.getMsName()).putIfAbsent(permission.getRoleKey(), new TreeSet<>()); map.get(permission.getMsName()).get(permission.getRoleKey()).add(permission); }); return mapper.writeValueAsString(map); } catch (Exception e) { log.error("Failed to create permissions YML file from collection, error: {}", e.getMessage(), e); } return null; }
[ "public", "String", "permissionsToYml", "(", "Collection", "<", "Permission", ">", "permissions", ")", "{", "try", "{", "Map", "<", "String", ",", "Map", "<", "String", ",", "Set", "<", "Permission", ">", ">", ">", "map", "=", "new", "TreeMap", "<>", "(", ")", ";", "permissions", ".", "forEach", "(", "permission", "->", "{", "map", ".", "putIfAbsent", "(", "permission", ".", "getMsName", "(", ")", ",", "new", "TreeMap", "<>", "(", ")", ")", ";", "map", ".", "get", "(", "permission", ".", "getMsName", "(", ")", ")", ".", "putIfAbsent", "(", "permission", ".", "getRoleKey", "(", ")", ",", "new", "TreeSet", "<>", "(", ")", ")", ";", "map", ".", "get", "(", "permission", ".", "getMsName", "(", ")", ")", ".", "get", "(", "permission", ".", "getRoleKey", "(", ")", ")", ".", "add", "(", "permission", ")", ";", "}", ")", ";", "return", "mapper", ".", "writeValueAsString", "(", "map", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Failed to create permissions YML file from collection, error: {}\"", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "return", "null", ";", "}" ]
Convert permissions collection to yml string. @param permissions collection @return yml string
[ "Convert", "permissions", "collection", "to", "yml", "string", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/PermissionMapper.java#L30-L43
142,071
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/PermissionMapper.java
PermissionMapper.ymlToPermissions
public Map<String, Permission> ymlToPermissions(String yml, String msName) { Map<String, Permission> result = new TreeMap<>(); try { Map<String, Map<String, Set<Permission>>> map = mapper .readValue(yml, new TypeReference<TreeMap<String, TreeMap<String, TreeSet<Permission>>>>() { }); map.entrySet().stream() .filter(entry -> StringUtils.isBlank(msName) || StringUtils.startsWithIgnoreCase(entry.getKey(), msName)) .filter(entry -> entry.getValue() != null) .forEach(entry -> entry.getValue() .forEach((roleKey, permissions) -> permissions.forEach(permission -> { permission.setMsName(entry.getKey()); permission.setRoleKey(roleKey); result.put(roleKey + ":" + permission.getPrivilegeKey(), permission); }) )); } catch (Exception e) { log.error("Failed to create permissions collection from YML file, error: {}", e.getMessage(), e); } return Collections.unmodifiableMap(result); }
java
public Map<String, Permission> ymlToPermissions(String yml, String msName) { Map<String, Permission> result = new TreeMap<>(); try { Map<String, Map<String, Set<Permission>>> map = mapper .readValue(yml, new TypeReference<TreeMap<String, TreeMap<String, TreeSet<Permission>>>>() { }); map.entrySet().stream() .filter(entry -> StringUtils.isBlank(msName) || StringUtils.startsWithIgnoreCase(entry.getKey(), msName)) .filter(entry -> entry.getValue() != null) .forEach(entry -> entry.getValue() .forEach((roleKey, permissions) -> permissions.forEach(permission -> { permission.setMsName(entry.getKey()); permission.setRoleKey(roleKey); result.put(roleKey + ":" + permission.getPrivilegeKey(), permission); }) )); } catch (Exception e) { log.error("Failed to create permissions collection from YML file, error: {}", e.getMessage(), e); } return Collections.unmodifiableMap(result); }
[ "public", "Map", "<", "String", ",", "Permission", ">", "ymlToPermissions", "(", "String", "yml", ",", "String", "msName", ")", "{", "Map", "<", "String", ",", "Permission", ">", "result", "=", "new", "TreeMap", "<>", "(", ")", ";", "try", "{", "Map", "<", "String", ",", "Map", "<", "String", ",", "Set", "<", "Permission", ">", ">", ">", "map", "=", "mapper", ".", "readValue", "(", "yml", ",", "new", "TypeReference", "<", "TreeMap", "<", "String", ",", "TreeMap", "<", "String", ",", "TreeSet", "<", "Permission", ">", ">", ">", ">", "(", ")", "{", "}", ")", ";", "map", ".", "entrySet", "(", ")", ".", "stream", "(", ")", ".", "filter", "(", "entry", "->", "StringUtils", ".", "isBlank", "(", "msName", ")", "||", "StringUtils", ".", "startsWithIgnoreCase", "(", "entry", ".", "getKey", "(", ")", ",", "msName", ")", ")", ".", "filter", "(", "entry", "->", "entry", ".", "getValue", "(", ")", "!=", "null", ")", ".", "forEach", "(", "entry", "->", "entry", ".", "getValue", "(", ")", ".", "forEach", "(", "(", "roleKey", ",", "permissions", ")", "->", "permissions", ".", "forEach", "(", "permission", "->", "{", "permission", ".", "setMsName", "(", "entry", ".", "getKey", "(", ")", ")", ";", "permission", ".", "setRoleKey", "(", "roleKey", ")", ";", "result", ".", "put", "(", "roleKey", "+", "\":\"", "+", "permission", ".", "getPrivilegeKey", "(", ")", ",", "permission", ")", ";", "}", ")", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "log", ".", "error", "(", "\"Failed to create permissions collection from YML file, error: {}\"", ",", "e", ".", "getMessage", "(", ")", ",", "e", ")", ";", "}", "return", "Collections", ".", "unmodifiableMap", "(", "result", ")", ";", "}" ]
Convert permissions yml string to map with role and privilege keys. Return map fo specific service or all. @param yml string @param msName service name @return permissions map
[ "Convert", "permissions", "yml", "string", "to", "map", "with", "role", "and", "privilege", "keys", ".", "Return", "map", "fo", "specific", "service", "or", "all", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/domain/mapper/PermissionMapper.java#L63-L84
142,072
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/repository/PermittedRepository.java
PermittedRepository.findAll
public <T> List<T> findAll(Class<T> entityClass, String privilegeKey) { return findAll(null, entityClass, privilegeKey).getContent(); }
java
public <T> List<T> findAll(Class<T> entityClass, String privilegeKey) { return findAll(null, entityClass, privilegeKey).getContent(); }
[ "public", "<", "T", ">", "List", "<", "T", ">", "findAll", "(", "Class", "<", "T", ">", "entityClass", ",", "String", "privilegeKey", ")", "{", "return", "findAll", "(", "null", ",", "entityClass", ",", "privilegeKey", ")", ".", "getContent", "(", ")", ";", "}" ]
Find all permitted entities. @param entityClass the entity class to get @param privilegeKey the privilege key for permission lookup @param <T> the type of entity @return list of permitted entities
[ "Find", "all", "permitted", "entities", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/repository/PermittedRepository.java#L60-L62
142,073
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/repository/PermittedRepository.java
PermittedRepository.findAll
public <T> Page<T> findAll(Pageable pageable, Class<T> entityClass, String privilegeKey) { String selectSql = format(SELECT_ALL_SQL, entityClass.getSimpleName()); String countSql = format(COUNT_ALL_SQL, entityClass.getSimpleName()); String permittedCondition = createPermissionCondition(privilegeKey); if (StringUtils.isNotBlank(permittedCondition)) { selectSql += WHERE_SQL + permittedCondition; countSql += WHERE_SQL + permittedCondition; } log.debug("Executing SQL '{}'", selectSql); return execute(createCountQuery(countSql), pageable, createSelectQuery(selectSql, pageable, entityClass)); }
java
public <T> Page<T> findAll(Pageable pageable, Class<T> entityClass, String privilegeKey) { String selectSql = format(SELECT_ALL_SQL, entityClass.getSimpleName()); String countSql = format(COUNT_ALL_SQL, entityClass.getSimpleName()); String permittedCondition = createPermissionCondition(privilegeKey); if (StringUtils.isNotBlank(permittedCondition)) { selectSql += WHERE_SQL + permittedCondition; countSql += WHERE_SQL + permittedCondition; } log.debug("Executing SQL '{}'", selectSql); return execute(createCountQuery(countSql), pageable, createSelectQuery(selectSql, pageable, entityClass)); }
[ "public", "<", "T", ">", "Page", "<", "T", ">", "findAll", "(", "Pageable", "pageable", ",", "Class", "<", "T", ">", "entityClass", ",", "String", "privilegeKey", ")", "{", "String", "selectSql", "=", "format", "(", "SELECT_ALL_SQL", ",", "entityClass", ".", "getSimpleName", "(", ")", ")", ";", "String", "countSql", "=", "format", "(", "COUNT_ALL_SQL", ",", "entityClass", ".", "getSimpleName", "(", ")", ")", ";", "String", "permittedCondition", "=", "createPermissionCondition", "(", "privilegeKey", ")", ";", "if", "(", "StringUtils", ".", "isNotBlank", "(", "permittedCondition", ")", ")", "{", "selectSql", "+=", "WHERE_SQL", "+", "permittedCondition", ";", "countSql", "+=", "WHERE_SQL", "+", "permittedCondition", ";", "}", "log", ".", "debug", "(", "\"Executing SQL '{}'\"", ",", "selectSql", ")", ";", "return", "execute", "(", "createCountQuery", "(", "countSql", ")", ",", "pageable", ",", "createSelectQuery", "(", "selectSql", ",", "pageable", ",", "entityClass", ")", ")", ";", "}" ]
Find all pageable permitted entities. @param pageable the page info @param entityClass the entity class to get @param privilegeKey the privilege key for permission lookup @param <T> the type of entity @return page of permitted entities
[ "Find", "all", "pageable", "permitted", "entities", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/repository/PermittedRepository.java#L72-L85
142,074
xm-online/xm-commons
xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/repository/PermittedRepository.java
PermittedRepository.findByCondition
public <T> Page<T> findByCondition(String whereCondition, Map<String, Object> conditionParams, Collection<String> embed, Pageable pageable, Class<T> entityClass, String privilegeKey) { String selectSql = format(SELECT_ALL_SQL, entityClass.getSimpleName()); String countSql = format(COUNT_ALL_SQL, entityClass.getSimpleName()); selectSql += WHERE_SQL + whereCondition; countSql += WHERE_SQL + whereCondition; String permittedCondition = createPermissionCondition(privilegeKey); if (StringUtils.isNotBlank(permittedCondition)) { selectSql += AND_SQL + "(" + permittedCondition + ")"; countSql += AND_SQL + "(" + permittedCondition + ")"; } TypedQuery<T> selectQuery = createSelectQuery(selectSql, pageable, entityClass); if (!CollectionUtils.isEmpty(embed)) { selectQuery.setHint(QueryHints.HINT_LOADGRAPH, createEnitityGraph(embed, entityClass)); } TypedQuery<Long> countQuery = createCountQuery(countSql); conditionParams.forEach((paramName, paramValue) -> { selectQuery.setParameter(paramName, paramValue); countQuery.setParameter(paramName, paramValue); }); log.debug("Executing SQL '{}' with params '{}'", selectQuery, conditionParams); return execute(countQuery, pageable, selectQuery); }
java
public <T> Page<T> findByCondition(String whereCondition, Map<String, Object> conditionParams, Collection<String> embed, Pageable pageable, Class<T> entityClass, String privilegeKey) { String selectSql = format(SELECT_ALL_SQL, entityClass.getSimpleName()); String countSql = format(COUNT_ALL_SQL, entityClass.getSimpleName()); selectSql += WHERE_SQL + whereCondition; countSql += WHERE_SQL + whereCondition; String permittedCondition = createPermissionCondition(privilegeKey); if (StringUtils.isNotBlank(permittedCondition)) { selectSql += AND_SQL + "(" + permittedCondition + ")"; countSql += AND_SQL + "(" + permittedCondition + ")"; } TypedQuery<T> selectQuery = createSelectQuery(selectSql, pageable, entityClass); if (!CollectionUtils.isEmpty(embed)) { selectQuery.setHint(QueryHints.HINT_LOADGRAPH, createEnitityGraph(embed, entityClass)); } TypedQuery<Long> countQuery = createCountQuery(countSql); conditionParams.forEach((paramName, paramValue) -> { selectQuery.setParameter(paramName, paramValue); countQuery.setParameter(paramName, paramValue); }); log.debug("Executing SQL '{}' with params '{}'", selectQuery, conditionParams); return execute(countQuery, pageable, selectQuery); }
[ "public", "<", "T", ">", "Page", "<", "T", ">", "findByCondition", "(", "String", "whereCondition", ",", "Map", "<", "String", ",", "Object", ">", "conditionParams", ",", "Collection", "<", "String", ">", "embed", ",", "Pageable", "pageable", ",", "Class", "<", "T", ">", "entityClass", ",", "String", "privilegeKey", ")", "{", "String", "selectSql", "=", "format", "(", "SELECT_ALL_SQL", ",", "entityClass", ".", "getSimpleName", "(", ")", ")", ";", "String", "countSql", "=", "format", "(", "COUNT_ALL_SQL", ",", "entityClass", ".", "getSimpleName", "(", ")", ")", ";", "selectSql", "+=", "WHERE_SQL", "+", "whereCondition", ";", "countSql", "+=", "WHERE_SQL", "+", "whereCondition", ";", "String", "permittedCondition", "=", "createPermissionCondition", "(", "privilegeKey", ")", ";", "if", "(", "StringUtils", ".", "isNotBlank", "(", "permittedCondition", ")", ")", "{", "selectSql", "+=", "AND_SQL", "+", "\"(\"", "+", "permittedCondition", "+", "\")\"", ";", "countSql", "+=", "AND_SQL", "+", "\"(\"", "+", "permittedCondition", "+", "\")\"", ";", "}", "TypedQuery", "<", "T", ">", "selectQuery", "=", "createSelectQuery", "(", "selectSql", ",", "pageable", ",", "entityClass", ")", ";", "if", "(", "!", "CollectionUtils", ".", "isEmpty", "(", "embed", ")", ")", "{", "selectQuery", ".", "setHint", "(", "QueryHints", ".", "HINT_LOADGRAPH", ",", "createEnitityGraph", "(", "embed", ",", "entityClass", ")", ")", ";", "}", "TypedQuery", "<", "Long", ">", "countQuery", "=", "createCountQuery", "(", "countSql", ")", ";", "conditionParams", ".", "forEach", "(", "(", "paramName", ",", "paramValue", ")", "->", "{", "selectQuery", ".", "setParameter", "(", "paramName", ",", "paramValue", ")", ";", "countQuery", ".", "setParameter", "(", "paramName", ",", "paramValue", ")", ";", "}", ")", ";", "log", ".", "debug", "(", "\"Executing SQL '{}' with params '{}'\"", ",", "selectQuery", ",", "conditionParams", ")", ";", "return", "execute", "(", "countQuery", ",", "pageable", ",", "selectQuery", ")", ";", "}" ]
Find permitted entities by parameters with embed graph. @param whereCondition the parameters condition @param conditionParams the parameters map @param embed the embed list @param pageable the page info @param entityClass the entity class to get @param privilegeKey the privilege key for permission lookup @param <T> the type of entity @return page of permitted entities
[ "Find", "permitted", "entities", "by", "parameters", "with", "embed", "graph", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-permission/src/main/java/com/icthh/xm/commons/permission/repository/PermittedRepository.java#L132-L164
142,075
l0rdn1kk0n/wicket-jquery-selectors
src/main/java/de/agilecoders/wicket/jquery/CombinableConfig.java
CombinableConfig.combine
public CombinableConfig combine(Config... fallbackConfigs) { CombinableConfig newConfig = this; for (Config fallback : fallbackConfigs) { newConfig = new ConfigWithFallback(newConfig, fallback); } return newConfig; }
java
public CombinableConfig combine(Config... fallbackConfigs) { CombinableConfig newConfig = this; for (Config fallback : fallbackConfigs) { newConfig = new ConfigWithFallback(newConfig, fallback); } return newConfig; }
[ "public", "CombinableConfig", "combine", "(", "Config", "...", "fallbackConfigs", ")", "{", "CombinableConfig", "newConfig", "=", "this", ";", "for", "(", "Config", "fallback", ":", "fallbackConfigs", ")", "{", "newConfig", "=", "new", "ConfigWithFallback", "(", "newConfig", ",", "fallback", ")", ";", "}", "return", "newConfig", ";", "}" ]
combines this configuration with given ones. Given configuration doesn't override existing one. @param fallbackConfigs the configurations to combine @return this instance for chaining
[ "combines", "this", "configuration", "with", "given", "ones", ".", "Given", "configuration", "doesn", "t", "override", "existing", "one", "." ]
a606263f7821d0b5f337c9e65f8caa466ad398ad
https://github.com/l0rdn1kk0n/wicket-jquery-selectors/blob/a606263f7821d0b5f337c9e65f8caa466ad398ad/src/main/java/de/agilecoders/wicket/jquery/CombinableConfig.java#L31-L37
142,076
xm-online/xm-commons
xm-commons-metric/src/main/java/com/icthh/xm/commons/metric/MetricsConfiguration.java
MetricsConfiguration.init
@PostConstruct public void init() { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(getPlatformMBeanServer())); metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet()); metricRegistry.register(PROP_METRIC_REG_OS, new OperatingSystemGaugeSet(getOperatingSystemMXBean())); if (jhipsterProperties.getMetrics().getJmx().isEnabled()) { log.debug("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build(); jmxReporter.start(); } if (jhipsterProperties.getMetrics().getLogs().isEnabled()) { log.info("Initializing Metrics Log reporting"); Marker metricsMarker = MarkerFactory.getMarker("metrics"); final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry) .outputTo(LoggerFactory.getLogger("metrics")) .markWith(metricsMarker) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(jhipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS); } }
java
@PostConstruct public void init() { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(getPlatformMBeanServer())); metricRegistry.register(PROP_METRIC_REG_JVM_ATTRIBUTE_SET, new JvmAttributeGaugeSet()); metricRegistry.register(PROP_METRIC_REG_OS, new OperatingSystemGaugeSet(getOperatingSystemMXBean())); if (jhipsterProperties.getMetrics().getJmx().isEnabled()) { log.debug("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build(); jmxReporter.start(); } if (jhipsterProperties.getMetrics().getLogs().isEnabled()) { log.info("Initializing Metrics Log reporting"); Marker metricsMarker = MarkerFactory.getMarker("metrics"); final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry) .outputTo(LoggerFactory.getLogger("metrics")) .markWith(metricsMarker) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(jhipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS); } }
[ "@", "PostConstruct", "public", "void", "init", "(", ")", "{", "log", ".", "debug", "(", "\"Registering JVM gauges\"", ")", ";", "metricRegistry", ".", "register", "(", "PROP_METRIC_REG_JVM_MEMORY", ",", "new", "MemoryUsageGaugeSet", "(", ")", ")", ";", "metricRegistry", ".", "register", "(", "PROP_METRIC_REG_JVM_GARBAGE", ",", "new", "GarbageCollectorMetricSet", "(", ")", ")", ";", "metricRegistry", ".", "register", "(", "PROP_METRIC_REG_JVM_THREADS", ",", "new", "ThreadStatesGaugeSet", "(", ")", ")", ";", "metricRegistry", ".", "register", "(", "PROP_METRIC_REG_JVM_FILES", ",", "new", "FileDescriptorRatioGauge", "(", ")", ")", ";", "metricRegistry", ".", "register", "(", "PROP_METRIC_REG_JVM_BUFFERS", ",", "new", "BufferPoolMetricSet", "(", "getPlatformMBeanServer", "(", ")", ")", ")", ";", "metricRegistry", ".", "register", "(", "PROP_METRIC_REG_JVM_ATTRIBUTE_SET", ",", "new", "JvmAttributeGaugeSet", "(", ")", ")", ";", "metricRegistry", ".", "register", "(", "PROP_METRIC_REG_OS", ",", "new", "OperatingSystemGaugeSet", "(", "getOperatingSystemMXBean", "(", ")", ")", ")", ";", "if", "(", "jhipsterProperties", ".", "getMetrics", "(", ")", ".", "getJmx", "(", ")", ".", "isEnabled", "(", ")", ")", "{", "log", ".", "debug", "(", "\"Initializing Metrics JMX reporting\"", ")", ";", "JmxReporter", "jmxReporter", "=", "JmxReporter", ".", "forRegistry", "(", "metricRegistry", ")", ".", "build", "(", ")", ";", "jmxReporter", ".", "start", "(", ")", ";", "}", "if", "(", "jhipsterProperties", ".", "getMetrics", "(", ")", ".", "getLogs", "(", ")", ".", "isEnabled", "(", ")", ")", "{", "log", ".", "info", "(", "\"Initializing Metrics Log reporting\"", ")", ";", "Marker", "metricsMarker", "=", "MarkerFactory", ".", "getMarker", "(", "\"metrics\"", ")", ";", "final", "Slf4jReporter", "reporter", "=", "Slf4jReporter", ".", "forRegistry", "(", "metricRegistry", ")", ".", "outputTo", "(", "LoggerFactory", ".", "getLogger", "(", "\"metrics\"", ")", ")", ".", "markWith", "(", "metricsMarker", ")", ".", "convertRatesTo", "(", "TimeUnit", ".", "SECONDS", ")", ".", "convertDurationsTo", "(", "TimeUnit", ".", "MILLISECONDS", ")", ".", "build", "(", ")", ";", "reporter", ".", "start", "(", "jhipsterProperties", ".", "getMetrics", "(", ")", ".", "getLogs", "(", ")", ".", "getReportFrequency", "(", ")", ",", "TimeUnit", ".", "SECONDS", ")", ";", "}", "}" ]
Init commons metrics
[ "Init", "commons", "metrics" ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-metric/src/main/java/com/icthh/xm/commons/metric/MetricsConfiguration.java#L68-L95
142,077
xm-online/xm-commons
xm-commons-security/src/main/java/com/icthh/xm/commons/security/oauth2/ConfigSignatureVerifierClient.java
ConfigSignatureVerifierClient.getSignatureVerifier
@Override public SignatureVerifier getSignatureVerifier() throws Exception { try { HttpEntity<Void> request = new HttpEntity<>(new HttpHeaders()); String content = restTemplate.exchange(getPublicKeyEndpoint(), HttpMethod.GET, request, String.class).getBody(); if (StringUtils.isEmpty(content)) { log.info("Public key not fetched"); return null; } InputStream fin = new ByteArrayInputStream(content.getBytes()); CertificateFactory f = CertificateFactory.getInstance("X.509"); X509Certificate certificate = (X509Certificate) f.generateCertificate(fin); PublicKey pk = certificate.getPublicKey(); return new RsaVerifier(String.format(PUBLIC_KEY, new String(Base64.getEncoder().encode(pk.getEncoded())))); } catch (IllegalStateException ex) { log.warn("could not contact Config to get public key"); return null; } }
java
@Override public SignatureVerifier getSignatureVerifier() throws Exception { try { HttpEntity<Void> request = new HttpEntity<>(new HttpHeaders()); String content = restTemplate.exchange(getPublicKeyEndpoint(), HttpMethod.GET, request, String.class).getBody(); if (StringUtils.isEmpty(content)) { log.info("Public key not fetched"); return null; } InputStream fin = new ByteArrayInputStream(content.getBytes()); CertificateFactory f = CertificateFactory.getInstance("X.509"); X509Certificate certificate = (X509Certificate) f.generateCertificate(fin); PublicKey pk = certificate.getPublicKey(); return new RsaVerifier(String.format(PUBLIC_KEY, new String(Base64.getEncoder().encode(pk.getEncoded())))); } catch (IllegalStateException ex) { log.warn("could not contact Config to get public key"); return null; } }
[ "@", "Override", "public", "SignatureVerifier", "getSignatureVerifier", "(", ")", "throws", "Exception", "{", "try", "{", "HttpEntity", "<", "Void", ">", "request", "=", "new", "HttpEntity", "<>", "(", "new", "HttpHeaders", "(", ")", ")", ";", "String", "content", "=", "restTemplate", ".", "exchange", "(", "getPublicKeyEndpoint", "(", ")", ",", "HttpMethod", ".", "GET", ",", "request", ",", "String", ".", "class", ")", ".", "getBody", "(", ")", ";", "if", "(", "StringUtils", ".", "isEmpty", "(", "content", ")", ")", "{", "log", ".", "info", "(", "\"Public key not fetched\"", ")", ";", "return", "null", ";", "}", "InputStream", "fin", "=", "new", "ByteArrayInputStream", "(", "content", ".", "getBytes", "(", ")", ")", ";", "CertificateFactory", "f", "=", "CertificateFactory", ".", "getInstance", "(", "\"X.509\"", ")", ";", "X509Certificate", "certificate", "=", "(", "X509Certificate", ")", "f", ".", "generateCertificate", "(", "fin", ")", ";", "PublicKey", "pk", "=", "certificate", ".", "getPublicKey", "(", ")", ";", "return", "new", "RsaVerifier", "(", "String", ".", "format", "(", "PUBLIC_KEY", ",", "new", "String", "(", "Base64", ".", "getEncoder", "(", ")", ".", "encode", "(", "pk", ".", "getEncoded", "(", ")", ")", ")", ")", ")", ";", "}", "catch", "(", "IllegalStateException", "ex", ")", "{", "log", ".", "warn", "(", "\"could not contact Config to get public key\"", ")", ";", "return", "null", ";", "}", "}" ]
Fetches the public key from the MS Config. @return the public key used to verify JWT tokens; or null.
[ "Fetches", "the", "public", "key", "from", "the", "MS", "Config", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-security/src/main/java/com/icthh/xm/commons/security/oauth2/ConfigSignatureVerifierClient.java#L44-L67
142,078
xm-online/xm-commons
xm-commons-security/src/main/java/com/icthh/xm/commons/security/oauth2/ConfigSignatureVerifierClient.java
ConfigSignatureVerifierClient.getPublicKeyEndpoint
private String getPublicKeyEndpoint() { String tokenEndpointUrl = oauth2Properties.getSignatureVerification().getPublicKeyEndpointUri(); if (tokenEndpointUrl == null) { throw new InvalidClientException("no token endpoint configured in application properties"); } return tokenEndpointUrl; }
java
private String getPublicKeyEndpoint() { String tokenEndpointUrl = oauth2Properties.getSignatureVerification().getPublicKeyEndpointUri(); if (tokenEndpointUrl == null) { throw new InvalidClientException("no token endpoint configured in application properties"); } return tokenEndpointUrl; }
[ "private", "String", "getPublicKeyEndpoint", "(", ")", "{", "String", "tokenEndpointUrl", "=", "oauth2Properties", ".", "getSignatureVerification", "(", ")", ".", "getPublicKeyEndpointUri", "(", ")", ";", "if", "(", "tokenEndpointUrl", "==", "null", ")", "{", "throw", "new", "InvalidClientException", "(", "\"no token endpoint configured in application properties\"", ")", ";", "}", "return", "tokenEndpointUrl", ";", "}" ]
Returns the configured endpoint URI to retrieve the public key.
[ "Returns", "the", "configured", "endpoint", "URI", "to", "retrieve", "the", "public", "key", "." ]
43eb2273adb96f40830d7b905ee3a767b8715caf
https://github.com/xm-online/xm-commons/blob/43eb2273adb96f40830d7b905ee3a767b8715caf/xm-commons-security/src/main/java/com/icthh/xm/commons/security/oauth2/ConfigSignatureVerifierClient.java#L72-L78
142,079
beangle/beangle3
orm/hibernate/src/main/java/org/beangle/orm/hibernate/RailsNamingStrategy.java
RailsNamingStrategy.logicalCollectionTableName
public String logicalCollectionTableName(String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName) { if (tableName == null) { // use of a stringbuilder to workaround a JDK bug return new StringBuilder(ownerEntityTable).append("_") .append(associatedEntityTable == null ? unqualify(propertyName) : associatedEntityTable).toString(); } else { return tableName; } }
java
public String logicalCollectionTableName(String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName) { if (tableName == null) { // use of a stringbuilder to workaround a JDK bug return new StringBuilder(ownerEntityTable).append("_") .append(associatedEntityTable == null ? unqualify(propertyName) : associatedEntityTable).toString(); } else { return tableName; } }
[ "public", "String", "logicalCollectionTableName", "(", "String", "tableName", ",", "String", "ownerEntityTable", ",", "String", "associatedEntityTable", ",", "String", "propertyName", ")", "{", "if", "(", "tableName", "==", "null", ")", "{", "// use of a stringbuilder to workaround a JDK bug", "return", "new", "StringBuilder", "(", "ownerEntityTable", ")", ".", "append", "(", "\"_\"", ")", ".", "append", "(", "associatedEntityTable", "==", "null", "?", "unqualify", "(", "propertyName", ")", ":", "associatedEntityTable", ")", ".", "toString", "(", ")", ";", "}", "else", "{", "return", "tableName", ";", "}", "}" ]
Returns either the table name if explicit or if there is an associated table, the concatenation of owner entity table and associated table otherwise the concatenation of owner entity table and the unqualified property name
[ "Returns", "either", "the", "table", "name", "if", "explicit", "or", "if", "there", "is", "an", "associated", "table", "the", "concatenation", "of", "owner", "entity", "table", "and", "associated", "table", "otherwise", "the", "concatenation", "of", "owner", "entity", "table", "and", "the", "unqualified", "property", "name" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/orm/hibernate/src/main/java/org/beangle/orm/hibernate/RailsNamingStrategy.java#L151-L160
142,080
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/action/ActionSupport.java
ActionSupport.addMessage
protected final void addMessage(String msgKey, Object... args) { getFlash().addMessageNow(getTextInternal(msgKey, args)); }
java
protected final void addMessage(String msgKey, Object... args) { getFlash().addMessageNow(getTextInternal(msgKey, args)); }
[ "protected", "final", "void", "addMessage", "(", "String", "msgKey", ",", "Object", "...", "args", ")", "{", "getFlash", "(", ")", ".", "addMessageNow", "(", "getTextInternal", "(", "msgKey", ",", "args", ")", ")", ";", "}" ]
Add action message. @param msgKey @param args
[ "Add", "action", "message", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/action/ActionSupport.java#L213-L215
142,081
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/action/ActionSupport.java
ActionSupport.addError
protected final void addError(String msgKey, Object... args) { getFlash().addErrorNow(getTextInternal(msgKey, args)); }
java
protected final void addError(String msgKey, Object... args) { getFlash().addErrorNow(getTextInternal(msgKey, args)); }
[ "protected", "final", "void", "addError", "(", "String", "msgKey", ",", "Object", "...", "args", ")", "{", "getFlash", "(", ")", ".", "addErrorNow", "(", "getTextInternal", "(", "msgKey", ",", "args", ")", ")", ";", "}" ]
Add action error. @param msgKey @param args
[ "Add", "action", "error", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/action/ActionSupport.java#L223-L225
142,082
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/action/ActionSupport.java
ActionSupport.addFlashError
protected final void addFlashError(String msgKey, Object... args) { getFlash().addError(getTextInternal(msgKey, args)); }
java
protected final void addFlashError(String msgKey, Object... args) { getFlash().addError(getTextInternal(msgKey, args)); }
[ "protected", "final", "void", "addFlashError", "(", "String", "msgKey", ",", "Object", "...", "args", ")", "{", "getFlash", "(", ")", ".", "addError", "(", "getTextInternal", "(", "msgKey", ",", "args", ")", ")", ";", "}" ]
Add error to next action. @param msgKey @param args
[ "Add", "error", "to", "next", "action", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/action/ActionSupport.java#L233-L235
142,083
beangle/beangle3
struts/s2/src/main/java/org/beangle/struts2/action/ActionSupport.java
ActionSupport.addFlashMessage
protected final void addFlashMessage(String msgKey, Object... args) { getFlash().addMessage(getTextInternal(msgKey, args)); }
java
protected final void addFlashMessage(String msgKey, Object... args) { getFlash().addMessage(getTextInternal(msgKey, args)); }
[ "protected", "final", "void", "addFlashMessage", "(", "String", "msgKey", ",", "Object", "...", "args", ")", "{", "getFlash", "(", ")", ".", "addMessage", "(", "getTextInternal", "(", "msgKey", ",", "args", ")", ")", ";", "}" ]
Add message to next action. @param msgKey @param args
[ "Add", "message", "to", "next", "action", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/struts/s2/src/main/java/org/beangle/struts2/action/ActionSupport.java#L243-L245
142,084
massfords/jaxb-visitor
src/main/java/com/massfords/jaxb/CreateTraversingVisitorClass.java
CreateTraversingVisitorClass.addGetterAndSetter
private void addGetterAndSetter(JDefinedClass traversingVisitor, JFieldVar field) { String propName = Character.toUpperCase(field.name().charAt(0)) + field.name().substring(1); traversingVisitor.method(JMod.PUBLIC, field.type(), "get" + propName).body()._return(field); JMethod setVisitor = traversingVisitor.method(JMod.PUBLIC, void.class, "set" + propName); JVar visParam = setVisitor.param(field.type(), "aVisitor"); setVisitor.body().assign(field, visParam); }
java
private void addGetterAndSetter(JDefinedClass traversingVisitor, JFieldVar field) { String propName = Character.toUpperCase(field.name().charAt(0)) + field.name().substring(1); traversingVisitor.method(JMod.PUBLIC, field.type(), "get" + propName).body()._return(field); JMethod setVisitor = traversingVisitor.method(JMod.PUBLIC, void.class, "set" + propName); JVar visParam = setVisitor.param(field.type(), "aVisitor"); setVisitor.body().assign(field, visParam); }
[ "private", "void", "addGetterAndSetter", "(", "JDefinedClass", "traversingVisitor", ",", "JFieldVar", "field", ")", "{", "String", "propName", "=", "Character", ".", "toUpperCase", "(", "field", ".", "name", "(", ")", ".", "charAt", "(", "0", ")", ")", "+", "field", ".", "name", "(", ")", ".", "substring", "(", "1", ")", ";", "traversingVisitor", ".", "method", "(", "JMod", ".", "PUBLIC", ",", "field", ".", "type", "(", ")", ",", "\"get\"", "+", "propName", ")", ".", "body", "(", ")", ".", "_return", "(", "field", ")", ";", "JMethod", "setVisitor", "=", "traversingVisitor", ".", "method", "(", "JMod", ".", "PUBLIC", ",", "void", ".", "class", ",", "\"set\"", "+", "propName", ")", ";", "JVar", "visParam", "=", "setVisitor", ".", "param", "(", "field", ".", "type", "(", ")", ",", "\"aVisitor\"", ")", ";", "setVisitor", ".", "body", "(", ")", ".", "assign", "(", "field", ",", "visParam", ")", ";", "}" ]
Convenience method to add a getter and setter method for the given field. @param traversingVisitor @param field
[ "Convenience", "method", "to", "add", "a", "getter", "and", "setter", "method", "for", "the", "given", "field", "." ]
0d66cd4d8b6700b5eb67c028a87b53792be895b8
https://github.com/massfords/jaxb-visitor/blob/0d66cd4d8b6700b5eb67c028a87b53792be895b8/src/main/java/com/massfords/jaxb/CreateTraversingVisitorClass.java#L151-L157
142,085
beangle/beangle3
commons/web/src/main/java/org/beangle/commons/web/url/UrlBuilder.java
UrlBuilder.buildServletPath
private String buildServletPath() { String uri = servletPath; if (uri == null && null != requestURI) { uri = requestURI; if (!contextPath.equals("/")) uri = uri.substring(contextPath.length()); } return (null == uri) ? "" : uri; }
java
private String buildServletPath() { String uri = servletPath; if (uri == null && null != requestURI) { uri = requestURI; if (!contextPath.equals("/")) uri = uri.substring(contextPath.length()); } return (null == uri) ? "" : uri; }
[ "private", "String", "buildServletPath", "(", ")", "{", "String", "uri", "=", "servletPath", ";", "if", "(", "uri", "==", "null", "&&", "null", "!=", "requestURI", ")", "{", "uri", "=", "requestURI", ";", "if", "(", "!", "contextPath", ".", "equals", "(", "\"/\"", ")", ")", "uri", "=", "uri", ".", "substring", "(", "contextPath", ".", "length", "(", ")", ")", ";", "}", "return", "(", "null", "==", "uri", ")", "?", "\"\"", ":", "uri", ";", "}" ]
Returns servetPath without contextPath
[ "Returns", "servetPath", "without", "contextPath" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/web/src/main/java/org/beangle/commons/web/url/UrlBuilder.java#L53-L60
142,086
beangle/beangle3
commons/web/src/main/java/org/beangle/commons/web/url/UrlBuilder.java
UrlBuilder.buildRequestUrl
public String buildRequestUrl() { StringBuilder sb = new StringBuilder(); sb.append(buildServletPath()); if (null != pathInfo) { sb.append(pathInfo); } if (null != queryString) { sb.append('?').append(queryString); } return sb.toString(); }
java
public String buildRequestUrl() { StringBuilder sb = new StringBuilder(); sb.append(buildServletPath()); if (null != pathInfo) { sb.append(pathInfo); } if (null != queryString) { sb.append('?').append(queryString); } return sb.toString(); }
[ "public", "String", "buildRequestUrl", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "sb", ".", "append", "(", "buildServletPath", "(", ")", ")", ";", "if", "(", "null", "!=", "pathInfo", ")", "{", "sb", ".", "append", "(", "pathInfo", ")", ";", "}", "if", "(", "null", "!=", "queryString", ")", "{", "sb", ".", "append", "(", "'", "'", ")", ".", "append", "(", "queryString", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Returns request Url contain pathinfo and queryString but without contextPath.
[ "Returns", "request", "Url", "contain", "pathinfo", "and", "queryString", "but", "without", "contextPath", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/web/src/main/java/org/beangle/commons/web/url/UrlBuilder.java#L65-L75
142,087
beangle/beangle3
commons/web/src/main/java/org/beangle/commons/web/url/UrlBuilder.java
UrlBuilder.buildUrl
public String buildUrl() { StringBuilder sb = new StringBuilder(); boolean includePort = true; if (null != scheme) { sb.append(scheme).append("://"); includePort = (port != (scheme.equals("http") ? 80 : 443)); } if (null != serverName) { sb.append(serverName); if (includePort && port > 0) { sb.append(':').append(port); } } if (!Objects.equals(contextPath, "/")) { sb.append(contextPath); } sb.append(buildRequestUrl()); return sb.toString(); }
java
public String buildUrl() { StringBuilder sb = new StringBuilder(); boolean includePort = true; if (null != scheme) { sb.append(scheme).append("://"); includePort = (port != (scheme.equals("http") ? 80 : 443)); } if (null != serverName) { sb.append(serverName); if (includePort && port > 0) { sb.append(':').append(port); } } if (!Objects.equals(contextPath, "/")) { sb.append(contextPath); } sb.append(buildRequestUrl()); return sb.toString(); }
[ "public", "String", "buildUrl", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "boolean", "includePort", "=", "true", ";", "if", "(", "null", "!=", "scheme", ")", "{", "sb", ".", "append", "(", "scheme", ")", ".", "append", "(", "\"://\"", ")", ";", "includePort", "=", "(", "port", "!=", "(", "scheme", ".", "equals", "(", "\"http\"", ")", "?", "80", ":", "443", ")", ")", ";", "}", "if", "(", "null", "!=", "serverName", ")", "{", "sb", ".", "append", "(", "serverName", ")", ";", "if", "(", "includePort", "&&", "port", ">", "0", ")", "{", "sb", ".", "append", "(", "'", "'", ")", ".", "append", "(", "port", ")", ";", "}", "}", "if", "(", "!", "Objects", ".", "equals", "(", "contextPath", ",", "\"/\"", ")", ")", "{", "sb", ".", "append", "(", "contextPath", ")", ";", "}", "sb", ".", "append", "(", "buildRequestUrl", "(", ")", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Returns full url
[ "Returns", "full", "url" ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/web/src/main/java/org/beangle/commons/web/url/UrlBuilder.java#L80-L98
142,088
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/collection/FastHashMap.java
FastHashMap.getEntry
public Map.Entry<K, V> getEntry(Object key) { EntryImpl<K, V> entry = _entries[keyHash(key) & _mask]; while (entry != null) { if (key.equals(entry._key)) { return entry; } entry = entry._next; } return null; }
java
public Map.Entry<K, V> getEntry(Object key) { EntryImpl<K, V> entry = _entries[keyHash(key) & _mask]; while (entry != null) { if (key.equals(entry._key)) { return entry; } entry = entry._next; } return null; }
[ "public", "Map", ".", "Entry", "<", "K", ",", "V", ">", "getEntry", "(", "Object", "key", ")", "{", "EntryImpl", "<", "K", ",", "V", ">", "entry", "=", "_entries", "[", "keyHash", "(", "key", ")", "&", "_mask", "]", ";", "while", "(", "entry", "!=", "null", ")", "{", "if", "(", "key", ".", "equals", "(", "entry", ".", "_key", ")", ")", "{", "return", "entry", ";", "}", "entry", "=", "entry", ".", "_next", ";", "}", "return", "null", ";", "}" ]
Returns the entry with the specified key. @param key the key whose associated entry is to be returned. @return the entry for the specified key or <code>null</code> if none.
[ "Returns", "the", "entry", "with", "the", "specified", "key", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/collection/FastHashMap.java#L199-L206
142,089
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/collection/FastHashMap.java
FastHashMap.addEntry
private void addEntry(K key, V value) { EntryImpl<K, V> entry = _poolFirst; if (entry != null) { _poolFirst = entry._after; entry._after = null; } else { // Pool empty. entry = new EntryImpl<K, V>(); } // Setup entry paramters. entry._key = key; entry._value = value; int index = keyHash(key) & _mask; entry._index = index; // Connects to bucket. EntryImpl<K, V> next = _entries[index]; entry._next = next; if (next != null) { next._previous = entry; } _entries[index] = entry; // Connects to collection. if (_mapLast != null) { entry._before = _mapLast; _mapLast._after = entry; } else { _mapFirst = entry; } _mapLast = entry; // Updates size. _size++; sizeChanged(); }
java
private void addEntry(K key, V value) { EntryImpl<K, V> entry = _poolFirst; if (entry != null) { _poolFirst = entry._after; entry._after = null; } else { // Pool empty. entry = new EntryImpl<K, V>(); } // Setup entry paramters. entry._key = key; entry._value = value; int index = keyHash(key) & _mask; entry._index = index; // Connects to bucket. EntryImpl<K, V> next = _entries[index]; entry._next = next; if (next != null) { next._previous = entry; } _entries[index] = entry; // Connects to collection. if (_mapLast != null) { entry._before = _mapLast; _mapLast._after = entry; } else { _mapFirst = entry; } _mapLast = entry; // Updates size. _size++; sizeChanged(); }
[ "private", "void", "addEntry", "(", "K", "key", ",", "V", "value", ")", "{", "EntryImpl", "<", "K", ",", "V", ">", "entry", "=", "_poolFirst", ";", "if", "(", "entry", "!=", "null", ")", "{", "_poolFirst", "=", "entry", ".", "_after", ";", "entry", ".", "_after", "=", "null", ";", "}", "else", "{", "// Pool empty.", "entry", "=", "new", "EntryImpl", "<", "K", ",", "V", ">", "(", ")", ";", "}", "// Setup entry paramters.", "entry", ".", "_key", "=", "key", ";", "entry", ".", "_value", "=", "value", ";", "int", "index", "=", "keyHash", "(", "key", ")", "&", "_mask", ";", "entry", ".", "_index", "=", "index", ";", "// Connects to bucket.", "EntryImpl", "<", "K", ",", "V", ">", "next", "=", "_entries", "[", "index", "]", ";", "entry", ".", "_next", "=", "next", ";", "if", "(", "next", "!=", "null", ")", "{", "next", ".", "_previous", "=", "entry", ";", "}", "_entries", "[", "index", "]", "=", "entry", ";", "// Connects to collection.", "if", "(", "_mapLast", "!=", "null", ")", "{", "entry", ".", "_before", "=", "_mapLast", ";", "_mapLast", ".", "_after", "=", "entry", ";", "}", "else", "{", "_mapFirst", "=", "entry", ";", "}", "_mapLast", "=", "entry", ";", "// Updates size.", "_size", "++", ";", "sizeChanged", "(", ")", ";", "}" ]
Adds a new entry for the specified key and value. @param key the entry's key. @param value the entry's value.
[ "Adds", "a", "new", "entry", "for", "the", "specified", "key", "and", "value", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/collection/FastHashMap.java#L648-L683
142,090
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/collection/FastHashMap.java
FastHashMap.removeEntry
private void removeEntry(EntryImpl<K, V> entry) { // Removes from bucket. EntryImpl<K, V> previous = entry._previous; EntryImpl<K, V> next = entry._next; if (previous != null) { previous._next = next; entry._previous = null; } else { // First in bucket. _entries[entry._index] = next; } if (next != null) { next._previous = previous; entry._next = null; } // Else do nothing, no last pointer. // Removes from collection. EntryImpl<K, V> before = entry._before; EntryImpl<K, V> after = entry._after; if (before != null) { before._after = after; entry._before = null; } else { // First in collection. _mapFirst = after; } if (after != null) { after._before = before; } else { // Last in collection. _mapLast = before; } // Clears value and key. entry._key = null; entry._value = null; // Recycles. entry._after = _poolFirst; _poolFirst = entry; // Updates size. _size--; sizeChanged(); }
java
private void removeEntry(EntryImpl<K, V> entry) { // Removes from bucket. EntryImpl<K, V> previous = entry._previous; EntryImpl<K, V> next = entry._next; if (previous != null) { previous._next = next; entry._previous = null; } else { // First in bucket. _entries[entry._index] = next; } if (next != null) { next._previous = previous; entry._next = null; } // Else do nothing, no last pointer. // Removes from collection. EntryImpl<K, V> before = entry._before; EntryImpl<K, V> after = entry._after; if (before != null) { before._after = after; entry._before = null; } else { // First in collection. _mapFirst = after; } if (after != null) { after._before = before; } else { // Last in collection. _mapLast = before; } // Clears value and key. entry._key = null; entry._value = null; // Recycles. entry._after = _poolFirst; _poolFirst = entry; // Updates size. _size--; sizeChanged(); }
[ "private", "void", "removeEntry", "(", "EntryImpl", "<", "K", ",", "V", ">", "entry", ")", "{", "// Removes from bucket.", "EntryImpl", "<", "K", ",", "V", ">", "previous", "=", "entry", ".", "_previous", ";", "EntryImpl", "<", "K", ",", "V", ">", "next", "=", "entry", ".", "_next", ";", "if", "(", "previous", "!=", "null", ")", "{", "previous", ".", "_next", "=", "next", ";", "entry", ".", "_previous", "=", "null", ";", "}", "else", "{", "// First in bucket.", "_entries", "[", "entry", ".", "_index", "]", "=", "next", ";", "}", "if", "(", "next", "!=", "null", ")", "{", "next", ".", "_previous", "=", "previous", ";", "entry", ".", "_next", "=", "null", ";", "}", "// Else do nothing, no last pointer.", "// Removes from collection.", "EntryImpl", "<", "K", ",", "V", ">", "before", "=", "entry", ".", "_before", ";", "EntryImpl", "<", "K", ",", "V", ">", "after", "=", "entry", ".", "_after", ";", "if", "(", "before", "!=", "null", ")", "{", "before", ".", "_after", "=", "after", ";", "entry", ".", "_before", "=", "null", ";", "}", "else", "{", "// First in collection.", "_mapFirst", "=", "after", ";", "}", "if", "(", "after", "!=", "null", ")", "{", "after", ".", "_before", "=", "before", ";", "}", "else", "{", "// Last in collection.", "_mapLast", "=", "before", ";", "}", "// Clears value and key.", "entry", ".", "_key", "=", "null", ";", "entry", ".", "_value", "=", "null", ";", "// Recycles.", "entry", ".", "_after", "=", "_poolFirst", ";", "_poolFirst", "=", "entry", ";", "// Updates size.", "_size", "--", ";", "sizeChanged", "(", ")", ";", "}" ]
Removes the specified entry from the map. @param entry the entry to be removed.
[ "Removes", "the", "specified", "entry", "from", "the", "map", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/collection/FastHashMap.java#L690-L732
142,091
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/collection/FastHashMap.java
FastHashMap.readObject
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { int capacity = stream.readInt(); initialize(capacity); int size = stream.readInt(); for (int i = 0; i < size; i++) { addEntry((K) stream.readObject(), (V) stream.readObject()); } }
java
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { int capacity = stream.readInt(); initialize(capacity); int size = stream.readInt(); for (int i = 0; i < size; i++) { addEntry((K) stream.readObject(), (V) stream.readObject()); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "void", "readObject", "(", "ObjectInputStream", "stream", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "int", "capacity", "=", "stream", ".", "readInt", "(", ")", ";", "initialize", "(", "capacity", ")", ";", "int", "size", "=", "stream", ".", "readInt", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "addEntry", "(", "(", "K", ")", "stream", ".", "readObject", "(", ")", ",", "(", "V", ")", "stream", ".", "readObject", "(", ")", ")", ";", "}", "}" ]
Requires special handling during de-serialization process. @param stream the object input stream. @throws IOException if an I/O error occurs. @throws ClassNotFoundException if the class for the object de-serialized is not found.
[ "Requires", "special", "handling", "during", "de", "-", "serialization", "process", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/collection/FastHashMap.java#L777-L785
142,092
beangle/beangle3
commons/core/src/main/java/org/beangle/commons/collection/FastHashMap.java
FastHashMap.writeObject
private void writeObject(ObjectOutputStream stream) throws IOException { stream.writeInt(_capacity); stream.writeInt(_size); int count = 0; EntryImpl<K, V> entry = _mapFirst; while (entry != null) { stream.writeObject(entry._key); stream.writeObject(entry._value); count++; entry = entry._after; } if (count != _size) { throw new IOException("FastMap Corrupted"); } }
java
private void writeObject(ObjectOutputStream stream) throws IOException { stream.writeInt(_capacity); stream.writeInt(_size); int count = 0; EntryImpl<K, V> entry = _mapFirst; while (entry != null) { stream.writeObject(entry._key); stream.writeObject(entry._value); count++; entry = entry._after; } if (count != _size) { throw new IOException("FastMap Corrupted"); } }
[ "private", "void", "writeObject", "(", "ObjectOutputStream", "stream", ")", "throws", "IOException", "{", "stream", ".", "writeInt", "(", "_capacity", ")", ";", "stream", ".", "writeInt", "(", "_size", ")", ";", "int", "count", "=", "0", ";", "EntryImpl", "<", "K", ",", "V", ">", "entry", "=", "_mapFirst", ";", "while", "(", "entry", "!=", "null", ")", "{", "stream", ".", "writeObject", "(", "entry", ".", "_key", ")", ";", "stream", ".", "writeObject", "(", "entry", ".", "_value", ")", ";", "count", "++", ";", "entry", "=", "entry", ".", "_after", ";", "}", "if", "(", "count", "!=", "_size", ")", "{", "throw", "new", "IOException", "(", "\"FastMap Corrupted\"", ")", ";", "}", "}" ]
Requires special handling during serialization process. @param stream the object output stream. @throws IOException if an I/O error occurs.
[ "Requires", "special", "handling", "during", "serialization", "process", "." ]
33df2873a5f38e28ac174a1d3b8144eb2f808e64
https://github.com/beangle/beangle3/blob/33df2873a5f38e28ac174a1d3b8144eb2f808e64/commons/core/src/main/java/org/beangle/commons/collection/FastHashMap.java#L793-L805
142,093
massfords/jaxb-visitor
src/main/java/com/massfords/jaxb/ClassDiscoverer.java
ClassDiscoverer.discoverDirectClasses
static Set<JClass> discoverDirectClasses(Outline outline, Set<ClassOutline> classes) throws IllegalAccessException { Set<String> directClassNames = new LinkedHashSet<>(); for(ClassOutline classOutline : classes) { // for each field, if it's a bean, then visit it List<FieldOutline> fields = findAllDeclaredAndInheritedFields(classOutline); for(FieldOutline fieldOutline : fields) { JType rawType = fieldOutline.getRawType(); CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo(); boolean isCollection = propertyInfo.isCollection(); if (isCollection) { JClass collClazz = (JClass) rawType; JClass collType = collClazz.getTypeParameters().get(0); addIfDirectClass(directClassNames, collType); } else { addIfDirectClass(directClassNames, rawType); } parseXmlAnnotations(outline, fieldOutline, directClassNames); } } Set<JClass> direct = directClassNames .stream() .map(cn -> outline.getCodeModel().directClass(cn)) .collect(Collectors.toCollection(LinkedHashSet::new)); return direct; }
java
static Set<JClass> discoverDirectClasses(Outline outline, Set<ClassOutline> classes) throws IllegalAccessException { Set<String> directClassNames = new LinkedHashSet<>(); for(ClassOutline classOutline : classes) { // for each field, if it's a bean, then visit it List<FieldOutline> fields = findAllDeclaredAndInheritedFields(classOutline); for(FieldOutline fieldOutline : fields) { JType rawType = fieldOutline.getRawType(); CPropertyInfo propertyInfo = fieldOutline.getPropertyInfo(); boolean isCollection = propertyInfo.isCollection(); if (isCollection) { JClass collClazz = (JClass) rawType; JClass collType = collClazz.getTypeParameters().get(0); addIfDirectClass(directClassNames, collType); } else { addIfDirectClass(directClassNames, rawType); } parseXmlAnnotations(outline, fieldOutline, directClassNames); } } Set<JClass> direct = directClassNames .stream() .map(cn -> outline.getCodeModel().directClass(cn)) .collect(Collectors.toCollection(LinkedHashSet::new)); return direct; }
[ "static", "Set", "<", "JClass", ">", "discoverDirectClasses", "(", "Outline", "outline", ",", "Set", "<", "ClassOutline", ">", "classes", ")", "throws", "IllegalAccessException", "{", "Set", "<", "String", ">", "directClassNames", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "for", "(", "ClassOutline", "classOutline", ":", "classes", ")", "{", "// for each field, if it's a bean, then visit it", "List", "<", "FieldOutline", ">", "fields", "=", "findAllDeclaredAndInheritedFields", "(", "classOutline", ")", ";", "for", "(", "FieldOutline", "fieldOutline", ":", "fields", ")", "{", "JType", "rawType", "=", "fieldOutline", ".", "getRawType", "(", ")", ";", "CPropertyInfo", "propertyInfo", "=", "fieldOutline", ".", "getPropertyInfo", "(", ")", ";", "boolean", "isCollection", "=", "propertyInfo", ".", "isCollection", "(", ")", ";", "if", "(", "isCollection", ")", "{", "JClass", "collClazz", "=", "(", "JClass", ")", "rawType", ";", "JClass", "collType", "=", "collClazz", ".", "getTypeParameters", "(", ")", ".", "get", "(", "0", ")", ";", "addIfDirectClass", "(", "directClassNames", ",", "collType", ")", ";", "}", "else", "{", "addIfDirectClass", "(", "directClassNames", ",", "rawType", ")", ";", "}", "parseXmlAnnotations", "(", "outline", ",", "fieldOutline", ",", "directClassNames", ")", ";", "}", "}", "Set", "<", "JClass", ">", "direct", "=", "directClassNames", ".", "stream", "(", ")", ".", "map", "(", "cn", "->", "outline", ".", "getCodeModel", "(", ")", ".", "directClass", "(", "cn", ")", ")", ".", "collect", "(", "Collectors", ".", "toCollection", "(", "LinkedHashSet", "::", "new", ")", ")", ";", "return", "direct", ";", "}" ]
Finds all external class references @param outline root of the generated code @param classes set of generated classes @return set of external classes @throws IllegalAccessException throw if there's an error introspecting the annotations
[ "Finds", "all", "external", "class", "references" ]
0d66cd4d8b6700b5eb67c028a87b53792be895b8
https://github.com/massfords/jaxb-visitor/blob/0d66cd4d8b6700b5eb67c028a87b53792be895b8/src/main/java/com/massfords/jaxb/ClassDiscoverer.java#L43-L71
142,094
massfords/jaxb-visitor
src/main/java/com/massfords/jaxb/ClassDiscoverer.java
ClassDiscoverer.parseXmlAnnotations
private static void parseXmlAnnotations(Outline outline, FieldOutline field, Set<String> directClasses) throws IllegalAccessException { if (field instanceof UntypedListField) { JFieldVar jfv = (JFieldVar) FieldHack.listField.get(field); for(JAnnotationUse jau : jfv.annotations()) { JClass jc = jau.getAnnotationClass(); if (jc.fullName().equals(XmlElements.class.getName())) { JAnnotationArrayMember value = (JAnnotationArrayMember) jau.getAnnotationMembers().get("value"); for(JAnnotationUse anno : value.annotations()) { handleXmlElement(outline, directClasses, anno.getAnnotationMembers().get("type")); } } } } }
java
private static void parseXmlAnnotations(Outline outline, FieldOutline field, Set<String> directClasses) throws IllegalAccessException { if (field instanceof UntypedListField) { JFieldVar jfv = (JFieldVar) FieldHack.listField.get(field); for(JAnnotationUse jau : jfv.annotations()) { JClass jc = jau.getAnnotationClass(); if (jc.fullName().equals(XmlElements.class.getName())) { JAnnotationArrayMember value = (JAnnotationArrayMember) jau.getAnnotationMembers().get("value"); for(JAnnotationUse anno : value.annotations()) { handleXmlElement(outline, directClasses, anno.getAnnotationMembers().get("type")); } } } } }
[ "private", "static", "void", "parseXmlAnnotations", "(", "Outline", "outline", ",", "FieldOutline", "field", ",", "Set", "<", "String", ">", "directClasses", ")", "throws", "IllegalAccessException", "{", "if", "(", "field", "instanceof", "UntypedListField", ")", "{", "JFieldVar", "jfv", "=", "(", "JFieldVar", ")", "FieldHack", ".", "listField", ".", "get", "(", "field", ")", ";", "for", "(", "JAnnotationUse", "jau", ":", "jfv", ".", "annotations", "(", ")", ")", "{", "JClass", "jc", "=", "jau", ".", "getAnnotationClass", "(", ")", ";", "if", "(", "jc", ".", "fullName", "(", ")", ".", "equals", "(", "XmlElements", ".", "class", ".", "getName", "(", ")", ")", ")", "{", "JAnnotationArrayMember", "value", "=", "(", "JAnnotationArrayMember", ")", "jau", ".", "getAnnotationMembers", "(", ")", ".", "get", "(", "\"value\"", ")", ";", "for", "(", "JAnnotationUse", "anno", ":", "value", ".", "annotations", "(", ")", ")", "{", "handleXmlElement", "(", "outline", ",", "directClasses", ",", "anno", ".", "getAnnotationMembers", "(", ")", ".", "get", "(", "\"type\"", ")", ")", ";", "}", "}", "}", "}", "}" ]
Parse the annotations on the field to see if there is an XmlElements annotation on it. If so, we'll check this annotation to see if it refers to any classes that are external from our code schema compile. If we find any, then we'll add them to our visitor. @param outline root of the generated code @param field parses the xml annotations looking for an external class @param directClasses set of direct classes to append to @throws IllegalAccessException throw if there's an error introspecting the annotations
[ "Parse", "the", "annotations", "on", "the", "field", "to", "see", "if", "there", "is", "an", "XmlElements", "annotation", "on", "it", ".", "If", "so", "we", "ll", "check", "this", "annotation", "to", "see", "if", "it", "refers", "to", "any", "classes", "that", "are", "external", "from", "our", "code", "schema", "compile", ".", "If", "we", "find", "any", "then", "we", "ll", "add", "them", "to", "our", "visitor", "." ]
0d66cd4d8b6700b5eb67c028a87b53792be895b8
https://github.com/massfords/jaxb-visitor/blob/0d66cd4d8b6700b5eb67c028a87b53792be895b8/src/main/java/com/massfords/jaxb/ClassDiscoverer.java#L83-L96
142,095
massfords/jaxb-visitor
src/main/java/com/massfords/jaxb/ClassDiscoverer.java
ClassDiscoverer.handleXmlElement
private static void handleXmlElement(Outline outline, Set<String> directClasses, JAnnotationValue type) { StringWriter sw = new StringWriter(); JFormatter jf = new JFormatter(new PrintWriter(sw)); type.generate(jf); String s = sw.toString(); s = s.substring(0, s.length()-".class".length()); if (!s.startsWith("java") && outline.getCodeModel()._getClass(s) == null && !foundWithinOutline(s, outline)) { directClasses.add(s); } }
java
private static void handleXmlElement(Outline outline, Set<String> directClasses, JAnnotationValue type) { StringWriter sw = new StringWriter(); JFormatter jf = new JFormatter(new PrintWriter(sw)); type.generate(jf); String s = sw.toString(); s = s.substring(0, s.length()-".class".length()); if (!s.startsWith("java") && outline.getCodeModel()._getClass(s) == null && !foundWithinOutline(s, outline)) { directClasses.add(s); } }
[ "private", "static", "void", "handleXmlElement", "(", "Outline", "outline", ",", "Set", "<", "String", ">", "directClasses", ",", "JAnnotationValue", "type", ")", "{", "StringWriter", "sw", "=", "new", "StringWriter", "(", ")", ";", "JFormatter", "jf", "=", "new", "JFormatter", "(", "new", "PrintWriter", "(", "sw", ")", ")", ";", "type", ".", "generate", "(", "jf", ")", ";", "String", "s", "=", "sw", ".", "toString", "(", ")", ";", "s", "=", "s", ".", "substring", "(", "0", ",", "s", ".", "length", "(", ")", "-", "\".class\"", ".", "length", "(", ")", ")", ";", "if", "(", "!", "s", ".", "startsWith", "(", "\"java\"", ")", "&&", "outline", ".", "getCodeModel", "(", ")", ".", "_getClass", "(", "s", ")", "==", "null", "&&", "!", "foundWithinOutline", "(", "s", ",", "outline", ")", ")", "{", "directClasses", ".", "add", "(", "s", ")", ";", "}", "}" ]
Handles the extraction of the schema type from the XmlElement annotation. This was surprisingly difficult. Apparently the model doesn't provide access to the annotation we're referring to so I need to print it and read the string back. Even the formatter itself is final! @param outline root of the generated code @param directClasses set of classes to append to @param type annotation we're analysing
[ "Handles", "the", "extraction", "of", "the", "schema", "type", "from", "the", "XmlElement", "annotation", ".", "This", "was", "surprisingly", "difficult", ".", "Apparently", "the", "model", "doesn", "t", "provide", "access", "to", "the", "annotation", "we", "re", "referring", "to", "so", "I", "need", "to", "print", "it", "and", "read", "the", "string", "back", ".", "Even", "the", "formatter", "itself", "is", "final!" ]
0d66cd4d8b6700b5eb67c028a87b53792be895b8
https://github.com/massfords/jaxb-visitor/blob/0d66cd4d8b6700b5eb67c028a87b53792be895b8/src/main/java/com/massfords/jaxb/ClassDiscoverer.java#L108-L117
142,096
massfords/jaxb-visitor
src/main/java/com/massfords/jaxb/ClassDiscoverer.java
ClassDiscoverer.getter
static JMethod getter(FieldOutline fieldOutline) { final JDefinedClass theClass = fieldOutline.parent().implClass; final String publicName = fieldOutline.getPropertyInfo().getName(true); final JMethod getgetter = theClass.getMethod("get" + publicName, NONE); if (getgetter != null) { return getgetter; } else { final JMethod isgetter = theClass .getMethod("is" + publicName, NONE); if (isgetter != null) { return isgetter; } else { return null; } } }
java
static JMethod getter(FieldOutline fieldOutline) { final JDefinedClass theClass = fieldOutline.parent().implClass; final String publicName = fieldOutline.getPropertyInfo().getName(true); final JMethod getgetter = theClass.getMethod("get" + publicName, NONE); if (getgetter != null) { return getgetter; } else { final JMethod isgetter = theClass .getMethod("is" + publicName, NONE); if (isgetter != null) { return isgetter; } else { return null; } } }
[ "static", "JMethod", "getter", "(", "FieldOutline", "fieldOutline", ")", "{", "final", "JDefinedClass", "theClass", "=", "fieldOutline", ".", "parent", "(", ")", ".", "implClass", ";", "final", "String", "publicName", "=", "fieldOutline", ".", "getPropertyInfo", "(", ")", ".", "getName", "(", "true", ")", ";", "final", "JMethod", "getgetter", "=", "theClass", ".", "getMethod", "(", "\"get\"", "+", "publicName", ",", "NONE", ")", ";", "if", "(", "getgetter", "!=", "null", ")", "{", "return", "getgetter", ";", "}", "else", "{", "final", "JMethod", "isgetter", "=", "theClass", ".", "getMethod", "(", "\"is\"", "+", "publicName", ",", "NONE", ")", ";", "if", "(", "isgetter", "!=", "null", ")", "{", "return", "isgetter", ";", "}", "else", "{", "return", "null", ";", "}", "}", "}" ]
Borrowed this code from jaxb-commons project @param fieldOutline reference to a field @return Getter for the given field or null
[ "Borrowed", "this", "code", "from", "jaxb", "-", "commons", "project" ]
0d66cd4d8b6700b5eb67c028a87b53792be895b8
https://github.com/massfords/jaxb-visitor/blob/0d66cd4d8b6700b5eb67c028a87b53792be895b8/src/main/java/com/massfords/jaxb/ClassDiscoverer.java#L152-L167
142,097
massfords/jaxb-visitor
src/main/java/com/massfords/jaxb/ClassDiscoverer.java
ClassDiscoverer.isJAXBElement
static boolean isJAXBElement(JType type) { //noinspection RedundantIfStatement if (type.fullName().startsWith(JAXBElement.class.getName())) { return true; } return false; }
java
static boolean isJAXBElement(JType type) { //noinspection RedundantIfStatement if (type.fullName().startsWith(JAXBElement.class.getName())) { return true; } return false; }
[ "static", "boolean", "isJAXBElement", "(", "JType", "type", ")", "{", "//noinspection RedundantIfStatement", "if", "(", "type", ".", "fullName", "(", ")", ".", "startsWith", "(", "JAXBElement", ".", "class", ".", "getName", "(", ")", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if the type is a JAXBElement. In the case of JAXBElements, we want to traverse its underlying value as opposed to the JAXBElement. @param type element type to test to see if its a JAXBElement @return true if the type is a JAXBElement
[ "Returns", "true", "if", "the", "type", "is", "a", "JAXBElement", ".", "In", "the", "case", "of", "JAXBElements", "we", "want", "to", "traverse", "its", "underlying", "value", "as", "opposed", "to", "the", "JAXBElement", "." ]
0d66cd4d8b6700b5eb67c028a87b53792be895b8
https://github.com/massfords/jaxb-visitor/blob/0d66cd4d8b6700b5eb67c028a87b53792be895b8/src/main/java/com/massfords/jaxb/ClassDiscoverer.java#L175-L181
142,098
massfords/jaxb-visitor
src/main/java/com/massfords/jaxb/ClassDiscoverer.java
ClassDiscoverer.allConcreteClasses
static List<JClass> allConcreteClasses(Set<ClassOutline> classes) { return allConcreteClasses(classes, Collections.emptySet()); }
java
static List<JClass> allConcreteClasses(Set<ClassOutline> classes) { return allConcreteClasses(classes, Collections.emptySet()); }
[ "static", "List", "<", "JClass", ">", "allConcreteClasses", "(", "Set", "<", "ClassOutline", ">", "classes", ")", "{", "return", "allConcreteClasses", "(", "classes", ",", "Collections", ".", "emptySet", "(", ")", ")", ";", "}" ]
Returns all of the concrete classes in the system @param classes collection of classes to examine @return List of concrete classes
[ "Returns", "all", "of", "the", "concrete", "classes", "in", "the", "system" ]
0d66cd4d8b6700b5eb67c028a87b53792be895b8
https://github.com/massfords/jaxb-visitor/blob/0d66cd4d8b6700b5eb67c028a87b53792be895b8/src/main/java/com/massfords/jaxb/ClassDiscoverer.java#L188-L190
142,099
massfords/jaxb-visitor
src/main/java/com/massfords/jaxb/ClassDiscoverer.java
ClassDiscoverer.allConcreteClasses
static List<JClass> allConcreteClasses(Set<ClassOutline> classes, Set<JClass> directClasses) { List<JClass> results = new ArrayList<>(); classes.stream() .filter(classOutline -> !classOutline.target.isAbstract()) .forEach(classOutline -> { JClass implClass = classOutline.implClass; results.add(implClass); }); results.addAll(directClasses); return results; }
java
static List<JClass> allConcreteClasses(Set<ClassOutline> classes, Set<JClass> directClasses) { List<JClass> results = new ArrayList<>(); classes.stream() .filter(classOutline -> !classOutline.target.isAbstract()) .forEach(classOutline -> { JClass implClass = classOutline.implClass; results.add(implClass); }); results.addAll(directClasses); return results; }
[ "static", "List", "<", "JClass", ">", "allConcreteClasses", "(", "Set", "<", "ClassOutline", ">", "classes", ",", "Set", "<", "JClass", ">", "directClasses", ")", "{", "List", "<", "JClass", ">", "results", "=", "new", "ArrayList", "<>", "(", ")", ";", "classes", ".", "stream", "(", ")", ".", "filter", "(", "classOutline", "->", "!", "classOutline", ".", "target", ".", "isAbstract", "(", ")", ")", ".", "forEach", "(", "classOutline", "->", "{", "JClass", "implClass", "=", "classOutline", ".", "implClass", ";", "results", ".", "add", "(", "implClass", ")", ";", "}", ")", ";", "results", ".", "addAll", "(", "directClasses", ")", ";", "return", "results", ";", "}" ]
Returns all of the concrete classes plus the direct classes passed in @param classes collection of clases to test to see if they're abstract or concrete @param directClasses set of classes to append to the list of concrete classes @return list of concrete classes
[ "Returns", "all", "of", "the", "concrete", "classes", "plus", "the", "direct", "classes", "passed", "in" ]
0d66cd4d8b6700b5eb67c028a87b53792be895b8
https://github.com/massfords/jaxb-visitor/blob/0d66cd4d8b6700b5eb67c028a87b53792be895b8/src/main/java/com/massfords/jaxb/ClassDiscoverer.java#L198-L209